Order of calculations solar system model

In summary, the conversation is about writing Java code to model the solar system, specifically the positions and velocities of the Sun, Earth, and Mercury. The person is having trouble with the stability of the planets and is seeking advice on whether they are following the correct procedure. They are using circular orbits and calculating the velocities using the formula v = 2πr/T. They also mention calculating the centre of mass and subtracting it from the initial positions. The expert summarizer suggests simplifying the process by considering everything in the centre of mass frame and noting that the Sun does not have an orbit around the centre of mass.
  • #1
whatisreality
290
1
I am really, really stuck! I am trying to write java code to model the solar system, or at least currently just earth, the sun and mercury. I've made a big mistake somewhere, the planets are very unstable and either move in a line or spiral inwards! I just wanted to check that I'm doing things in the right order, I have so many loops.

I've set the sun to start at the origin, and the Earth's position is
$$x = 1.496 \times 10^{11}m$$ and Mercury is at $$x = 5.971 \times 10^{10}m$$

I want everything to be done in the centre of mass frame, so I then calculate the position of the centre of mass and subtract it from the initial positions, e.g. so the sun is at x - centreOfMass.
The velocity of each body is given by $$v = \frac{2\pi r}{T}$$ This is probably where I go wrong. I know the orbital period of mercury and Earth around the sun, so I can calculate their velocities around the centre of mass. But the sun will also move, even if only a tiny, tiny bit, and I don't have its orbital period around the centre of mass! So how can I work out its velocity?

Assuming I have the sun's velocity around the centre of mass, I then work out the velocity of the centre of mass. Because I want to stay in the centre of mass frame, I then subtract this velocity from the velocities of the planets.

My code is then written so that the position is recalculated, given a time step, then the centre of mass position is recalculated and subtracted from the new position. A new velocity for each planet is calculated, then the centre of mass velocity is recalculated and again subtracted from each velocity.

Is this the correct procedure? Do I need to recalculate the centre of mass position/velocity after each time step, or is that the problem?
 
Technology news on Phys.org
  • #2
whatisreality said:
I've set the sun to start at the origin, and the Earth's position is
##x = 1.496 \times 10^{11}m## and Mercury is at ##x = 5.971 \times 10^{10}m##
Your choice of x for a variable suggests that the planets are located along a one-dimensional line. How are you representing the positions of the planets? In the plane of their orbits you can represent the position of each with two coordinates. Are you using rectangular or polar coordinates for each position?

Also, the orbits of the planets are ellipses. Are you assuming that they are traveling in circular orbits?
 
  • #3
Mark44 said:
Your choice of x for a variable suggests that the planets are located along a one-dimensional line. How are you representing the positions of the planets? In the plane of their orbits you can represent the position of each with two coordinates. Are you using rectangular or polar coordinates for each position?

Also, the orbits of the planets are ellipses. Are you assuming that they are traveling in circular orbits?
Yes, I've assumed circular orbits. And my mistake, I am using x and y, just setting all y to zero at the start. Sorry, should have made that clear.
 
  • #4
whatisreality said:
I am really, really stuck! I am trying to write java code to model the solar system, or at least currently just earth, the sun and mercury. I've made a big mistake somewhere, the planets are very unstable and either move in a line or spiral inwards! I just wanted to check that I'm doing things in the right order, I have so many loops.

I've set the sun to start at the origin, and the Earth's position is
$$x = 1.496 \times 10^{11}m$$ and Mercury is at $$x = 5.971 \times 10^{10}m$$

I want everything to be done in the centre of mass frame, so I then calculate the position of the centre of mass and subtract it from the initial positions, e.g. so the sun is at x - centreOfMass.
The velocity of each body is given by $$v = \frac{2\pi r}{T}$$ This is probably where I go wrong. I know the orbital period of mercury and Earth around the sun, so I can calculate their velocities around the centre of mass. But the sun will also move, even if only a tiny, tiny bit, and I don't have its orbital period around the centre of mass! So how can I work out its velocity?

Assuming I have the sun's velocity around the centre of mass, I then work out the velocity of the centre of mass. Because I want to stay in the centre of mass frame, I then subtract this velocity from the velocities of the planets.

My code is then written so that the position is recalculated, given a time step, then the centre of mass position is recalculated and subtracted from the new position. A new velocity for each planet is calculated, then the centre of mass velocity is recalculated and again subtracted from each velocity.

Is this the correct procedure? Do I need to recalculate the centre of mass position/velocity after each time step, or is that the problem?

You are doing everything in the centre of mass frame, so the center of mass is always in the centre of that frame. Its velocity is zero by definition. It can change only if a new mass enters the system or the mass of an element changes.

The Sun does not have an orbit around the center of mass. It has an unpredictable path that depends on the orbits of the planets. The planets have elliptical orbits with one focus the centre of mass. They don't care where the sun moves as long as there is no collision.

This should simplify what you are doing quite a bit.
 
  • #5
Hornbein said:
You are doing everything in the centre of mass frame, so the center of mass is always in the centre of that frame. Its velocity is zero by definition. It can change only if a new mass enters the system or the mass of an element changes.

The Sun does not have an orbit around the center of mass. It has an unpredictable path that depends on the orbits of the planets. The planets have elliptical orbits with one focus the centre of mass. They don't care where the sun moves as long as there is no collision.

This should simplify what you are doing quite a bit.
So I don't need to recalculate the centre of mass position and velocity every time? According to my code, it changes a little bit though. Should I add the centre of mass velocity onto all other velocities to stay in its frame?

EDIT: Any movement of the sun does affect the planets though, surely. The only force on the planets(for my purposes) is gravity, and the position of and distance from the sun affects the direction of that gravity.
 
  • #6
whatisreality said:
So I don't need to recalculate the centre of mass position and velocity every time? According to my code, it changes a little bit though. Should I add the centre of mass velocity onto all other velocities to stay in its frame?

By definition it can't change in a center-of-mass frame. There is an error creeping in somewhere. It could be anything, so it's hard to say how to get rid of it. If it is roundoff error then you can't get rid of it, you just have to minimize it. Somehow or other you've got to patch up the error so that the center of mass remains in the center of the frame with velocity zero. This cannot change.

Adding it to the other velocity vectors definitely will not work. I think you meant subtraction.

You have to try to prevent the errors from feeding on themselves so that they increase exponentially.
 
  • #7
Your choice of ODE solver could be the issue. Euler is usually the worst for periodic motion. What one are you using?
 
  • #8
jedishrfu said:
Your choice of ODE solver could be the issue. Euler is usually the worst for periodic motion. What one are you using?
I'm using velocity verlet, meant to be good for orbital motion I read.
 

1. What is the purpose of creating an "Order of calculations solar system model"?

The purpose of creating an "Order of calculations solar system model" is to accurately represent the motion and interactions of celestial bodies in our solar system. This model helps scientists study and understand the complex dynamics of our solar system.

2. How is the "Order of calculations solar system model" different from other models of the solar system?

The "Order of calculations solar system model" differs from other models of the solar system in its level of detail and accuracy. This model takes into account factors such as the mass, velocity, and gravitational pull of each celestial body, as well as their positions in relation to each other.

3. What are the key components of the "Order of calculations solar system model"?

The key components of the "Order of calculations solar system model" are the celestial bodies in our solar system, such as the sun, planets, moons, and other smaller objects. Other important factors include the laws of motion and gravity, as well as the initial conditions of each celestial body.

4. How do scientists use the "Order of calculations solar system model" to make predictions?

Scientists use the "Order of calculations solar system model" to input data about the current positions and velocities of celestial bodies in our solar system. By running simulations with this model, they can make predictions about the future positions and interactions of these bodies.

5. What are some limitations of the "Order of calculations solar system model"?

One limitation of the "Order of calculations solar system model" is that it can only accurately represent the solar system at a specific moment in time, as the positions and interactions of celestial bodies are constantly changing. Additionally, this model does not take into account external factors, such as the influence of other stars and galaxies on our solar system.

Similar threads

  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
24
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
11
Views
1K
  • Programming and Computer Science
Replies
18
Views
5K
  • Astronomy and Astrophysics
Replies
13
Views
388
  • Introductory Physics Homework Help
Replies
18
Views
1K
Replies
13
Views
2K
Replies
1
Views
874
  • Sci-Fi Writing and World Building
Replies
21
Views
1K
Back
Top