Skip to content

๐Ÿƒ Euler fluid

JavaScriptThree.js

Source

๐ŸŽฏ 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!


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).

  1. Modify the velocity values based on the forces. Here we only use the gravitational force. We denote this step as integration.

    for all i, j
    v[i, j] = v[i, j] + ฮ”t * g
  2. 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.

  3. 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.