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

grid

Wall-resolving coordinates

meshes that put cells in the Hartmann and side layers

every 3-D solver

grid

Current-conservative electric scheme (Ni et al.)

the potential equation, face currents and the Lorentz force

every 3-D solver, the pipe, Joule heat

grid

Thin (Walker) and resolved conducting walls

wall currents, as a sheet node or a solid region

ducts, the pipe

grid

Divergence-free imposed field

a varying field, such as the ANL fringe

fringe ducts, open ducts

grid

Fast-diagonal Poisson and Helmholtz solves

pressure, potential, implicit viscosity and conduction

every 3-D solver, heat transport

solvers

CG and PCG

the steady Stokes-limit operator

steady ducts, open ducts, the open pipe

solvers

Newton-Krylov (flexible GMRES)

the steady open duct with inertia

open ducts

solvers

Projection-step preconditioner, varying-field rate (2b.4)

the steady CG solve

steady ducts, open ducts

solvers

Defect correction

round-off left by the fast solves

steady ducts, open ducts

solvers

Drive elimination

the drive for a given flow rate, \(f=Q/G\)

fully developed ducts

steady

Steady state as a differentiable root

steady flows and their derivatives

steady ducts, open ducts

steady

Projection step with an implicit damping shift

one time step of the 3-D core

hartmax.core3d, heat transport

time

Implicit Euler and IMEX RK3

time integration

hartmax.core3d, the open-duct march

time

Courant and damping step control

the step size

hartmax.core3d, open ducts

time

Explicit Lorentz force

transients that the shift would slow

hartmax.core3d runs in time

time

Compiled trajectory (lax.scan, checkpointed)

a run in time as one compiled loop

hartmax.core3d

time

Implicit derivatives and adjoints

gradients of converged and transient solves

every solver

derivatives

Inlet lift and outlet face

the inflow and outflow conditions

open ducts

open ducts

March or Newton

the steady flow with inertia

open ducts

open ducts

Open polar axis

the pipe with an inlet and an outlet

the open pipe

open ducts

Variational core-flow discretization

TM-228’s core equations

validation.coreflow

core flow

Spectral IFRK4 with two-thirds dealiasing

depth-averaged vorticity

hartmax.q2d

Q2D

Upwind and van Leer heat transport

advection of temperature

hartmax.thermal

heat transport

Implicit conduction in the fluid

heat conduction

hartmax.thermal

heat transport

Conduction through solid walls

conjugate heat transfer

hartmax.thermal

solid walls

Developed-heat solves

the thermally fully developed duct

hartmax.thermal

developed heat

Boussinesq buoyancy

the buoyancy force on the velocity faces

hartmax.thermal

buoyant convection

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.