本文整理汇总了Python中amuse.community.evtwin.interface.EVtwin.new_particle_from_model方法的典型用法代码示例。如果您正苦于以下问题:Python EVtwin.new_particle_from_model方法的具体用法?Python EVtwin.new_particle_from_model怎么用?Python EVtwin.new_particle_from_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.evtwin.interface.EVtwin
的用法示例。
在下文中一共展示了EVtwin.new_particle_from_model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test11
# 需要导入模块: from amuse.community.evtwin.interface import EVtwin [as 别名]
# 或者: from amuse.community.evtwin.interface.EVtwin import new_particle_from_model [as 别名]
def test11(self):
print "Test for importing new stellar models"
instance = EVtwin()
#~ instance.parameters.import_model_entropy_force = 1.0
#~ instance.parameters.import_model_entropy_accuracy = 1.0e-1
instance.parameters.verbosity = True
instance.particles.add_particles(Particles(mass = [0.8] | units.MSun))
instance.evolve_model()
instance.new_particle_from_model(instance.particles[0].get_internal_structure())
# The above line is equivalent with:
#copy = Particles(1)
#copy.internal_structure = instance.particles[0].get_internal_structure()
#instance.particles.add_particles(copy)
number_of_zones = instance.particles[0].get_number_of_zones()
self.assertEqual(len(instance.particles), 2)
self.assertEqual(instance.particles[1].get_number_of_zones(), number_of_zones)
self.assertIsOfOrder(instance.particles[1].get_radius_profile()[-1], 1.0 | units.RSun)
self.assertIsOfOrder(instance.particles[1].get_temperature_profile()[0], 1.0e7 | units.K)
self.assertIsOfOrder(instance.particles[1].get_pressure_profile()[0], 1.0e17 | units.barye)
instance.evolve_model(keep_synchronous = False)
self.assertAlmostRelativeEqual(
instance.particles[0].temperature, instance.particles[1].temperature, 2)
self.assertAlmostRelativeEqual(
instance.particles[0].luminosity, instance.particles[1].luminosity, 2)
instance.stop()
示例2: slowtest5
# 需要导入模块: from amuse.community.evtwin.interface import EVtwin [as 别名]
# 或者: from amuse.community.evtwin.interface.EVtwin import new_particle_from_model [as 别名]
def slowtest5(self):
print "Test convert_SPH_to_stellar_model result in EVtwin"
stellar_evolution = EVtwin()
stellar_evolution.parameters.verbosity = True
stellar_evolution.particles.add_particle(Particle(mass=1.0|units.MSun)) # reference particle
stellar_evolution.evolve_model(100.0|units.Myr)
model = convert_SPH_to_stellar_model(self.new_particles()) # model is from center to surface
stellar_evolution.new_particle_from_model(model, 0.0|units.Myr)
print stellar_evolution.particles
self.assertAlmostEqual(stellar_evolution.particles.age, [100.0, 0.0] | units.Myr, 1)
stellar_evolution.evolve_model(200.0|units.Myr)
print stellar_evolution.particles
self.assertAlmostEqual(stellar_evolution.particles.age, [200.0, 100.0] | units.Myr, 1)
self.assertAlmostRelativeEqual(stellar_evolution.particles[0].temperature,
stellar_evolution.particles[1].temperature, 2)
self.assertAlmostRelativeEqual(stellar_evolution.particles[0].luminosity,
stellar_evolution.particles[1].luminosity, 2)
stellar_evolution.stop()
示例3: xslowtest11
# 需要导入模块: from amuse.community.evtwin.interface import EVtwin [as 别名]
# 或者: from amuse.community.evtwin.interface.EVtwin import new_particle_from_model [as 别名]
def xslowtest11(self):
print "Test 11: Continue the stellar evolution of a 'merger product' - WIP"
instance = EVtwin()
instance.initialize_code()
instance.commit_parameters()
instance.parameters.min_timestep_stop_condition = 1.0 | units.s
stars = Particles(3)
stars.mass = [1.0, 2.0, 1.0] | units.MSun
instance.particles.add_particles(stars)
instance.commit_particles()
instance.evolve_model(1.0 | units.Myr)
stellar_models = instance.native_stars.get_internal_structure()
self.assertEqual(len(stellar_models), 3)
self.assertEqual(len(stellar_models[0]), 199)
self.assertEqual(len(stellar_models[1]), 199)
self.assertAlmostEqual(stellar_models[0].mass[198], 1.0 | units.MSun, 2)
self.assertAlmostEqual(stellar_models[1].mass[198], 2.0 | units.MSun, 2)
self.assertAlmostEqual(stellar_models[0].mass[0], 0.0 | units.MSun, 2)
instance.new_particle_from_model(stellar_models[0], instance.particles[0].age)
self.assertEqual(len(instance.particles), 4)
self.assertEqual(len(instance.imported_stars), 1)
imported_stellar_model = instance.imported_stars[0].get_internal_structure()
self.assertEqual(len(imported_stellar_model), 199)
self.assertAlmostEqual(imported_stellar_model.mass[198], 1.0 | units.MSun, 2)
self.assertAlmostEqual(imported_stellar_model.mass[0], 0.0 | units.MSun, 2)
self.assertAlmostRelativeEqual(imported_stellar_model.X_H, stellar_models[0].X_H, 5)
self.assertAlmostRelativeEqual(imported_stellar_model.X_He, stellar_models[0].X_He, 5)
self.assertAlmostRelativeEqual(imported_stellar_model.mass, stellar_models[0].mass, 2)
self.assertAlmostRelativeEqual(imported_stellar_model.radius[1:], stellar_models[0].radius[1:], 2)
# instance.evolve_model(2.0 | units.Myr)
print instance.particles
instance.stop()
del instance