Input File
The primary NTX command-line interface is:
ntx input.toml
One TOML file defines one monoenergetic solve.
Minimal Example
[surface]
type = "example"
[grid]
n_theta = 9
n_zeta = 9
n_xi = 8
[case]
nu_hat = 1e-2
epsi_hat = 0.0
Running
ntx input.toml
prints a Rich summary and writes input.nc unless another output file is
configured. Current examples default to NetCDF, so a typical file-backed run is:
ntx examples/example_surface.toml --plot
This writes examples/outputs/example_surface.nc and
examples/outputs/example_surface.pdf.
Top-Level Tables
Required tables:
[surface][grid][case]
Optional tables:
[output][logging]
[surface]
Common Keys
Key |
Required |
Meaning |
|---|---|---|
|
yes |
one of |
|
for |
input file path, resolved relative to the TOML file |
type = "example"
Uses example_surface() from src/ntx/geometry.py.
type = "dkes"
Loads a DKES-style Boozer harmonic file through
load_dkes_surface(...) in src/ntx/io.py.
The file supplies:
nfppsi_pchi_piotaB_thetaB_zetaBoozer Fourier harmonics for
B
type = "vmec"
Loads one VMEC flux surface through load_vmec_surface(...) in
src/ntx/vmec.py.
Additional keys:
Key |
Required |
Default |
Meaning |
|---|---|---|---|
|
yes |
none |
requested normalized toroidal flux |
|
no |
|
radial interpolation / snapping mode |
|
no |
|
reduced or Nyquist mode set |
|
no |
|
reduced versus filtered-Nyquist mode convention |
|
no |
|
drop small |
vmec_radial_option
0: interpolate to the requestedpsi_n1: snap to nearest interior VMEC surface2: snap to nearest VMEC surface including endpoints
vmec_nyquist_option
1: reduced mode set2: keep Nyquist modes
vmec_mode_convention
"reduced""filtered_nyquist"
[grid]
Key |
Required |
Default |
Meaning |
|---|---|---|---|
|
yes |
none |
number of poloidal grid points |
|
yes |
none |
number of toroidal grid points in one field period |
|
yes |
none |
highest Legendre mode index retained |
|
no |
|
working scalar dtype ( |
|
no |
|
enable JAX x64 mode |
Constraints from src/ntx/grids.py:
n_theta >= 3n_zeta >= 3n_xi >= 2
[case]
Key |
Required |
Default |
Meaning |
|---|---|---|---|
|
yes |
none |
monoenergetic collisionality |
|
no |
|
normalized electric field in the solver normalization |
|
no |
|
radial electric field in the input normalization |
Exactly one of epsi_hat and er_hat may be set.
Electric-Field Resolution
If epsi_hat is given, NTX uses it directly.
If er_hat is given, NTX converts it internally:
Boozer / DKES:
\[\hat E_\psi = \hat E_r / \psi_p\]VMEC:
\[r_n = \sqrt{\psi_n},\quad \hat r = a_\mathrm{minor} r_n,\quad \frac{d\hat\psi}{d\hat r} = \frac{2\hat\psi_a r_n}{a_\mathrm{minor}},\quad \hat E_\psi = \hat E_r \left(\frac{d\hat\psi}{d\hat r}\right)^{-1}\]
[output]
Key |
Required |
Default |
Meaning |
|---|---|---|---|
|
no |
|
output file path; suffix selects NetCDF, NPZ, or HDF5 |
|
no |
none |
legacy alias for |
|
no |
none |
alias for NetCDF output path |
|
no |
none |
alias for HDF5 output path |
|
no |
|
include |
Set only one output path key. Supported suffixes are:
.ncor.netcdf: uncompressed NetCDF4, the default file-backed format.npz: compressed NumPy archive, useful for compact Python-only exchange.h5or.hdf5: uncompressed HDF5, useful for fast array interchange
The CLI can override the TOML path:
ntx input.toml --output outputs/run.npz
ntx input.toml --output outputs/run.nc --plot
Python callers can use the same suffix selection:
from ntx import run_from_input_file
payload = run_from_input_file("input.toml", output_path="outputs/run.nc", plot=True)
print(payload["output_path"], payload["plot_pdf"])
[logging]
Key |
Required |
Default |
Meaning |
|---|---|---|---|
|
no |
|
print Rich run summaries and metadata tables |
Verbose Terminal Output
Verbose runs print:
input file path
surface summary
source-file metadata
geometry statistics
resolved electric-field normalization
algorithm summary
transport coefficients and diagnostics
prepare/solve/write/plot runtime timings
output-file summary
optional PDF plot path when
--plotis used
Output Payload
The CLI writes the same data to NetCDF, NPZ, and HDF5. NetCDF and HDF5 store string metadata as file attributes and numeric arrays as variables/datasets. NPZ stores every entry as a NumPy array. The payload has four classes of data.
1. Input And Run Metadata
input_pathinput_toml_textrun_config_jsonsurface_typesurface_pathsurface_source_namesurface_source_size_bytessurface_source_mtimesurface_source_sha256
2. Solver Setup
n_thetan_zetan_xidtypex64nu_hatepsi_hat_inputer_hat_inputepsi_hat_resolved
3. Geometry Arrays
theta_gridzeta_gridbd_b_dthetad_b_dzetajacobianb_sub_thetab_sub_zetab_sup_thetab_sup_zetaradial_drift_spatialvolume_primeb2_mean
4. Transport Results
D11D31D13D33D33_spitzerresidual_l2onsager_residualoptionally
f1_modesoptionally
f3_modes
Metadata is also stored as JSON strings:
surface_metadata_jsongeometry_metadata_jsonalgorithm_metadata_json
All of this is written in save_run_output(...) in
src/ntx/_inputfiles_output.py, with
save_run_output(...) selecting the concrete writer from the filename suffix.
Example Inputs
Analytic Sample
[surface]
type = "example"
[grid]
n_theta = 9
n_zeta = 9
n_xi = 8
[case]
nu_hat = 1e-2
epsi_hat = 0.0
DKES-Style Boozer Input
[surface]
type = "dkes"
path = "sample.ddkes2.data"
[grid]
n_theta = 17
n_zeta = 25
n_xi = 32
[case]
nu_hat = 1e-5
er_hat = 1e-3
[output]
path = "outputs/sample_dkes.nc"
include_modes = true
VMEC Input
[surface]
type = "vmec"
path = "wout_example.nc"
psi_n = 0.25
vmec_radial_option = 0
vmec_nyquist_option = 1
vmec_mode_convention = "reduced"
min_bmn_to_load = 0.0
[grid]
n_theta = 17
n_zeta = 25
n_xi = 32
[case]
nu_hat = 1e-5
er_hat = 1e-3
[output]
path = "outputs/sample_vmec.nc"
include_modes = true
Post-Processing
Inspect an output file graphically with:
python examples/plot_output_file.py path/to/output.nc
That script turns the saved payload into a publication-style multi-panel figure.
The legacy script name examples/plot_output_npz.py remains available and now
accepts .nc, .npz, and .h5 files.