Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeatherBox – Interactive 2D Weather Simulation (MVP)

Interactive weather simulation on a vertical x-z slice of the atmosphere (20 km × 10 km), built according to PRD.md. Orographic clouds, foehn and thermal convection emerge from a stable-fluids solver with moisture physics — nothing is scripted, and physical plausibility beats numerical correctness by design.

Live demo: https://weatherbox-sim.vercel.app

Running locally

Static site without a build step (NFR-03). ES modules require an HTTP server:

task serve        # or: python3 serve.py 8000

Then open http://localhost:8000 in a desktop browser (WebGL2 required).

Usage

  • Presets (top bar): "Orographic lift & foehn", "Summer day", "Lee waves", "Shower day", "Sea breeze" (water/land contrast), "Radiative night" and "Free experimentation" — each with a short description of the expected phenomenon.
  • Time: pause (Space), single step, reset, time lapse (1×–3600×), time-of-day slider.
  • Tools: draw/carve terrain, paint heat, inject moisture, push wind, place radiosondes (max. 2, windward/lee comparison), tracer particles with path trails.
  • Diagnostics: field overlays (T, θ, q_v, RH, w, q_c) with legend and explanations, wind arrows, point inspector (status bar), radiosonde plot (temperature solid, dew point dashed), accumulated-rainfall bar below the scene (radar-like colour scale), wet-ground visualization.

Architecture (NFR-05)

Layer File(s)
Sim kernel (GLSL, ping-pong FBOs) src/shaders.js
Sim orchestration (fixed sub-step loop) src/simulation.js, src/main.js
Rendering (sky, clouds, rain, terrain, overlays) src/renderer.js, src/shaders.js (render)
UI / diagnostics src/ui.js, src/sounding.js, src/particles.js
Physics constants, central & commented src/config.js

Fields: velocity (u, w), θ′ (deviation from the reference profile), q_v, q_c, q_r as RGBA16F textures (256×128); pressure/divergence/curl as R32F. Semi-Lagrangian advection, Jacobi pressure projection (40 iterations, warm-started), buoyancy via θ′ with water loading, Magnus saturation, latent heat, autoconversion/accretion/rain evaporation (Kessler-like, proportional to rain content and subsaturation), surface heat fluxes with a diurnal cycle, water/land surface mask (sea breeze).

Smoke test (NFR-06)

http://localhost:8000/?smoke=1 runs 500 steps of the foehn preset and checks for NaN/blow-up. Result in the console ([SMOKE] OK/FAIL), window.__smokeResult and the page title. Debug API: window.weatherbox (.step(n), .sample(xKm, zKm), .preset(name), .scan(), .smoke()).

Open points (from PRD §10)

  • Q001 grid size: 256×128 chosen; evaluate 512×256 after benchmarking.
  • Q002 advection: decided — bilinear (default). MacCormack is implemented and tested (sharper edges, blend 0.8 + limiter) but looked less realistic; the soft numerical diffusion also doubles as an entrainment substitute. Toggle: weatherbox.app.sim.useMacCormack = true.
  • Q003 UI: custom panel (no Tweakpane) — zero dependencies.
  • FR-24 time-series plot (nice-to-have): not implemented.
  • UI language: English since 2026-08-05 (deviation from NFR-07 by request).
  • Default preset: "Orographic lift & foehn" (deviation from PRD §5.1 — shows the most compelling phenomenon immediately).

License

MIT — see LICENSE.


Created 2026-08-01, last updated 2026-08-06 (README in English, public deployment) · state/SHA: see git log

About

Interactive 2D weather simulation (WebGL2): orographic clouds, foehn, thermal convection — emergent from a stable-fluids solver with moisture physics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages