LMhdX
Differentiable inductionless liquid-metal MHD in JAX. Documentation: https://lmhdx.readthedocs.io/
LMhdX solves liquid metal flowing through strong magnetic fields, the physics of fusion blanket channels: ducts and pipes with insulating or thin conducting walls, three-dimensional ducts leaving a magnet, heat transfer, and quasi-two-dimensional vortex dynamics. Everything is differentiable end to end; solvers and implicit derivatives come from SOLVAX.
- Resolve the layers: meshes chosen from
a/Haanda/√Ha, not from a cell count. - Skip the transient: the steady state is a differentiable root, not a march.
- Check against something else: an independent spectral solve that shares no code.
- Run where you like: CPU or GPU, one compiled trajectory per run.
Install and first run
pip install lmhdx # JAX runs on the CPU; for a GPU follow the JAX installation guide
lmhdx examples/hartmann_case.toml
import lmhdx
solution = lmhdx.solve(lmhdx.duct(100.0, 48, wall_conductance=0.027))
print(float(solution.velocity[0].data.max()))
solve takes a Problem and a Solver. A steady problem is solved by conjugate gradients or
Newton–Krylov; an open duct with advection by Newton or by marching the Runge–Kutta step (method="auto" picks
the faster); Solver(method="euler" | "rk3", dt=, steps=) runs an unsteady problem, and an Output writes
records, ParaView files and a summary that a later run restarts from bit for bit. A TOML file builds the
same objects as Python does.
Validated results
- Ducts: Hartmann profiles at Ha 20, 100 and 300 collapse onto
1 − e^{−ξ}; flow rate is within 0.4–2.3 % ofvalidation/shercliff.py, a Chebyshev solve sharing no operator, mesh or solver with the package, on a 48² mesh, at second order in the mesh. - Pipes:
Q/A = 1/8at zero field (Hagen–Poiseuille) and within 0.04–0.43 % ofvalidation/pipe.pyover Ha 0 to 100. - Blanket scale: Ha 1000 insulating duct 0.5 % from the reference; all eight rows of Smolentsev et al. (2015) Table I (Ha 500 to 15,000) at second order with the analytic value inside the GCI band.
- Gradients: implicit adjoints agree with central differences to 7e-12 in the drive and 1.2e-10 in the field.
Research stage, not validated against a reference flow: three-dimensional convective transport, heat transfer (though its Nusselt numbers and Chandrasekhar's critical Rayleigh number are matched within 0.35 % and 0.8 %), the fringe in the inertialess limit only, the ALEX B1/B2 benchmarks, and multi-device execution. The validation matrix states each gate.
Performance
Measured on one idle RTX A4000 (JAX 0.10.2, median of 12 runs; ADR 0006):
| 3-D core | 64³ | 128³ | 192³ | 256³ |
|---|---|---|---|---|
| float64-accurate (mixed), ms per step | 2.14 | 17.5 | 69.7 | 166 |
| true float32, ms per step | 0.515 | 4.84 | 19.3 | 48.0 |
256³ fits on one 16 GB card. Against this code on XLA:CPU (36 cores, float64, 128³) the GPU is 7.85× faster.
Two GPUs give the same answer bit for bit on the Q2D solve and no speed-up yet. Reproduce with
python scripts/run_benchmarks.py; results are in benchmarks/results.
Examples
| Command | Physics |
|---|---|
lmhdx examples/hartmann_case.toml |
Hartmann duct from a TOML file |
lmhdx examples/heated_duct.toml |
heated duct with buoyancy |
python examples/hunt_example.py |
conducting walls, side-layer jets |
python examples/fringe_duct_example.py |
duct leaving a magnet, drop and its field derivative |
python examples/open_duct_inertia_example.py |
inertial share of the fringe drop |
python examples/q2d_turbulence_demo.py |
Q2D vorticity evolution and energy decay |
python examples/duct_design_law.py |
optimum aspect ratio of an insulated duct |
Parameters and evidence status are in examples/catalog.toml;
python scripts/make_showcase_figures.py regenerates the figures.
Cite and contribute
Cite the commit or release you used (CITATION.cff). Development: pip install -e ".[dev,docs]",
then python scripts/run_full_test_suite.py --changed-from HEAD; see CONTRIBUTING.md and the
plan. LMhdX was called LMX before 1.5: import lmx is now import lmhdx.
Metadata
Release files for lmhdx 1.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lmhdx-1.12.0.tar.gz | 277.6 kB | With provenance | Details for lmhdx-1.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lmhdx-1.12.0-py3-none-any.whl | Python 3 | none | any | Details for lmhdx-1.12.0-py3-none-any.whl |
Total release size: 569.6 kB
Release files / lmhdx-1.12.0.tar.gz
| Download URL | lmhdx-1.12.0.tar.gz |
|---|---|
| Size | 277.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
403846696b348f9397213c3b4eb2259ef9ce8b2679184bde9f7f161a97bb2acd
|
|
BLAKE2b-256 checksum How to use checksums |
8debbbb50b01585b85c03844d8e1cbf9aeb7871b1f07056e2ec8335bb28a23bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logRelease files / lmhdx-1.12.0-py3-none-any.whl
| Download URL | lmhdx-1.12.0-py3-none-any.whl |
|---|---|
| Size | 292.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f14b29596b922ff77afe16124ccdfe907dd56072275286c309e0f7aff9072fca
|
|
BLAKE2b-256 checksum How to use checksums |
69ee5df5b27cbfcd348eb209d9d0b81b61334dee7b1b3605a0c193ca6e8a4dbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logSecurity for lmhdx 1.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lmhdx-1.12.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.