0

I've been having a go at programming an orbital simulator from scratch (without using any existing libraries) using the formula below to find the acceleration first for particle A and then for particle B towards each other.

$$F = \frac{m_Am_BG}{r^2}$$

$$a_{AB} = \frac{m_BG}{r^2}$$ $$a_{BA} = \frac{m_AG}{r^2}$$

The particles have masses: $m_A = 300\times10^{23}, m_B = 10\times10^{23}$

This produces what looks to be almost a correct orbit with the lighter particle B orbiting around particle A however particle A does not move in an ellipse rather a half ellipse before continuing upwards with another half ellipse and so on. This can be seen in the image below:

Orbits issue image

The time step does not seem to be an issue as I've adjusted that and it made no difference, it is currently set to $0.000001\mathrm{s}$. I'm not sure as to what might cause this.

Joshua
  • 105
  • 5
  • 2
    This question appears to be off-topic because it belongs to CompSci. – jinawee Feb 14 '14 at 19:02
  • 1
    @jinawee But the major part is related to the Physics surely? I doubt I'd be able to get as good an answer on SO as this is entirely Physics related. – Joshua Feb 14 '14 at 19:03
  • Hard to tell from the picture, but is the weirdness really only happening at the edges? Are your initial conditions such that there is an upward momentum of the system? – BMS Feb 14 '14 at 19:11
  • @BMS Yes, particle B has an upward velocity of $70000\mathrm{m/s}$ – Joshua Feb 14 '14 at 19:12
  • 1
    So the system has initial momentum upward, and the center of mass is also traveling upward? Sounds realistic to me. – BMS Feb 14 '14 at 19:15
  • You may want to check your algorithm with my algorithm – Kyle Kanos Feb 14 '14 at 19:18
  • @BMS That's a good point, I somehow managed to overlook that entirely. Thanks. Is it possible to produce a stable orbit with this method though? – Joshua Feb 14 '14 at 19:23
  • @KyleKanos I use an algorithm very similar to yours, it does not make use of the Runge-Kutta methods though. – Joshua Feb 14 '14 at 19:24
  • Related: http://physics.stackexchange.com/questions/98447/what-are-the-correct-initial-conditions-for-the-moon-in-a-simulation – dmckee --- ex-moderator kitten Feb 15 '14 at 04:02

0 Answers0