def new_particle_from_model(self,
                             internal_structure,
                             current_age,
                             key=None):
     tmp_star = Particle(key=key)
     tmp_star.mass = internal_structure["mass"]
     tmp_star.radius = internal_structure["radius"]
     tmp_star.type = "new particle from model"
     return self.particles.add_particle(tmp_star)
def new_system(star_mass=1 | units.MSun,
               star_radius=1 | units.RSun,
               disk_minimum_radius=0.05 | units.AU,
               disk_maximum_radius=10 | units.AU,
               disk_mass=20 | MEarth,
               accurancy=0.0001,
               planet_density=3 | units.g / units.cm**3,
               rng=None,
               kepler=None):

    central_particle = Particle()
    central_particle.mass = star_mass
    central_particle.position = (0, 0, 0) | units.AU
    central_particle.velocity = (0, 0, 0) | units.kms
    central_particle.radius = star_radius
    central_particle.name = "star"
    central_particle.type = "star"
    central_particle.id = 0

    if rng is None:
        rng = numpy.random

    converter = nbody_system.nbody_to_si(1 | units.MSun, 1 | units.AU)

    if kepler is None:
        kepler = Kepler(converter)
        kepler.initialize_code()

    m, r, f = new_planet_distribution(disk_minimum_radius, disk_maximum_radius,
                                      disk_mass, accurancy)

    planets = make_planets(central_particle,
                           m,
                           r,
                           density=planet_density,
                           phi=0,
                           theta=None,
                           kepler=kepler,
                           rng=rng)
    planets.name = "planet"
    planets.type = "planet"
    for i in range(len(planets)):
        planets[i].id = i

    central_particle.planets = planets
    kepler.stop()
    p = Particles()
    p.add_particle(central_particle)
    return p
def get_moons_for_planet(planet, delta_JD=0. | units.day):
    """
  The Earth's moon
  as for JD = 2457099.500000000 = A.D. 2015-Mar-18 00:00:00.0000 (CT)
  https://ssd.jpl.nasa.gov/?sat_elem
  """

    data = numpy.array([tuple(entry) for entry in _lunar_data],
                       dtype=[('planet_name', 'S10'), ('name', 'S10'),
                              ('mass', '<f8'), ('radius', '<f8'),
                              ('semimajor_axis', '<f8'),
                              ('eccentricity', '<f8'),
                              ('argument_of_peri', '<f8'),
                              ('mean_anomaly', '<f8'), ('inclination', '<f8'),
                              ('longitude_oan', '<f8')])
    moon_data = data[data['planet_name'] == planet.name.encode('UTF-8')]
    print("Planet=", planet.name, "moon=", moon_data["name"])
    moons = Particles()
    if len(moon_data["name"]):
        print(len(moon_data["name"]))
        for moon in moon_data:
            #Ignore the moon for now, because it's complicated
            if planet.name == "EarthMoon":
                planet.mass -= moon["mass"] * 1.e+16 | units.kg
                planet.name = "Earth"
            #print moon
            r, v = get_position(planet.mass,
                                moon["mass"] * 1.e+16 | units.kg,
                                moon["eccentricity"],
                                moon["semimajor_axis"] | units.km,
                                numpy.deg2rad(moon["mean_anomaly"]),
                                numpy.deg2rad(moon["inclination"]),
                                numpy.deg2rad(moon["longitude_oan"]),
                                numpy.deg2rad(moon["argument_of_peri"]),
                                delta_t=delta_JD)
            single_moon = Particle()
            single_moon.type = "moon"
            single_moon.name = moon["name"]
            single_moon.mass = moon["mass"] * 1.e+16 | units.kg
            single_moon.hostname = moon["planet_name"]
            single_moon.radius = moon["radius"] | units.km
            single_moon.position = r
            single_moon.position += planet.position
            single_moon.velocity = v
            single_moon.velocity += planet.velocity
            moons.add_particle(single_moon)

    return moons
Esempio n. 4
0
def get_moons_for_planet(planet, delta_JD=0.|units.day):
  """
  The Earth's moon
  as for JD = 2457099.500000000 = A.D. 2015-Mar-18 00:00:00.0000 (CT)
  https://ssd.jpl.nasa.gov/?sat_elem
  """

  data = numpy.array([tuple(entry) for entry in _lunar_data],
        dtype=[('planet_name','S10'), ('name','S10'), 
        ('mass','<f8'), ('radius','<f8'), ('semimajor_axis','<f8'), 
        ('eccentricity','<f8'), ('argument_of_peri','<f8'),
        ('mean_anomaly','<f8'), ('inclination','<f8'), ('longitude_oan','<f8')])
  moon_data = data[data['planet_name']==planet.name]
  print "Planet=", planet.name, "moon=", moon_data["name"]
  moons = Particles()
  if len(moon_data["name"]):
      print len(moon_data["name"])
      for moon in moon_data:
          #print moon
          r, v = get_position(planet.mass,
                              moon["mass"] * 1.e+16 | units.kg,
                              moon["eccentricity"],
                              moon["semimajor_axis"]|units.km,
                              numpy.deg2rad(moon["mean_anomaly"]),
                              numpy.deg2rad(moon["inclination"]),
                              numpy.deg2rad(moon["longitude_oan"]),
                              numpy.deg2rad(moon["argument_of_peri"]),
                              delta_t=delta_JD)
          single_moon = Particle()
          single_moon.type = "moon"
          single_moon.name = moon["name"]
          single_moon.mass = moon["mass"] * 1.e+16 | units.kg
          single_moon.hostname = moon["planet_name"]
          single_moon.radius = moon["radius"] | units.km
          single_moon.position = r
          single_moon.position += planet.position
          single_moon.velocity = v
          single_moon.velocity += planet.velocity
          moons.add_particle(single_moon)
    
  return moons
Esempio n. 5
0
 def new_particle_from_model(self, internal_structure, current_age, key=None):
     tmp_star = Particle(key=key)
     tmp_star.mass = internal_structure["mass"]
     tmp_star.radius = internal_structure["radius"]
     tmp_star.type = "new particle from model" | units.string
     return self.particles.add_particle(tmp_star)