本文整理汇总了Python中amuse.community.hermite0.interface.Hermite.dt_dia方法的典型用法代码示例。如果您正苦于以下问题:Python Hermite.dt_dia方法的具体用法?Python Hermite.dt_dia怎么用?Python Hermite.dt_dia使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.hermite0.interface.Hermite
的用法示例。
在下文中一共展示了Hermite.dt_dia方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test3
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import dt_dia [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()
示例2: test2
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import dt_dia [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()
示例3: test1
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import dt_dia [as 别名]
def test1(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
hermite.parameters.end_time_accuracy_factor = 0.0
hermite.dt_dia = 5000
stars = self.new_system_of_sun_and_earth()
earth = stars[1]
hermite.particles.add_particles(stars)
hermite.evolve_model(365.0 | units.day)
hermite.particles.copy_values_of_all_attributes_to(stars)
position_at_start = earth.position.value_in(units.AU)[0]
position_after_full_rotation = earth.position.value_in(units.AU)[0]
self.assertAlmostRelativeEqual(position_at_start, position_after_full_rotation, 6)
hermite.evolve_model(365.0 + (365.0 / 2) | units.day)
hermite.particles.copy_values_of_all_attributes_to(stars)
position_after_half_a_rotation = earth.position.value_in(units.AU)[0]
self.assertAlmostRelativeEqual(-position_at_start, position_after_half_a_rotation, 3)
hermite.evolve_model(365.0 + (365.0 / 2) + (365.0 / 4) | units.day)
hermite.particles.copy_values_of_all_attributes_to(stars)
position_after_half_a_rotation = earth.position.value_in(units.AU)[1]
self.assertAlmostRelativeEqual(-position_at_start, position_after_half_a_rotation, 3)
hermite.cleanup_code()
hermite.stop()
示例4: test2
# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import dt_dia [as 别名]
def test2(self):
convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
bhtree = BHTree(convert_nbody)
bhtree.initialize_code()
bhtree.eps2_for_gravity = 0.001
bhtree_particles = self.new_system_sun_and_earth()
bhtree.particles.add_particles(bhtree_particles)
if bhtree.legacy_interface.channel_type == 'mpi':
from mpi4py import MPI
if not MPI.Query_thread() == MPI.THREAD_MULTIPLE:
bhtree.stop()
self.skip("can only test parallel with multiple thread support in mpi implementation")
hermite = Hermite(convert_nbody)
hermite.dt_dia = 5000
hermite.commit_parameters()
hermite_particles = self.new_system_sun_and_earth()
hermite.particles.add_particles(hermite_particles)
thread1 = threading.Thread(target = self.evolve_model_unit_day, args = (bhtree, bhtree_particles, 10))
thread2 = threading.Thread(target = self.evolve_model_unit_day, args = (hermite, hermite_particles, 10))
thread1.start()
thread2.start()
thread1.join()
thread2.join()
if HAS_MATPLOTLIB:
figure = pyplot.figure()
plot = figure.add_subplot(1,1,1)
earth = bhtree_particles[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')
earth = hermite_particles[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 = "g", 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, "parallel-earth-sun.svg")
figure.savefig(output_file)
bhtree.stop()
hermite.stop()
bhtree.stop()