1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Some questions regarding proportions in a two-body problem

  1. Mar 3, 2013 #1
    I am programming an n-body simulation, but to test my program, I decided to start with two bodies. Specifically, I decided to model the Earth-Moon system. The issue I have is that Kepler's laws involve only the motion of one of the two bodies. From my understanding, the other is assumed to be static or of such mass that its motion is insignificant. That leaves me working with Newtonian gravitation and motion.

    My problem is the starting conditions. Wikipedia tells me the mass of the Earth and Moon, and the orbital radius and velocity of the Moon. Simply inputting these parameters does not create a stable simulation, though. The entire system slowly moves. I was obvious that I was not accounting for the Earth's motion in my starting conditions. It was not obvious as to how I should determine the Earth's velocity.

    Because my maths are effectively pre-calculus (I took single-variable calculus over a decade ago and have forgotten most of it), it is difficult to understand the maths behind celestial mechanics. Eventually, though, after playing with some numbers I found that the velocity of the Earth should be of a proportion to the Moon's that is inverse to the proportion of their masses. Basically:


    Where v and m are velocity and mass, respectively; and the subscripts m and e are the Moon and the Earth, respectively. The Earth's velocity obviously points in the opposite direction as the Moon's. This creates a stables simulation regardless of the values input and the distances involved. As long as these proportions remain the same, the bodies trace the same orbital paths each time.

    Now I'm sure that this proportion may be derived from the relevant formulae by those who have sufficient competence in the maths involved, but that's not me. I was unable to find this information on Wikipedia or in various Google searches, though perhaps that's not surprising. My questions therefore are: is this proportion documented somewhere and are there any others that I should be aware of?

    Thank you.

  2. jcsd
  3. Mar 3, 2013 #2
    The math for doing an n-body simulation is pretty simple. All you need are Newton's laws. It's the algorithm that you have to be careful with. I did my first program using the information at this site:


    Although it's for Java, you can still use the info to write the program in any language you like. Also, the instructions at the link site are for x and y coordinates only. But it's pretty easy to add the Z coordinates once you understand how it works.
  4. Mar 3, 2013 #3
    Yes, the simulation was relatively easy to create. I even incorporated RK4 integration based on some information I found elsewhere in these forums. The problem is figuring out the starting parameters for bodies of arbitrary mass and orbital radii.
  5. Mar 3, 2013 #4
    I seed my simulation with the ephemerides generated at the Horizons web site. I then calculate the center of mass for the bodies I am simulating and set that coordinate at 0,0,0 adjusting the coordinates and velocities of the other bodies accordingly.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook