Thomas Faour 2859edb62e fixes
2025-06-20 17:15:02 -04:00
2025-06-20 17:12:56 -04:00
2025-06-20 17:15:02 -04:00
2025-06-20 17:13:34 -04:00
2025-06-20 17:12:56 -04:00

Orbital Simulator

A fast N-body orbital mechanics simulator written in Rust.
Simulate the motion of celestial bodies under Newtonian gravity, with easy configuration and efficient output for visualization.


Features

  • N-body simulation
  • Configurable initial conditions via JSON
  • Binary trajectory files
  • Progress bar
  • Unit normalization
  • Ready for visualization (Coming Soon)

Getting Started

Prerequisites

  • Rust (edition 2021 or later)
  • Bevy dependencies (for 3D visualization; see Bevy's docs for Linux requirements)

Build

cargo build --release

Running the Simulator (CLI)

cargo run --release --bin simulator -- \
  --config path/to/your_config.json \
  --time 30d \
  --step-size 10.0 \
  --output-file trajectory.bin

Arguments:

  • --config (required): Path to your JSON config file with initial body states.
  • --time (required): Total simulation time (e.g. 10s, 5m, 2h, 100d).
  • --step-size: Simulation step size in seconds (default: 10.0).
  • --output-file (required): Where to save the trajectory data.
  • --steps-per-save: How often to update the progress bar and save (default: 1000).

Running the 3D Visualizer (orbiter)

cargo run --release --bin orbiter
  • Opens a 3D window with a camera and a blue sphere (placeholder for future simulation data).
  • Camera controls:
    • Right mouse drag: Orbit around the origin
    • Scroll wheel: Zoom in/out

Future updates will allow loading and animating simulation output.


Configuration

The config file is a JSON file describing the initial state of each body.
Examples provided in config/

{
  "bodies": [
    {
      "name": "BodyName",
      "mass": 1e10, //kg
      "position": [0.0, 0.0, 0.0], //meters
      "velocity": [0.0, 0.0, 0.0] // m/s
    },
    ...
  ]
}
  • Units:
    • Mass: kilograms (kg)
    • Position: meters (m)
    • Velocity: meters per second (m/s)

Output

  • The simulator writes binary snapshots of the system state to the output file using bincode.
  • Each snapshot contains the simulation time and the real (de-normalized) positions, velocities, and masses of all bodies.

Extending

  • Add more bodies or change initial conditions in the config file.
  • Adjust step size and simulation time for accuracy/performance trade-offs.
  • The code is modular and ready for extension (e.g., new force laws, output formats, or integrators).

License

MIT License


Acknowledgments


Author

  • Thomas Faour
Description
Basic orbital mechanics simulator and visualization
Readme 6.7 MiB
Languages
Rust 28.6%
TypeScript 28.5%
Python 25.1%
Shell 10.3%
CSS 5.5%
Other 2%