def new_fixed_mass_distribution(number_of_particles, *list_arguments, **keyword_arguments): return new_flat_mass_distribution( number_of_particles, mass_min=stellar_mass / number_of_stars, mass_max=stellar_mass / number_of_stars, )
def test4(self): print("Test 4: testing user interface (SI units)") numpy.random.seed(345672) masses = new_flat_mass_distribution(10000) self.assertEqual(len(masses), 10000) self.assertAlmostRelativeEqual(masses.mean(), FlatIMF().mass_mean(), 3) self.assertAlmostEqual(masses.mean(), 17.5145247111 | units.MSun) self.assertAlmostEqual(masses.amin(), 0.100145673289 | units.MSun) self.assertAlmostEqual(masses.amax(), 124.94980234 | units.MSun)
def test4(self): print "Test 4: testing user interface (SI units)" numpy.random.seed(345672) masses = new_flat_mass_distribution(10000) self.assertEqual(len(masses), 10000) self.assertAlmostRelativeEqual(masses.mean(), FlatIMF().mass_mean(), 3) self.assertAlmostEqual(masses.mean(), 17.5145247111 | units.MSun) self.assertAlmostEqual(masses.amin(), 0.100145673289 | units.MSun) self.assertAlmostEqual(masses.amax(), 124.94980234 | units.MSun)
def test5(self): print("Test 5: testing user interface (SI units), optional args") numpy.random.seed(345672) masses = new_flat_mass_distribution(10000, mass_min=10.0|units.MSun, mass_max=100.0|units.MSun) self.assertEqual(len(masses), 10000) self.assertAlmostRelativeEqual(masses.mean(), FlatIMF(mass_min=10.0|units.MSun, mass_max=100.0|units.MSun).mass_mean(), 2) self.assertAlmostEqual(masses.mean(), 39.1111546565 | units.MSun) self.assertAlmostEqual(masses.amin(), 10.0047015091 | units.MSun) self.assertAlmostEqual(masses.amax(), 99.9870310764 | units.MSun)
def test5(self): print "Test 5: testing user interface (SI units), optional args" numpy.random.seed(345672) masses = new_flat_mass_distribution(10000, mass_min=10.0|units.MSun, mass_max=100.0|units.MSun) self.assertEqual(len(masses), 10000) self.assertAlmostRelativeEqual(masses.mean(), FlatIMF(mass_min=10.0|units.MSun, mass_max=100.0|units.MSun).mass_mean(), 2) self.assertAlmostEqual(masses.mean(), 39.1111546565 | units.MSun) self.assertAlmostEqual(masses.amin(), 10.0047015091 | units.MSun) self.assertAlmostEqual(masses.amax(), 99.9870310764 | units.MSun)
stellar_evolution.particles.add_particles(particles) return stellar_evolution def new_gravity(particles, converter): gravity = BHTree(converter) gravity.particles.add_particles(particles) return gravity if __name__ in ('__main__', '__plot__'): number_of_particles = 100 # create a Plummer sphere with a number of stars numpy.random.seed(12345) masses = new_flat_mass_distribution(number_of_particles) converter = nbody_system.nbody_to_si(1.0 | units.parsec, masses.sum()) particles = new_plummer_model(number_of_particles, converter) particles.mass = masses particles.move_to_center() # create simulation codes gravity = new_gravity(particles, converter) stellar_evolution = new_stellar_evolution(particles) # create channels to and from the local particle set and the simulations from_gravity_to_local = gravity.particles.new_channel_to(particles) from_stellar_evolution_to_local = \ stellar_evolution.particles.new_channel_to(particles) from_stellar_evolution_to_local.copy()
stellar_evolution.particles.add_particles(particles) return stellar_evolution def new_gravity(particles, converter): gravity = BHTree(converter) gravity.particles.add_particles(particles) return gravity if __name__ in ('__main__', '__plot__'): number_of_particles = 100 # create a Plummer sphere with a number of stars numpy.random.seed(12345) masses = new_flat_mass_distribution(number_of_particles) converter = nbody.nbody_to_si(1.0 | units.parsec, masses.sum()) particles = new_plummer_model(number_of_particles, converter) particles.mass = masses particles.move_to_center() # create simulation codes gravity = new_gravity(particles, converter) stellar_evolution = new_stellar_evolution(particles) # create channels to and from the local particle set and the simulations from_gravity_to_local = gravity.particles.new_channel_to(particles) from_stellar_evolution_to_local = \ stellar_evolution.particles.new_channel_to(particles) from_stellar_evolution_to_local.copy()