def test_in_reference_plane_eccentricity_elliptical(self): new_binary = new_binary_from_elements m = 1 | units.MSun sma = 1 | units.AU ecc = 0.5 true_anom = 0 inc = 0 long_ascnode = 0 argper = 0 G = constants.G binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=argper, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertAlmostEqual(a.number, sma.number, places=self.places) self.assertAlmostEqual(e, ecc, places=self.places) self.assertAlmostEqual(i, inc, places=self.places) self.assertAlmostEqual(w, argper, places=self.places) self.assertAlmostEqual(W, long_ascnode, places=self.places) self.assertAlmostEqual(f, true_anom, places=self.places)
def test_in_reference_plane_argument_of_periapsis(self): new_binary = new_binary_from_elements m = 1 | units.MSun sma = 1 | units.AU ecc = 0.5 true_anom = 10 inc = 10 long_ascnode = 10 argper = numpy.linspace(0, 359, 100) G = constants.G for w0 in argper: binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=w0, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertAlmostEqual(a.number, sma.number, places=self.places) self.assertAlmostEqual(e, ecc, places=self.places) self.assertAlmostEqual(i, inc, places=self.places) self.assertAlmostEqual(w, w0, places=self.places) self.assertAlmostEqual(W, long_ascnode, places=self.places) self.assertAlmostEqual(f, true_anom, places=self.places)
def test_elements_type(self): new_binary = new_binary_from_elements m = 1 | units.MSun sma = 1 | units.AU ecc = 0 true_anom = 0 inc = 0 long_ascnode = 0 argper = 0 G = constants.G binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=argper, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertTrue(isinstance(a, Quantity)) self.assertTrue(isinstance(e, float)) self.assertTrue(isinstance(i, float)) self.assertTrue(isinstance(w, float)) self.assertTrue(isinstance(W, float)) self.assertTrue(isinstance(f, float))
def test_in_reference_plane_eccentricity_parabolical(self): new_binary = new_binary_from_elements m = 1|units.MSun sma = 1|units.AU ecc = 1 true_anom = 0 inc = 0 long_ascnode = 0 argper = 0 G = constants.G binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=argper, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertAlmostEqual(a.number, sma.number, places=self.places) self.assertAlmostEqual(e, ecc, places=self.places) self.assertAlmostEqual(i, inc, places=self.places) self.assertAlmostEqual(w, argper, places=self.places) self.assertAlmostEqual(W, long_ascnode, places=self.places) self.assertAlmostEqual(f, true_anom, places=self.places)
def test_in_reference_plane_argument_of_periapsis(self): new_binary = new_binary_from_elements m = 1|units.MSun sma = 1|units.AU ecc = 0.5 true_anom = 10 inc = 10 long_ascnode = 10 argper = numpy.linspace(0,359, 100) G = constants.G for w0 in argper: binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=w0, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertAlmostEqual(a.number, sma.number, places=self.places) self.assertAlmostEqual(e, ecc, places=self.places) self.assertAlmostEqual(i, inc, places=self.places) self.assertAlmostEqual(w, w0, places=self.places) self.assertAlmostEqual(W, long_ascnode, places=self.places) self.assertAlmostEqual(f, true_anom, places=self.places)
def test_elements_type(self): new_binary = new_binary_from_elements m = 1|units.MSun sma = 1|units.AU ecc = 0 true_anom = 0 inc = 0 long_ascnode = 0 argper = 0 G = constants.G binary = new_binary(m, m, sma, eccentricity=ecc, true_anomaly=true_anom, inclination=inc, longitude_of_the_ascending_node=long_ascnode, argument_of_periapsis=argper, G=G) a, e, i, w, W, f = orbital_elements(binary) self.assertTrue(isinstance(a, Quantity)) self.assertTrue(isinstance(e, float)) self.assertTrue(isinstance(i, float)) self.assertTrue(isinstance(w, float)) self.assertTrue(isinstance(W, float)) self.assertTrue(isinstance(f, float))
def store_data(intr, state, datahandler): """ Set up which parameters to store in the hdf5 file here. """ h = datahandler p = intr.particles h.append(intr.get_time().in_(units.yr), "time") h.append(Time.time(), "walltime") h.append(p.center_of_mass(), "CM_position") h.append(p.center_of_mass_velocity(), "CM_velocity") h.append(p.position, "position") h.append(p.velocity, "velocity") h.append(p.mass, "mass") h.append(p.kinetic_energy(), "kinetic_energy") h.append(p.potential_energy(), "potential_energy") h.append(intr.get_total_energy(), "total_energy") p0 = p.copy_to_new_particles() p1 = p.copy_to_new_particles() p0.remove_particle(p0[2]) p1.remove_particle(p1[1]) for i, pset in enumerate([p0, p1]): currentprefix = datahandler.prefix datahandler.prefix = currentprefix+"p"+str(i)+"/" a, e, i, w, W, f = orbital_elements(pset) mu = pset.mass.sum() #NOT the stand. grav. parameter period = ((2*numpy.pi)**2*a**3/(constants.G*mu)).sqrt() mean_motion = 2*numpy.pi / period massloss_index = state.mdot / (mean_motion*mu) h.append(a, "sma") h.append(e, "eccentricity") h.append(i, "inclination") h.append(f, "true_anomaly") h.append(w, "argument_of_periapsis") h.append(W, "longitude_of_ascending_node") h.append(period, "period") h.append(massloss_index, "massloss_index") datahandler.prefix = currentprefix
def store_data(intr, state, datahandler): """ Set up which parameters to store in the hdf5 file here. """ h = datahandler p = intr.particles h.append(intr.get_time().in_(units.yr), "time") h.append(Time.time(), "walltime") h.append(p.center_of_mass(), "CM_position") h.append(p.center_of_mass_velocity(), "CM_velocity") h.append(p.position, "position") h.append(p.velocity, "velocity") h.append(p.mass, "mass") h.append(p.kinetic_energy(), "kinetic_energy") h.append(p.potential_energy(), "potential_energy") h.append(intr.get_total_energy(), "total_energy") p0 = p.copy_to_new_particles() p1 = p.copy_to_new_particles() p0.remove_particle(p0[2]) p1.remove_particle(p1[1]) for i, pset in enumerate([p0, p1]): currentprefix = datahandler.prefix datahandler.prefix = currentprefix + "p" + str(i) + "/" a, e, i, w, W, f = orbital_elements(pset) mu = pset.mass.sum() #NOT the stand. grav. parameter period = ((2 * numpy.pi)**2 * a**3 / (constants.G * mu)).sqrt() mean_motion = 2 * numpy.pi / period massloss_index = state.mdot / (mean_motion * mu) h.append(a, "sma") h.append(e, "eccentricity") h.append(i, "inclination") h.append(f, "true_anomaly") h.append(w, "argument_of_periapsis") h.append(W, "longitude_of_ascending_node") h.append(period, "period") h.append(massloss_index, "massloss_index") datahandler.prefix = currentprefix
def store_data(intr, state, datahandler): """ Set up which parameters to store in the hdf5 file here. """ h = datahandler p = intr.particles h.append(intr.get_time().in_(units.yr), "time") h.append(Time.time(), "walltime") h.append(p.center_of_mass(), "CM_position") h.append(p.center_of_mass_velocity(), "CM_velocity") h.append(p.position, "position") h.append(p.velocity, "velocity") h.append(p.mass, "mass") h.append(p.total_angular_momentum(), "angular_momentum") h.append(p.kinetic_energy(), "kinetic_energy") h.append(p.potential_energy(), "potential_energy") h.append(intr.get_total_energy(), "total_energy") currentprefix = datahandler.prefix datahandler.prefix = currentprefix+"p0"+"/" a, e, i, w, W, f = orbital_elements(p) mu = p.mass.sum() period = ((2*numpy.pi)**2*a**3/(constants.G*mu)).sqrt() mean_motion = 2*numpy.pi / period massloss_index = state.mdot / (mean_motion*mu) h.append(a, "sma") h.append(e, "eccentricity") h.append(i, "inclination") h.append(w, "argument_of_periapsis") h.append(W, "longitude_of_ascending_node") h.append(f, "true_anomaly") h.append(period, "period") h.append(massloss_index, "massloss_index") datahandler.prefix = currentprefix
def store_data(intr, state, datahandler): """ Set up which parameters to store in the hdf5 file here. """ h = datahandler p = intr.particles h.append(intr.get_time().in_(units.yr), "time") h.append(Time.time(), "walltime") h.append(p.center_of_mass(), "CM_position") h.append(p.center_of_mass_velocity(), "CM_velocity") h.append(p.position, "position") h.append(p.velocity, "velocity") h.append(p.mass, "mass") h.append(p.total_angular_momentum(), "angular_momentum") h.append(p.kinetic_energy(), "kinetic_energy") h.append(p.potential_energy(), "potential_energy") h.append(intr.get_total_energy(), "total_energy") currentprefix = datahandler.prefix datahandler.prefix = currentprefix + "p0" + "/" a, e, i, w, W, f = orbital_elements(p) mu = p.mass.sum() period = ((2 * numpy.pi)**2 * a**3 / (constants.G * mu)).sqrt() mean_motion = 2 * numpy.pi / period massloss_index = state.mdot / (mean_motion * mu) h.append(a, "sma") h.append(e, "eccentricity") h.append(i, "inclination") h.append(w, "argument_of_periapsis") h.append(W, "longitude_of_ascending_node") h.append(f, "true_anomaly") h.append(period, "period") h.append(massloss_index, "massloss_index") datahandler.prefix = currentprefix