Solving a maze with a pressure gradient
Channel: Nils Berglund
Date: 2023-04-30

This variant of the video https://youtu.be/o0IFH3-I9Ig uses the same maze, but with different boundary conditions. Here a pressure gradient is imposed, by increasing the pressure in the left pipe, and decreasing it in the right pipe. As a result, the fluid tends to flow mostly along the shortest path crossing the maze, though there is some leakage due to the imperfect boundary conditions.
The boundary conditions are imposed by multiplying the fields with a cut-off function, that smoothly interpolates between 0 and 1 when moving across the boundary of the maze, effectively introducing a boundary layer. In addition, there is a force field perpendicular to the walls of the maze, given by the gradient of a slightly less steep version of the cut-off function. I was able to decrease the leakage in the dead-ends somewhat, by increasing the repelling forces from the maze boundaries, but not to remove it altogether. 
The video has four parts, showing the same simulation with two different color schemes and at two different speeds:
Speed: 0:00
Pressure: 1:42
Speed (time lapse): 3:24
Pressure (time lapse): 3:58
In the first and third part, the color hue shows the speed of the fluid (the norm of the velocity). In the second and fourth part, the color hue depends on the pressure, which is proportional to the density of the fluid. One can observe an increase in pressure at the dead-end of the maze, while the pressure decreases continuously along the path solving the maze. 
The velocity field of the fluid is materialized by 1000 tracer particles, whose initial position is distributed randomly over the simulation region. There are periodic boundary conditions.
The compressible Euler equations are partial differential equations for the density and the velocity field of the fluid. The system as such is not closed, because the right-hand side of the velocity equation involves the pressure, which has to be linked to known quantities by a thermodynamic relation. I assumed here that the fluid is an ideal gas, so that the pressure is proportional to the density. 
In a sense, the compressible Euler equations are easier to simulate than the incompressible ones, because one does not have to impose a zero divergence condition on the velocity field. However, they appear to be a bit more unstable numerically, and I had to add a smoothing mechanism to avoid blow-up. This mechanism is equivalent to adding a small viscosity, making the equations effectively a version of the Navier-Stokes equations. 

Render time: 1 hour 25 minutes
Color scheme: Parts 1 and 3 -   Inferno by Nathaniel J. Smith and Stefan van der Walt
Parts 2 and 4 - Viridis by Nathaniel J. Smith, Stefan van der Walt and Eric Firing
https://github.com/BIDS/colormap
 
Music: "Kamogawa Dreaming" by South London Hifi@discobiscuit1320

See also https://images.math.cnrs.fr/Des-ondes-dans-mon-billard-partie-I.html for more explanations (in French) on  a few previous simulations of wave equations. 

The simulation solves the 2D compressible Euler equation by discretization (finite differences).

C code: https://github.com/nilsberglund-orleans/YouTube-simulations
https://www.idpoisson.fr/berglund/software.html
Many thanks to Marco Mancini and Julian Kauth for helping me to accelerate my code!