Missing something basic about simple orbital mechanics

I seem to be missing something basic.

I've been trying to get a simple orbital simulation working, and my two objects are Earth around the Sun.

My problem is this. I placed the Earth at 93M miles away from the Sun, or 155M km.

As I understand it, the orbital velocity of something at 155M km from the Sun is:

$$v = \sqrt{\frac{GM}{r}}$$

Plugging in the numbers for the Sun, I get a velocity of:

$$29261 \frac{\mathrm{m}}{\mathrm{s}}$$

However, if I want to get the acceleration that the Sun has upon the earth, I use:

$$g = \frac{GM}{r^2}$$

For the Sun, and 155M km, I get an acceleration of:

$$0.0055\frac{\mathrm{m}}{\mathrm{s}^2}$$

Now, I start with a simple body at the proper radius out along the X axis and give it a simply vector of 29261 m/s along the Y axis, then I start applying the 0.0055 m/s^2 acceleration to it. And the acceleration of the Sun is simply not enough to hold the Earth.

If the Earth starts with a vector of (0, 29261 m/s), and after and I add the acceleration vector of (-0.0055 m/s, 0) to it, you can see that after a single second, it doesn't move a whole lot. If I chunk things to days, 86400 seconds, then the acceleration vector is only, roughly, -477 m/day, but the velocity vector is:

$$2,325,974,400 \frac{\mathrm{m}}{\mathrm{day}} = 29,261 \frac{\mathrm{m}}{\mathrm{s}} \times 86,400 \frac{\mathrm{s}}{\mathrm{day}}$$

As you can imagine, the -477 isn't going to move that much towards the Sun.

I understand that better simulations use better techniques than simply adding basic vectors together, but that's not what this is. I seem to be missing something fundamental. I had assumed that given the correct velocity, that the pull of the Sun should keep the Earth in orbit, but the "pull" that I'm using doesn't seem to be having the desired effect.

So, I'm curious what basic "D'oh" thing I'm missing here.

Edit for Luboš Motl answer.

Perhaps there's something more fundamental I'm missing here. I understand you point, but .0055 m/s * 86,400 is -477. I was doing that math fine.

Simply, I have an object with a velocity vector. Then I apply an acceleration at a right angle. I do that for N seconds to come up with a new, right angle velocity vector. I then add that to the original vector to come up with the objects new vector. I then take that vector, apply to the current position of the object, and arrive at a new position.

Clearly there is a granularity issue which makes some amount of seconds a better choice for a model than others, but this is high school level simple mechanics, so there's going to be some stepping. I chose one day so that my little dot of a planet on my screen would move. If I update every 1/10th of a second "real time", and each update is a day, then I should get a rough orbit that's really a 365ish polygon in a little over 30s real time.

If I choose a step size of 1 second, then my acceleration (0.0055 m/s^2) * 1 s = a right angle velocity vector that's -0.0055 in magnitude. That vector is added to the original vector of 29261 (at right angles), giving me a new vector of (-0.0055, 29261). That's after one second. That's not much of a bump. It's barely a blip. If I apply one days full of acceleration, "all at once", I am obligated to not only multiply the acceleration by 86,400, but also the original vector (since it's 29261 m/s, and we have 86,400 s), thus giving me, proportionally, the same vector, just longer. And it's still just a bump.

So, I'm mis-applying something somewhere here, as I think the numbers are fine. I'm simply "doing it wrong". Trying to figure out what that wrong part is.

Edit 2, responding to Platypus Lover

Thank you very much for the simple code you posted. It showed me my error.

My confusion was conflating updating of the vector with the calculation of the velocity vector. I felt that I had to multiply both the original vector AND the acceleration amount by the time step, which would give me the silly results.

It was just confused in my head.

-

You wrote "acceleration vector of (-0.0055 m/s, 0)" but that's actually a velocity vector, judging by the units. Was that a typo? – David Zaslavsky♦ Feb 27 '11 at 6:44
1) Unfortunately, you can't just "chunk things to days". 2) The acceleration vector changes as to always be at right angles to the velocity vector. $g_x v_x + g_y v_y = 0$ – Eelvex Feb 27 '11 at 6:49
@David: actually he treats this as "velocity vector per second" so it should be ok. – Eelvex Feb 27 '11 at 6:50
@Will: I don't understand why you think something is wrong in your calculation. – timur Feb 27 '11 at 17:36
@timur I thought something was wrong with my calculation when my simple animation showed "the Earth" flying off and away instead of in a circle like it should have. – Will Hartung Feb 27 '11 at 21:30
show 2 more comments

3 Answers

I suspect there is something wrong in the way you are adding the acceleration vector to the velocity vector after the first timestep. The simplest way to check you are doing things correctly is to write down your scheme in cartesian coordinates.

To point you in the right direction, I wrote a sample orbit integrator for you here: Simplest orbit integrator, which should be at a level appropriate for a high school student. This is probably simplest integrator you can possibly write. With your code, you should get a nice circle for an x-y plot, and a nice sinusoid for the position and velocity components:

Notice that it uses Euler's method:

$\vec{v}(t+\Delta t) = \vec{v}(t) + \Delta t \ \vec{a}(t)$

$\vec{x}(t+\Delta t) = \vec{x}(t) + \Delta t \ \vec{v}(t)$

which is probably what you have been doing so far without realizing. This is the most inaccurate method to use when integrating, and once you introduce elliptical orbits, this method will give you wrong results after a few orbits. There are many simple recommendations I can give you on how to further improve your code once it is fixed (normalizing units, a better integration scheme, etc.).

-
I added to the original post what my issue was, thank you. I'd be very interested in your recommendations. I know that this technique is fraught with problems, but the basic premise was to test that my simple gravity model and animation was being applied properly, which would demonstrate itself if the Earth ran in a circle. – Will Hartung Feb 27 '11 at 21:34
– Platypus Lover Feb 27 '11 at 22:26

1
– Platypus Lover Feb 27 '11 at 22:34

Dear Will, your error is that you think that the acceleration $a$ adds distances $s$ linearly in time $t$. In reality, it adds them quadratically via the formula $$s = \frac{1}{2} at^2$$ Many kids know this formula: it's the time $t$ multiplied by the average speed during the interval which is $(v_{initial}+v_{final})/2=at/2$. The graph of the motion is a parabola, a good approximation whenever the acceleration is approximately constant during the short enough time interval. In other words, you have increased the velocity during the first second, but you forgot to increase the velocity by the same amount during the remaining $86,399$ seconds of the first day.

After the first second, the velocity changes by $0.0055 m/s$ and the total distance the Earth travels during the first second is $0.0055/2 = 0.00275 m$. However, if you study how this distance changes if you increase 1 second to 86,400 seconds, the total distance doesn't jump 86,400 times. Instead, it jumps $(86,400)^2$ times, to $$0.0275 \times 86,400^2 = 20,528,000 m.$$ You may check that 20,000 kilometers is approximately - within the errors that you introduced - the right amount to keep the Earth on a quasi-circular orbit because $$\frac{155\times 10^9 m}{2}\left(\frac{2\pi}{365.25}\right)^2 = 20,000,000 m$$ or so. In the equation above, I calculated the angle of the rotation around the Sun, squared it, divided by two (that's the approximation of $1-\cos\phi$), and multiplied by the radius.

After 86,400 seconds, the final speed in the transverse direction is not $0.0055 m/s$ as you assumed but $86,400\times 0.0055 m/s$.

-

Your units are wrong. Your acceleration of 0.0055 is m/s^2, and when you multiply by 86400 s/day, you get m/s/day, and not m/day^2, which is what you think you're getting. That's what confused you.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 15, "mathjax_display_tex": 8, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9547122716903687, "perplexity_flag": "middle"}