Understanding and implementing gauge conditions to remove constraint degeneracies in Dedalus
When entering a system of PDEs in Dedalus, the left-hand side (LHS) of the equations is parsed into a sparse linear system. For the solver to succeed, this LHS matrix must be square and nonsingular - it must have a unique solution for any possible values on the right-hand side (RHS).
The linear system must constrain all degrees of freedom of the variables, including gauge freedoms. Failure to do so results in singular matrices that cannot be inverted.
Consider incompressible hydrodynamics in a fully periodic domain discretized with Fourier bases:
import dedalus.public as d3import numpy as npcoords = d3.CartesianCoordinates('x', 'y', 'z')dist = d3.Distributor(coords, dtype=np.float64)bases = (d3.RealFourier(coords['x'], size=Nx, bounds=(0, Lx)), d3.RealFourier(coords['y'], size=Ny, bounds=(0, Ly)), d3.RealFourier(coords['z'], size=Nz, bounds=(0, Lz)))# Fieldsp = dist.Field(name='p', bases=bases)u = dist.VectorField(coords, name='u', bases=bases)# Problem - INCORRECT: This will produce singular matrices!problem = d3.IVP([p, u], namespace=locals())problem.add_equation("div(u) = 0")problem.add_equation("dt(u) + grad(p) - nu*lap(u) = - u@grad(u)")
This formulation produces square matrices but they are not nonsingular. The pressure gauge is undetermined - any constant can be added to the pressure without affecting the equations.
Underdetermined variable: Any constant can be added to the pressure
Degenerate constraint: For the mean k=0 Fourier mode, the divergence equation becomes "0 = 0"
While this seems consistent, the system must be solvable for any RHS, not just the one we entered. If we entered "div(u) = 1", the mean mode would give "0 = 1" - clearly impossible.
We expand the system by adding a spatially-constant variable (a tau variable) to the divergence equation to absorb the degeneracy, and impose the pressure gauge as a separate equation:
We’ve added one degree of freedom (tau_p) and one constraint (integ(p) = 0), so the system is still square. Now it’s also nonsingular since the mean pressure is fixed.
Similar modifications work for other types of gauges and geometries. For incompressible hydrodynamics in a bounded domain, we still need this modification so the integral of the divergence equation is compatible with specified inflow boundary conditions.