My satellite should go in a circle, not an ellipse

Click For Summary

Discussion Overview

The discussion revolves around a programming project aimed at simulating a satellite orbiting a planet in a two-dimensional space. The participant encounters an issue where the satellite's orbit appears elliptical rather than circular, despite using the correct orbital velocity equations. The conversation explores potential reasons for this discrepancy, including numerical errors and the effects of gravitational calculations.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • The participant describes their setup, including scaled constants for gravitational parameters and the expected orbital velocity for a circular orbit.
  • Some participants suggest that "round off error" in numerical iterations could lead to inaccuracies, potentially resulting in an elliptical orbit.
  • One participant questions why discrepancies in accuracy lead to a non-uniform "yo-yo effect" in the orbit, rather than a consistent spiral away from the planet.
  • Another participant points out that the distance measurement might be affected if the gravitational body is not centered correctly, suggesting that the sun's position could influence the perceived orbit shape.
  • The participant clarifies their measurement method, indicating they are measuring from the center of the planet and not from the sun, and expresses a desire for a circular orbit.
  • Details of the iteration process are shared, including how gravitational effects and thrust vectors are calculated and updated during each time step.
  • A question is raised about the applicability of the Euler Method for this simulation.

Areas of Agreement / Disagreement

Participants express various viewpoints regarding the causes of the elliptical orbit, with no consensus reached on the exact reasons. Some agree that numerical errors could be a factor, while others focus on the measurement of distances and the setup of the simulation.

Contextual Notes

Participants note limitations related to numerical accuracy and the potential influence of the gravitational body's position on the orbit's shape. The discussion does not resolve these issues, leaving them open for further exploration.

Who May Find This Useful

This discussion may be of interest to those involved in programming simulations of orbital mechanics, numerical methods in physics, or anyone curious about the challenges of accurately modeling gravitational interactions in a computational environment.

Rapidrain
Messages
31
Reaction score
0
I have been toying with a java programming project for a few months now. I want to
depict a satelite orbiting a planet (2 dimensional).

I've scaled down certain constants to fit the screen and have put GM (mu) at 200000 and
the distance from the gravitaional body, a planet, at 200 (pixels). Using the equations
where a perfect orbital velocity is equal to sqrt(GM/dist), I must have a velocity of
sqrt(1000) 31.62 pixels/sec to remain in a circle.

Problem is my model depicts an ellipse.

The distance starts at 200, drops down to nearly 150 halfway around and climbs up again
(!) to 200 when it reaches the starting point. This is better than crashing into the
planet or flying away in a straight line...but still it should be a "perfect" circle.

I could understand it if my crude iteration method made a consistently "too small" or
"too big" quantity and cause the satellite to slowly spiral into the planet and crash or
caused the satellite to slowly spiral away from the planet. However the satellite
creeps down and then creeps up in a single orbit. Very strange. Why the wobble?

Yes, I am moving in singular one second steps around the planet and complete the orbit
in about 24 steps. And yes, if I took infinitely small steps an infinite number of
times, instead of a finite number of iterations, then I would come out with a perfect
circle. I am not Isaac Newton though.

Can I compensate in any way? Multiply the vector magnitude by sqrt(1/pi) or something
like that? Tilt the initial velocity vector away from the planet by 1/distance degree or
something?
 

Attachments

  • Orbit with 1sec Iteration.jpg
    Orbit with 1sec Iteration.jpg
    15 KB · Views: 528
Physics news on Phys.org
A general problem with iterations like this is "round off error". You are keeping only a limited number of decimal places and the error, unless you are very careful, can add up. That will result, eventually, not just in an ellipse rather than a circle but in a spiral that ends up going off to infinity.
 
Thanks HallsofIvy, I've thought about it, the fact that in some cases 1.0 is depicted as 0.9999999999. I'd like to understand however why any discrepency in accuracy leads to this yo-yo effect.

If my discrepency in accuracy lead 'a spiral that ends up going off to infinity' then okay. I'm happy. It's a discrepency with a uniform effect. Constantly moving away.

However the radius of the orbit goes down and then comes up again. Down and then up. This is not uniform. This is wierd.

But now I must sleep.
 
rapidrain said:
I've scaled down certain constants to fit the screen and have put GM (mu) at 200000 and
the distance from the gravitaional body, a planet, at 200 (pixels). Using the equations
where a perfect orbital velocity is equal to sqrt(GM/dist), I must have a velocity of
sqrt(1000) 31.62 pixels/sec to remain in a circle.

Problem is my model depicts an ellipse.

The distance starts at 200, drops down to nearly 150 halfway around and climbs up again
(!) to 200 when it reaches the starting point. This is better than crashing into the
planet or flying away in a straight line...but still it should be a "perfect" circle.

Where are you measuring the distance from? The image you included seems to have the sun at one of the foci of the ellipse, so if you're measuring the distance from the sun to the planet, and the planet is traveling in an elliptical orbit, then the distance should go up and down as you describe.

If I do some rough eyeball measurements using your drawing, it looks like the sun is located about 40 to 50 pixels to the right of the center of the ellipse. That would account for the discrepancy you are seeing in the distance.
 
Can you show us code snippets or at least your algorithm?
 
to Mark44, I am measuring the distance from the center of the planet (sun, gravitational object). And I *know* it is traveling in an elliptical orbit. I want it to travel in a pure circular orbit. The planet in the center is *indeed* located 50 pixels off-center.

to olivermsun, okay.
I have two vectors.
The first is visible in the screen shot, going off to the right. That is my V-thrust vector. The spaceship fired his engines and attained a velocity of 31.62 which would generate a circular orbit--I wish.

The second is the V-grav caused by gravity after falling one second, calculated each time at the beginning of the interation as 1 sec*GM/(dist**2)

The iteration : In one second gravity at this point causes the object to fall towards the planet a certain distance and also causes the object to attain a downward velocity of V-grav.

The V-thrust vector causes the object to move to the right a certain distance in one second and retains this V-thrust velocity.

I move the object according to the two movements described above.

I give the object a *NEW* V-thrust vector = old-V-thrust + V-grav.
V-grav becomes zero again.

End of the iteration. I start again at this new position, about 14 degrees clockwise from the starting position. Adding the V-grav vector has tilted the V-thrust vector a bit downward.

I've added a screenshot of one single hop.
 

Attachments

  • HopOnce.jpg
    HopOnce.jpg
    23.6 KB · Views: 463
Last edited:

Similar threads

Replies
1
Views
2K
  • · Replies 42 ·
2
Replies
42
Views
8K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 39 ·
2
Replies
39
Views
4K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 126 ·
5
Replies
126
Views
7K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
15
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K