What It Demonstrates

This simulation uses Smoothed Particle Hydrodynamics (SPH) — a Lagrangian mesh-free method widely used in astrophysics, oceanography, and game engines. Each water particle interacts with neighbours within a smoothing radius h. Pressure forces prevent compression; viscosity damps velocity differences; gravity pulls everything down. The result is a realistic dam-collapse and wave-runup with splashing and free-surface dynamics.

How to Use

Click Reset Dam to restart the simulation. Increase Gravity for a faster, more violent collapse. Raise Viscosity to simulate honey-like flow. Increase Pressure Stiffness to make the fluid less compressible. Switch color modes to visualise speed, pressure, or density fields.

Did You Know?

SPH was originally invented by Lucy (1977) and Gingold & Monaghan (1977) to simulate astrophysical phenomena. Today it powers the fluid simulations in video games like Half-Life 2's water, hurricane storm surge models, and blood-flow in arteries.

About this simulation

Every particle in this dam break carries its own mass, velocity, and density; a cubic-spline kernel W(r,h) blends properties from neighbours within a smoothing radius of 18 pixels. Density is accumulated with the poly6 kernel, pressure is computed from p = k(ρ−ρ₀), and the spiky-gradient and viscosity-Laplacian kernels turn that pressure and neighbour velocity differences into forces — plus gravity — that are integrated with simple Euler steps at dt = 0.004.

🔬 What it shows

A rectangular column of particles on the left 32% of the tank collapses under gravity, splashes against the far wall, and settles — the classic SPH benchmark used to validate free-surface fluid solvers.

🎮 How to use

Adjust Particles for resolution, Gravity and Viscosity for collapse speed and thickness, Pressure stiffness for compressibility, and Rest density ρ₀ for the equilibrium point pressure resists. Switch Colour By between Speed, Pressure, and Density, and press Reset Dam to rebuild the column.

💡 Did you know?

SPH was invented independently by Lucy (1977) and Gingold & Monaghan (1977) to model exploding stars in astrophysics — decades before it became the go-to technique for water in video games like Half-Life 2 and for storm-surge and blood-flow simulations.

Frequently asked questions

What is Smoothed Particle Hydrodynamics (SPH)?

SPH is a mesh-free, Lagrangian method for simulating fluids: instead of a fixed grid, the fluid is represented by particles that carry mass, velocity, and density, and interact only with neighbours inside a smoothing radius h via weighting kernels. It's widely used in astrophysics, oceanography, and game engines.

How does the simulation compute water pressure?

Each particle's density is estimated by summing a poly6 kernel over nearby particles, then pressure is derived from the equation of state p = k(ρ−ρ₀), where k is the Pressure stiffness slider and ρ₀ is Rest density. Higher density than ρ₀ produces positive pressure that pushes particles apart, resisting compression.

What does increasing viscosity actually do?

The viscosity term uses a Laplacian kernel to damp velocity differences between neighbouring particles, effectively "smoothing out" relative motion. Raising it makes the fluid behave more like honey — waves die out faster and splashing is suppressed.

Why do particles bounce off the walls?

The simulation applies simple reflective boundary conditions: whenever a particle crosses the tank's left, right, top, or bottom edge, its position is clamped back inside and its velocity component perpendicular to that wall is reversed and damped by a factor of 0.4, mimicking an inelastic collision with a solid boundary.

Why does raising Pressure stiffness make the fluid less compressible?

Pressure stiffness (k) scales how strongly density deviations from ρ₀ turn into repulsive pressure forces. A higher k means even a small compression generates a large restoring force, so particles resist being packed closer together — approximating the near-incompressibility of real water.