Skip to content

Commit d702aba

Browse files
foxontheerunclaude
andcommitted
Build out standalone Solar System demo
- Velocity-Verlet N-body integrator (src/physics-engine.js) with vendored three.js@0.160.0 (vendor/three/); zero CDN runtime dependency. - KAM-stability presets (Real, phi, 2:1, 3:1, break) with physically- justified parameters and inline cheat-sheet explainers in the HUD. - Diagnostics with osculating Saturn:Jupiter period ratio (live Great Inequality readout) computed from current positions via vis-viva. - Mobile-first HUD: bottom-sheet layout below 768px, accessible sliders (label/for associations), touch targets >=44px, prefers-reduced-motion pauses simulation on load. - Floating pause and screenshot controls (top-center) with SVG icons. Screenshot saves a PNG of the current frame; spacebar toggles pause. - CSS design-token system: styles/tokens.css holds all custom properties, styles/main.css holds the rest. Retheming is a single-file edit. - vitest unit tests for orbital-mechanics + physics-engine: 20 tests covering Kepler placements, LRL eccentricity, energy/angular-momentum conservation, COM invariance, capture detection. All passing. - Documentation: README with file map and live-demo instructions; PHYSICS.md with units, integrator choice, force derivations, KAM-preset physical justifications, what's NOT modelled, and references (Murray-Dermott, Wisdom-Holman, Laskar, KAM classics, Doyle Kepler-16b). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2b0d84d commit d702aba

21 files changed

Lines changed: 57956 additions & 481 deletions

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# OS
2+
Thumbs.db
3+
ehthumbs.db
4+
Desktop.ini
5+
.DS_Store
6+
7+
# Editors
8+
.vscode/
9+
.idea/
10+
*.swp
11+
*~
12+
13+
# Node — test runner deps (vitest, three). Runtime is still no-build,
14+
# but `npm install` is needed before `npm test`.
15+
node_modules/
16+
npm-debug.log
17+
.npm
18+
19+
# Local notes / drafts not intended for the repo
20+
*.local.md
21+
scratch/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Alsu Bulatova
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PHYSICS.md

Lines changed: 302 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@ Built with [three.js](https://threejs.org/), no build step required.
1111
## What you can do
1212

1313
- Watch the real Solar System under Newtonian gravity at speeds from 1 to 1000 years per second.
14-
- See Mercury's perihelion precession (the classical Newtonian part — about 5557″/century).
14+
- See Mercury's perihelion precession from planetary perturbations — about 532″/century is the part an N-body integrator can in principle reproduce at long times (the 43″/century relativistic excess is not modelled; the demo doesn't measure the precession rate explicitly).
1515
- Switch to the inertial frame and see the Sun wobble around the system's centre of mass (the basis of the radial-velocity exoplanet-detection method).
1616
- Break stability through any of four mechanisms: planet masses, orbital eccentricities, inclinations, or gas drag.
1717
- Apply KAM presets that demonstrate specific dynamical regimes: golden-ratio resonance protection, integer resonances (2:1, 3:1) at Kirkwood-gap positions, and full catastrophic collapse.
1818

1919
## Files
2020

2121
```
22-
solar-system-split/
22+
solar-system/
2323
├── index.html page structure, importmap for three.js, UI panels
24-
├── styles.css HUD, sliders, accordion sections
24+
├── styles/
25+
│ ├── tokens.css CSS custom properties (colours) — edit to retheme
26+
│ └── main.css HUD, sliders, sections, mobile media queries
2527
├── main.js scene assembly and orchestration
2628
├── README.md
29+
├── PHYSICS.md
30+
├── LICENSE MIT
31+
├── .gitignore
32+
├── vendor/three/ pinned three.js@0.160.0 (vendored — no CDN dependency)
2733
├── screenshots/ preview images
2834
└── src/
2935
├── data.js planet data, KAM presets, camera presets
36+
├── theme.js planet and Sun colour palette
3037
├── orbital-mechanics.js Kepler ↔ Cartesian, instantaneous eccentricity
3138
├── physics-engine.js N-body Velocity-Verlet integration with drag
3239
├── scene-builder.js scene, lights, mesh factories, barycenter marker
@@ -35,12 +42,27 @@ solar-system-split/
3542
└── animation-loop.js requestAnimationFrame, HUD updates
3643
```
3744

45+
## Tests
46+
47+
Unit tests for the pure-math modules and integration tests for energy / angular-momentum / centre-of-mass conservation.
48+
49+
```bash
50+
npm install # one-time: installs vitest and three for testing
51+
npm test
52+
```
53+
54+
Runtime stays no-build — the npm dependencies are dev-only and live in `node_modules/` (gitignored). The page itself loads three.js from the vendored `vendor/three/`.
55+
56+
## Physics and numerical methods
57+
58+
See [PHYSICS.md](PHYSICS.md) for detailed documentation of units, the Velocity-Verlet integrator, force calculations (Newtonian gravity + linear gas drag), coordinate frames, derived quantities (Laplace–Runge–Lenz eccentricity, Kepler period), KAM preset rationale, asteroid-belt simplifications, and references.
59+
3860
## Run locally
3961

4062
ES modules require a local HTTP server — opening `index.html` directly via double-click will fail with CORS errors.
4163

4264
```bash
43-
cd solar-system-split
65+
cd solar-system
4466
python -m http.server 8000
4567
# then open http://localhost:8000 in browser
4668
```
@@ -49,26 +71,16 @@ Or any other static server (Node `http-server`, VS Code Live Server extension, e
4971

5072
## Deploy to GitHub Pages
5173

52-
1. Create a new GitHub repository (e.g. `solar-system`).
53-
2. Copy the contents of this folder into the repo root.
54-
3. Commit and push:
55-
56-
```bash
57-
git init
58-
git add .
59-
git commit -m "Initial commit: solar system simulation"
60-
git branch -M main
61-
git remote add origin git@github.com:YOUR_USERNAME/solar-system.git
62-
git push -u origin main
63-
```
74+
If you fork this repository and want to publish your own copy:
6475

65-
4. In the repository on GitHub: **Settings → Pages → Source: Deploy from a branch → Branch: main → / (root) → Save.**
66-
5. Wait ~1 minute. The site will be live at `https://YOUR_USERNAME.github.io/solar-system/`.
76+
1. Push the contents to the root of a public GitHub repository.
77+
2. Open **Settings → Pages**, set Source to **Deploy from a branch**, Branch to **main**, folder to **/ (root)**, and Save.
78+
3. After ~1 minute the site will be live at `https://<your-username>.github.io/<repo-name>/`.
6779

6880
## Embedding on another site
6981

7082
```html
71-
<iframe src="https://YOUR_USERNAME.github.io/solar-system/"
83+
<iframe src="https://<your-username>.github.io/<repo-name>/"
7284
width="100%" height="700"
7385
style="border: none; border-radius: 12px;">
7486
</iframe>
@@ -78,7 +90,7 @@ git push -u origin main
7890

7991
The simulation reproduces several real celestial-mechanical effects, in order of how visible they are:
8092

81-
1. **Perihelion precession of Mercury** (Newtonian only — ~5557″/century, classical part). Visible at speeds above 100 years/s as the orbit plane slowly turning.
93+
1. **Perihelion precession of Mercury** — about 532″/century from gravitational perturbations by the other planets is what an N-body integrator is expected to reproduce at long times (the demo doesn't measure it explicitly). The famous additional 43″/century that Einstein explained via General Relativity is not modelled here; the often-quoted total of ~5600″/century includes the precession of the equinox itself, which is a choice-of-frame effect rather than an orbital one. Visible at speeds above 100 years/s as the orbit plane slowly turning.
8294
2. **Sun wobble around the barycenter** in the inertial frame. The barycenter of the Sun-Jupiter pair lies 1.07 solar radii outside the Sun's surface in reality. Use the visual-scale slider to shrink the Sun and verify this geometrically.
8395
3. **Precession of ascending nodes**, eccentricity oscillations (Laplace-Lagrange cycles, ~100 000-year period for Earth), inclination drift.
8496
4. **Near-resonance Jupiter-Saturn** ~5:2 ratio is a stable feature of the actual Solar System, reproduced naturally by N-body integration.
@@ -96,4 +108,8 @@ The simulation reproduces several real celestial-mechanical effects, in order of
96108

97109
## License
98110

99-
MIT.
111+
Released under the [MIT License](LICENSE).
112+
113+
## Author
114+
115+
[Alsu Bulatova](https://bulatovaalsu.substack.com) — independent researcher.

0 commit comments

Comments
 (0)