This is a simple N-body simulation of Celestials.
-
2D vs 3D: For now we choose to use 3D, but we can also use 2D.
-
System invariance and consistency of state
Regardless of how and where the bodies are initialized, the states of these initialized points should also be consistent.
- potential solution:
- center of mass frame
- fixing the initial positions of the bodies
- use invariant encodings of the state
- Collision detection
-
Properties
- mass (m)
- position (x, y, z)
- velocity (vx, vy, vz)
-
Default Units
- ( G = 1 )
- ( M_{\text{planet}} = 1 )
- ( M_{\text{star}} = 1 )
A one star and one planet system is used as the default system.
-
Solar-sys like Units
- ( Yr = 365.25 ) days (Julian)
- ( AU = 1.495978707 \times 10^{11} ) m
- ( M_{\text{sun}} = 1.98855 \times 10^{30} ) kg
- ( G = 4 \pi^2 \left( \frac{AU^3}{M_{\text{sun}} \times Yr^2} \right) = 39.47841760435743 )
Details explaination about the units and gravitational constant.
-
Properies (State)
- mass (m)
- position (x, y)
- velocity (vx, vy)
-
Energy
- kinetic energy
- potential energy
-
Default Units
- ( G = 1 )
- ( M_{\text{celestial}} = 1 )
-
Return Values
- Position and Velocity of the bodies in time steps (x, y, vx, vy)
- Derivatives of the position and velocity of the bodies in time steps (dx/dt, dy/dt, dvx/dt, dvy/dt)
- Energy of the system in time steps (e = potential + kinetic)
A more advanced implementation: Using the Rebound library to calculate the gravitational interactions between the bodies. The simulation is done in 3D, but the output is a 2D projection of the orbits on the XY plane.
- Properties
- mass (m)
- position (x, y, z)
- velocity (vx, vy, vz)