๐ Euler fluid
Simulation
Section titled โSimulationโ๐ฏ A somewhat more elaborate demo using the Helion library
๐ง Copyright of original idea and software: Matthias Mรผller โ Ten Minute Physics
๐ Check out the accompanying Lattice-Boltzmann Fluid Dynamics PDF!
๐ You can move the obstacle with your mouse!
Implementation
Section titled โImplementationโLetโs first assert that:
- Liquids and gasses behave quite similarly, so they can often be modeled using similar modeling techniques.
- We will opt for a grid-based approach, also known as โEulerian approachโ. This means we start with a grid of some particular size and can only have fluid/gas inside that grid.
- We assume the fluid (or free gas) to be incompressible. Water is actually very close to being incompressible.
- We also assume the liquid to be inviscid (i.e. non-viscous).
The three main steps
Section titled โThe three main stepsโ-
Modify the velocity values based on the forces. Here we only use the gravitational force. We denote this step as integration.
for all i, jv[i, j] = v[i, j] + ฮt * g -
Make the fluid incompressible. We call this step projection. An incompressible fluid means that the divergence (i.e. inflow and outflow) at each grid cell needs to be zero.
-
We move the velocity field in the grid. We call this step advection, as advection is defined as the transfer of a property from one place to another due to the motion of the fluid. So if youโve got some black dye in some water, and the water is moving to the right, then the black dye moves right.
Just as black ink would move through the fluid, so too will the velocity field itself! Intuitively you can think of it this way: a particle moving in a certain direction will continue moving in that direction, even after itโs moved.
Since weโre storing velocity in a grid just like we do with the smoke, we can use the exact same routine to advect velocity through itself.
References
Section titled โReferencesโ- Fluid Simulation (with WebGL demo) by Jamie Wong