Astro simulation program problem - program bugs?

Click For Summary

Discussion Overview

The discussion revolves around a programming issue encountered in a simulation project focused on the interaction of orbital objects. Participants are exploring the calculations involved in simulating gravitational forces and motion based on user-defined parameters such as mass, position, and velocity of the objects.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes the simulation's approach, which calculates the gravitational force between pairs of objects and updates their velocities and positions based on a timestep.
  • Another participant suggests that the correct method involves summing all forces acting on an object, dividing by the object's mass, and then updating the speed accordingly.
  • A question is raised about the significance of summing forces versus calculating changes in speed directly.
  • A participant acknowledges a mistake in their earlier explanation regarding the averaging of acceleration and indicates that the issue persists despite this correction.

Areas of Agreement / Disagreement

Participants express differing views on the correct approach to calculating forces and updating velocities, indicating that there is no consensus on the best method to resolve the simulation's issues.

Contextual Notes

There are unresolved assumptions regarding the implementation of the gravitational calculations and the specific definitions of the terms used in the simulation. The discussion does not clarify whether the formulas applied are universally accepted or if they depend on specific conditions.

concious
Messages
3
Reaction score
0
Hello all,

for the past few weeks my friend and me have been working on a project involving simulation of orbital objects interaction. For example, one could see how everything looks if he/she entered all the details about the objects (that is: mass, position and velocity vector). The simulation is based on timesteps, that is, the system calculates new positions of objects after a timestep (default is one day). One can see how everything looks by "timestepping".

The problem is, the calculations are bogus!
Moreover, the formulas used MUST be right and this puts us into confusion:
the problem lies not in the program but in the principle used.

We pick each two objects, calculate the distance between them, the gravitational force between the objects, the average of speed gained ant the latter is added to objects' speed (obj.speed.x += accel.x * time_step / 2). After all that we move all the objects (like obj.place.x += obj.speed.x * time_step).
Everything is calculated in the SI.

We tested the system with the Earth and the Sun and it results in Earth going out of the orbit! So something's certainly wrong...

We would appreciate any help. If there is any interest, we can send you the sources (C++, GPL license) which compile great on Win32 and Linux (OpenGL is used for displaying 3D graphics).

Thanks in advance.
 
Last edited:
Astronomy news on Phys.org
aren't you supposed to sum all the forces and then divide by object mass and multiply that by delta_t and add that to speed?
 
What difference does that make if we sum the forces or the delta_speed? :?
 
I thought you were saying you averaging them
 
Yes, that was a mistake, there should be accel * time / 2... Though it doesn't help :/.
 
Last edited:

Similar threads

  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
17
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 86 ·
3
Replies
86
Views
8K