问题描述
我用 scipy 和 mathplotlib 解决了围绕太阳引力场的运动,但遇到了一个问题。我的解决方案不正确。它不像example。 Formulas 我用过。
from scipy.integrate import odeint
import scipy.constants as constants
import numpy as np
import matplotlib.pyplot as plt
M = 1.989 * (10 ** 30)
G = constants.G
alpha = 30
alpha0 = (alpha / 180) * np.pi
v00 = 0.7
v0 = v00 * 1000
def dqdt(q,t):
x = q[0]
y = q[2]
ax = - G * M * (x / ((x ** 2 + y ** 2) ** 1.5))
ay = - G * M * (y / ((x ** 2 + y ** 2) ** 1.5))
return [q[1],ax,q[3],ay]
vx0 = v0 * np.cos(alpha0)
vy0 = v0 * np.sin(alpha0)
x0 = -150 * (10 ** 11)
y0 = 0 * (10 ** 11)
q0 = [x0,vx0,y0,vy0]
N = 1000000
t = np.linspace(0.0,100000000000.0,N)
pos = odeint(dqdt,q0,t)
x1 = pos[:,0]
y1 = pos[:,2]
plt.plot(x1,y1,'ro')
plt.ylabel('y')
plt.xlabel('x')
plt.grid(True)
plt.show()
我该如何解决这个问题? 也许您可以使用另一种方法告诉我解决方案,例如使用欧拉公式或使用其他库。 如果您能帮助我,我将非常感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)