Liquid Pour Simulator Back
SPH Fluid Simulator

Liquid Pour Simulator

Experience SPH-based particle fluid in real time. Adjust gravity, viscosity, and container shape to intuitively explore fluid dynamics.

Controls

300
0.98
3 p/frame
200
Click canvas to drop a burst of particles
0
Particles
0%
Fill Level

Theory Notes

SPH discretizes fluid into particles. Each particle's physical quantities are weighted averages over neighbors via a smoothing kernel.

P = ρgh (hydrostatic pressure)
a = −∇P/ρ + g + F_visc

Inter-particle repulsion models pressure; cohesion approximates surface tension. In industry, LS-DYNA SPH is used for casting fill and sloshing analysis.

What is SPH Fluid Simulation?

🧑‍🎓
What exactly is SPH? The particles in this simulator seem to flow like a real liquid, but they're just dots. How does that work?
🎓
Great question! SPH stands for Smoothed Particle Hydrodynamics. Basically, it's a clever way to simulate fluids by representing them as millions of moving particles, not as a grid. Each particle carries properties like density and pressure. In this simulator, when you change the **Pour Rate**, you're controlling how many of these computational particles are introduced into the scene each second.
🧑‍🎓
Wait, really? So the particles aren't just for show—they *are* the fluid? How do they know to stick together and not just fly apart?
🎓
Exactly! They interact. The core idea is that each particle "smoothes" its influence over its neighbors. A particle's density is calculated by summing up the contributions of all nearby particles. This density then determines its pressure. High-density regions (like the bottom of the container) create high pressure, which pushes particles apart, preventing them from collapsing. Try lowering the **Gravity** slider—you'll see the particles spread out more easily because the pressure from stacking up isn't as strong.
🧑‍🎓
That makes sense for pressure, but what about stickiness? Why does honey in the simulator flow slower than water? Is that just the **Viscous Damping**?
🎓
You've hit on a key force! Viscosity is the internal friction of a fluid. In SPH, it's modeled as a force that resists the relative motion between neighboring particles. The **Viscous Damping** parameter you see directly controls the strength of this force. A high value makes particles "drag" on each other more, mimicking thick honey. A low value lets them slide past easily, like water. It's a simplified but very effective model for visual simulation.

Physical Model & Key Equations

The heart of SPH is estimating continuous field quantities (like density $\rho$) at any point in space by summing contributions from neighboring particles. This is done using a smoothing kernel function $W$.

$$ \rho_i = \sum_j m_j W(\mathbf{r}_i - \mathbf{r}_j, h) $$

Here, $\rho_i$ is the density at particle $i$, $m_j$ is the mass of a neighboring particle $j$, $\mathbf{r}$ are positions, and $h$ is the smoothing length that defines the radius of influence. In the simulator, this is why particles only affect those close to them.

Once density is known, pressure is typically calculated using a simple equation of state. The pressure force then drives the fluid motion, combined with viscosity and gravity.

$$ \mathbf{F}^{pressure}_i = - \sum_j m_j \left( \frac{P_i}{\rho_i^2}+ \frac{P_j}{\rho_j^2}\right) \nabla W(\mathbf{r}_i - \mathbf{r}_j, h) $$

$\mathbf{F}^{pressure}_i$ is the pressure force on particle $i$, and $P$ is pressure derived from density. $\nabla W$ is the gradient of the smoothing kernel. This force pushes particles from high-density to low-density areas. The **Gravity** parameter in the simulator adds a constant downward force $\mathbf{F}^{gravity}_i = m_i \mathbf{g}$ to this equation.

Real-World Applications

Automotive Engineering: SPH is extensively used in car crash tests to simulate fuel sloshing in tanks or coolant flow. Engineers use tools like LS-DYNA to ensure fluids don't cause secondary hazards during an impact, which is much cheaper and safer than physical testing.

Visual Effects (VFX): Nearly every large-scale water, lava, or magical fluid effect in movies is created using SPH-based solvers. The method's particle-based nature fits perfectly with rendering pipelines, allowing for realistic splashes and flows around complex shapes.

Civil & Hydraulic Engineering: SPH is used to model extreme fluid-structure interactions, such as dam breaks, wave impact on coastal structures, or debris flows. Its ability to handle large deformations and free surfaces makes it ideal for these chaotic events.

Manufacturing Process Simulation: Engineers simulate processes like liquid metal casting, concrete pouring, or even 3D printing with liquid resins. SPH helps predict potential defects like air bubbles or incomplete filling based on the fluid's viscosity and pour rate.

Common Misconceptions and Points to Note

First, it's a major misconception that more particles always lead to a better simulation. While increasing particle count does improve resolution, the computation time grows at a rate close to the square of the particle number. In practice, identifying the minimum number of particles required to achieve the necessary accuracy is where your skill comes into play. For instance, coarse particles may suffice to observe the overall flow in a container, but capturing fine splashes or the formation of tiny droplets due to surface tension requires techniques like locally refining the particle resolution.

Next, beware of parameter setting pitfalls. Sliders for "viscosity" or "surface tension" in simulators are often dimensionless relative values. This means you must consider scaling (similarity laws) to directly correlate them with values for real-world fluids. For example, simply increasing the viscosity slider using settings that replicate water to mimic more viscous glycerin will produce results deviating from actual behavior. In practical work, a "validation" process is essential, where you calibrate parameters by comparing simulation results against theoretical/experimental values for known simple cases (e.g., pipe flow).

Finally, don't overlook the importance of initial conditions. Whether you start injection with particles arranged in a uniform grid or placed randomly can lead to completely different initial instabilities, significantly affecting the results. Also, setting an injection speed unrealistically high can generate non-physical pressures or splashing, causing the calculation to diverge. The first step is to carefully observe the real-world process and set an initial state that matches it.

Related Engineering Fields

The technology behind this SPH-based liquid injection simulation is, in fact, deeply connected to many other fields. The first that comes to mind is "multiphase flow analysis." While currently limited to liquid, adding bubbles or solid particles allows application to processes like filling beverages containing foam or analyzing the flow of slurries (fluids mixed with solid particles). Particle methods have the strength of handling different phases relatively easily.

Another is "coupled analysis with structures (FSI: Fluid-Structure Interaction)." In the current simulator, the container is a rigid, immovable body. However, by coupling SPH fluid particles with flexible structures (e.g., rubber tanks or thin plates) calculated using other methods (like FEM), you can simulate complex phenomena where fluid forces deform the structure, and that deformation in turn alters the flow... This technology directly relates to fatigue analysis from sloshing in fuel tanks or analyzing blood-vessel interactions in bioengineering.

Broadening your perspective further, it also connects to "powder technology." By replacing the forces between particles (like viscosity or surface tension) with friction or cohesive forces for calculation, you essentially work with the conceptual sibling of the "Discrete Element Method (DEM)" used to simulate the flow and collapse of materials like sand, grains, or pharmaceutical powders. As a CAE engineer, understanding the core of one method provides a powerful foothold for learning simulation technologies in other fields.

For Further Learning

Once you've gained an intuitive feel with this simulator, take the next step and delve into its mathematical foundations. A recommended three-stage learning path is: First, grasp the basics of continuum mechanics. SPH solves the Navier-Stokes equations, the governing equations of fluid motion. Instead of diving straight into the equations, conceptually understanding how the three physical laws—"conservation of mass," "conservation of momentum," and "conservation of energy"—are formulated will clarify what each simulation parameter controls.

Second, learn about discretization concepts. The core of SPH lies in the "kernel approximation," which approximates integrals with sums over particles, and the method for calculating their gradients. For example, why does the symmetric form ($P_i/\rho_i^2 + P_j/\rho_j^2$) appear in the pressure gradient force equation? This is a clever design to satisfy momentum conservation, greatly contributing to numerical stability. Understanding the "meaning behind the form of equations" one by one builds your ability to write code yourself or deeply analyze results.

Finally, challenge yourself with practical problems. Interesting next-step topics are "handling free surfaces" and "boundary conditions." The current simulator uses simple reflection for container walls, but in practice, modeling more complex wettability (contact angle at walls) becomes crucial. Also, how to set inflow/outflow boundaries is a significant theme. Tackling these challenges will allow you to approach the core of what commercial CAE software is calculating internally.