A first simulation of the shallow water equations
Channel: Nils Berglund
Date: 2023-05-27

This is a first attempt at simulating the shallow water equation. I started including this equation in my code after a viewer sent me a reference showing experiments, where nice patterns appear in a circular container filled with a thin layer of water, when the boundary of the container is set into vibration. Before getting there, it is necessary to simulate the shallow water equations in simpler cases, in order do get a feel for good parameter values.
The shallow water equations are nonlinear equations, which give a better description of the motion of water than the linear wave equation. In particular, unlike the linear wave equation, they conserve the total volume of water. The linear equation gives an approximation of the solutions, when the wave height remains close to its average over space. 
The equations used here include viscosity and dissipation, as described for instance in 
https://en.wikipedia.org/wiki/Shallow_water_equations#Non-conservative_form , without the Coriolis force. Viscosity and dissipation have been added mainly to avoid blow-up of solutions, and will be gradually decreased in forthcoming simulations. 
The video has four parts, showing the same simulation with two different color schemes and at two different speeds:
Wave height: 0:00
Velocity (norm and direction): 1:02
Wave height (time lapse): 2:04
Velocity (time lapse): 2:24
In the first and third part, the color hue and z coordinate show the height of the water. In the second and fourth part, the color hue shows the direction of the flow, and the z-coordinates shows its speed (the norm of the velocity). There are periodic boundary conditions.
 
Render time: 38 minutes 50 seconds
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 - Twilight by Bastian Bechtold
https://github.com/bastibe/twilight
 
Music: "Sunrise Drive" 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 shallow water 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!

#shallowwater #waves