Source-Code Map
This page maps the main physics formulas and workflows onto the NTX source tree.
Core Solver Modules
Topic |
Main file |
Key functions / classes |
|---|---|---|
Surface dataclasses and geometry evaluation |
|
|
Angular grids and Fourier differentiation |
|
|
Legendre-space operator coefficients |
|
|
Dense block solve and scans |
|
|
Transport post-processing |
|
|
CLI/TOML workflow |
|
|
VMEC loading |
|
|
In-memory |
|
|
Boozer file loading |
|
Boozer harmonic file loaders |
NEOPAX coupling |
|
|
Profile-grade imported workflows |
|
radial profile dataclasses, scan-channel interpolation, primitive-force reconstruction, ambipolar |
Throughput-oriented multi-device execution |
|
|
Autodiff examples and optimization helpers |
|
inverse, sensitivity, uncertainty, and deterministic/robust bootstrap-current optimization helpers |
Validation registries |
|
benchmark-matrix evaluator, benchmark claim types, lane-owned benchmark metadata, finite-beta geometry-breadth metadata, analytical physics-gate definitions, artifact-backed gate definitions, finite-beta artifact-gate registry definitions, registry facade, shared artifact-gate evaluators, finite-beta artifact-gate ownership, finite-beta closure-target artifact parsing, and finite-beta source-channel artifact summaries |
The compatibility modules remain the primary public import locations. New implementation ownership can sit behind those facades when the split improves testing or source navigation. The newer namespace packages provide stable grouped imports:
ntx.corefor solver, scan, and transport helpers.ntx.workflowsfor autodiff, profile, and imported database helpers.ntx.validationfor benchmark and validation registries.
Refactoring Target
The source tree should keep moving toward smaller ownership boundaries, but only when a move improves testing, documentation, or API clarity.
Target ownership:
Package |
Responsibility |
|---|---|
|
grids, operator assembly, dense solve, transport coefficients, prepared solve/VJP |
|
analytic, Boozer, VMEC, and imported JAX geometry evaluation |
|
TOML, NPZ, HDF5, NetCDF, and benchmark artifact loading/writing |
|
profile, NEOPAX, autodiff, optimization, and publication workflows |
|
benchmark matrix, physics gates, literature claim metadata, artifact summaries |
Compatibility facades should remain stable for users. Internal modules can move
behind those facades when the new location has direct unit tests and the docs
map has been updated in the same change.
tests/test_source_map.py keeps the split internal modules listed here, so each
future ownership split must update this map in the same change.
Equation-To-Code Mapping
Fourier Representation Of B
Implemented in:
evaluate_fourier_series(...)evaluate_boozer_modes(...)
Boozer Jacobian And Field Components
Implemented in:
_boozer_geometry_on_grid(...)insrc/ntx/geometry.py_apply_boozer_sign_convention(...)and_apply_boozer_sign_convention_profiles(...)insrc/ntx/_vmec_jax_boozer.py, which enforce the same right-handed sign convention for in-memory JAX Boozer data that the file-backed loader applies before constructingBoozerSurface
The fast physics-gate suite checks the right-handed Boozer identity
\mathcal J B^2 = B_\zeta + \iota B_\theta, plus the corresponding
contravariant identities B^\theta \mathcal J = \iota and
B^\zeta \mathcal J = 1, before any transport coefficient is interpreted.
Radial-Drift Spatial Factor
Implemented in:
_boozer_geometry_on_grid(...)_vmec_geometry_on_grid(...)
Legendre-Space Block System
Implemented in:
coefficients_for_k(...)operator_blocks(...)
in src/ntx/operators.py, and solved by
_solve_modes(...) in
src/ntx/_solver_factorization.py.
Nullspace Fix
Implemented in:
apply_nullspace_condition(...)insrc/ntx/operators.py
Flux-Surface Averages And Transport Coefficients
Implemented in:
coefficients_from_modes(...)insrc/ntx/transport.py
This is the only module that turns solved Legendre modes into the reported
D11, D31, D13, D33, and D33_spitzer.
Electric-Field Normalization
Implemented in:
MonoenergeticCase.resolved_epsi_hat(...)insrc/ntx/solver.pyload_vmec_surface(...)insrc/ntx/vmec.py
Scan And Differentiable Workflows
Implemented in:
solve_monoenergetic_scan(...)insrc/ntx/solver.pybuild_ntx_neopax_scan(...)insrc/ntx/_neopax_scan.pyscan field-channel normalization in
src/ntx/_neopax_scan_fields.pyscan coefficient and bridge-block assembly in
src/ntx/_neopax_scan_coefficients.pyhelpers in
src/ntx/autodiff.py
Profile Forces And Ambipolarity
The profile workflow reconstructs the thermodynamic-force channels
from primitive density, temperature, charge, and radial-electric-field inputs in
src/ntx/_profiles_primitives.py.
Scan-channel interpolation and species particle/current responses live in
src/ntx/_profiles_channels.py. The
ambipolar profile residual uses the charge-weighted particle-flux condition
before the radial-electric-field solve in
src/ntx/_profiles_eval.py.
Normalized transport mismatch terms, update clipping, and primitive
density/temperature mismatch algebra live in
src/ntx/_profiles_transport_terms.py;
the positivity-preserving explicit update itself lives in
src/ntx/_profiles_transport_closure.py.
Publication Figures
The publication-ready example scripts live in examples/:
validation_summary.pybootstrap_current_optimization.pybootstrap_current_from_vmec_or_boozmn.pybootstrap_current_with_neopax.pybootstrap_current_fixed_field_validation.pybootstrap_current_reference_audit_w7x.pyowned_geometry_neopax_dataset.pyowned_finite_beta_sfincs_jax_inputs.pyowned_finite_beta_sfincs_jax_resolution_audit.pyowned_finite_beta_sfincs_jax_production_ladder_audit.pyowned_finite_beta_sfincs_jax_profile_current_audit.pyowned_finite_beta_sfincs_jax_profile_current_resolution_audit.pyowned_finite_beta_bootstrap_comparison.pyowned_finite_beta_closure_localization.pyowned_finite_beta_profile_current_observable_audit.pyowned_finite_beta_current_conditioning_audit.pyowned_finite_beta_closure_quadrature_audit.pyowned_finite_beta_source_channel_audit.pyowned_finite_beta_source_response_profile_audit.pyowned_finite_beta_closure_target_audit.pyperformance_scaling.pyperformance_strong_scaling.pyprepared_geometry_reuse_profile.pyautodiff_inverse_problem.pyneopax_autodiff_profiles.pyderivative_audit.pyderivative_path_benchmark.pygeometry_control_derivative_benchmark.pyfile_backed_geometry_control_derivative_benchmark.pyexplicit_relaxed_boundary_current_derivative_benchmark.pygeometry_family_breadth_summary.pygeometry_family_transport_convergence.pyambipolar_profile.pyambipolar_profile_family.pyprofile_control_optimization.pyprofile_basis_optimization.pyprofile_transport_loop.pyprimitive_profile_transport.pyplot_output_file.py
The fixed-field validation script delegates reviewable artifact math to
examples/_fixed_field_validation_metrics.py and
examples/_fixed_field_validation_plotting.py, and
examples/_fixed_field_validation_summary.py; the closure-specific diagnostic
assembly lives in examples/_fixed_field_validation_closure.py. The expensive
QA/QH simulation path remains in
examples/bootstrap_current_fixed_field_validation.py.
The figure bundle generator is:
make_publication_figures.py
The benchmark-matrix artifact generator is:
scripts/build_benchmark_matrix.py
Performance timing artifacts are generated by:
scripts/benchmark_scaling.pyscripts/benchmark_strong_scaling.py