Help with Orbit Sim: 2-Body Anomalous Motion Problem

  • Context: Graduate 
  • Thread starter Thread starter check
  • Start date Start date
  • Tags Tags
    Orbit
Click For Summary
SUMMARY

The forum discussion centers on the challenges faced in developing a 2D orbit simulator, specifically addressing anomalous motion in a two-body system. The user, utilizing Qbasic, encountered issues with the expected wobble of a heavier mass (M2) when a lighter mass (M1) orbits it. The solution involves ensuring that M2 has a counteracting initial velocity relative to the system's barycenter, rather than M1. The discussion also highlights the importance of using real units for gravitational calculations to achieve accurate simulations.

PREREQUISITES
  • Understanding of gravitational physics and orbital mechanics
  • Familiarity with programming concepts in Qbasic
  • Knowledge of barycentric coordinates and their application in simulations
  • Experience with numerical methods for simulating physical systems
NEXT STEPS
  • Implement barycentric motion calculations in your simulator
  • Explore gravitational constant values and their application in simulations
  • Learn about adding a third dimension (z-axis) to orbital simulations
  • Investigate the use of real-world units in physics simulations for accuracy
USEFUL FOR

Aspiring game developers, physics enthusiasts, and hobbyists interested in creating realistic orbital simulations and understanding gravitational interactions in multi-body systems.

check
Messages
146
Reaction score
0
I’ve been trying to make a multiple body 2D orbit simulator off and on for a few years now. Just as sort of a hobby, nothing too serious (ie, doesn’t have to model what would happen in a reality exactly but the body motions should be more or less correct)

Well anyway, I’m not a programmer by any sense of the word. The only language I am somewhat okay at is Qbasic.

I recently started work on a simulator again using a more realistic approach. My previous attempts all looked very nice and were simple enough as to allow up to a thousand bodies to be smoothly calculated and displayed. Because of the calculations required in my latest attempt, only about 40 interacting objects at a time can be smoothly done.

Anyway, things are looking pretty nice except I have one major nagging problem:
When testing on 2 bodies (one mass orbiting another much heavier mass) there seems to be an anomalous motion to the system. Now, I expect the centre, heavy mass to wobble as the lighter mass orbits it, however, the wobble is not complete as I would expect. Please see diagram:
http://img142.exs.cx/img142/3865/grav19fe.gif
(Note, because I’m running the program in DOS, I can’t take a screen shot)

The diagram shows 2 complete orbits of m1 about m2. You’ll notice the wobble of m2 is not a complete circle/oval as is expected. This is my problem, I don’t know why. You see that the system also moves to the right for some reason. In this example, m1 is given an initial velocity in the horizontal direction to the right, but m2 is not. Yet for some reason, m2 moves continually rightward. The graphs at the side of the diagram approximates the x and y component velocities of both m1 and m2 during one orbit. You’ll notice that m1 looks just about as it should while m2 never has a negative x velocity. I have no idea why. I’ve tried changing the order in which the forces are calculated, the initial position of m1 with respect to m2 and I still get the same strange incomplete wobble. If I start m1 to the left of m2 and give it an initial vertical velocity, then the wobble of m2 is incomplete, but in the y direction and the motion of the system is now in the y direction.

The way I program is really gross and incoherent, but that’s just my style. The program is attached if anyone can make sense of it. I’ve checked over the calculations and they all seem to be fine. The problem is always with the greater mass.

*Actually while I was writing this, I realized that the problem may be that the forces are added twice (and thus changing velocities) during a loop. I fixed that and now the lighter masses don’t spiral into the heavier ones, but the weird motion of the system still remains.
 

Attachments

Astronomy news on Phys.org
Here's what's happening.

Even though you don't give M2 any initial velocity, the velocity you give to M2 is with respect to M1, not the system barycenter. As you guessed, M2 will not sit still. So it is not the stationary point in your system. That's why it drifts. M2 needs to have a little bit of of leftward motion to counter M1's rightward motion. So that the combined motions on the x-axis = 0. But it must be a weighted calculation unless your masses are the same. For example, if M1 has a velocity of 4 km/s in the x direction relative to M2, and M1 is half the mass of M2, then you should give m1 an initial velocity 2.667 km/s to the right, and M2 an initial velocity of 1.333 km/s to the left. These velocities still add to 4, so m1 will still be moving 4 km/s relative to 2. But now the speeds are relative to the system barycenter, which does not move.

I encountered this problem in Gravity Simulator, a program I wrote in Visual Basic and C++ that is similar to what you're trying to do. ( www.gravitysimulator.com )

By the way, it's not much more work to add the z axis to your computations. If you do this, and you use real units and numbers instead of ones you make up, your system should be quite accurate. ie: Use 6.672e-11 for G, 5.98e24 kg for Earth's mass, express your distances in meters, and your velocity in m/s, and you'll notice that the period of an object at the moon's orbit behaves just like the real moon. Low Earth satellites too.
 
tony873004 said:
Here's what's happening.

Even though you don't give M2 any initial velocity, the velocity you give to M2 is with respect to M1, not the system barycenter. As you guessed, M2 will not sit still. So it is not the stationary point in your system. That's why it drifts. M2 needs to have a little bit of of leftward motion to counter M1's rightward motion. So that the combined motions on the x-axis = 0. But it must be a weighted calculation unless your masses are the same. For example, if M1 has a velocity of 4 km/s in the x direction relative to M2, and M1 is half the mass of M2, then you should give m1 an initial velocity 2.667 km/s to the right, and M2 an initial velocity of 1.333 km/s to the left. These velocities still add to 4, so m1 will still be moving 4 km/s relative to 2. But now the speeds are relative to the system barycenter, which does not move.

I encountered this problem in Gravity Simulator, a program I wrote in Visual Basic and C++ that is similar to what you're trying to do. ( www.gravitysimulator.com )

By the way, it's not much more work to add the z axis to your computations. If you do this, and you use real units and numbers instead of ones you make up, your system should be quite accurate. ie: Use 6.672e-11 for G, 5.98e24 kg for Earth's mass, express your distances in meters, and your velocity in m/s, and you'll notice that the period of an object at the moon's orbit behaves just like the real moon. Low Earth satellites too.


Oh my! Thank you very much. It all makes sense now :biggrin:
Yeah, I was going to add realistic units a bit later on...maybe I'll add a z-axis. But thanks a lot!

EDIT

Just checked out your program. It's great!
 
Last edited:

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 84 ·
3
Replies
84
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 86 ·
3
Replies
86
Views
9K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 23 ·
Replies
23
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K