Skip to content

About

NEO, Chang-Hinton, Hirshman-Sigmar, FACIT neoclassical calculations

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

NeoclassicalTransport.jl

Neoclassical transport for IMAS data (used by FUSE):

  • Hirshman-Sigmar and Chang-Hinton analytic models
  • FACIT impurity transport
  • yancc: drift kinetic solver with the linearized Fokker-Planck collision operator, through Yancc.jl (see below)
  • Yancc-NN: neural-network surrogates of the drift kinetic solver with sonic rotation (see below)
  • run_neo: calls a locally installed Fortran NEO executable (see below)

Analytic models

geom = NeoclassicalTransport.get_equilibrium_geometry(eqt, cp1d)
prof = NeoclassicalTransport.get_plasma_profiles(eqt, cp1d)
sol  = NeoclassicalTransport.hirshmansigmar(gridpoint, eqt, cp1d, prof, geom)   # GACODE.FluxSolution
sol  = NeoclassicalTransport.changhinton(eqt, cp1d, rho, 1)                      # ion energy flux only

Drift kinetic solver (yancc)

gridpoints = [argmin(abs.(cp1d.grid.rho_tor_norm .- rho)) for rho in 0.25:0.1:0.85]
geometry = NeoclassicalTransport.get_yancc_geometry(eqt, cp1d, gridpoints)         # Miller flux surfaces
caches = [NeoclassicalTransport.YanccCache() for _ in gridpoints]                  # optional
sol = NeoclassicalTransport.yancc(gridpoints[k], eqt, cp1d, geometry.fields[k]; geometry.a, cache=caches[k])   # GACODE.FluxSolution

Electron and ion energy and particle fluxes from Yancc.jl, the Julia port of yancc by Rory Conlin, on the Miller parametrization of the flux surface and without rotation or radial electric field. The species are those of InputNEO and hirshmansigmar: every ion with its total density (thermal + fast) and its own temperature, and the electrons. A cache kept from one call to the next at the same grid point reuses the preconditioner and the last solution, as between the iterations of a transport solver. Keywords nx, nalpha and ntheta (of get_yancc_geometry) set the resolution; the defaults (6, 65, 41) are within a few percent of the converged energy fluxes at moderate collisionality and about 10 % above them in the collisionless core of a reactor.

If you use this model, please cite R. Conlin and M. Landreman, "yancc: a GPU-accelerated, differentiable solver for neoclassical transport in tokamaks and stellarators", Plasma Phys. Control. Fusion 68, 115001 (2026), doi:10.1088/1361-6587/aeb628.

Neural-network surrogates of the drift kinetic solver (run_yanccnn)

input_neo = NeoclassicalTransport.InputNEO(eqt, cp1d, gridpoint)
sol  = NeoclassicalTransport.run_yanccnn(input_neo)        # GACODE.FluxSolution, gyro-Bohm units
flow = NeoclassicalTransport.run_yanccnn_flow(input_neo)   # poloidal flows and parallel current
sol  = NeoclassicalTransport.run_yanccnn(input_neo; uncertain=true)   # Measurements: mean ± spread over the ensemble

The models are ensembles of 20 networks trained on drift kinetic solutions with sonic toroidal rotation for core plasmas (r/a from 0.1 to 0.9, deuterium with carbon, 41 poloidal and 10 energy points):

model training set pitch points median / 90th percentile error on held-out data
yanccnn_mastu+nstx_flux (default of run_yanccnn) MAST-U and NSTX 65 0.2–0.4 % / 0.9–2.3 %
yanccnn_mastu+nstx_flow (default of run_yanccnn_flow) MAST-U and NSTX 65 below 0.1 % / 0.3 %
yanccnn_d3d_flux DIII-D 129 0.06–0.14 % / 0.4–0.9 %
yanccnn_d3d_flow DIII-D 129 0.02–0.06 % / 0.1–0.3 %

The errors are those of the ensemble mean relative to the solver, over the output channels. The plasma is reduced to a bulk ion, one lumped impurity and electrons (yanccnn_inputs), and warn_nn_train_bounds=true warns when an input is outside the range of the training set. The forward pass is differentiable with ForwardDiff. yanccnn_models() lists the models.

The weights (models/*.bin) are stored with Git LFS. In a git checkout git lfs pull fetches them; in a package installation they are downloaded on first use.

python utilities/yanccnn_to_onnx.py models/<name> [outdir] --check converts a model to ONNX: one graph for the whole ensemble (plain inputs to mean and standard deviation) and one for each member, with the normalisation in text files (needs numpy and onnx; onnxruntime for --check).

Fortran NEO (run_neo)

run_neo(ineo) writes input.neo, runs the GACODE NEO executable and returns a GACODE.FluxSolution; it is kept for cross-checks and is not differentiable. It needs GACODE installed locally: https://fuse.help/install.html#Install-GACODE (see the note after step 6 — on macOS you may need to replace mpif90-openmpi-mp with mpif90-openmpi-gcc12 in $GACODE_ROOT/platform/build/make.inc.OSX_MONTEREY and mpirun-openmpi-mp with mpirun-openmpi-gcc12 in $GACODE_ROOT/platform/exec/exec.OSX_MONTEREY). On login nodes where the neo -e wrapper cannot launch, source your GACODE environment and call NeoclassicalTransport.use_serial_neo!(), which builds a serial no-MPI NEO from utilities/serial_neo/ and points run_neo at it.

Online documentation

For more details, see the online documentation.

Docs

About

NEO, Chang-Hinton, Hirshman-Sigmar, FACIT neoclassical calculations

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages