An incompressible Euler shear flow on the sphere
Channel: Nils Berglund
Date: 17/03/2024

Having simulated the wave equation, reaction-diffusion equations, and Schrödinger's equation on the sphere, I now want to move to fluid mechanics. This simulation shows a solution of the incompressible Euler equations on the sphere. The initial state is a shear flow, that consists of 5 layers moving at different speeds. The layers have almost constant latitude, but not quite: there is a small oscillation of period 2*pi/6 in the North-South directions that induces an instability leading to vortex formation.
The color hue and radial coordinate depend on the vorticity of the fluid, which measures its quantity of rotation. In green areas, the vorticity is zero, meaning that the speed of the fluid does not change when moving laterally with respect to its velocity. In red and blue areas, the vorticity is large. The point of view of the observer is rotating around the polar axis of the sphere at constant latitude. 
The incompressible Euler equations describe the velocity field of a non-viscous, incompressible fluid. They are strongly non-linear, because of the presence of a so-called advection term in what is known as the material derivative. Another difficulty in solving these equations numerically is the incompressibility condition, which requires the velocity to remain divergence-free. Since most numerical schemes will not conserve the divergence, a common approach is to "project" the solution on the space of divergence-free flows after each integration step. 
I used here a different approach, based on the so-called stream function. By writing the velocity as the curl (rotational) of a stream function, directed along the z-axis perpendicular to the plane of the two-dimensional fluid, one ensures that the velocity is always divergence-free. The incompressible Euler equations are then equivalent to a partial differential equation for the stream function, and a Poisson equation linking stream function and vorticity. Since I had no solver for the Poisson equation at hand, I used a forced heat equation for the evolution of the vorticity, which admits the solution of the Poisson equation as a stationary solution. This induces additional errors, which are hopefully not too important. There is also a weak dissipation term, proportional to the Laplacian of the stream function, to prevent numerical blow-up, so the governing system is in fact closer to the Navier-Stokes equations with small viscosity. 
The equation is solved by finite differences, where the Laplacian and gradient are computed in spherical coordinates. Some smoothing has been used at the poles, where the Laplacian becomes singular in these coordinates. 

Render time: 1 hour 53 minutes
Compression: crf 20
Color scheme:  Turbo, by Anton Mikhailov
https://gist.github.com/mikhailov-work/6a308c20e494d9e0ccc29036b28faa7a

Music: "Zoinks Scoob" by R.LUM.R@r.lum.r

The simulation solves the incompressible Euler equation by discretization. 
C code: https://github.com/nilsberglund-orleans/YouTube-simulations

#Euler_equation #fluid_mechanics #vortex