本文整理汇总了Python中amuse.community.hermite0.interface.Hermite.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Hermite.stop方法的具体用法?Python Hermite.stop怎么用?Python Hermite.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.hermite0.interface.Hermite
的用法示例。
在下文中一共展示了Hermite.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evolve_model
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例2: test5
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [as 别名]
def test5(self):
convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)
instance = Hermite(convert_nbody)
instance.initialize_code()
particles = datamodel.Particles(2)
self.assertEquals(len(instance.particles), 0)
particles.mass = [15.0, 30.0] | units.kg
particles.radius = [10.0, 20.0] | units.m
particles.position = [[10.0, 20.0, 30.0], [20.0, 40.0, 60.0]] | units.m
particles.velocity = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] | units.m / units.s
instance.particles.add_particles(particles)
self.assertEquals(len(instance.particles), 2)
instance.set_state(1, 16|units.kg,
20.0|units.m, 40.0|units.m, 60.0|units.m,
1.0|units.ms, 1.0|units.ms, 1.0|units.ms ,
20.0|units.m)
curr_state = instance.get_state(1)
for expected, actual in zip([16|units.kg,
20.0|units.m, 40.0|units.m, 60.0|units.m,
1.0|units.ms, 1.0|units.ms, 1.0|units.ms ,
20.0|units.m], curr_state):
self.assertAlmostRelativeEquals(expected, actual)
instance.stop()
self.assertEquals(curr_state[0], 16|units.kg, 8)
示例3: test13
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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)
示例4: test6
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [as 别名]
def test6(self):
print "Test6: Testing Hermite parameters"
convert_nbody = nbody_system.nbody_to_si(1.0 | units.yr, 1.0 | units.AU)
instance = Hermite(convert_nbody)
value = instance.get_eps2()
self.assertEquals(0.0 | units.AU**2 , value)
self.assertAlmostEquals(0.0 | units.AU**2, instance.parameters.epsilon_squared, in_units=units.AU**2)
for x in [0.01, 0.1, 0.2]:
instance.parameters.epsilon_squared = x | units.AU**2
self.assertAlmostEquals(x | units.AU**2, instance.parameters.epsilon_squared, in_units=units.AU**2)
value = instance.get_dt_param()
self.assertEquals(0.03 , value)
self.assertAlmostEquals(0.03 , instance.parameters.dt_param)
for x in [0.001, 0.01, 0.1]:
instance.parameters.dt_param = x
self.assertAlmostEquals(x, instance.parameters.dt_param)
value = instance.get_dt_dia()
self.assertAlmostEquals(1.0 | units.yr, value)
self.assertAlmostEquals(1.0 | units.yr, instance.parameters.dt_dia, in_units=units.yr)
for x in [0.1, 10.0, 100.0]:
instance.parameters.dt_dia = x | units.yr
self.assertAlmostEquals(x | units.yr, instance.parameters.dt_dia, in_units=units.yr)
value = instance.get_begin_time()
self.assertEquals(0.0| units.yr, value)
self.assertAlmostEquals(0.0 | units.yr, instance.parameters.begin_time, in_units=units.yr)
for x in [1.0, 10.0, 100.0]:
instance.parameters.begin_time = x | units.yr
self.assertAlmostEquals(x | units.yr, instance.parameters.begin_time, in_units=units.yr)
instance.stop()
示例5: test15
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [as 别名]
def test15(self):
particles = datamodel.Particles(2)
particles.x = [0.0,10.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)
p = datamodel.Particle(
x = 1.0 | nbody_system.length,
y = 2.0 | nbody_system.length,
z = 3.0 | nbody_system.length,
vx = 1.0 | nbody_system.speed,
vy = 2.0 | nbody_system.speed,
vz = 3.0 | nbody_system.speed,
mass = 1.0 | nbody_system.mass,
radius = 4.0 | nbody_system.length,
)
instance.particles.add_particle(p)
self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
self.assertEquals(instance.particles[1].radius, 0.0 | nbody_system.length)
self.assertEquals(instance.particles[2].radius, 4.0 | nbody_system.length)
instance.stop()
示例6: test18
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例7: simulate_system_until
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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
示例8: test3
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例9: evolve_system
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例10: test8
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例11: test19
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例12: test23
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例13: test2
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例14: test12
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()
示例15: test10
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import stop [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()