Presets
Playback
Fluid
Gravity, viscosity and stiffness of the equation of state.
Scenario and resolution
Initial layout, particle spacing and gravity tilt. Drag in the tank to push or pull the fluid.
Layers
Model checks
The science
Smoothed-particle hydrodynamics
SPH represents a fluid by particles that carry mass, position and velocity. Any field is estimated by a kernel-weighted sum over neighbours within the smoothing radius h; the density at particle i is rho_i = sum_j m_j W(|r_i - r_j|, h). This page uses the 2D poly6 kernel W = 4 / (pi h^8) (h^2 - r^2)^3 for density.
Pressure, viscosity, gravity
A stiff equation of state turns compression into pressure: p = k (rho - rho0), so the speed of sound is about sqrt(k / alpha), where alpha (about 0.4 for this kernel and spacing) is the lattice gradient-consistency factor by which the pressure force is divided and the fluid is weakly compressible. The pressure force uses the symmetrised form f_i = - sum_j m_j (p_i + p_j) / (2 rho_j) grad W_spiky with the spiky kernel gradient -30 / (pi h^5) (h - r)^2, so the force on i from j is exactly opposite to the force on j from i (momentum is conserved). Viscosity uses the Laplacian of the viscosity kernel, mu m_j (v_j - v_i) 40 / (pi h^5) (h - r) / rho_j. Acceleration is a_i = f_i / rho_i + g.
Walls and time step
The tank walls are two layers of static particles that take part in the density and pressure sums, which prevents the density deficit and particle clumping at a wall. The explicit scheme needs a time step below about 0.4 h / c (c = sqrt(k)); this page uses 1 ms.
What the graphs check
In a calm pool the pressure must rise linearly with depth, p = rho g d; the second graph compares the measured profile with this line. The dam-break front travels at about 2 sqrt(g H0) in the ideal shallow-water (Ritter) solution; SPH with viscosity and walls is slower, which the fourth graph shows. Energy is not conserved because viscosity dissipates it.
Honest simplifications
Two dimensions (the slab is 1 m deep, so density is kg per square metre); weakly compressible fluid with an artificially stiff equation of state; no surface tension; wall friction only through viscosity; density and pressure near free surfaces are underestimated (fewer neighbours). Hydrostatic pressure agrees to within roughly 25 percent, which is typical for this simple SPH variant.
What to try
- "Dam break": the water column collapses and hits the far wall; compare the front in graph four with the dashed shallow-water line.
- "Calm pool (hydrostatic test)": switch the colour to pressure; the pressure profile in graph two should follow rho g d.
- "Honey": raise viscosity and see the slow, thick flow.
- Drag with the mouse to stir or pull the fluid; "Rocking tank" tilts gravity periodically.