[Physics] Finding the initial velocity vector of an orbiting body

celestial-mechanicscomputational physicsorbital-motionsimulationssoftware

I'm writing a program that simulates Newton's law of universal gravitation by simply calculating the force and applying it on the objects. The simulation works very well, but now I want to simulate real systems using real data. I looked all over for how to find the initial conditions such as the initial velocity and initial position, but I can't find anything.

I'll make it clear by taking the Earth as an example as in the figure below. How do I calculate w (green vector)? If I want to set up the system and simulate it, what would the Earth's initial velocity be so that it orbits the sun at a period of 365 days? And what would its respective position be? I know the orbital speeds of the Earth and the Moon, but they are obviously not the initial velocities of the bodies in the system.

I played around with the values and got something around 30 km/s, but now the Earth's gravity can't pull the moon along the orbit path because it's too fast, even at extremely small time steps. I can give them similar velocities that is enough to drag the moon along, but then the moon's orbit period becomes less than 27 days.

enter image description here

Best Answer

By the sounds of it you have made a mistake with the units. In fact, you should not be using SI units at all in your simulation; astronomical values in SI units vary by such huge orders of magnitude that they are often a source of floating point errors that can destroy trajectories.

You should instead use the astronomical system of units. Specifically, express your masses in solar masses, your lengths in the astronomical unit, and time in the mean solar day.

Your value of $G$ will then be the square of the Gaussian gravitational constant, i.e.

$$ G=k^2=0.0002959122083\,\mathrm{AU}^3\mathrm{D}^{-2}\mathrm{M}_\odot^{-1} $$


You can get position and velocity data for the planets, their moons, comets, and hundreds of thousands of asteroids, etc, from JPL HORIZONS. You need to connect to their servers via telnet and request the data.

Alternatively, as a starting point, if you know the distance $r$ and mass $m$ of a planet, then its orbital speed should be

$$ v = \sqrt{\frac{GM}{r}} $$

where $M=1\,\mathrm{M}_\odot$. If we ignore eccentricity then the direction should be tangential to the orbit (e.g. position it at $(r,0)$ and give it a velocity $(0,v)$).

Related Question