Help with Orbit Sim: 2-Body Anomalous Motion Problem

  • Thread starter check
  • Start date
  • Tags
    Orbit
In summary, the conversation is about a person's attempt to create a multiple body 2D orbit simulator using Qbasic as a hobby. They have encountered a problem with the motion of the system, where one body does not have the expected wobble when another body is orbiting around it. They have realized that the issue may be due to the forces being added twice during a loop and have made adjustments to fix it. They also suggest incorporating the z axis and using real units for more accuracy in the simulation.
  • #1
check
145
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

  • grav1.txt
    1.7 KB · Views: 437
Astronomy news on Phys.org
  • #2
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.
 
  • #3
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:

FAQ: Help with Orbit Sim: 2-Body Anomalous Motion Problem

1. What is the 2-body anomalous motion problem in orbit simulation?

The 2-body anomalous motion problem in orbit simulation refers to the mathematical challenge of accurately predicting the trajectory of an orbiting object around a central body, such as a planet or star. This problem arises due to the influence of other forces, such as gravitational forces from other objects, that can affect the orbit of the object in question.

2. How do you solve the 2-body anomalous motion problem in orbit simulation?

There are various mathematical methods and algorithms that can be used to solve the 2-body anomalous motion problem in orbit simulation. Some common approaches include using numerical integration methods, such as the Runge-Kutta method, or analytical methods, such as the Kepler's equations.

3. What factors affect the accuracy of orbit simulations?

The accuracy of orbit simulations can be affected by various factors, including the precision of input data, the complexity of the orbital system, the chosen mathematical model, and the computational power of the simulation program. Other factors, such as external forces and perturbations, can also contribute to the accuracy of the simulation.

4. Can the 2-body anomalous motion problem be solved for all types of orbits?

No, the 2-body anomalous motion problem cannot be solved for all types of orbits. This is because certain types of orbits, such as highly elliptical or chaotic orbits, may require more complex mathematical models and simulations, making them difficult to accurately predict and solve.

5. How can orbit simulations be used in real-world applications?

Orbit simulations have various real-world applications, including in space exploration, satellite and spacecraft operations, and astronomical studies. They can also be used in engineering and design processes for space missions and in understanding and predicting the behavior of celestial bodies in the universe.

Similar threads

Replies
6
Views
534
Replies
4
Views
2K
Replies
23
Views
4K
Replies
6
Views
967
Replies
18
Views
3K
Replies
3
Views
1K
Replies
19
Views
10K
Replies
2
Views
2K
Replies
3
Views
2K
Back
Top