本文整理匯總了Python中amuse.community.hermite0.interface.Hermite.set_state方法的典型用法代碼示例。如果您正苦於以下問題:Python Hermite.set_state方法的具體用法?Python Hermite.set_state怎麽用?Python Hermite.set_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類amuse.community.hermite0.interface.Hermite
的用法示例。
在下文中一共展示了Hermite.set_state方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test5
# 需要導入模塊: from amuse.community.hermite0.interface import Hermite [as 別名]
# 或者: from amuse.community.hermite0.interface.Hermite import set_state [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)