How Do You Model the Earth-Moon-Sun System?

Share

How Do You Model the Earth-Moon-Sun System?

Why should I stop talking about the Earth-moon-Sun system? There really is no reason. So, let me continue the discussion with a short tutorial that goes through the steps to make this model.

The Physics
———–

There isn't that much physics that we need to use here. Just a couple of key points. First, the gravitational force. How do you model this for interacting planet-like objects? I will use the following model.

Here, G is the gravitational constant. The m's are the masses of the two objects and r is the distance between their centers. What about the r-hat? This is a unit vector that points from one object to the other. Ok, maybe you already knew how to do all this. Let me just draw one more picture so we can be clear about this calculation (not to scale).

There are really 6 important vectors. I need a vector for the positions of the Earth, Sun, and moon. Then I need the vector from the Sun to the Earth (called se in the diagram), Sun to moon and Earth to moon. I didn't draw the Sun to moon vector to keep things a little cleaner. Also, I am going to put the origin at the starting location of the Earth. Why? In Vpython, the camera view starts centered around the origin. Since I want to look at the Earth-moon system, this just makes sense.

So, with these vectors I can calculate the three gravitational forces (as vectors). But what then? Then I will just use the momentum principle to see how the momentum of the Earth and Moon change after some small time. Let me write this expression down for the moon.

But what about the position of the moon? If I know the momentum and some small time interval, I can also calculate the change in position of the moon.

This shows the lie that we use in a numerical calculation. Can you see it? It's there. I calculate the change in position for the moon based on the velocity at the beginning of the time interval. However, if the momentum is changing, so is the velocity. Technically, I should use the average velocity in this calculation. If the velocity is not changing at a constant rate, the velocity would NOT be the sum of the initial and final velocity divided by two - it would be more difficult than that. But, cheating is fine here. If I use a small time interval, the difference between these velocities will be small enough to not matter.

Here is the plan:

Calculate the forces on the moon and the Earth (I will assume the Sun doesn't move).

Use the force and the momentum to calculate the new momentum after a short time interval for both the Earth and moon.

Use the momentum (and velocity) to find the new position of the Earth and moon.

That's it. Now for the details.

Python Program
————–

Let me just go over my code for this calculation. First, I will assume you have already installed vpython. Oh, you don't know what that is? Vpython is python (the programming language) along with a visual module. The visual module has awesome stuff included to make some 3-D objects and other thinks like the vector class. Of course, there is also the browser-based equivalent of vpython - Glowscript. Glowscript runs browsers that supports WebGL. Honestly, Glowscript is pretty cool, but I always forget to use it.

On to the program. Here is the first part.

The first line just loads the visual module. The rest of this stuff is just constants that I will use. That's simple, right? Here is the next part.

The "sphere" function in vpython makes a 3-D image of a sphere. Here, I made the Earth and the moon spheres with their positions as shown. I put the Earth at the location (0, 0, 0) meters. This is at the origin of the universe as was originally intended. There is also the radius and color parameters which I suspect make sense all by themselves. The "make_trail" is a nice feature that makes the object leave a trail as it moves around. I guess that's obvious too.

After I make an object like the Earth and moon, I can assign other properties to those objects. Here I assign earth.m as the mass of the object. Oh sure, I could have just kept using Me for the mass of the Earth, but this is easier to keep track of things.

What about the Sun? I just made the Sun a location and not an object. This way I can use this value for calculations but Vpython won't try to include it in the display.

If it makes you happy, you could save and run the program at this point. I usually do this just to make sure nothing is out of whack yet.

Here is the next part.

What's going on here? In order to use the steps above in a numerical calculation, you have to start somewhere. You also have to start with some momentum. That's what this part does. It sets the initial conditions for the momentum of the Earth and moon. The first part is to calculate the angular speed of the Earth (or moon) as it orbits. Since I just want the magnitude of the angular velocity, I can set the gravitational force on that planet equal to the change in momentum for the case of circular motion.

This shows the calculation for the angular speed of the Earth, the moon is essentially the same thing. Oh, the r in the above equation is the distance from the Earth to the Sun. Once I have the angular speed (for a perfectly circular orbit), I can calculate the momentum of the Earth as just the mass of the Earth times ωr for the velocity. In this case, I started the Earth moving in the y-direction. For the moon, I need it's velocity relative to the stationary Sun, not just relative to the Earth. That's why I added in the velocity of the Earth in the moon's momentum.

Now for the real part of the program.

I don't think this needs much explanation. I guess I could say something about the tmonth variable. This is the approximate length of a month. That way, I don't have to let the model run for a whole year - what would be the point of that?

So now you have an Earth-Sun-moon model. You can try changing some of the parameters to see what happens. If you like, could modify the program to include the motion of the Sun due to the interaction with the Earth. How much would the Sun move and how difficult would it be to detect this motion?