本文整理汇总了Python中amuse.community.bhtree.interface.BHTree.new_particle方法的典型用法代码示例。如果您正苦于以下问题:Python BHTree.new_particle方法的具体用法?Python BHTree.new_particle怎么用?Python BHTree.new_particle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.bhtree.interface.BHTree
的用法示例。
在下文中一共展示了BHTree.new_particle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test5
# 需要导入模块: from amuse.community.bhtree.interface import BHTree [as 别名]
# 或者: from amuse.community.bhtree.interface.BHTree import new_particle [as 别名]
def test5(self):
instance = BHTree()
instance.commit_parameters()
index = instance.new_particle(
15.0 | nbody_system.mass,
10.0 | nbody_system.length, 20.0 | nbody_system.length, 30.0 | nbody_system.length,
1.0 | nbody_system.speed, 1.0 | nbody_system.speed, 3.0 | nbody_system.speed,
10.0 | nbody_system.length
)
instance.commit_particles()
self.assertEquals(instance.get_mass(index), 15.0| nbody_system.mass)
self.assertEquals(instance.get_radius(index), 10.0| nbody_system.length)
instance.cleanup_code()
instance.stop()
示例2: test4
# 需要导入模块: from amuse.community.bhtree.interface import BHTree [as 别名]
# 或者: from amuse.community.bhtree.interface.BHTree import new_particle [as 别名]
def test4(self):
convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)
instance = BHTree(convert_nbody)
instance.commit_parameters()
index = instance.new_particle(
15.0 | units.kg,
10.0 | units.m, 20.0 | units.m, 30.0 | units.m,
#1.0 | units.m/units.s, 1.0 | units.m/units.s, 3.0 | units.m/units.s
0.0 | units.m/units.s, 0.0 | units.m/units.s, 0.0 | units.m/units.s,
10.0 | units.m
)
instance.commit_particles()
self.assertEquals(instance.get_mass(index), 15.0| units.kg)
self.assertEquals(instance.get_radius(index), 10.0| units.m)
instance.cleanup_code()
instance.stop()
示例3: test6
# 需要导入模块: from amuse.community.bhtree.interface import BHTree [as 别名]
# 或者: from amuse.community.bhtree.interface.BHTree import new_particle [as 别名]
def test6(self):
convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)
instance = BHTree(convert_nbody)
instance.commit_parameters()
indices = instance.new_particle(
[15.0, 30.0] | units.kg,
[10.0, 20.0] | units.m, [20.0, 40.0] | units.m, [30.0, 50.0] | units.m,
#1.0 | units.m/units.s, 1.0 | units.m/units.s, 3.0 | units.m/units.s
[0.0, 0.01] | units.m/units.s, [0.0, 0.01] | units.m/units.s, [0.0, 0.01] | units.m/units.s,
[10.0, 20.0] | units.m
)
instance.commit_particles()
self.assertEquals(instance.get_mass(indices[0]), 15.0| units.kg)
self.assertEquals(instance.get_mass(indices)[0], 15.0| units.kg)
self.assertRaises(AmuseException, instance.get_mass, [4,5],
expected_message = "Error when calling 'get_mass' of a 'BHTree', errorcode is -1")
instance.cleanup_code()
instance.stop()