- #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.
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.