使用 matlab 编程三体问题
我正在尝试使用 matlab 对三体问题进行编程。我得到了月球在太空旋转框架中的轨迹公式。它基本上是 ydotdot, xdotdot=GM/(x^2+y^2)^3/2 公式。公式是什么,并不那么重要。
我面临的问题是,我应该编写一个程序来数值求解月球的轨迹方程。我使用 ODE45 进行比较,因为我的目标是获得与 ODE45 相同的结果。我的最终问题是,我想以天为单位迭代时间,因此 tspan= [0 365]。问题是,当我将引力常数转换为秒,然后执行 tspace= [0 365] 时,我会得到完全不同的结果,如果我执行 [0 365*3600*34] 表示一年中的秒数,G= 6.67e -11。看来我的单位很奇怪。
我想知道是否有人可以解释为什么当我使用 ODE 45 时会发生这种情况。为什么我不能使用 ODE45 将秒转换为天?我还需要执行额外的步骤吗?我的问题中唯一的其他变量是半径、距离和 3 个物体的质量。
太感谢了。我已经为此工作了很长时间。任何帮助将不胜感激。
I am trying to program a 3 body problem using matlab. I was given the formula for the moon's trajectory in its rotational frame in space. It's basically the ydotdot, xdotdot=GM/(x^2+y^2)^3/2 formula. What the formula is, is not that important.
THe problem I am facing is that, I am supposed to code up a program that will numerically solve the moon's trajectory equation. I'm using ODE45 to compare with since my goal is to get the same results as ODE45. My ultimate problem is that, I want to iterate through time in terms of days so tspan= [0 365]. The thins is when I convert Gravitational constant to seconds and then do tspace= [0 365] I get a completely different result then If I were to do [0 365*3600*34] representing the seconds in a year and G= 6.67e-11. It seems that my units are very weird.
I was wondering if anyone can explain why this is happening when I use ODE 45. Why can't I convert seconds to days clearly using ODE45? Is there an extra step I have to do? The only other variables in my problem is radius, distance, and the mass of the 3 bodies.
Thank you so much. I've been working on this for a very very long time. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
沿每个轴的重力加速度公式不正确。
将质量为 M_e 的地球置于原点,将月球(质量 M_m)置于 (x,y)。然后
地月距离由下式给出:
地月总力由下式给出:
地球引力引起的总加速度由下式给出:
且指向原点。沿加速度
每个轴是:
注意您所说的公式中缺少的 x 和 y 因子。
我不确定“将引力常数转换为秒”是什么意思。
您使用的 G 值的单位为牛顿米^2/公斤^2。所以已经是
以MKS(米-千克-秒)系统表示,并计算出加速度
使用此值的单位为米/秒^2。
对于 (x_s, y_s) 处的第三个物体(例如太阳),您可以计算一个新的 R_s 表示
月球-太阳距离,并使用上面的方法计算新的加速度向量
太阳的质量 M_s(除了加速度现在的方向是 (x_s, y_s),而不是 (0,0))。一旦所有东西都被放入一个共同的坐标系中,来自地球和太阳引力的月球加速度就会按分量相加(这里,
地心坐标——尽管如果您要模拟太阳-地球-月亮系统,日心坐标可能是更方便的选择)。加上初始位置和速度,应该就是计算下一个时间步的位置和速度所需的全部内容。
That formula for gravitational acceleration along each axis isn't correct.
Put the earth, with mass M_e, at the origin, with the moon (mass M_m) at (x,y). Then
the earth-moon distance is given by:
The total earth-moon force is given by:
The total acceleration due to Earth's gravity is given by:
and is directed toward the origin. The acceleration along
each axis is then:
Note the x and y factors, which are missing from the formula you stated.
I'm not sure what you mean by "converting the gravitational constant to seconds".
The value you're using for G has units of newton-meter^2/kg^2. So it's already
expressed in the MKS (meter-kilogram-second) system, and the accelerations calculated
using this value will have units of meters/sec^2.
With a third body (say, the sun) at (x_s, y_s), you compute a new R_s representing
the moon-sun distance, and compute new acceleration vectors as above, using the
sun's mass M_s (except the acceleration is now in the direction of (x_s, y_s), rather than (0,0)). The accelerations of the moon from the gravity of the earth and the sun just add component-wise, once everything is put into a common coordinate system (here,
geocentric coordinates -- although heliocentric might be a more convenient choice, if you're simulating the sun-earth-moon system). That, plus the initial positions and velocities, should be all you need to compute the positions and velocities at the next time step.