M7-JAX
A Python/JAX port of the ECHAM6.3-HAM2.3 M7 aerosol microphysics, validated
against the original Fortran routines and the complete native m7 call. This
repository is independent of SALSA-JAX.
step_all advances HAM's 18-component, seven-mode state: sulfate, black
carbon, organic carbon, sea salt and dust in the four soluble and three
insoluble lognormal modes, plus H₂SO₄ gas. It includes coagulation,
condensation, binary (Vehkamäki) and ion-mediated (Kazil–Lovejoy) sulfuric-acid
nucleation, organic nucleation, insoluble-to-soluble ageing, particle
properties, kappa hydration and modal redistribution in the native process
order, and the host-tracer conversions of HAM's ham_subm_interface. The
original pure-sulfate step (four soluble modes, empty insoluble modes, both
hydration options) remains. The rest of HAM (chemistry, emissions,
deposition, the box and GCM drivers), secondary organic aerosol and radiation
are outside this scope.
Install
pip install m7-jax
The wheel includes the authentic 45 MB kappa lookup table
(m7_jax.properties.default_kappa_table_path()). The Fortran reference
harness, the recorded configurations and the test suite need a checkout of
this repository.
Develop and test
Use this repository's own virtual environment. GNU Fortran must be on PATH;
NetCDF Python reading uses SciPy, so the reference harness does not require
NetCDF Fortran libraries. The authentic 45 MB kappa lookup table is included.
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements-dev.txt
.venv/bin/python -m pip install --no-deps -e .
.venv/bin/python -m pytest -q
Run commands from this checkout. Enable JAX double precision before constructing
arrays. requirements-dev.txt records the tested environment; the editable
checkout includes the reference inputs used by command-line tools.
Run the sulfate experiment
.venv/bin/python -m tools.run_m7_sulfate \
--config configs/m7-sulfate.toml --output outputs/sulfate
Use a fresh output directory. The command runs both JAX and checked/optimized Fortran, saves every timestep to NPZ and CSV, records source/compiler hashes, and checks parity, physical state and sulfur budgets. It exits nonzero if a comparison or budget gate fails, retaining the report for inspection.
The example starts with 100 and 900 particles/cm³ in the nucleation and Aitken
modes, dry count-median diameters 3 and 25 nm, 280 K, 101325 Pa, RH 50%, and
10⁸ H₂SO₄ molecules/cm³. Gas production is 10⁵ molecules/cm³/s; the gas evolves
rather than remaining constant. It runs 600 one-second steps. Other checked
configurations are in configs/.
Python API
import jax
jax.config.update('jax_enable_x64', True)
from m7_jax.model import initialize, step, STATIC_OPTIONS
from m7_jax.properties import default_kappa_table_path, load_kappa_table
state = initialize(dry_diameter_nm=(3., 25., 200., 2000.))
table = load_kappa_table(default_kappa_table_path())
advance = jax.jit(step, static_argnames=STATIC_OPTIONS)
result = advance(state, 280., 101325., .5, 1., production=1e5, table=table)
assert bool(result.valid)
state = result.state
Independent APIs: coagulation.coaset/dnum,
condensation.condensation_sink/produce_and_condense, and
nucleation.vehkamaeki/nucleate. Use native concentrations in cm⁻³, radii
in cm, pressure in Pa, temperature in K and timestep in seconds. Leading
array dimensions represent independent cells. Host validation rejects insoluble
populations; check StepResult.valid inside repeated integration.
Evidence and limits
353 tests pass on JAX 0.10.2, 0.11.0 and 0.12.1, with 8 real-PARNUC-table
variants skipped; 361 pass when HAM_INPUT_DIR names the table.
All six recorded trajectories pass every-step Fortran comparison and sulfur
budgets. This establishes compatibility with the Fortran for the tested
configurations, not independent physical accuracy. The
validation report has the measured errors.
- Architecture, units and scientific limitations
- Validation results, timestep refinement and CPU measurements
- Commit-sized implementation and verification plan
- Reference provenance
JAX is slower for the measured single-cell workloads. Native cancellation and
lookup discretization are preserved in float64. The float32 path of
step_all uses algebraically identical forms that avoid the cancellations
(model contract). The Kazil/Lovejoy lookup option
(nucleate_all/step_all, scheme=2) is supported given its PARNUC table
(HAM_INPUT_DIR, not shipped -- see docs/validation.md); without one it is
rejected there too, and the independent nucleate/step APIs reject it
unconditionally. Coupled nucleation with condensation disabled is also
rejected because native M7 leaves its sink uninitialized; the independent
nucleation API accepts an explicit sink. One native defect is corrected, as
the r7492 reference configuration itself corrects it (the insoluble-mode
radius, TUT-ISI/SALSA#6); every other native formula, including the known
defects listed in the model contract,
is unchanged. Original source/license notices are retained in reference/.
License
M7-JAX is licensed under the Apache License 2.0. The JAX kernels
and native oracle are derived from HAMMOZ M7 and also remain subject to the
BSD 3-Clause License; see NOTICE.
Upstream sources and data under reference/ are BSD 3-Clause; see NOTICE
for the two ICON constant modules that still carry older MPI-M headers.
Metadata
Release files for m7-jax 0.2.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 |
|---|---|---|---|---|
| m7_jax-0.2.0.tar.gz | 42.4 MB | With provenance | Details for m7_jax-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| m7_jax-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for m7_jax-0.2.0-py3-none-any.whl |
Total release size: 84.8 MB
Release files / m7_jax-0.2.0.tar.gz
| Download URL | m7_jax-0.2.0.tar.gz |
|---|---|
| Size | 42.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
641b0555f11ef2ad400f5252210fb8b844e2ab538dc11222767d346a224286b8
|
|
BLAKE2b-256 checksum How to use checksums |
19ff20937419d3365d6c0d5dd7408ba90dfef16e0420e6a0d2e0c73cf5ba8bf5
|
| 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 25, 2026.
Transparency logRelease files / m7_jax-0.2.0-py3-none-any.whl
| Download URL | m7_jax-0.2.0-py3-none-any.whl |
|---|---|
| Size | 42.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3bb3e3d0a2355070dcda37319c35b2be106953af3f1e715f6ac0222b15be5d7
|
|
BLAKE2b-256 checksum How to use checksums |
14f3467e367f1b885c790ca3518ecb04ecac85562adf30d00750beff47ee21d6
|
| 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 25, 2026.
Transparency logSecurity for m7-jax 0.2.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 m7_jax-0.2.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 25, 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.