Numerical methods¶
HARTMAX discretizes every duct and pipe on one staggered finite-volume grid with a current-conservative electric scheme. Shared methods, such as the grid, the solvers, the steady solves, the time step and the derivatives, have their own pages. A scheme that only one physics module uses lives on that module’s page. The table lists every scheme and where it is described.
Every term of the time step converges at second order in space (code verification).
Schemes¶
Scheme |
What it discretizes or solves |
Used by |
Where |
|---|---|---|---|
Staggered (marker-and-cell) finite volumes |
velocity on faces, pressure and potential at cell centres |
every 3-D solver, the pipe, heat transport |
|
Wall-resolving coordinates |
meshes that put cells in the Hartmann and side layers |
every 3-D solver |
|
Current-conservative electric scheme (Ni et al.) |
the potential equation, face currents and the Lorentz force |
every 3-D solver, the pipe, Joule heat |
|
Thin (Walker) and resolved conducting walls |
wall currents, as a sheet node or a solid region |
ducts, the pipe |
|
Divergence-free imposed field |
a varying field, such as the ANL fringe |
fringe ducts, open ducts |
|
Fast-diagonal Poisson and Helmholtz solves |
pressure, potential, implicit viscosity and conduction |
every 3-D solver, heat transport |
|
CG and PCG |
the steady Stokes-limit operator |
steady ducts, open ducts, the open pipe |
|
Newton-Krylov (flexible GMRES) |
the steady open duct with inertia |
open ducts |
|
Projection-step preconditioner, varying-field rate (2b.4) |
the steady CG solve |
steady ducts, open ducts |
|
Defect correction |
round-off left by the fast solves |
steady ducts, open ducts |
|
Drive elimination |
the drive for a given flow rate, \(f=Q/G\) |
fully developed ducts |
|
Steady state as a differentiable root |
steady flows and their derivatives |
steady ducts, open ducts |
|
Projection step with an implicit damping shift |
one time step of the 3-D core |
|
|
Implicit Euler and IMEX RK3 |
time integration |
|
|
Courant and damping step control |
the step size |
|
|
Explicit Lorentz force |
transients that the shift would slow |
|
|
Compiled trajectory ( |
a run in time as one compiled loop |
|
|
Implicit derivatives and adjoints |
gradients of converged and transient solves |
every solver |
|
Inlet lift and outlet face |
the inflow and outflow conditions |
open ducts |
|
March or Newton |
the steady flow with inertia |
open ducts |
|
Open polar axis |
the pipe with an inlet and an outlet |
the open pipe |
|
Variational core-flow discretization |
TM-228’s core equations |
|
|
Spectral IFRK4 with two-thirds dealiasing |
depth-averaged vorticity |
|
|
Upwind and van Leer heat transport |
advection of temperature |
|
|
Implicit conduction in the fluid |
heat conduction |
|
|
Conduction through solid walls |
conjugate heat transfer |
|
|
Developed-heat solves |
the thermally fully developed duct |
|
|
Boussinesq buoyancy |
the buoyancy force on the velocity faces |
|
Run it¶
The drive elimination is the quickest way to see the numerics at work. One solve measures how much flow a unit drive gives, and the drive for any flow rate follows exactly. The example takes under half a minute on a laptop CPU.
import hartmax
hartmax.configure(dtype="float64")
problem = hartmax.duct(20, 24, flow_rate=0.02) # square duct, insulating walls, Stokes limit
solution = hartmax.solve(problem) # one solve at unit drive measures G; the drive is f = Q / G
drive, flow = float(solution.pressure_gradient), float(solution.flow_rate)
print(f"G = {flow / drive:.5f}, drive {drive:.4f}, flow rate {flow:.6f}")
# G = 0.15614, drive 0.1281, flow rate 0.020000
How results are checked¶
Analytical and manufactured tests check the observed order on refined meshes. Production claims also need stable physical observables, stricter solver tolerances and conservation gates. Timings measure JAX compilation and warm execution separately.