Several Tesla valves in series - Pressure and vorticity
Channel: Nils Berglund
Date: 20/04/2023

This video shows the same simulation of several Tesla valves in series as in the video https://youtu.be/L15pIFs0yrc , but with different color gradients. Instead of the intensity and direction of the velocity field, they show first the pressure, and then the vorticity. The pressure evolution turns out not to be so impressive, due to the chosen boundary conditions - it will probably get more interesting when imposing a pressure gradient. At least, this visualization allows to see the tracer particles more clearly. 
A Tesla valve is a clever one-way fluid valve without moving parts, that was invented (and patented) by Nikola Tesla in 1920. The design used here features two conduits attached to the main pipe, and folded back on it. When used in the forward direction, the fluid can easily flow along the main pipe. When used in the backward direction, however, the back-folded conduits make the fluid interact with the flow in the main pipe, slowing it down or even stopping it altogether. 
In this simulation, there are two parallel set-ups of 4 Tesla valves in series, allowing to compare the forward and the backward flows more easily. The figures at the left show the average horizontal components of the velocity, for the upper and lower half. The set-up used here increases the chances that the fluid follows the blocking path in the backward direction, increasing the efficiency of the valves. Unlike in previous simulations of Tesla valves, the velocity and density fields are only imposed at the beginning, and then the fluid is left to evolve freely, without imposing any velocity at the boundaries. As a result, the horizontal velocity can even become negative when the valves are used in the backward direction.
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 valve, effectively introducing a boundary layer. In addition, there is a repulsive force orthogonal to the boundary, proportional to the gradient of the cut-off function. 
The video has four parts, showing the same simulation with two different color schemes, and at two different speeds:
Pressure: 0:00
Vorticity: 1:34
Pressure (time lapse): 3:08
Vorticity (time lapse): 3:39
In the first and third part, the color hue shows the pressure of the fluid, which is proportional to its density. In the second and fourth part, it shows its vorticity (the curl of the velocity field). 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, which is why vortices can be seen wrap around the displayed rectangular region.
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 19 minutes
Color scheme: Parts 1 and 3 - Viridis by Nathaniel J. Smith, Stefan van der Walt and Eric Firing
https://github.com/BIDS/colormap
Parts 2 and 4 - Turbo, by Anton Mikhailov
https://gist.github.com/mikhailov-work/6a308c20e494d9e0ccc29036b28faa7a
 
Music: "Coastline" by TrackTribe@TrackTribe

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!