Skip to content

x1n0x/Planetary-Ocean-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 Planetary Ocean Simulator

An interactive ocean-world simulator with real fluid dynamics

Drag a moon. Sculpt the seabed. Watch the ocean respond.

Physics Frontend Backend Status


What is Planetary Ocean Simulator?

Planetary Ocean Simulator is a browser-based simulator of a water-covered planet. The physics are real β€” rotating shallow water equations on a full sphere, tidal forcing from orbiting moons, topographic reflection β€” but the interface is a Google Earth-style globe with four sliders.

Move the moon closer and watch tidal bulges grow. Spin the planet faster and see zonal jets emerge from the Coriolis force. Raise a seamount and watch waves reflect. The anomaly detector highlights when the ocean enters an unusual state.


Demo

image

Features

  • 🌍 Full-sphere ocean β€” rotating shallow water equations on SΒ², no flat-plane approximations
  • πŸŒ• Live tidal forcing β€” drag moon distance and mass, tides respond in real time
  • πŸŒ€ Coriolis dynamics β€” scale planetary rotation from 0.1Γ— to 5Γ— Earth, watch jets form
  • ⛰️ Seabed sculpting β€” ridges and seamounts reflect waves via volume penalization
  • πŸ”΄ Anomaly detection β€” three-layer DS module: z-score threshold, Isolation Forest, energy spike detector
  • πŸ“Š Live analytics β€” kinetic + potential energy time series, anomaly count, rotation indicator

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Browser (React + CesiumJS + deck.gl)        β”‚
β”‚  Globe Β· Heatmap Β· Vectors Β· Controls        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ REST (JSON)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  FastAPI backend                             β”‚
β”‚  /state Β· /land Β· /scenarios Β· /anomaly     β”‚
β”‚  zarr reader Β· sklearn anomaly models        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ zarr files
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Physics (Dedalus v3, Python)                β”‚
β”‚  Rotating SWE Β· Tidal forcing Β· Topography  β”‚
β”‚  Precomputed scenario library                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Layer Technology
Physics solver Dedalus v3 β€” spectral SWE on SΒ²
Backend API FastAPI + zarr + scikit-learn
3D Globe CesiumJS + deck.gl BitmapLayer
Frontend React 18 + TypeScript + Vite
Anomaly detection scikit-learn Isolation Forest + numpy
Data format zarr (chunked arrays, O(1) timestep reads)
Deploy Railway

Getting Started

Prerequisites

  • Python 3.11+
  • Node 20+
  • Git

1. Clone

git clone https://github.com/youruser/planetary-ocean-simulator.git
cd planetary-ocean-simulator

2. Backend

cd backend
pip install -r requirements.txt

# Generate fake test data (no physics solver needed)
python scripts/generate_test_zarr.py

# Start API
uvicorn main:app --reload --port 8000

3. Frontend

cd frontend
npm install
npm run dev
# Opens at http://localhost:5173

4. Verify

curl "http://localhost:8000/scenarios"
curl "http://localhost:8000/state?scenario=scenario_test_moon384km_omega1x_temp15&t=0"

Project Structure

planetary-ocean-simulator/
β”œβ”€β”€ CLAUDE.md          # Full context for Claude Code (read this first)
β”œβ”€β”€ README.md          # This file
β”œβ”€β”€ physics/           # Kirill's domain β€” Dedalus SWE solver
β”‚   β”œβ”€β”€ simulation.py
β”‚   β”œβ”€β”€ generate_scenarios.py
β”‚   └── validate.py
β”œβ”€β”€ backend/           # Vlad's FastAPI
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ routers/
β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ data/          # zarr stores (gitignored)
β”‚   └── models/        # sklearn models (gitignored)
β”œβ”€β”€ frontend/          # Vlad's React app
β”‚   └── src/
β”‚       β”œβ”€β”€ components/
β”‚       β”œβ”€β”€ hooks/
β”‚       └── utils/
└── docker-compose.yml

Data Contract

The physics module outputs zarr stores consumed by the backend. Full schema documented in CLAUDE.md Β§ 4.

scenario_moon384km_omega1x_temp15/
  eta.zarr        # wave height      (T, lat, lon) float32
  u.zarr          # zonal velocity   (T, lat, lon) float32
  v.zarr          # meridional vel   (T, lat, lon) float32
  chi.zarr        # land mask        (lat, lon)    float32
  E_k.zarr        # kinetic energy   (T,)          float32
  E_p.zarr        # potential energy (T,)          float32
  metadata.json

Physics

The core model is the rotating shallow water equations on a full sphere:

βˆ‚u/βˆ‚t + (uΒ·βˆ‡)u + fΒ·kΜ‚Γ—u = βˆ’gβˆ‡Ξ· + βˆ‡U_tidal + F_drag + F_land
βˆ‚Ξ·/βˆ‚t + βˆ‡Β·(Hu) = 0
f(Ο†) = 2Ω·sin(Ο†)          ← full sphere, not beta-plane

Solved spectrally with Dedalus v3 (SphereBasis, RK443 IMEX timestepper). Topographic reflection via volume penalization (tanh land mask Ο‡).

Full physics specification: CLAUDE.md Β§ 3 and physics/spec_v2.pdf.


Anomaly Detection

Three independent layers stacked into a composite signal:

Layer Method What it catches
1 Rolling z-score per grid cell Local point anomalies (Ξ· > 3Οƒ)
2 Isolation Forest on [Ξ·, u, v, speed] Multivariate outliers
3 Energy spike ratio System-level phase transitions

Ocean cells only β€” land mask applied before flagging.


Roadmap

  • Physics spec v2 (full sphere, corrected tidal force, volume penalization)
  • Zarr data contract agreed
  • FastAPI scaffold + fake zarr generator
  • CesiumJS globe with heatmap (Phase 1)
  • Timeline slider + 4-control panel (Phase 2)
  • First real physics zarr from Kirill (Phase 2 end)
  • Anomaly layers 1 + 3 live (Phase 3)
  • Isolation Forest on real data (Phase 4)
  • Deploy on Railway (Phase 4)

Full build plan: CLAUDE.md Β§ 14.


Team

Person Role
Vlad Frontend (React + CesiumJS), backend (FastAPI), data science (anomaly detection)
Kirill Physics (Dedalus SWE solver), mathematics (tidal mechanics, Coriolis dynamics)

Name

Planetary Ocean Simulator (Ξ˜Ξ¬Ξ»Ξ±ΟƒΟƒΞ±) β€” goddess of the sea in Greek mythology, and a moon of Neptune.


License

MIT

About

Interactive water-world simulator: full-sphere shallow-water ocean physics (Dedalus v3) rendered on a CesiumJS globe. Drag a moon, change rotation, watch tides, currents and anomalies respond in real time. FastAPI + React/TypeScript, zarr data contract, live anomaly detection.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors