本文整理汇总了Python中amuse.community.bhtree.interface.BHTree.get_potential_at_point方法的典型用法代码示例。如果您正苦于以下问题:Python BHTree.get_potential_at_point方法的具体用法?Python BHTree.get_potential_at_point怎么用?Python BHTree.get_potential_at_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.bhtree.interface.BHTree
的用法示例。
在下文中一共展示了BHTree.get_potential_at_point方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test9
# 需要导入模块: from amuse.community.bhtree.interface import BHTree [as 别名]
# 或者: from amuse.community.bhtree.interface.BHTree import get_potential_at_point [as 别名]
def test9(self):
instance = BHTree()
instance.initialize_code()
instance.parameters.epsilon_squared = 0.00001 | nbody_system.length**2
particles = datamodel.Particles(2)
particles.mass = [1.0, 1.0] | nbody_system.mass
particles.radius = [0.0001, 0.0001] | nbody_system.length
particles.position = [[0.0,0.0,0.0], [2.0,0.0,0.0]] | nbody_system.length
particles.velocity = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] | nbody_system.speed
instance.particles.add_particles(particles)
zero = 0.0 | nbody_system.length
fx, fy, fz = instance.get_gravity_at_point(zero, 1.0 | nbody_system.length, zero, zero)
self.assertAlmostEqual(fx, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fy, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fz, 0.0 | nbody_system.acceleration, 3)
for x in (0.25, 0.5, 0.75):
x0 = x | nbody_system.length
x1 = (2.0 - x) | nbody_system.length
potential0 = instance.get_potential_at_point(zero, x0, zero, zero)
potential1 = instance.get_potential_at_point(zero, x1, zero, zero)
fx0, fy0, fz0 = instance.get_gravity_at_point(zero, x0, zero, zero)
fx1, fy1, fz1 = instance.get_gravity_at_point(zero, x1, zero, zero)
self.assertAlmostEqual(fy0, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fz0, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fy1, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fz1, 0.0 | nbody_system.acceleration, 3)
self.assertAlmostEqual(fx0, -1.0 * fx1, 5)
fx = (-1.0 / (x0**2) + 1.0 / (x1**2)) * (1.0 | nbody_system.length ** 3 / nbody_system.time ** 2)
self.assertAlmostEqual(fx, fx0, 2)
self.assertAlmostEqual(potential0, potential1, 5)
instance.cleanup_code()
instance.stop()