EVRION.
Physics·Lab — main project image

Web App · Interactive Simulation

An interactive physics simulator: nine real-time models — from springs and projectiles to N-body gravity, wave interference, and kinetic gas theory — on a shared fixed-timestep RK4 integrator with live charts, adjustable parameters, and selectable planetary gravity.

Project
Physics·Lab
Year
2025
Discipline
Simulation · Data Viz
Stack
React · Vite · RK4

Context

Physics·Lab turns the browser into a working physics lab. Nine simulations across four wings — mechanics (spring, projectile, bouncing ball), chaos & gravity (double pendulum, Kepler orbits, N-body), waves (interference, pendulum wave), and statistical physics (kinetic gas theory) — run live, each with adjustable parameters, preset scenarios, and charts that update as the system evolves.

It's the kind of thing that's easy to fake with canned animations and genuinely hard to do right: real numerical integration that stays stable, conserves what it should, and reveals chaos where it should.

Challenge

Naive physics integration drifts — energy leaks, orbits spiral, and chaotic systems become frame-rate-dependent nonsense. A double pendulum integrated carelessly will give a different answer on a 60Hz screen than a 144Hz one, which defeats the entire point.

And rendering: pushing every physics substep into a chart would either choke the UI or melt memory, so the visualization had to stay smooth without dropping the fidelity of the simulation underneath it.

Approach

All five models share one fixed-timestep RK4 integrator, so the chaotic and orbital systems stay stable and reproducible regardless of frame rate. The physics lives in pure, framework-agnostic functions — state to derivatives to RK4 — completely separate from rendering, which makes it unit-testable and reusable across every sim.

Charts read from rolling, throttled buffers that keep memory bounded and avoid re-rendering on every substep, and the canvases are high-DPI and responsive. Each sim can even run under a different planet's gravity.

Outcome

The undamped spring validates the integrator against the known analytic solution; orbital mechanics conserves energy and angular momentum and traces clean Kepler ellipses; twin double-pendulum runs visibly diverge to demonstrate deterministic chaos. The newer wings push further: the N-body sim reproduces the famous figure-8 three-body choreography, and hundreds of colliding gas molecules settle onto the Maxwell–Boltzmann speed distribution. The physics is correct, not just pretty.

Because the math is isolated in pure functions, it's covered by tests and could be lifted straight into another project — a small simulation engine that happens to ship with a polished dashboard around it.

Technical Detail

React + Vite with React Router and Recharts. The core is a pure RK4 integrator with one math module per model under `src/physics`, unit-tested in isolation; a shared canvas renderer and custom hooks handle the fixed-timestep animation loop, responsive high-DPI drawing, throttled chart buffers, and cross-sim stats.

Planetary gravity data is fetched with a cache and an offline fallback, so swapping the gravity constant per simulation never blocks the render.

// Gallery

Projectile motion against the ideal vacuum parabola
Projectile motion against the ideal vacuum parabola
N-body gravity — the figure-8 three-body choreography
N-body gravity — the figure-8 three-body choreography
Kinetic gas theory — pressure emerging from pure collisions
Kinetic gas theory — pressure emerging from pure collisions

// Next step

The next case study could be yours. Tell us what you're building and we'll tell you honestly how we'd ship it.