本文整理汇总了Python中amuse.community.hermite0.interface.Hermite.evolve_model方法的典型用法代码示例。如果您正苦于以下问题:Python Hermite.evolve_model方法的具体用法?Python Hermite.evolve_model怎么用?Python Hermite.evolve_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.hermite0.interface.Hermite
的用法示例。
在下文中一共展示了Hermite.evolve_model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test13
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test13(self):
particles = plummer.new_plummer_model(31)
instance = Hermite(number_of_workers=1)#, debugger="xterm")
instance.initialize_code()
instance.parameters.epsilon_squared = 0.01 | nbody_system.length ** 2
instance.particles.add_particles(particles)
instance.evolve_model(0.1 | nbody_system.time)
instance.synchronize_model()
expected_positions = instance.particles.position
instance.stop()
positions_per_workers = []
for n in [2,3,4,5]:
instance = Hermite(number_of_workers=n)
instance.initialize_code()
instance.parameters.epsilon_squared = 0.01 | nbody_system.length ** 2
instance.particles.add_particles(particles)
instance.evolve_model(0.1 | nbody_system.time)
instance.synchronize_model()
positions_per_workers.append(instance.particles.position)
instance.stop()
for index, n in enumerate([2,3,4,5]):
self.assertAlmostEqual(expected_positions, positions_per_workers[index], 15)
示例2: test3
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test3(self):
convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
instance = Hermite(convert_nbody)
instance.initialize_code()
instance.parameters.epsilon_squared = 0.00001 | units.AU**2
instance.dt_dia = 5000
stars = datamodel.Stars(2)
star1 = stars[0]
star2 = stars[1]
star1.mass = units.MSun(1.0)
star1.position = units.AU(numpy.array((-1.0,0.0,0.0)))
star1.velocity = units.AUd(numpy.array((0.0,0.0,0.0)))
star1.radius = units.RSun(1.0)
star2.mass = units.MSun(1.0)
star2.position = units.AU(numpy.array((1.0,0.0,0.0)))
star2.velocity = units.AUd(numpy.array((0.0,0.0,0.0)))
star2.radius = units.RSun(100.0)
instance.particles.add_particles(stars)
for x in range(1,2000,10):
instance.evolve_model(x | units.day)
instance.particles.copy_values_of_all_attributes_to(stars)
stars.savepoint()
instance.stop()
示例3: test18
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test18(self):
particles = datamodel.Particles(2)
particles.x = [0.0,1.0] | nbody_system.length
particles.y = 0.0 | nbody_system.length
particles.z = 0.0 | nbody_system.length
particles.vx = 0.0 | nbody_system.speed
particles.vy = 0.0 | nbody_system.speed
particles.vz = 0.0 | nbody_system.speed
particles.mass = 1.0 | nbody_system.mass
instance = Hermite()
instance.particles.add_particles(particles)
instance.commit_particles()
self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
instance.parameters.end_time_accuracy_factor = 1.0
instance.evolve_model(0.1 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.10563767746 |nbody_system.time, 5)
instance.parameters.end_time_accuracy_factor = -1.0
instance.evolve_model(0.3 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.266758127609 |nbody_system.time, 5)
instance.parameters.end_time_accuracy_factor = 0.0
instance.evolve_model(0.4 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.4 |nbody_system.time, 6)
instance.parameters.end_time_accuracy_factor = -0.5
instance.evolve_model(0.5 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.48974930698 |nbody_system.time, 6)
instance.parameters.end_time_accuracy_factor = +0.5
instance.evolve_model(0.6 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.6042733579 |nbody_system.time, 6)
instance.stop()
示例4: evolve_model
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def evolve_model(self):
convert_nbody = nbody_system.nbody_to_si(
1.0 | units.MSun, 149.5e6 | units.km)
hermite = Hermite(convert_nbody)
hermite.initialize_code()
hermite.parameters.epsilon_squared = 0.0 | units.AU**2
stars = self.new_system_of_sun_and_earth()
earth = stars[1]
sun = stars[0]
Earth = blender.Primitives.sphere(10, 10, 0.1) # Make the earth avatar
Sun = blender.Primitives.sphere(32, 32, 1) # Make the sun avatar
hermite.particles.add_particles(stars)
for i in range(1*365):
hermite.evolve_model(i | units.day)
hermite.particles.copy_values_of_all_attributes_to(stars)
# update avatar positions:
Earth.loc = (
1*earth.position.value_in(units.AU)[0],
1*earth.position.value_in(units.AU)[1],
earth.position.value_in(units.AU)[2])
Sun.loc = (
1*sun.position.value_in(units.AU)[0],
1*sun.position.value_in(units.AU)[1],
sun.position.value_in(units.AU)[2])
blender.Redraw()
hermite.print_refs()
hermite.stop()
示例5: simulate_system_until
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def simulate_system_until(particles, end_time):
convert_nbody = nbody_system.nbody_to_si(
1.0 | units.MSun, 149.5e6 | units.km)
instance = Hermite(convert_nbody)
instance.parameters.epsilon_squared = 0.0 | units.AU**2
instance.particles.add_particles(particles)
t0 = 0 | units.day
dt = 10 | units.day
t = t0
earth = instance.particles[1]
x_values = quantities.AdaptingVectorQuantity()
y_values = quantities.AdaptingVectorQuantity()
while t < end_time:
instance.evolve_model(t)
x_values.append(earth.x)
y_values.append(earth.y)
t += dt
instance.stop()
return x_values, y_values
示例6: evolve_system
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def evolve_system(particles):
"""
Evolves the system using the Hermite integrator.
Parameters
----------
particles: amuse.datamodel.particles.Particles instance
"""
times = numpy.linspace(0.0001, args.time, args.steps) |u.yr
intr = Hermite(nbody_to_si(particles.total_mass(), 1 | u.AU))
intr.particles.add_particles(particles)
energy_begin = intr.get_total_energy()
if args.dt is not None:
intr.set_dt_param(args.dt)
for t in times:
intr.evolve_model(t)
energy_error = (intr.get_total_energy() - energy_begin)/energy_begin
print(intr.get_time_step().in_(u.day), intr.get_time().in_(u.yr))
print(energy_error)
print("energy error:{}".format(energy_error))
intr.stop()
示例7: test8
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test8(self):
print "Testing Hermite collision_detection"
particles = datamodel.Particles(7)
particles.mass = 0.001 | nbody_system.mass
particles.radius = 0.01 | nbody_system.length
particles.x = [-101.0, -100.0, -0.5, 0.5, 100.0, 101.0, 104.0] | nbody_system.length
particles.y = 0 | nbody_system.length
particles.z = 0 | nbody_system.length
particles.velocity = [[2, 0, 0], [-2, 0, 0]]*3 + [[-4, 0, 0]] | nbody_system.speed
instance = Hermite()
instance.initialize_code()
instance.parameters.set_defaults()
instance.particles.add_particles(particles)
collisions = instance.stopping_conditions.collision_detection
collisions.enable()
instance.evolve_model(1.0 | nbody_system.time)
self.assertTrue(collisions.is_set())
self.assertTrue(instance.model_time < 0.5 | nbody_system.time)
self.assertEquals(len(collisions.particles(0)), 3)
self.assertEquals(len(collisions.particles(1)), 3)
self.assertEquals(len(particles - collisions.particles(0) - collisions.particles(1)), 1)
self.assertEquals(abs(collisions.particles(0).x - collisions.particles(1).x) <=
(collisions.particles(0).radius + collisions.particles(1).radius),
[True, True, True])
sticky_merged = datamodel.Particles(len(collisions.particles(0)))
sticky_merged.mass = collisions.particles(0).mass + collisions.particles(1).mass
sticky_merged.radius = collisions.particles(0).radius
for p1, p2, merged in zip(collisions.particles(0), collisions.particles(1), sticky_merged):
merged.position = (p1 + p2).center_of_mass()
merged.velocity = (p1 + p2).center_of_mass_velocity()
print instance.model_time
print instance.particles
instance.particles.remove_particles(collisions.particles(0) + collisions.particles(1))
instance.particles.add_particles(sticky_merged)
instance.evolve_model(1.0 | nbody_system.time)
print
print instance.model_time
print instance.particles
self.assertTrue(collisions.is_set())
self.assertTrue(instance.model_time < 1.0 | nbody_system.time)
self.assertEquals(len(collisions.particles(0)), 1)
self.assertEquals(len(collisions.particles(1)), 1)
self.assertEquals(len(instance.particles - collisions.particles(0) - collisions.particles(1)), 2)
self.assertEquals(abs(collisions.particles(0).x - collisions.particles(1).x) <=
(collisions.particles(0).radius + collisions.particles(1).radius),
[True])
instance.stop()
示例8: test19
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test19(self):
particles = datamodel.Particles(2)
particles.x = [0.0,200.0] | nbody_system.length
particles.y = 0.0 | nbody_system.length
particles.z = 0.0 | nbody_system.length
particles.vx = 0.0 | nbody_system.speed
particles.vy = 0.0 | nbody_system.speed
particles.vz = 0.0 | nbody_system.speed
particles.mass = 1.0 | nbody_system.mass
instance = Hermite()
instance.particles.add_particles(particles)
instance.commit_particles()
self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
instance.parameters.end_time_accuracy_factor = 0.0
instance.evolve_model(0.1 | nbody_system.time)
self.assertAlmostRelativeEquals(instance.model_time, 0.1 |nbody_system.time, 5)
instance.stop()
示例9: test23
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test23(self):
hermite = Hermite()
hermite.parameters.epsilon_squared = 0.0 | nbody_system.length**2
particles = datamodel.Particles(1)
particles.position = ([0,0,0] )| nbody_system.length
particles.velocity = ([1,0,0] )| nbody_system.speed
particles.radius = 0| nbody_system.length
particles.mass = 0.1| nbody_system.mass
hermite.particles.add_particles(particles)
hermite.evolve_model(1 | nbody_system.time)
print hermite.particles.x
self.assertAlmostRelativeEquals(hermite.model_time, 1 | nbody_system.time)
self.assertAlmostRelativeEquals(hermite.particles[0].x, 1 | nbody_system.length)
hermite.evolve_model(1.5 | nbody_system.time)
print hermite.particles.x
self.assertAlmostRelativeEquals(hermite.model_time, 1.5 | nbody_system.time)
self.assertAlmostRelativeEquals(hermite.particles[0].x, 1.5 | nbody_system.length)
hermite.stop()
示例10: test2
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test2(self):
convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
instance = Hermite(convert_nbody)
instance.initialize_code()
instance.parameters.epsilon_squared = 0.0 | units.AU**2
instance.dt_dia = 5000
stars = self.new_system_of_sun_and_earth()
earth = stars[1]
instance.particles.add_particles(stars)
for x in range(1, 500, 10):
instance.evolve_model(x | units.day)
instance.particles.copy_values_of_all_attributes_to(stars)
stars.savepoint()
if HAS_MATPLOTLIB:
figure = pyplot.figure()
plot = figure.add_subplot(1,1,1)
x_points = earth.get_timeline_of_attribute("x")
y_points = earth.get_timeline_of_attribute("y")
x_points_in_AU = map(lambda (t,x) : x.value_in(units.AU), x_points)
y_points_in_AU = map(lambda (t,x) : x.value_in(units.AU), y_points)
plot.scatter(x_points_in_AU,y_points_in_AU, color = "b", marker = 'o')
plot.set_xlim(-1.5, 1.5)
plot.set_ylim(-1.5, 1.5)
test_results_path = self.get_path_to_results()
output_file = os.path.join(test_results_path, "hermite-earth-sun2.svg")
figure.savefig(output_file)
instance.cleanup_code()
instance.stop()
示例11: test12
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test12(self):
particles = datamodel.Particles(2)
particles.x = [0.0,1.00] | nbody_system.length
particles.y = [0.0,0.0] | nbody_system.length
particles.z = [0.0,0.0] | nbody_system.length
particles.radius = 0.005 | nbody_system.length
particles.vx = [5.1,0.0] | nbody_system.speed
particles.vy = [0.0,0.0] | nbody_system.speed
particles.vz = [0.0,0.0]| nbody_system.speed
particles.mass = [0.1,0.1] | nbody_system.mass
instance = Hermite()
instance.initialize_code()
instance.parameters.stopping_conditions_out_of_box_size = .5 | nbody_system.length
self.assertEquals(instance.parameters.stopping_conditions_out_of_box_size, .5 | nbody_system.length)
instance.particles.add_particles(particles)
instance.stopping_conditions.out_of_box_detection.enable()
instance.evolve_model(0.1 | nbody_system.time)
self.assertTrue(instance.stopping_conditions.out_of_box_detection.is_set())
self.assertAlmostEqual(instance.stopping_conditions.out_of_box_detection.particles(0).x, 1.0 |nbody_system.length, 3)
instance.stop()
示例12: test10
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test10(self):
convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
instance = Hermite(convert_nbody)
instance.initialize_code()
instance.parameters.epsilon_squared = 0.0 | units.AU**2
instance.parameters.stopping_conditions_number_of_steps = 10
self.assertEquals(instance.parameters.stopping_conditions_number_of_steps,10)
stars = self.new_system_of_sun_and_earth()
earth = stars[1]
instance.particles.add_particles(stars)
instance.stopping_conditions.number_of_steps_detection.enable()
instance.evolve_model(365.0 | units.day)
self.assertTrue(instance.stopping_conditions.number_of_steps_detection.is_set())
instance.particles.copy_values_of_all_attributes_to(stars)
instance.cleanup_code()
instance.stop()
示例13: test22
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test22(self):
hermite = Hermite()
hermite.parameters.epsilon_squared = 0.0 | nbody_system.length**2
particles = datamodel.Particles(2)
particles.position = ([0,0,0], [1,0,0] )| nbody_system.length
particles.velocity = ([-2,0,0], [2,0,0] )| nbody_system.speed
particles.radius = 0| nbody_system.length
particles.mass = 0.1| nbody_system.mass
hermite.particles.add_particles(particles)
hermite.stopping_conditions.out_of_box_detection.enable()
hermite.parameters.stopping_conditions_out_of_box_size = 2 | nbody_system.length
hermite.parameters.stopping_conditions_out_of_box_use_center_of_mass = False
hermite.evolve_model(1 | nbody_system.time)
print hermite.particles.x
print hermite.particles.key, particles[1].key
print hermite.stopping_conditions.out_of_box_detection.particles(0)
self.assertTrue(hermite.stopping_conditions.out_of_box_detection.is_set())
self.assertEquals(len(hermite.stopping_conditions.out_of_box_detection.particles(0)), 1)
self.assertEquals(hermite.stopping_conditions.out_of_box_detection.particles(0)[0].key, particles[1].key)
hermite.stop()
示例14: test11
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def test11(self):
particles = datamodel.Particles(2)
particles.x = [0.0,10.0] | nbody_system.length
particles.y = 0 | nbody_system.length
particles.z = 0 | nbody_system.length
particles.radius = 0.005 | nbody_system.length
particles.vx = 0 | nbody_system.speed
particles.vy = 0 | nbody_system.speed
particles.vz = 0 | nbody_system.speed
particles.mass = 1.0 | nbody_system.mass
instance = Hermite()
instance.initialize_code()
instance.parameters.stopping_conditions_number_of_steps = 2
self.assertEquals(instance.parameters.stopping_conditions_number_of_steps, 2)
instance.particles.add_particles(particles)
instance.stopping_conditions.number_of_steps_detection.enable()
instance.evolve_model(10 | nbody_system.time)
self.assertTrue(instance.stopping_conditions.number_of_steps_detection.is_set())
self.assertTrue(instance.model_time < 10 | nbody_system.time)
instance.stop()
示例15: simulate_small_cluster
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import evolve_model [as 别名]
def simulate_small_cluster(
number_of_stars=1000,
end_time=40 | nbody_system.time,
number_of_workers=1
):
particles = new_plummer_model(number_of_stars)
particles.scale_to_standard()
gravity = Hermite(number_of_workers=number_of_workers)
gravity.parameters.epsilon_squared = 0.15 | nbody_system.length ** 2
gravity.particles.add_particles(particles)
from_gravity_to_model = gravity.particles.new_channel_to(particles)
time = 0.0 * end_time
total_energy_at_t0 = gravity.kinetic_energy + gravity.potential_energy
positions_at_different_times = []
positions_at_different_times.append(particles.position)
times = []
times.append(time)
print("evolving the model until t = " + str(end_time))
while time < end_time:
time += end_time / 3.0
gravity.evolve_model(time)
from_gravity_to_model.copy()
positions_at_different_times.append(particles.position)
times.append(time)
print_log(time, gravity, particles, total_energy_at_t0)
gravity.stop()
return times, positions_at_different_times