# Clarification of the physics involved of an orbiting body in a circular orbit

I am writing a physics simulation program to simulate a body orbiting a planet but I am a little confused about the physics involved and would like some clarification.

To simulate gravity I am using the following formula

$F = G \frac{m_1 m_2}{r^2}$

and to find the circular velocity of the orbiting body

$v = \sqrt{G (m_1 + m_2) \over r}$

Would I be correct in saying if I initialise the orbiting body's circular velocity using the above formula perpendicular to the radial gravitational force the body will stay in a circular orbit or is there something else going on here that I have missed?

If so how can I calculate the x and y components of the circular velocity as I am working with a cartesian coordinate system?

• Hello. If the mass of the orbiting body is $m_1$ (and assuming $m_2$ is much larger than $m_1$), then the orbital velocity is actually given by $v = \sqrt{\frac{Gm_2}{r}}$. It only depends on the central mass $m_2$, not on the mass of the orbiting object. – Gert Aug 29 '15 at 1:04
• No but the centripetal force acting on $m_1$ is $F=\frac{m_1 v^2}{r}$. Set that equal to $F = G \frac{m_1 m_2}{r^2}$ and solve for $v$. – Gert Aug 29 '15 at 1:54
• I think it's not the "x and y components of the circular velocity" that should concern you but rather the $(x,y)$ position of the orbiting object in your Cartesian coordinate system, as a function of time $t$. – Gert Aug 29 '15 at 2:22

## 1 Answer

If you want to actually simulate the behavior of the planet as it experiences the (vector) force as it moves around, then you need to find a stepping method and write your velocity vectors and position vector in terms of coordinates. I recommend a Verlet velocity method. Others at this site have their favorites, too. Euler's method is not good enough for orbital motion.

Euler's method uses only a first-order expansion to approximate integrals. It is easy to program, but isn't designed to conserve important physics quantities like energy and angular momentum, plus the error accumulation after about 1 complete orbit will be too large at reasonable time steps. Euler will be either too slow (extremely small steps) or to sloppy, and will eventually violate conservation laws.

Verlet methods and other symplectic methods are designed to solve Hamiltonian mechanics systems and are physics friendly. Verlet is also a second order method which means that it has smaller inherent error for a given time step $\Delta t$. For example, in Euler's method, cutting the time step in half (and doubling the number of steps) only cuts the error to 1/2 of what it was (roughly). In Verlet (and other 2nd order methods), cutting the time step in half cuts the error to (1/2)$^2$ = 1/4 of what it was.

Put the large body at the origin, and put the smaller body at ($r_o$,0) at $t=0$. You will need to change the acceleration vector at each step, too, because it will change direction. Write all your vectors in $\hat{i}, \hat{j}$ notation.

And like @Gert says in the comments, the initial speed for a circular orbit will be $v=\sqrt{\frac{Gm_2}{r}}.$

If you have the position vector of a particle and you want to force the velocity vector to be perpendicular then you have to find the instantaneous angle of the position vector in your well-defined coordinate system. $$\theta_r = \arctan\left(\frac{y}{x}\right).$$ Then increase that angle by 90$^o$ to find the direction of the velocity vector. Use the magnitude of the velocity and the angle to find the components of the vector.

• Velocity-Verlet is great, but you may want to explain (and/or provide links to) each method. At the very least, point out why Euler won't work and symplectic methods like VV are needed. – tpg2114 Aug 29 '15 at 3:17
• @tpg2114 Edited to incorporate your suggestions. – Bill N Aug 29 '15 at 3:36
• I believe I am doing something similar to your suggestion. Here is my code so you have a better understanding of what I am trying to achieve. pastebin.com/Nk14NnmG My problem is on line 50. – Sean Wilkinson Aug 29 '15 at 4:49
• See my edited answer, last paragraph. – Bill N Aug 29 '15 at 15:47
• Thankyou for your help Bill and Gert for your input. I have one more question would I need to force the velocity vector to be perpendicular in each time step? I would have thought if the velocity vector was initialised perpendicular to the gravitational force it would be enough to stay in orbit in all future time steps. – Sean Wilkinson Aug 30 '15 at 1:25