Order of calculations solar system model

Click For Summary

Discussion Overview

The discussion revolves around modeling the solar system, specifically focusing on the Earth, the Sun, and Mercury using Java code. Participants explore the order of calculations necessary for simulating planetary motion, particularly in the context of the center of mass frame, and address issues related to stability and accuracy in the simulation.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes their approach to modeling the solar system, including initial positions and the calculation of velocities based on orbital periods.
  • Concerns are raised about the stability of the simulation, with planets either moving in a line or spiraling inwards.
  • Questions arise regarding the need to recalculate the center of mass position and velocity after each time step, with some participants asserting that the center of mass should remain fixed in the center of the frame with zero velocity.
  • Another participant points out that the Sun's movement does not constitute an orbit around the center of mass, but rather an unpredictable path influenced by the planets' orbits.
  • There is a discussion about the potential impact of roundoff errors and the choice of numerical methods for solving ordinary differential equations (ODEs), with one participant mentioning the use of the velocity Verlet method.

Areas of Agreement / Disagreement

Participants express differing views on whether the center of mass position and velocity need to be recalculated after each time step. While some assert it should remain constant, others note that the Sun's movement can affect the planets, indicating a lack of consensus on this point.

Contextual Notes

Some participants highlight the importance of accurately representing the orbits of the planets, noting that they are elliptical rather than circular. There is also mention of potential errors in the simulation that could arise from the choice of numerical methods or roundoff errors.

whatisreality
Messages
286
Reaction score
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
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?
 
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.
 
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.
 
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.
 
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.
 
Your choice of ODE solver could be the issue. Euler is usually the worst for periodic motion. What one are you using?
 
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 24 ·
Replies
24
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
13
Views
4K
Replies
18
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K