使用物理定律模拟轨道 [英] Simulating orbits using laws of physics

查看:138
本文介绍了使用物理定律模拟轨道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去几个星期里,我一直试图模拟作为大学模块一部分的太阳系模拟中的轨道。为了简化,我的模拟使用Ogre3D渲染引擎用C ++编写。我试图使用牛顿万有引力定律来实现轨道,这使我的星球朝着太阳直线前进,穿过太阳,然后回到起始位置。我也尝试了从维基百科文章中的作为时间的函数的位置部分的步骤,但是对我来说也不行。



我用一个简单的欧拉积分法驱动模拟。如果任何人有任何经验与这种模拟,或只是一般知道很多关于这些物理定律,那么任何帮助或指向我正确的方向将非常感激。

解决方案

您必须给予行星与所需轨道相切的初始速度v =(vx,vy,vz)。如果太阳的位置是s并且行星是p,则总是存在作用在两者之间的力:行星上的一个指向太阳,矢量t =(s-p),反之亦然。该力的大小为g Ms Mp /(t dot t),其中dot是点积,g是由于重力的标准加速度,M s,M p是各自的质量。



如果你正在做一个详细的模型,其中所有的物体都可以对所有其他物体施加拉力,那么算法是累积所有的成对力,得到一个合力矢量作用于每个身体(行星或太阳)。



因此,算法是:

 选择dt,时间步长,小间隔。 
设置初始位置和速度
(对于行星,速度与所需轨道相切,太阳具有速度零点)
loop
用当前位置累加所有物体上的所有力。
对于每个物体位置= p,velocity = v,net合力= f,mass = m,
更新其速度:v_new = v + f / m dt
更新位置p_new = p + 0.5 *(v + v_new)
v = v_new; p = p_new
Render
end loop

如上所述,Euler简单,但需要非常小的时间步骤才能获得合理的精度。有时你可以在系统中引入一点点阻力(乘以一个小于1的因子),以保持稳定,否则它们会爆炸。


Over the past couple of weeks I've been trying to simulate orbits in a solar system simulation I am making as part of a University module. To cut things short, my simulation is written in C++ using the Ogre3D rendering engine. I have attempted to implement orbits using Newton's law of universal gravitation which made my planet head towards the sun in a straight line, pass through the sun and then come back to its starting position. I also tried the steps from 'Position as a function of time' section of this wikipedia article, but that did not work for me either.

I am driving the simulation with a simple Euler integration method. If anyone has any experience with this kind of simulation, or just generally knows a lot about these physics laws then any help or pointing me in the right direction would be greatly appreciated.

解决方案

You must give the planet initial velocity v = (vx, vy, vz) tangent to the desired orbit. If the position of the sun is s and planet is p, then there is always a force acting between the two: the one on the planet points toward the sun, vector t=(s - p) and vice versa. The magnitude of this force is g Ms Mp / (t dot t), where "dot" is the dot product, g is the standard acceleration due to gravity, and Ms, Mp are the respective masses.

If you are doing a detailed model where all bodies can exert pull on all other bodies, then the algorithm is to accumulate all the pairwise forces to get a single resultant force vector acting on each body (planet or sun). Otherwise you might settle for an approximation where only the sun pulls on planets and other forces are deemed too small to matter.

So the algorithm is:

Choose dt, the time step, a small interval.
Set initial positions and velocities 
    (for planets, velocity is tangent to desired orbit. Sun has velocity zero.)
loop
  Accumulate all forces on all bodies with current positions.
  For each body position=p, velocity=v, net resultant force=f, mass=m, 
    update its velocity: v_new = v + f / m dt
    update position p_new = p + 0.5 * (v + v_new) 
    v = v_new; p = p_new
  Render
end loop

As has been mentioned, Euler is simple but requires a very small time step to get even reasonable accuracy. Sometimes you can introduce just a tiny bit of drag in the system (multiply velocity by a factor just a tad below 1) to keep things stable where otherwise they blow up.

这篇关于使用物理定律模拟轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆