Skip to main content

JAX-native monoenergetic neoclassical transport solver

Project description

Release License: MIT Tests Docs Coverage Python

NTX

NTX is a JAX-native monoenergetic neoclassical transport solver for stellarator flux surfaces. It solves the Legendre-space formulation described in Javier Escoto's PhD thesis, Fast monoenergetic neoclassical transport coefficients in stellarators.

Use NTX as:

  • a command-line solver for file-backed transport calculations,
  • a Python/JAX library for scans, autodiff, uncertainty propagation, and optimization,
  • a NEOPAX-compatible monoenergetic database builder for bootstrap-current workflows.

Install

pip install ntx

For local development:

pip install -e ".[dev,docs,io]"

Optional geometry-coupled examples use upstream JAX geometry tools:

pip install git+https://github.com/uwplasma/vmec_jax.git
pip install git+https://github.com/uwplasma/booz_xform_jax.git

Quick Start

Run the smallest bundled case:

ntx examples/example_surface.toml --plot

This writes examples/outputs/example_surface.nc plus a PDF summary panel. Choose the output format by filename:

ntx examples/example_surface.toml --output examples/outputs/example_surface.npz --plot
ntx examples/example_surface.toml --output examples/outputs/example_surface.h5 --plot
python examples/plot_output_file.py examples/outputs/example_surface.nc

Use NTX from Python:

from ntx import GridSpec, MonoenergeticCase, example_surface, solve_monoenergetic

surface = example_surface()
grid = GridSpec(n_theta=17, n_zeta=25, n_xi=32)
case = MonoenergeticCase(nu_hat=1e-3, epsi_hat=0.0)

result = solve_monoenergetic(surface, grid, case)
print(result.D11, result.D31, result.D13, result.D33)

For JAX scans:

import jax.numpy as jnp
from ntx import GridSpec, example_surface, solve_monoenergetic_scan

surface = example_surface()
grid = GridSpec(17, 25, 16)
nu_hat = jnp.logspace(-5, -2, 8)

coefficients = solve_monoenergetic_scan(
    surface,
    grid,
    nu_hat,
    epsi_hat=jnp.zeros_like(nu_hat),
)

Outputs

For each monoenergetic case, NTX computes:

  • D11, D31, D13, D33, and D33_spitzer,
  • residual and Onsager diagnostics,
  • resolved electric-field normalization,
  • geometry arrays and run metadata in NetCDF, NPZ, or HDF5 outputs.

The input schema is documented in docs/input-file.md.

Physics In One Paragraph

NTX solves the local monoenergetic drift-kinetic equation on one flux surface, keeping parallel streaming, mirror force, radial-electric-field precession, and Lorentz pitch-angle scattering at fixed speed. The unknown non-adiabatic response is projected onto Legendre polynomials in pitch angle, giving the block-tridiagonal system solved by the code. The two right-hand sides are the radial-transport drive and the parallel-flow/bootstrap-current drive; NTX returns the monoenergetic coefficients consumed by profile and NEOPAX workflows. The full equation, ordering, normalizations, and coefficient definitions are in docs/physics.md.

Validation Snapshot

Validation claims are tracked in the maintained benchmark matrix and physics-gate summary. The README keeps only the highest-signal artifacts:

Solver validation Fixed-field current comparison
Monoenergetic validation summary Fixed-field SFINCS, Redl, and NTX + NEOPAX bootstrap-current comparison
Bootstrap-current workflow Differentiable geometry/current path
NTX + NEOPAX bootstrap-current profile Explicit-relaxed boundary current derivative benchmark

Current promoted validation includes monoenergetic convergence and identities, the fixed-field Redl comparison on the precise-QS benchmark family, the fixed-field NTX+NEOPAX total-current stress gate, the integrated W7-X workflow transfer, and prepared derivative agreement against direct reverse-mode differentiation. The fixed-field current result uses documented normalization and moment-closure conventions, not fitted bridge constants. Species-resolved fixed-field closure parity, broader geometry-family studies, and large-optimization studies remain tracked as stress diagnostics or planned research lanes in the docs.

Run the local gate summary with:

python scripts/check_physics_gates.py

Common Workflows

CLI solves:

ntx examples/sample_dkes.toml
ntx examples/sample_vmec.toml

NEOPAX database and bootstrap-current examples:

python examples/neopax_with_ntx.py
python examples/bootstrap_current_with_neopax.py
python examples/bootstrap_current_from_vmec_or_boozmn.py

Autodiff and optimization examples:

python examples/derivative_audit.py
python examples/explicit_relaxed_boundary_current_derivative_benchmark.py
python examples/bootstrap_current_optimization.py

Performance examples:

python examples/prepared_geometry_reuse_profile.py --preset smoke
python scripts/benchmark_scaling.py --help

Full example coverage is in docs/examples.md.

Current Open Research Lanes

The major open lanes are:

  • full geometry-family reproduction on paper-resolution W7-X, QI, QA/QH, and additional stellarator-family inputs,
  • reusable hidden-symmetry and omnigenous benchmark families,
  • broader geometry-control autodiff with direct AD, prepared adjoints, and finite-difference agreement on reusable geometry families,
  • restoration of implicit-equilibrium sensitivities only after residual contraction and Boozer/NTX transport finite-difference agreement pass,
  • additional dedicated GPU nodes with healthy multi-GPU execution and device-memory timelines,
  • broader fixed-field NTX+NEOPAX closure transfer, including species-resolved current decomposition and any future default closure, without regressing the integrated W7-X workflow,
  • broader profile, uncertainty, and robust-design studies before promoting stellarator-design claims.

The live roadmap is in docs/research-roadmap.md.

Documentation

Local Checks

python -m ruff check .
python -m mypy src/ntx
python -m pytest -q
python -m sphinx -b html docs docs/_build/html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntx-0.2.3.tar.gz (8.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ntx-0.2.3-py3-none-any.whl (131.5 kB view details)

Uploaded Python 3

File details

Details for the file ntx-0.2.3.tar.gz.

File metadata

  • Download URL: ntx-0.2.3.tar.gz
  • Upload date:
  • Size: 8.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ntx-0.2.3.tar.gz
Algorithm Hash digest
SHA256 0cad52e05b16d88c08643dfd05ef7c2cf2b29d106fe03cf63d7d6cb19f9a8862
MD5 293855903edd0e24be496ff7251bccd9
BLAKE2b-256 de45046380f93f1954c2496d06d0dc1c7921bf4698ce7dee5c823a485806ee61

See more details on using hashes here.

Provenance

The following attestation bundles were made for ntx-0.2.3.tar.gz:

Publisher: release.yml on uwplasma/NTX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ntx-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ntx-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 131.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ntx-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e642e4658a857ce6153e7c67b7974fb52d9eec85135351237982b1a195b4815
MD5 d83d26b5fd2e629b1b38915729b760fd
BLAKE2b-256 3a416be9a1319c1927f012c6308f71fd63c34c7aebc62a909ce832afae4f814d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ntx-0.2.3-py3-none-any.whl:

Publisher: release.yml on uwplasma/NTX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page