本文整理汇总了Python中amuse.community.huayno.interface.Huayno.get_gravity_at_point方法的典型用法代码示例。如果您正苦于以下问题:Python Huayno.get_gravity_at_point方法的具体用法?Python Huayno.get_gravity_at_point怎么用?Python Huayno.get_gravity_at_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.huayno.interface.Huayno
的用法示例。
在下文中一共展示了Huayno.get_gravity_at_point方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test16
# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import get_gravity_at_point [as 别名]
def test16(self):
instance = Huayno()
instance.parameters.epsilon_squared = 0.0 | nbody_system.length**2
particles = datamodel.Particles(2)
particles.mass = [1.] | nbody_system.mass
particles.radius = [0.0] | nbody_system.length
particles.position = [[0.0,0.0,0.0],[1.0,0.0,0.0]] | nbody_system.length
particles.velocity = [[0.0, 0.0, 0.0]] | nbody_system.speed
instance.particles.add_particles(particles)
zero = 0.0 | nbody_system.length
for x in (0.25, 0.5, 0.75):
x0 = x | nbody_system.length
potential0 = instance.get_potential_at_point(zero, x0, zero, zero)
fx0, fy0, fz0 = instance.get_gravity_at_point(zero, x0, zero, zero)
self.assertAlmostEqual(fy0, 0.0 | nbody_system.acceleration,14)
self.assertAlmostEqual(fz0, 0.0 | nbody_system.acceleration,14)
fx = (-1.0 / (x0**2)+1.0 / (((1.0|nbody_system.length)-x0)**2)) * (1.0 | nbody_system.length ** 3 / nbody_system.time ** 2)
self.assertAlmostEqual(fx, fx0,14)
self.assertAlmostEqual(potential0, -nbody_system.G*(1.|nbody_system.mass)*(1./x0+1./((1.|nbody_system.length)-x0)),14)
instance.stop()
示例2: test16
# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import get_gravity_at_point [as 别名]
def test16(self):
solsys = new_solar_system()
solsys.x-=1.| units.AU
p=datamodel.Particles(3)
p.mass=[1,2,3] | units.MSun
p.x=[1,10,100] | units.AU
p.y=[0,0,-10] | units.AU
p.z=[0,0,10] | units.AU
from amuse.community.huayno.interface import Huayno
from amuse.units import nbody_system
conv=nbody_system.nbody_to_si(1. | units.AU, 1.| units.MSun)
h = Huayno(conv)
h.particles.add_particles(solsys)
ax1,ay1,az1=h.get_gravity_at_point(p.x*0.,p.x,p.y,p.z)
mercury = Mercury()
mercury.particles.add_particles(solsys)
ax2,ay2,az2=mercury.get_gravity_at_point(p.x*0.,p.x,p.y,p.z)
self.assertAlmostRelativeEqual(ax1,ax2,12)
self.assertAlmostRelativeEqual(ay1,ay2,12)
self.assertAlmostRelativeEqual(az1,az2,12)