# Using iteration to orbit dual suns - losing energy

## Main Question or Discussion Point

Using iteration I've got a satellite flying around two gravity sources. (See picture)

When using the iteration over a 100 times I see that TE, total energy slowly sinks so I need to make a correction after each iteration to insure that TE is constant.

Trouble is I have several possibilities :

Example : at the start I have :
PE = -100 KE = 125 => TE = 25

after one iteration I have TE = 20 (a quite exaggerated difference in this example)
I have lost 5 Joules.

to compensate :
A should I increase the KE by 5, increasing the magnitude of the velocity by sqrt(5)?

B should I increase the PE by moving the satellite a bit farther away from the GS bodies?

C should I split the difference evenly? Each should compensate 2.5 Joules.

D should I split the different 4:5 or 5:4 due to the different sizes of PE and KE?

Maybe I need a Math professor for this one.

#### Attachments

• 13.6 KB Views: 305

Related Astronomy and Astrophysics News on Phys.org
mfb
Mentor
Which method do you use to calculate your iterations?
Can you track where the error comes from?

Increasing the velocity can be tricky - add velocity in which direction? In the same way, shift the body in which direction?

>>Which method do you use to calculate your iterations?

I found by way of another entry in this forum a link to a site where
'Euler Implicit' and 'Euler Explicit' and 'Euler Semi-Implici' were described

http://www.physics.udel.edu/~jim/Ordinary%20Differential%20Equations/The%20Implicit%20Euler%20Method.pdf [Broken]

http://web.mit.edu/10.001/Web/Course_Notes/Differential_Equations_Notes/node3.html

http://en.wikipedia.org/wiki/Semi-implicit_Euler_method

I use the semi-implicit method so :
where I first calc the position :

newPos = oldPOs + time*oldVelocity

Then I use the old velocity and new accelleration to find the new velocity.
All done with 2 dimensional vectors.

newVel = oldVel + time*newAccelleration

the websites said p(k+1) = p(k) + time*v(k)
v(k+1) = v(k) + time*acc(k+1)

>>Increasing the velocity can be tricky - add velocity in which direction? In the same way, shift the body in which direction?

I do not alter the direction in any way, just multiply the scaler value of the magnitude of the vecotr.

In the picture I put one gravity source at a position and got (not using iteration) a beautiful ellipse. However I take two gravity sources and place them each at the same position (each with half the original mass) and when using iteration I expect the same curve.

A point at the top at Y = 380.0 should be met after 198 iterations. I always come to it in this example at 379.5.

Now the punchline : when I try to get more accuracy by increasing the speed and thereby increasing KE by the amount of energy it loses in TE in each iteration,
then the inaccuracy increases to 383.7 !!!!! instead of 380.0.

My attempt to increase accuracy has decreased accuracy.

#### Attachments

• 23.1 KB Views: 314
Last edited by a moderator:
mfb
Mentor
Why do you expect more accuracy with increased speed? Do you get a better accuracy with a reduced time step?
Maybe you can test other integration methods.

Did you try A or B? Do they help?

When using the iteration over a 100 times I see that TE, total energy slowly sinks so I need to make a correction after each iteration to insure that TE is constant.
What you really need to do is

1) reduce the number of iterations so that the TE is constant
2) If 1) doesn't work consider using another differencing scheme (i.e. Runga-Kutta)

Adding things post-hoc to get the numerics to work usually ends up not working very well.

Also, one thing to do is to try to look at the energy with smaller time steps. If you use small time steps and your energy is still going down at the same rate, then this isn't an issue with the difference scheme. It could be a bug in the way that energy is being calculated.

>>1) reduce the number of iterations so that the TE is constant

Reducing the number of iterations does not cause the TE to become constant.

>>Also, one thing to do is to try to look at the energy with smaller time steps.

Smaller times steps = increasing number of iterations.

Done that, the TE rate of change becomes less, goes down at a slower rate,

but I am looking for an iteration algorithm which is more accurate.

>>It could be a bug in the way that energy is being calculated.

The energy is calculated in the same manner, always.

*****************

I'll look into Runga-Kutta