Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I found the following simulation of an orbit given the semi-major axis of the ellipse, eccentricity, initial velocity, the mass of the object being orbited, and initial position of the orbiting satellite.

The program basically starts off with the following initial conditions:

$$ h \to stepSize\\ a \to semiMajorAxis\\ e \to eccentricity\\ g \to GM/a\\ \vec{X_0} = (a(1+e), 0, 0)\\ \vec{V_o} = (0, \sqrt{\frac{g(1-e)}{(1+e)}},0) $$

Given these initial conditions, the next state is calculated as follow:

$$ \vec{X_{temp}} = \vec{X_0} + (\frac h2)\vec{V_0}\\ r^3 \to (\sqrt{x_0^2 + y_o^2})^3\\ \vec{Acc_{temp}} = \frac{-GM}{r^3}(\vec{X_{temp}})\\ \vec{V_1} = \vec{V_0} + h*\vec{Acc_{temp}}\\ \vec{X_1} = \vec{X_{temp}} + \frac h2 \vec{V_1}\\ $$

The approximations continue accordingly with accuracy increasing for smaller stepSize values.

Assuming I presented this in a way that makes sense, my question is in regards to my result. Look at my simulation here:

http://zixg.com/orbits/

Take note of the two stationary blue dots. These represent the apogee and perigee of an ellipse with semi-major axis 'a' and eccentricity 'e' (Hence, the sun-like object is centered at a corresponding focal point). So it seems that this method doesn't approximate the initial ellipse at all, but rather results in a orbital trajectory that is much larger than the initially assumed ellipse. I'm not sure what to make of this?

share|improve this question

migrated from physics.stackexchange.com May 29 '13 at 20:07

This question came from our site for active researchers, academics and students of physics.

    
I certainly had trouble figuring out where to stick this one. Perhaps that is the best place? Anyone else? –  Tyrick May 29 '13 at 19:18
    
Whatever you do, don't crosspost. Flag for migration instead. –  Qmechanic May 29 '13 at 19:19
    
Done, I flagged it with a message requesting appropriate migration. Thanks –  Tyrick May 29 '13 at 20:05

1 Answer 1

Looking at your code:

var v = new Array(0, Math.sqrt((g*(1-e))/1+e), 0);

You seem to be missing a set of parenthesis around (1+e). Should be:

var v = new Array(0, Math.sqrt((g*(1-e))/(1+e)), 0);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.