Walls and imposed fields

This page builds a wall stack whose currents the solver resolves cell by cell, and an imposed field from a formula or a measured table. The steps follow python examples/li_aln_wall_stack_example.py, which compares a liquid-lithium duct with an aluminium-nitride (AlN) coated wall against a bare steel one.

Wall layers

The Li, AlN and 316L wall stack, its effective conductance with pinholes, and the solved current

The Li | AlN | 316L wall stack’s conductivity, its effective conductance as pinholes open in the insulator, and the solved current with the insulator intact and bare. Drawn by python examples/li_aln_wall_stack_example.py.

Thin and resolved walls and the electric scheme explain how the walls enter the solve.

Import what the solve needs and work in double precision.

import numpy as np

from hartmax import enable_x64
from hartmax.core3d import ChannelProblem
from hartmax.steady import solve_steady_state
from hartmax.units import (
    WallLayer,
    dynamic_to_kinematic_viscosity,
    hartmann_number,
    normal_stack_leakage_ratio,
    tangential_stack_conductance_ratio,
)
from hartmax.grid import NEUMANN, PERIODIC, BoundaryCondition, Grid, uniform_faces, wall_resolving_faces

enable_x64()

Set the fluid and the field, in SI units. The duct’s half-width is 5 cm.

HALF_WIDTH, FIELD = 0.05, 0.05  # m, T
DENSITY, CONDUCTIVITY = 500.0, 3.2e6  # lithium: kg/m^3, S/m
viscosity = dynamic_to_kinematic_viscosity(4.0e-4, DENSITY)  # m^2/s
ha = hartmann_number(
    magnetic_field=FIELD, length_scale=HALF_WIDTH, conductivity=CONDUCTIVITY,
    density=DENSITY, kinematic_viscosity=viscosity,
)

State each wall layer’s thickness, resolution and conductivity with WallLayer, from the fluid outwards. This stack is a thin AlN coating on 316L steel.

layers = (
    WallLayer(name="aln", conductivity=1.0e-8, thickness=2.0e-4, cells=1),
    WallLayer(name="316L", conductivity=1.35e6, thickness=1.0e-3, cells=2),
)
c = tangential_stack_conductance_ratio(layers, fluid_conductivity=CONDUCTIVITY, length_scale=HALF_WIDTH)
leakage = normal_stack_leakage_ratio(layers, fluid_conductivity=CONDUCTIVITY, length_scale=HALF_WIDTH)

Give the solver the stack as wall cells, with one conductivity ratio (wall over fluid) and one width per cell.

ratios = tuple(layer.conductivity / CONDUCTIVITY for layer in layers for _ in range(layer.cells))
widths = tuple(layer.thickness / layer.cells for layer in layers for _ in range(layer.cells))
stack = (ratios, widths)

Build a cross-section of 24 cells, three of them inside each Hartmann layer, and one periodic cell along the duct.

faces = wall_resolving_faces(
    24, -HALF_WIDTH, HALF_WIDTH, layer_thickness=HALF_WIDTH / ha, cells_in_layer=3, max_ratio=None
)
grid = Grid(uniform_faces(1, 0.0, HALF_WIDTH), faces, faces)

ChannelProblem(wall_layers=...) takes one stack per end of each wall-normal axis. Drive the flow with a pressure gradient of 1 Pa/m.

problem = ChannelProblem(
    grid=grid,
    conditions=(BoundaryCondition(PERIODIC), BoundaryCondition(NEUMANN), BoundaryCondition(NEUMANN)),
    density=DENSITY,
    viscosity=viscosity,
    conductivity=CONDUCTIVITY,
    magnetic_field=(0.0, FIELD, 0.0),
    forcing=(1.0, 0.0, 0.0),
    dt=HALF_WIDTH**2 / viscosity,
    wall_layers=(None, (stack, stack), (stack, stack)),
)

Solve, then scale the drive to a mean velocity of 1 cm/s. The flow is linear in the drive.

solution = solve_steady_state(problem)
areas = np.diff(faces)[:, None] * np.diff(faces)[None, :]
mean_velocity = np.sum(areas * solution.velocity[0].data[0]) / np.sum(areas)
print(f"Ha {ha:.0f}, c {c:.3g}, normal leakage {leakage:.3g}, dp/dx {0.01 / mean_velocity:.4g} Pa/m at 1 cm/s")
Ha 224, c 0.00844, normal leakage 7.81e-13, dp/dx 0.3686 Pa/m at 1 cm/s

The example repeats this for a bare 316L wall of the same thickness, which needs 1.14 Pa/m. It also sweeps pinholes in the coating, checks the residual and the charge balance, and plots the comparison. Its results assess electrical MHD performance only, not Li/AlN material compatibility.

How the solver handles the stack:

  • The staggered core resolves the currents in the wall cells and takes the interface conductance from the adjacent material values and face distances.

  • A corner cell takes the nearer wall’s layer.

  • wall_conductance_ratio, tangential_stack_conductance_ratio and normal_stack_leakage_ratio describe the regime of a stack.

Solid walls

Thin and resolved walls covers the electric side, and conduction through solid walls the thermal side.

Wall layers solve the potential separably, so they reach two axes only when the third has one cell. Solid walls lift that limit (ADR 0009, D36).

from hartmax.core3d import SolidWall

steel = SolidWall(
    2e-3, 4, thermal_conductivity=18.3, heat_capacity=4.27e6, electrical_conductivity=1.04e6
)
# ChannelProblem(..., solid_walls=((None, None), (steel, steel), (steel, steel)))

ChannelProblem(solid_walls=...) takes a core3d.SolidWall or None at each end of the wall-bounded axes 1 and 2. A solid wall is a thickness in equal cells, with an absolute electrical_conductivity (not a ratio over the fluid’s) beside the thermal_conductivity and heat_capacity a thermal problem uses.

How HARTMAX solves them:

  • The walls become cells of an extended grid (core3d.conjugate_grid). The velocity and pressure stay on the fluid’s grid.

  • solvax.pcg_linear_solve solves the charge balance through fluid and walls. The fast-diagonal Poisson inverse (poisson.variable_helmholtz with no shift) preconditions it.

  • The currents into the walls heat the fluid’s half cells. The Lorentz force leaves them out, as it does a resolved wall’s.

  • A corner cell, in walls of both axes, takes the nearer wall’s material, and the first axis’s where the two are equally near. Walls of equal cells on both axes tie exactly there; earlier versions split such ties unevenly (what changed).

What tests/test_core3d.py checks:

  • On a section one cell long, solid walls of the same cells give the resolved path’s potential, currents and powers to 1e-9, corners included, and its developed flow rate to 1e-8.

  • Thinned at a fixed conductance ratio \(c = \sigma_w t_w/(\sigma a)\), Hartmann walls alone approach the thin-wall model at second order in \(t_w\). The flow rate of Hunt’s duct at Ha 20 and \(c = 0.05\) is 4.3e-3, 1.1e-3 and 2.8e-4 off at \(t_w = a/10\), \(a/20\) and \(a/40\).

  • On a 12-cell section, the steel of the Mistrangelo benchmark (plan step 5.4) at its pinned conductivity converges to 1e-13 in 10 PCG iterations.

The nullspace contract. The charge balance through insulated walls is singular, and its null mode is the constants. The solve adds a V (V . x)/sum V and removes the volume mean afterwards, so the gauge removes the constants and nothing else.

  • The solve refuses a right-hand side whose volume mean exceeds rounding, which is a net source. It returns NaN rather than absorbing it.

  • VariableHelmholtz.defect reports the mean the solve would have removed. For the charge balance it is rounding, 1e-15 of the right-hand side.

Charge, current and work. tests/test_core3d.py checks these:

  • The currents’ divergence vanishes in every cell, fluid and wall, to the solve’s 1e-13.

  • The walls carry current, and the insulated outer faces carry none.

  • The Lorentz work is minus the fluid’s and the walls’ Joule dissipation, to 1e-9.

The walls’ Joule heat is left out, and measured. The thermal step deposits the fluid’s Joule heat only. On plan step 5.4’s developed section (Case 1, 48 fluid cells, the pinned steel), the walls dissipate 84 % of the Joule heat. That is 0.029 W/m, against the 2000 W/m that heats the duct, a ratio of 1.5e-5. If the step deposited it, it would raise the bulk temperature by under 1e-3 K of its 10 K, far inside Figure 6’s digitizing uncertainty of 0.064 K.

A published number. Hunt’s duct at Ha 300 has conducting Hartmann walls of \(c = 0.1\) and insulating side walls.

  • Ni et al. (2007) Table 3 gives its analytic \(Re\,dp/dx\), at a flow rate of 4, as 5854.302. The validation index checks it against the spectral solve.

  • On 48 cells the thin-wall model is 0.66 % below it, converging from 1.6 % on 32 cells.

  • Solid walls of that \(c\), \(a/10\), \(a/20\) and \(a/40\) thick, give a result 2.3 %, 0.64 % and 0.16 % below the thin-wall model, approaching it at second order in the thickness.

This runs with the scheduled tests.

Derivatives. A solid wall’s electrical conductivity is a leaf of the charge solve. The tests check its derivative to the derivative standard, and a new value needs no recompilation. The steady solve builds its walls as constants. A gradient of the pressure drop in a wall’s conductivity is planned with the wall-conductance work. SolidWall refuses a traced conductivity.

Add an analytic field

The imposed field explains how a varying field enters the Lorentz force and the potential.

hartmax.fields.Func(fn, params) takes a callable fn(x, y, z, params) that returns the three components of the field at the cell centres, params being any pytree of numbers. Sample it on the duct’s grid before a production run and verify its divergence and intended extrema.

import hartmax
from hartmax.fields import Func


def sheared(x, y, z, strength):
    return 0 * y, strength * (1.0 + 0.3 * z) + 0 * y, 0 * y


problem = hartmax.duct(20, 32).replace(B=Func(sheared, 20.0))

Use measured field data

Store Cartesian coordinates (metres) and components (tesla) in an NPZ table that covers the conducting walls. Replace this synthetic, divergence-free example’s arrays with your measured or exported data.

from pathlib import Path

import numpy as np

import hartmax
from hartmax.fields import Table, load_tabulated_field, write_tabulated_field_npz

y = z = np.linspace(-1.2, 1.2, 17)
yy, zz = np.meshgrid(y, z, indexing="ij")
path = write_tabulated_field_npz(
    Path("artifacts/imposed_field.npz"), y=y, z=z,
    bx=np.zeros_like(yy), by=0.1 * yy, bz=5.0 - 0.1 * zz,
)
table = load_tabulated_field(path)
assert np.allclose(table["bz"], 5.0 - 0.1 * zz)
problem = hartmax.duct(20, 24).replace(B=Table(str(path)))

A file with an x axis and components shaped (nx, ny, nz) is a field that varies along the duct, sampled on the 3-D grid (see the fringe tutorial). Axes must be finite, strictly increasing vectors with at least two points; component shapes must match. Out-of-domain/nonfinite queries raise ValueError, never silently extrapolate. The file-loading interface is host-side setup, not a differentiable live coil/geometry interface. Keep source provenance, interpolation error and independent Maxwell checks with each run.

Run python examples/li_aln_wall_stack_example.py for explicit conducting and insulating layers: each wall is a stack of cells of its own conductivity (ChannelProblem.wall_layers), solved on the staggered core with the corner cells taking the nearer wall’s layer.