Metadata-Version: 2.1
Name: axionmultiphysics
Version: 0.1.0
Summary: Finite-element simulation for axion dark-matter detectors: lumped-element detectors from the field solve to the scan reach, with beta modules for cavity haloscopes, SRF heterodyne cavities, dc SQUID readout, incompressible flow and electrochemistry
Keywords: axion,dark matter,finite element,electromagnetics,haloscope,lumped-element detector,MFEM
Author: Joshua N. Benabou, Joshua W. Foster, Benjamin R. Safdi
License: BSD 3-Clause License
         
         Copyright (c) 2026, Joshua N. Benabou, Joshua W. Foster, Benjamin R. Safdi
         
         Redistribution and use in source and binary forms, with or without
         modification, are permitted provided that the following conditions are met:
         
         1. Redistributions of source code must retain the above copyright notice, this
            list of conditions and the following disclaimer.
         
         2. Redistributions in binary form must reproduce the above copyright notice,
            this list of conditions and the following disclaimer in the documentation
            and/or other materials provided with the distribution.
         
         3. Neither the name of the copyright holder nor the names of its
            contributors may be used to endorse or promote products derived from
            this software without specific prior written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
         FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Physics
Project-URL: Homepage, https://bsafdi.github.io/axionMultiPhysics/
Project-URL: Documentation, https://bsafdi.github.io/axionMultiPhysics/
Project-URL: Repository, https://github.com/bsafdi/axionMultiPhysics
Project-URL: Issues, https://github.com/bsafdi/axionMultiPhysics/issues
Project-URL: Changelog, https://github.com/bsafdi/axionMultiPhysics/blob/main/CHANGELOG.md
Requires-Python: >=3.10
Requires-Dist: numpy>=1.23
Requires-Dist: scipy>=1.10
Provides-Extra: mesh
Requires-Dist: gmsh<4.16,>=4.15; extra == "mesh"
Provides-Extra: notebook
Requires-Dist: anywidget>=0.9; extra == "notebook"
Requires-Dist: ipython>=8; extra == "notebook"
Provides-Extra: plots
Requires-Dist: matplotlib>=3.6; extra == "plots"
Provides-Extra: draw
Requires-Dist: schemdraw>=0.19; extra == "draw"
Requires-Dist: matplotlib>=3.6; extra == "draw"
Provides-Extra: mcp
Requires-Dist: mcp>=2.0; extra == "mcp"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: jsonschema>=4; extra == "test"
Requires-Dist: scipy>=1.10; extra == "test"
Provides-Extra: all
Requires-Dist: gmsh<4.16,>=4.15; extra == "all"
Requires-Dist: anywidget>=0.9; extra == "all"
Requires-Dist: ipython>=8; extra == "all"
Requires-Dist: matplotlib>=3.6; extra == "all"
Requires-Dist: mcp>=2.0; extra == "all"
Requires-Dist: schemdraw>=0.19; extra == "all"
Description-Content-Type: text/markdown

# axionMultiPhysics

axionMultiPhysics is a finite-element package for electromagnetics, structural
mechanics, heat conduction, fluid flow and electrochemistry. We built it to
design axion dark-matter detectors: lumped-element experiments (e.g.,
ABRACADABRA, DMRadio, CORE), resonant-cavity haloscopes (e.g., ADMX, HAYSTAC,
CAPP, QUAX, ORGAN) and superconducting radio-frequency heterodyne cavities.
The solvers themselves are general and apply to magnets, superconducting
devices, RF structures and resonators in other settings. It has a C++ core
built on MFEM, a Python interface, a 3D viewer, and an MCP server so that
designs can be built and evaluated through chat.

**What it solves:** magnetostatics and magnetoquasistatics (superconducting,
resistive and iron-core magnets and shields; fields, inductances, forces);
full-wave electromagnetics (impedances, S-parameters, radiation, eigenmodes);
superconductors (flux constraints, critical surfaces, the HTS critical state);
electrostatics; circuits with the noise of every element; mechanics and heat
conduction; adjoint shape sensitivities and optimization; and, in beta,
incompressible flow and electrochemistry. Geometries are axisymmetric profiles
or 3D solids, including imported CAD (STEP). Axisymmetric problems run on one
machine; 3D problems use MPI.

**Documentation:** [bsafdi.github.io/axionMultiPhysics](https://bsafdi.github.io/axionMultiPhysics/) (installation, tutorials, API reference)

![The axionMultiPhysics viewer on the quick-start toroid](https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/viewer_toroid.png)

*The interactive viewer (`res.show()` in a notebook, or `res.export_html(...)` for a standalone page)
on the quick-start ABRACADABRA-style toroid (R = 2 m, H = 2 m): a 90° cutaway colored by the
pickup-mode field per ampere $`|\mathbf B_I|`$ (log scale), with the pickup field lines and the results panel
(signal coupling $`\Psi`$, pickup inductance $`L_p`$, $`\mathcal F=\Psi^4/L_p^2`$, stored energy, peak fields).*

<details>
<summary>Static field $`\mathbf B_\mathrm{lab}`$ of the same toroid (3D cutaway)</summary>

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/home/hero_toroid_dark.png">
  <img src="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/home/hero_toroid_light.png" alt="Static field of the quick-start toroid" width="100%">
</picture>

*The toroidal lumped-element detector of the quick start (R = H = 2.0 m, NI = 1.0 × 10⁶ A turns), solved axisymmetrically and drawn by axionMultiPhysics's renderer as a 3D cutaway. Colour: the static field |B| on the cut planes (viridis, 0 to 0.167 T), which is confined to the toroid volume; where it vanishes the planes are left uncoloured. Pink: field lines of the pickup mode in the bore. Signal coupling Ψ = 3.088 × 10⁻⁷ H T m², pickup inductance L_p = 1.458 µH, with third-order elements; second-order elements agree to 4 × 10⁻⁶.*
The figure is generated by [docs/images/make_homepage_figures.py](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/images/make_homepage_figures.py).

</details>

<img src="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/readme_cavity_offcentre.png" alt="Transverse cross-section of a cavity with an off-centre tuning rod" width="360">

*Transverse cross-section with an off-centre tuning rod (ADMX cavity, R = 210 mm, one 50.8 mm rod; pivot geometry
inferred): $`|E_z|`$ of the $`\mathrm{TM}_{010}`$-like mode from the cross-section eigensolver (`"symmetry": "xsec"`,
beta), with $`f`$ and the form factor $`C`$ ([script](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/images/make_readme_panels.py)); $`f`$ and $`C`$ agree with an
independent method-of-particular-solutions calculation to about 1e-8 ([validation](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/validation/cavity_xsec.md)).*

<img src="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/readme_srf_cylinder.png" alt="Meridional section of a closed cylinder SRF cavity: overlap density of the pump and signal modes" width="360">

*SRF heterodyne cavity (beta): the 60 L closed cylinder of Lasenby (arXiv:1912.11056), R = 20 cm, at the length where
the $`\mathrm{TE}_{012}`$ pump and the $`\mathrm{TM}_{013}`$ signal are degenerate: their overlap density
$`\tilde{\mathbf E}_1\cdot\tilde{\mathbf B}_0`$ on the meridional section (fields in units of their rms values), whose
volume average is the overlap factor $`\eta_{10}`$, from the axisymmetric eigensolver with `axionmultiphysics.srf`; the
closed form of the cylinder pair agrees to 1e-5
([docs/srf/](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/srf/README.md),
[script](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/images/make_readme_panels.py)).*

<img src="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/readme_readout_circuit.png" alt="Effective readout circuit: FEM pickup with axion EMF and loss, leads, tuning capacitor, dc SQUID input coil" width="49%">
<img src="https://raw.githubusercontent.com/bsafdi/axionMultiPhysics/main/docs/images/readme_squid_chain.png" alt="dc SQUID amplifier chain: first-stage dc SQUID, second-stage SQUID array, room-temperature preamplifier" width="49%">

*Left: the readout loop of `circuit.series_readout` ([docs/physics/readout_circuit.md](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/physics/readout_circuit.md)),
drawn by the package itself: `readout.draw(annotate=False)` (with values: `readout.draw()`; also `Chain.draw()`,
`MultiportReadout.draw()`; the `draw` extra). Right: the dc SQUID amplifier chain behind the input coil (beta),
`squid.chain("C1+low+RT").draw(annotate=False)` ([docs/physics/squid_chain.md](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/physics/squid_chain.md)). Typeset
by [docs/images/make_readme_panels.py](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/images/make_readme_panels.py); the plain SVG versions come from
[docs/images/make_circuit_figure.py](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/images/make_circuit_figure.py).*

> Status: version 0.1.0 (alpha). Axisymmetric and MPI 3D solvers, full-wave analysis, circuits, HTS, mechanics and
> heat conduction, and the design tools are checked against closed-form solutions, manufactured solutions,
> independent solvers or published results ([validation](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/validation/index.md)). Beta (working and tested, but
> with an interface or a validation that is not complete): cavity haloscopes, SRF heterodyne cavities, dc SQUID
> chains, multi-band and multipole scans, torsional dynamics, the COMSOL import, the fluids, scalar-transport and
> chemistry modules, the surface-resistance models, and in 3D full wave everything except current ports (prescribed
> sources, the imposed background field, perfectly matched layers, the error indicator, the Gauss-law guard, the
> adaptive sweep, the tree-cotree solve, eigenmodes, closed RF-only models and the energy-matrix, field-export and
> reactive-load diagnostics). The 3D engine and the fluids module need the MPI source build.

## What it computes for lumped-element detectors

For a lumped-element detector geometry (windings, superconductors, iron, normal conductors,
readout port) axionMultiPhysics solves the magnetoquasistatic problems that define a
lumped-element axion search:

- the static laboratory field $`\mathbf B_\mathrm{lab}`$ (nonlinear iron, superconductors with
  frozen fluxoid or prescribed current, exact open boundary);
- the pickup mode: the field of a unit readout current, giving $`L_p`$;
- the signal coupling $`\Psi=\frac{1}{I}\int \mathbf A_I\cdot\mathbf B_\mathrm{lab}\,d^3x`$ ($`\Phi_a=\kappa_a\Psi`$);
- the scan figure of merit $`\mathcal F=\Psi^4/L_p^2`$ against the requirement $`\mathcal F_\mathrm{req}`$ of
  the optimal resonant scan (Chaudhuri et al.), for any noise benchmark;
- stored energy, peak fields in windings and on superconducting surfaces,
  Lorentz forces and Maxwell pressure, cold-envelope area and a cost metric (a scaling metric for comparing
  designs, not a construction estimate);
- **shape sensitivities** of all of those with respect to the design parameters
  (adjoint on a morphed mesh) and gradient-based optimization
  ([docs/optimization.md](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/optimization.md)).

## Quick start

We install the wheel from PyPI with meshing and notebook support. The wheels are built for Linux x86_64 and macOS
(x86_64 and arm64), CPython 3.10–3.14:

```bash
pip install "axionmultiphysics[mesh,notebook]"
```

On Linux, gmsh's wheel (the `mesh` extra) needs a few X11/OpenGL libraries even without a display (Debian/Ubuntu:
`sudo apt-get install libglu1-mesa libgl1 libxcursor1 libxft2 libxinerama1`). Other platforms build from source
([installation](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/guides/install.md)).

We solve the quick-start toroid to inspect its summary and fields, then export an HTML view.

```python
import axionmultiphysics as axmp
res = axmp.template("toroid", R=2.0, H=2.0, y=0.6).solve()
print(res.summary())
res.show()                      # the 3D viewer in a Jupyter cell
res.export_html("toroid.html")  # or a self-contained page
```

The wheels have everything except the 3D engine and the fluids module, which need MPI and so the
[MPI source build](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/guides/install.md#mpi-source-build). `axmp.build_info()` reports the available build features.

Step-by-step [example notebooks](https://github.com/bsafdi/axionMultiPhysics/tree/main/examples/) (executed, and rendered on the documentation website) cover
lumped-element detectors, SQUID readout chains, cavity haloscopes, SRF heterodyne cavities, mechanics and heat,
fluids and chemistry.

With the MPI source build (on a cluster, in a compute allocation), we build the dependencies and axionMultiPhysics to
solve an example design.

```bash
bash scripts/fetch_deps.sh && bash scripts/build_deps.sh
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build
./build/axmp solve examples/long_solenoid_coax.json -o runs/demo
```

`axmp validate design.json` checks a design and prints actionable errors;
`axmp schema` prints the JSON Schema of the design format;
`axmp requirement` prints $`\mathcal F_\mathrm{req}`$ for the benchmarks.

## Layout

| Path | Contents |
|---|---|
| `cpp/` | C++ library `libaxionmultiphysics`, CLI `axmp`, mesher `axmp-mesher` (gmsh, separate process) |
| `python/axionmultiphysics` | Python package: builder API, templates, viewer server, MCP server |
| `viewer/` | three.js viewer shipped with the package |
| `docs/` | [installation](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/guides/install.md), [build options](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/install.md), [viewer](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/viewer.md), [COMSOL export](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/comsol_export.md), [COMSOL import](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/comsol_import.md) (`axmp import-comsol model.mph`, beta), physics notes, design-format reference, [validation](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/validation/index.md) |
| `benchmarks/` | validation cases and their records (e.g. [SRF cell](https://github.com/bsafdi/axionMultiPhysics/tree/main/benchmarks/srf/): 2D/3D convergence) |
| `examples/` | example designs and notebooks: [quick start](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/notebook_quickstart.ipynb), [lumped-element detectors](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/lumped_element_demo.ipynb) (toroid, solenoid, CORE: geometry → $`\Psi`$, $`L_p`$ → $`\mathcal F`$ vs $`\mathcal F_\mathrm{req}`$ → scan), [mechanics and thermal](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/mechanics_thermal_demo.ipynb) (forces on the winding, support stresses, cooldown, heat load with $`k(T)`$), [dc SQUID amplifier chains](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/squid_chain_demo.ipynb) (beta), [cavity haloscope walkthrough](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/cavity_demo.ipynb) (beta; geometry → eigenmodes → $`C`$, $`Q_0`$ → reach), [SRF heterodyne cavities](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/srf_demo.ipynb) (beta; mode pair → $`\eta_{10}`$, $`G`$, $`\xi`$ → required volume), [fluids](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/fluids_demo.ipynb) (beta; Stokes flow), [chemistry](https://github.com/bsafdi/axionMultiPhysics/blob/main/examples/chemistry_demo.ipynb) (beta; current distributions) |

## Building the docs

The documentation website (MkDocs Material; user guides from `docs/`, the
example notebooks, and an API reference generated from the docstrings) builds
without the compiled core.

We install the documentation dependencies and run the preview, strict build and offline build to generate the site.

```bash
pip install -r docs/requirements.txt -c docs/constraints.txt
mkdocs serve                        # live preview on http://127.0.0.1:8000
mkdocs build --strict               # what CI checks (.github/workflows/docs.yml)
bash scripts/docs/build_offline.sh  # a site/ that opens from disk (file://; MathJax still needs a network)
```

The API reference lists the public objects in `docs/api.md`; the validation pages, physics notes and other
reference pages are kept out of the site by `exclude_docs` in `mkdocs.yml` and linked on GitHub.

## Citing

We ask that work using axionMultiPhysics cite

> J. N. Benabou, J. W. Foster, B. R. Safdi, to appear (2026).

and the software itself, using the metadata in [CITATION.cff](https://github.com/bsafdi/axionMultiPhysics/blob/main/CITATION.cff). Please also cite the methods and
benchmark papers your work relies on, and MFEM. [About](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/about.md#citing-axionmultiphysics) has a BibTeX entry.

## Development

axionMultiPhysics was developed by its authors with Claude (Anthropic) as an AI coding agent in Claude Code, mostly
Claude Opus 5.5; most commits in its development history carry a Claude Opus 5.5 co-author trailer. The correctness of
axionMultiPhysics rests on its checks, not on how the code was written: each validated capability is checked against
closed-form solutions, manufactured solutions, independent solvers or published results, most of those checks run in the
test suite, and modules with less validation evidence are labelled beta. Contributions are welcome; the
[developer guide](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/developer/contributing.md) and
[AGENTS.md](https://github.com/bsafdi/axionMultiPhysics/blob/main/AGENTS.md) describe the conventions.

## Authors

Joshua N. Benabou, Joshua W. Foster, Benjamin R. Safdi

## License

BSD 3-Clause ([LICENSE](https://github.com/bsafdi/axionMultiPhysics/blob/main/LICENSE)). The vendored three.js (`viewer/vendor/`, MIT) and stb_image_write
(`cpp/third_party/`, MIT or public domain) keep their own licences. gmsh (GPL) is used only as an external program, is
not redistributed in our wheels, and comes from its own PyPI package; licensing details are in
[docs/install.md](https://github.com/bsafdi/axionMultiPhysics/blob/main/docs/install.md#licensing-of-each-wheel), "Licensing of each wheel".

## Trademarks

COMSOL and COMSOL Multiphysics are registered trademarks of COMSOL AB. axionMultiPhysics is not affiliated with, sponsored by or endorsed by COMSOL AB. Other product names are trademarks of their owners.
