Solar System Forces -- Simulating the planetary orbits for my project

In summary, your goal is to recreate the Solar system with forces on Unity, but the attraction between the Earth and Moon makes it difficult. You need to account for the Moon's velocity and acceleration when simulating its orbit around the Earth.
  • #1
Parziter
6
3
Thread moved from the technical forums to the schoolwork forums
TL;DR Summary: Solar sytem forces on Unity

Hello !
For my last year in my school, I've got a project to do, and I wanted to recreate the Solar system with forces on Unity. My forces are Velocity and Acceleration (I'm using the Frenet's formulas).
I'm sorry I'm not a physicist and that's why I'm asking for your help.
Actually, I'm having my planets rotating around the Solar as expected, the velocity is calculated once and acceleration once for all celestial bodies.
Now, I'm trying to add the Moon to rotate around the Earth, but if I just add the Moon in the scene, it will rotate around the Sun as other planets, and will never rotate around the Earth...

Do you think I missed something ? Or maybe I've done something bad ? Or I though to try to do something with the escape velocity, but I don't know how it would change something...

Do not hesitate to tell me if something's trigger your mind !

Thanks to all

Edit : as it is a simulation, I've tried to give to the moon only the acceleration with the Earth, and the velocity of the Earth, and it started turning around the Earth, but in one complete Earth's revolution...
 
Physics news on Phys.org
  • #2
Parziter said:
TL;DR Summary: Solar sytem forces on Unity

Hello !
For my last year in my school, I've got a project to do, and I wanted to recreate the Solar system with forces on Unity. My forces are Velocity and Acceleration (I'm using the Frenet's formulas).
I'm sorry I'm not a physicist and that's why I'm asking for your help.
Actually, I'm having my planets rotating around the Solar as expected, the velocity is calculated once and acceleration once for all celestial bodies.
Ok. So they are orbiting in a perfect circle, right?
Parziter said:
Now, I'm trying to add the Moon to rotate around the Earth, but if I just add the Moon in the scene, it will rotate around the Sun as other planets, and will never rotate around the Earth...
Do you calculate the attraction between the Earth and the Moon? Do you start by giving the Moon the right velocity around the Earth?
It is not clear to me that your simple one-time velocity and acceleration calculations will handle this unless you ignore the attraction between the Sun and the Moon and just simulate the moon orbiting around the Earth.
Parziter said:
Do you think I missed something ?
You are greatly simplifying the real situation. Is it your intention to simulate something that would look ok to the casual observer or are you really trying to get the physics right?
Parziter said:
Or maybe I've done something bad ?
It's not a capital crime, if that is what you are asking. ;-)
But it is greatly simplified.
Parziter said:
Or I though to try to do something with the escape velocity,
No. I don't think you need to consider that.
Parziter said:
but I don't know how it would change something...

Do not hesitate to tell me if something's trigger your mind !

Thanks to all

Edit : as it is a simulation, I've tried to give to the moon only the acceleration with the Earth, and the velocity of the Earth,
You would need to give the Moon the velocity relative to the Earth in order to simulate it orbiting the Earth. And you can simplify it by totally ignoring the Sun and positioning the Moon relative to the Earth.
Parziter said:
and it started turning around the Earth, but in one complete Earth's revolution...
 
  • Like
Likes Parziter
  • #3
FactChecker said:
Ok. So they are orbiting in a perfect circle, right?
Yeah, later i'll use formulas for ellipse rotations but for now it'll be ok with that I think.

FactChecker said:
Do you calculate the attraction between the Earth and the Moon? Do you start by giving the Moon the right velocity around the Earth?
It is not clear to me that your simple one-time velocity and acceleration calculations will handle this unless you ignore the attraction between the Sun and the Moon and just simulate the moon orbiting around the Earth.
What I am doing is that, at every frame, every planets' velocity is re calculated, and attractions to, with all planets + sun. So yeah, when I add the moon, its velocity also depends on solar mass, and it's also attracted to the Earth, and every planets.

FactChecker said:
You are greatly simplifying the real situation. Is it your intention to simulate something that would look ok to the casual observer or are you really trying to get the physics right?
What am I simplifying ? I'd like to do the best I suppose, but as a programmer I don't know everything sooo I've found some informations on differents websites :/ so yeah, my real goal would be to get physics right !
I'll try to explain more clearly : at every frame, the velocity of all planets (and Moon ?) is calculated as v = square(G*SolarMass/distance), and the acceleration is a = G*mass/d² with every other planets + Sun
I suppose that it should be the same for the Moon, but because it's "near" the Earth, it should attract it, right ?
 
  • #4
Parziter said:
I'll try to explain more clearly : at every frame, the velocity of all planets (and Moon ?) is calculated as v = square(G*SolarMass/distance), and the acceleration is a = G*mass/d² with every other planets + Sun
I suppose that it should be the same for the Moon, but because it's "near" the Earth, it should attract it, right ?
Each planetary body attracts each planetary body in the system. The directions of the forces on each body at each instant have consequences for the net force each body experiences at an instant. So, the acceleration of a particular body is not just the sum of the magnitudes. Are you accounting for both magnitude and direction of net force acting on each body at each instant, or just magnitude to find the acceleration of a particular body?
 
  • Like
Likes FactChecker
  • #5
Parziter said:
Yeah, later i'll use formulas for ellipse rotations but for now it'll be ok with that I think.
That sounds right.
Parziter said:
What I am doing is that, at every frame, every planets' velocity is re calculated, and attractions to, with all planets + sun. So yeah, when I add the moon, its velocity also depends on solar mass, and it's also attracted to the Earth, and every planets.What am I simplifying ?
I misunderstood your original post. In fact, that is probably more complicated than it needs to be. The Sun's gravity has 0.00059836 of the effect that the earth has on the Moon, so you can probably ignore it unless you need great accuracy. If I were you, I would only worry about the Sun's attraction to each planet and the Earth's attraction to the Moon. Once that is working, you might add more.
Parziter said:
I'd like to do the best I suppose, but as a programmer I don't know everything sooo I've found some informations on differents websites :/ so yeah, my real goal would be to get physics right !
I'll try to explain more clearly : at every frame, the velocity of all planets (and Moon ?) is calculated as v = square(G*SolarMass/distance), and the acceleration is a = G*mass/d² with every other planets + Sun
I suppose that it should be the same for the Moon, but because it's "near" the Earth, it should attract it, right ?
Right. In fact, the Earth is practically the only thing you need to worry about to get the Moon's orbit.
 
  • #6
erobz said:
Each planetary body attracts each planetary body in the system. The directions of the forces on each body at each instant have consequences for the net force each body experiences at an instant. So, the acceleration of a particular body is not just the sum of the magnitudes. Are you accounting for both magnitude and direction of net force acting on each body at each instant, or just magnitude to find the acceleration of a particular body?
Hey ! I'm not sure of what is your question, but I understand well, you're asking me if I'm multiplying the magnitude by the vector from A to B, A the body attracted and B the attractor, right ? If so, yeah I'm doing that, and re calculating all the forces at each instant.

FactChecker said:
If I were you, I would only worry about the Sun's attraction to each planet and the Earth's attraction to the Moon. Once that is working, you might add more.
Okay, but so, what would be the velocity of the moon ? For the planets, it is v = square(G*SolarMass/distance), for the moon, should it be the same ? Or v = square(G*EarthMass/distance) ? (the 2nd one makes my moon really slow compared to the Earth) That was actually my main question : should my formulas change for the moon because it is near a planet or should I consider it as a planet.
 
  • #7
Parziter said:
Hey ! I'm not sure of what is your question, but I understand well, you're asking me if I'm multiplying the magnitude by the vector from A to B, A the body attracted and B the attractor, right ? If so, yeah I'm doing that, and re calculating all the forces at each instant.

1678819753498.png


I was just saying the green vectors are representative of the net forces acting on a particular body from the other bodies at a particular instant.
 
  • Like
Likes FactChecker
  • #8
Parziter said:
Okay, but so, what would be the velocity of the moon ?
Calculate it from the elapsed time of an orbit and the radius.
Parziter said:
For the planets, it is v = square(G*SolarMass/distance), for the moon, should it be the same ? Or v = square(G*EarthMass/distance) ? (the 2nd one makes my moon really slow compared to the Earth) That was actually my main question : should my formulas change for the moon because it is near a planet
The orbit of the Moon is 99.99% determined only by its orbit around the Earth. So only consider that and then position it relative to the (moving) Earth.
Parziter said:
or should I consider it as a planet.
Definitely NOT a planet orbiting the Sun.
 
  • Like
Likes Parziter
  • #9
How do you get this number, 99.99% ? Is this a checked fact or just an impression?
 
  • #10
nasu said:
How do you get this number, 99.99% ? Is this a checked fact or just an impression?
It's a bit of an exaggeration. The Sun's gravity has 0.00059836 of the effect that the earth has on the Moon. So I should have said 99.94%.

CORRECTION: My number is wrong (it is comparing the attraction to humans on Earth). See @jbriggs444 's post #12.
 
Last edited:
  • #11
erobz said:
I was just saying the green vectors are representative of the net forces acting on a particular body from the other bodies at a particular instant.
Oh yeah I'm doing it, green arrows are the sum of the two other arrows right ?

FactChecker said:
Calculate it from the elapsed time of an orbit and the radius.
The orbit of the Moon is 99.99% determined only by its orbit around the Earth. So only consider that and then position it relative to the (moving) Earth.
Okay ! Thank you for your precisions ! Gonna try that tomorrow, I don't have the time to work on it today, and I'll tell you when it'll work :)
 
  • Like
Likes erobz
  • #12
FactChecker said:
It's a bit of an exaggeration. The Sun's gravity has 0.00059836 of the effect that the earth has on the Moon. So I should have said 99.94%.
This depends on exactly what you mean by "the Sun's gravity". The gravitational force of the Sun on the moon exceeds the gravitational force of the Earth on the moon. A quick trip to Google says that the ratio is 2.26 to one.

The tidal variation of the gravitational force of the sun on the moon across the diameter of the moon's orbit around the Earth is, of course, much less.

If we approximate the moon's orbital radius by 400,000 km and the Earth's orbital radius by 150,000,000 km respectively then the moon's orbital radius is about 0.25 percent of the Earth's orbital radius. Accordingly, the variation in (inverse square) solar gravity should be from -0.5 percent to +0.5 percent across the diameter of the moon's orbit.

So we have a variation of about 1 percentage point in the solar gravity on the moon. This is already 2.26 times the Earth's gravity on the moon. So that sounds to me more like 2 percent than 0.05 percent.

Edit: Corrected Earth orbital radius listed in post. Calculations remain correct.
 
Last edited:
  • Like
Likes FactChecker
  • #13
jbriggs444 said:
If we approximate the moon's orbital radius by 400,000 km and the Earth's orbital radius by 1,500,000 km
I think this should be 150,000,000 km
 
  • Like
Likes jbriggs444
  • #14
Parziter said:
Oh yeah I'm doing it, green arrows are the sum of the two other arrows right ?
Yeah, added vectorially.

Are you fixing the suns position in space?
 
  • #15
erobz said:
Are you fixing the suns position in space?
Uhh not sure to understand the question I'm sorry... But my Sun is moving in space, because it is attracted byt all planets, so it's slow but yeah, it's moving, if that was the question.
 
  • Like
Likes erobz
  • #16
Parziter said:
Uhh not sure to understand the question I'm sorry... But my Sun is moving in space, because it is attracted byt all planets, so it's slow but yeah, it's moving, if that was the question.
I wonder how having all the precise initial conditions will come into play. I believe n-body systems can exhibit chaotic behavior if things are a bit off. Does anyone know what happens if they start the simulation and all the initially conditions are a bit off from their "true" values for a particular initial configuration?
 
  • #17
erobz said:
I wonder how having all the precise initial conditions will come into play. I believe n-body systems can exhibit chaotic behavior if things are a bit off. Does anyone know what happens if they start the simulation and all the initially conditions are a bit off from their "true" values for a particular initial configuration?
Well, with my actual program, all the planets are well rotating. Then, if I for exemple change the mass of one planet, it will change everything and all other planets will be attracted by the most massive one.

image.png

Here is an old exemple of when my velocity's function was wrong, so the planets were too slow, so there were attracted by the sun.
 
  • Like
Likes erobz
  • #18
jbriggs444 said:
This depends on exactly what you mean by "the Sun's gravity". The gravitational force of the Sun on the moon exceeds the gravitational force of the Earth on the moon. A quick trip to Google says that the ratio is 2.26 to one.
I stand corrected. My google search headline implied that 0.00059836 was referring to the Sun's attraction to the Moon, but looking at that link, it is the Sun's attraction to humans on the Earth!

jbriggs444 said:
The tidal variation of the gravitational force of the sun on the moon across the diameter of the moon's orbit around the Earth is, of course, much less.
If I understand this, you are estimating the distortion of the Moon's orbit due to the Sun, considering that both the Earth and Moon are essentially in a free-fall orbit around the Sun. So the thing to consider is how the Sun's attraction varies from the Moon's orbit near the Sun versus away from the Sun.
jbriggs444 said:
If we approximate the moon's orbital radius by 400,000 km and the Earth's orbital radius by 150,000,000 km respectively then the moon's orbital radius is about 0.25 percent of the Earth's orbital radius. Accordingly, the variation in (inverse square) solar gravity should be from -0.5 percent to +0.5 percent across the diameter of the moon's orbit.

So we have a variation of about 1 percentage point in the solar gravity on the moon. This is already 2.26 times the Earth's gravity on the moon.
I guess I am not sure what is going on here. But I do not want to hijack this thread further. I'll accept your conclusion.
jbriggs444 said:
So that sounds to me more like 2 percent than 0.05 percent.
Ok. I'll buy this, although I am not sure that I follow it completely.
jbriggs444 said:
Edit: Corrected Earth orbital radius listed in post. Calculations remain correct.
So it was just a typo and the original final number was unchanged.
 
  • Like
Likes jbriggs444
  • #19
FactChecker said:
If I understand this, you are estimating the distortion of the Moon's orbit due to the Sun, considering that both the Earth and Moon are essentially in a free-fall orbit around the Sun. So the thing to consider is how the Sun's attraction varies from the Moon's orbit near the Sun versus away from the Sun.
Yes, that is what I was trying to estimate.
 
  • Like
Likes FactChecker

FAQ: Solar System Forces -- Simulating the planetary orbits for my project

What are the main forces that need to be considered when simulating planetary orbits?

The primary force to consider is gravity, which is the attractive force between two masses. In the context of the Solar System, the gravitational pull from the Sun is the dominant force acting on the planets, but the gravitational interactions between the planets (and other bodies like moons and asteroids) also play a significant role. Additionally, for more precise simulations, one might consider relativistic effects and solar radiation pressure.

How do I calculate the gravitational force between two planets?

The gravitational force between two planets can be calculated using Newton's Law of Universal Gravitation: \( F = G \frac{m_1 m_2}{r^2} \), where \( F \) is the gravitational force, \( G \) is the gravitational constant (\(6.67430 \times 10^{-11} \, \text{m}^3 \text{kg}^{-1} \text{s}^{-2}\)), \( m_1 \) and \( m_2 \) are the masses of the two planets, and \( r \) is the distance between their centers.

What numerical methods are commonly used for simulating planetary orbits?

Several numerical methods can be used to simulate planetary orbits, with the most common ones being the Euler method, the Verlet integration, and the Runge-Kutta methods (particularly the fourth-order Runge-Kutta, or RK4). The choice of method depends on the desired balance between computational efficiency and accuracy.

How can I ensure the stability of my orbital simulation over long periods?

To ensure stability over long periods, it is crucial to choose an appropriate numerical integration method. Higher-order methods like the Runge-Kutta can offer better accuracy and stability. Additionally, using adaptive time-stepping, where the time step size changes based on the dynamics of the system, can help maintain accuracy without sacrificing computational efficiency. Ensuring that energy and angular momentum are conserved in the simulation can also be a good indicator of stability.

What initial conditions do I need to start my simulation?

To start your simulation, you need the initial positions and velocities of all the bodies in the system. These can typically be obtained from astronomical databases or ephemerides, which provide the positions and velocities of celestial bodies at given times. For the Solar System, data from sources like NASA's JPL Horizons system can be very useful. Additionally, the masses of the bodies and the gravitational constant \( G \) are required to compute the forces.

Similar threads

Back
Top