Quasi-two-dimensional flow¶
hartmax.q2d evolves a periodic, depth-averaged flow in a strong uniform field normal to the flow plane. The
Q2D tutorial runs it, and the Q2D anchors validate it.
Decaying Q2D turbulence on 256² cells, with three snapshots of the vorticity and the energy spectrum against a \(k^{-3}\) guide.
The model¶
The basic Sommeria-Moreau closure evolves the depth-averaged vorticity,
Here \(1/\tau_H\) is the linear Hartmann-layer friction and \(f_\omega\) is a vorticity source. On a periodic domain the velocity is divergence free by construction. With kinetic energy \(E=\langle|\mathbf u_\perp|^2\rangle/2\) and enstrophy \(Z=\langle\omega^2\rangle/2\),
The model is a depth-averaged strong-field approximation. It does not resolve Hartmann-layer profiles or replace the 3-D formulation where the field varies along the flow.
The spectral IFRK4 step¶
HARTMAX works with real Fourier transforms of the periodic field (rfftn). In Fourier space the vorticity equation is \(\partial_t\hat\omega=-L\hat\omega+\hat N(\hat\omega)\), with
\(L=\nu\lambda_k+1/\tau_H\) and \(\hat N=P\big[\hat f_\omega-\mathcal F(\mathbf u_\perp\cdot\nabla_\perp\omega)\big]\).
Here \(\lambda_k\) is the periodic Poisson symbol, which SOLVAX supplies with the zero-mean spectral inversion for the
streamfunction, and \(P\) is the two-thirds dealiasing mask. With \(\mathcal E=e^{-\Delta t L}\), the fourth-order
integrating-factor Runge-Kutta step is
The scheme integrates the viscous and Hartmann-friction terms exactly within each step. HARTMAX owns the vorticity dynamics, the velocity reconstruction, the energy identity and physical acceptance.
HARTMAX compiles the largest stable integration segment. A positive history_stride divides a run into compiled
segments and moves only the requested vorticity frames to the host, and zero keeps no field history. Stored results
therefore do not grow with the number of time steps. Derivatives use a two-level checkpoint schedule
(Derivatives).
The energy budget¶
solve_q2d enforces energy_budget_tolerance (default \(10^{-3}\)) on the absolute integrated defect of the energy
identity, divided by the larger of the initial energy and the absolute integrated power. The smallest positive normal
value of the working dtype is a zero-energy floor. An absolute machine-epsilon floor would hide relative defects in
small-amplitude flows.
The solver integrates the power by the trapezoidal rule at every time step, whatever the saved-frame stride. This
diagnostic has second-order quadrature error even when the IFRK4 field evolution is more accurate. Refine the time step
when it fails. Even completed does not certify mesh independence or steady flow.