A modular, minimalistic, and physically accurate orbital simulator.
Experience as a modern interactive web app or classic desktop Python/matplotlib animation. Powered by symplectic Velocity-Verlet integration, Flask, and vanilla JS.
- Overview
- Screenshots / GIFs
- Features
- Architecture
- Quickstart
- Editing or Adding Bodies
- What's New in 2.0
- Numerical Analysis
- Future Work
- Known Issues
- Contributing
- License
- Credits
Orbit2.0 simulates orbital motion using energy-conserving Velocity-Verlet integration for long-term orbital stability. Built around a lightweight, performance-focused architecture designed for clarity, efficiency, and a seamless user experience while avoiding unnecessary complexity.
Experience it as:
- Desktop: Python + 3D Matplotlib animation (for research, teaching, or offline demos).
- Web: Flask backend + HTML/JS/CSS frontend (modern interactive 2D simulation).
Both interfaces use the same NumPy-based simulation core for scientific consistency.
- Symplectic Velocity-Verlet integration (replaces semi-implicit Euler), numerically stable for long-term orbits.
- Planetary/body data stored in editable
bodies.json.
- Dynamic body selection via interactive cards.
- Real-time Canvas animation with buffering and interpolation.
- Server-Sent Events (SSE) for low-latency updates.
- Play/Pause toggle, zoom in/out, configurable trails, starry background, and auto pause on tab change.
- Modular OOP physics core (sim.py).
- Flask backend serves snapshots to web; Matplotlib mode remains fully supported.
- Fully responsive design for desktop & mobile.
- Clean separation of code, data, and UI for maintainability.
- Open-source.
git clone https://github.com/Root3141/Orbit.git
cd Orbit
pip install -r requirements.txt
python app.py
Open http://localhost:5000 or view the live demo here↗.
python sim.py
[bodies.json]
|
+---------------------+
| simulation.py | <-- Shared simulation engine (NumPy + Verlet)
+---------------------+
| |
[Matplotlib] [Flask backend/API]
|
[HTML/JS frontend]
All celestial object data lives in bodies.json.
Add, remove, or edit entries - changes are reflected instantly in both interfaces.
| Feature | v1.0 | v2.0 (Current) |
|---|---|---|
| Integration | Semi-implicit Euler | Velocity-Verlet |
| Data | Hardcoded | Editable JSON file |
| Visualization | Matplotlib only | Web + Matplotlib |
| Architecture | Flat script | Modular, shared core, clean separation |
| UI/UX | Static plots | Modern, animated, interactive web UI |
In orbital simulation, small numerical errors may lead to long-term drift in energy and angular momentum, leading to orbits drifting off or causing false precession. To counter that, Orbit uses Velocity-Verlet integration which is a symplectic integration method (meaning it preserves the qualitative structure of the symplectic manifold, leading to bounded long-term errors in conserved quantities), resulting in bounded errors in energy and angular momentum rather than secular drift. To evaluate this, the engine was benchmarked against Euler and RK4 integrators.
While Velocity-Verlet remains closely bounded and oscillates around the initial energy state, the other methods exhibit secular drift.
Log-scale plot of relative energy error
By preserving the symmetry of the central force field, the Velocity-Verlet engine maintains angular momentum precision several orders of magnitude higher than standard integrators.
Log-scale plot of relative angular momentum error
Since Velocity-Verlet is symplectic, it preserves phase space volume, resulting in closed orbits in phase space over long simulations, while Euler catastrophically spirals and RK4 slowly drifts (despite higher computing costs).
Phase Space trajectory of Mars
Tip
For further details, see the analysis notebook.
- Modularize frontend JS/CSS for maintainability
- Expose user-configurable options (timestep, colors, trail memory)
- Expand
bodies.jsonto include moons, comets, dwarf planets - Optional: Web Workers/WebGL support for performance
- Add multi-user support
- On the deployed web version (Render), resuming a paused simulation may occasionally jump ahead instead of continuing from the pause point before proceeding smoothly. This does not occur when running locally, where it resumes as expected.
Pull requests are welcome!
For major changes, please open an issue first to discuss what you’d like to improve.
Developed by Aaryan Aaloke


