Equilibrium

Equilibrium reads or constructs the axisymmetric MHD equilibrium, maps it to the straight-field-line coordinates every later stage works in, and returns a PlasmaEquilibrium holding the flux-surface splines, the profiles and the global parameters of the plasma. It is the first stage of every run and the only one that reads physics input files: the equilibrium itself and, optionally, the kinetic profiles.

What it computes

From the poloidal flux $\psi(R, Z)$ and the profiles $F = R B_\phi$ and $p$ of a Grad–Shafranov solution, the module traces the closed flux surfaces, finds the magnetic axis and the separatrix, integrates the safety factor $q(\psi)$ and the surface quantities $dV/d\psi$, and builds bicubic splines of the surface geometry $R(\psi, \theta)$, $Z(\psi, \theta)$ and of the toroidal-angle offset $\nu(\psi, \theta)$ in the coordinates selected by jac_type ("hamada", "pest", "boozer", "equal_arc", …; see the Conventions Reference page). The normalized flux $\psi_N \in [0, 1]$ runs from the axis to the boundary, and the rational surfaces q = m/n of the run are located on it.

Inputs

[Equilibrium] eq_type selects the file format of eq_filename:

eq_typeFormatNotes
"efit"EFIT g-fileflux surfaces traced by a field-line ODE in the geometric angle; the default
"efit_arclength"EFIT g-filethe same traced in arc length, which stays regular near the separatrix and reaches higher psihigh
"efit_by_inversion"EFIT g-filelevel sets traced by marching squares and fed to the inverse solver; the most accurate geometry
"chease" ("chease_binary")CHEASE binary outputinverse solver
"chease2" ("chease_ascii")CHEASE ASCII outputinverse solver
"ifile"inverse i-file, as TokaMaker writesinverse solver
"imas"an IMASdd.dd passed from a scriptPlasmaEquilibrium(dd; kwargs...); see examples/DIIID-like_ideal_example_IMAS

An analytic equilibrium is selected by its own section instead of eq_type: [Solovev] (the Solov'ev solution), [LargeAspectRatio] (a large-aspect-ratio model with prescribed profiles) or [TJAnalytic] (the profile family of Fitzpatrick's TJ code, solver = "inverse" | "direct"); their keys are the fields of SolovevConfig, LargeAspectRatioConfig and TJAnalyticConfig.

Kinetic profiles

[Equilibrium] kinetic_file attaches the density, temperature, rotation and transport profiles that the kinetic solve, Kinetic Forces and the SLAYER layer of Tearing read, so every kinetic consumer sees one plasma. Two formats are read, by extension:

  • HDF5 (.h5, .hdf5), the GPEC kinetic schema: datasets at the file root, each with a units attribute, on the normalized flux psi: required n_e, T_i, T_e, omega_E (and n_i, defaulting to n_e); optional omega_tor, chi_e, chi_i, chi_phi (perpendicular heat and momentum diffusivities), zeff, and the supplied collision rates lnLambda, nu_i and nu_e (see Kinetic Forces); further n_* datasets are named per-species densities. Densities in m⁻³, temperatures in eV, frequencies in rad/s, collision rates in 1/s, diffusivities in m²/s. write_kinetic_h5 writes the format.
  • ASCII (.gpeckf, .kin, .dat): the six-column table psi_n n_i n_e T_i T_e omega_E, or with kinetic_format = "rates-v1" nine columns that append lnLambda nu_i nu_e (the Fortran PENTRC rates-v1 table); the column count must match kinetic_format, and header rows are skipped.

The ion composition is part of the same data: [[Equilibrium.ion_species]] lists the main ions, each with z, m and either fraction (its share of the file's total n_i) or density (a named n_* dataset), and impurity_charge and impurity_mass describe the impurity that closes quasineutrality; the default is one deuterium ion carrying all of n_i with a carbon impurity. $Z_\mathrm{eff}(\psi)$ is taken from the zeff dataset when present, else from n_i/n_e with the impurity charge. In a script the same data is attached with attach_kinetic_profiles!(equil, "kinetic.h5"; ion_species=[IonSpecies(; z=1, m=2, fraction=0.5), IonSpecies(; z=1, m=3, fraction=0.5)], impurity_charge=6, impurity_mass=12).

Radial grid

With grid_type = "auto" and mpsi = 0 (the defaults) the radial knots are placed by a two-pass refinement driven by one accuracy knob, psi_accuracy: the equilibrium is formed on a coarse grid, the curvature of the profiles, of the surface geometry and of the kinetic profiles is measured on it, and the knot density that keeps the cubic-spline derivative error below the tolerance is equidistributed, with geometric packing toward the axis and the separatrix and a mandatory knot at every rational surface of the run. Every region's knot count scales as psi_accuracy^(-1/3), so tightening it refines the core, the pedestal and the edge together; the rational-surface knots are what converge the Δ′ boundary-value problem. The fixed layouts grid_type = "core_edge_packed", "pow1" and "uniform" with an explicit mpsi remain available.

Radial knot packing on the DIII-D-like example: the automatic two-pass grid against a fixed core_edge_packed grid.

Running it

From examples/DIIID-like_ideal_example/gpec.toml:

[Equilibrium]
eq_type = "efit"
eq_filename = "TkMkr_D3Dlike_Hmode.geqdsk"
kinetic_file = "TkMkr_D3Dlike_Hmode_kinetic.h5"
jac_type = "hamada"
grid_type = "auto"
psilow = 1e-4                # innermost flux surface
psihigh = 0.995              # outermost flux surface
mpsi = 0                     # 0: automatic radial grid
psi_accuracy = 0.001         # spline accuracy that sizes the automatic grid
mtheta = 256                 # poloidal resolution
impurity_charge = 6
impurity_mass = 12

[[Equilibrium.ion_species]]
z = 1
m = 2
fraction = 1.0

The same from a script, with the deck keys as keywords:

using GeneralizedPerturbedEquilibrium

eq = PlasmaEquilibrium("examples/DIIID-like_ideal_example/TkMkr_D3Dlike_Hmode.geqdsk"; jac_type="hamada", psihigh=0.995)
eq = PlasmaEquilibrium(Equilibrium.LargeAspectRatioConfig(; r0=10.0, a=1.0, beta0=1e-3))   # an analytic equilibrium

Relative paths in the deck are resolved against the deck directory. A PlasmaEquilibrium built with mpsi = 0 keeps the coarse first-pass grid until a solve re-forms it; Equilibrium.reform with the nodes of refined_psi_grid does the same by hand.

Outputs

The group is written once [ForceFreeStates] has run, on the grid of the solve.

DatasetMeaningUnits
Equilibrium/R_axis, Z_axis, B_T_axis, R_mean, a_mean, aspect_ratio, kappa, delta_upper, delta_loweraxis position and field, mean radii and shape parametersm, T
Equilibrium/I_p, volumeplasma current and volumeMA, m³
Equilibrium/beta_N, beta_t, beta_p_1, l_i_1, …normalized, toroidal and poloidal beta and internal inductance
Equilibrium/q_axis, q_95, q_edge, q_min, q_max, q_extrema_psithe safety factor at the axis, the 95% surface and the edge, and its extrema
Equilibrium/psi_boundary, psi_total, I_p_sign, B_T_signthe flux normalization and the sign conventions of the file
Equilibrium/Profiles/psi, q, 2piF, mu0p, dVdpsithe 1-D profiles on ψN: q, 2πF, μ₀p and dV/dψNT·m (2piF), T² (mu0p), m³ (dVdpsi)
Equilibrium/Geometry/psi, theta, rcoords, offset, nu, jacthe 2-D surface geometry on (ψ_N, θ): the radial coordinate, the angle offset, the toroidal offset ν and the Jacobian

API reference

GeneralizedPerturbedEquilibrium.Equilibrium — Module
Equilibrium

Reads or solves an MHD equilibrium and maps it to straight-field-line flux coordinates as a PlasmaEquilibrium.

Where code goes

  • Config.jl: the run configuration (EquilibriumConfig) and global parameters (EquilibriumParameters).
  • PlasmaEquilibrium.jl: the result type and its spline containers.
  • Construction.jl: run_input for each source type, the PlasmaEquilibrium constructors, and reform.
  • Sources/: one file per input format, each building a DirectRunInput or InverseRunInput (Ingest.jl holds those and the ingest types). A new analytic model is one file in Sources/Analytic/ holding its config and solver, plus one ANALYTIC_EQ row.
  • Grid/: radial ψ grids, first-pass and refined.
  • Axisymmetric/: code that assumes axisymmetry (the 2D solvers, the Grad-Shafranov residual, separatrix finding). A non-axisymmetric equilibrium gets a sibling folder.
  • Derived/: quantities computed from a formed PlasmaEquilibrium.
source
GeneralizedPerturbedEquilibrium.Equilibrium.AnalyticEqSpec — Type
AnalyticEqSpec

Single-source-of-truth entry describing one analytic-equilibrium kind: the gpec.toml section that carries its parameters, the *Config type built from that section, and the run function that turns the config into solver input.

Fields

  • section::String — gpec.toml section, the config type's name without Config (e.g. "Solovev")
  • config_type::DataType — *Config type, built from the section's keys as keywords
  • run_fn::Function — (EquilibriumConfig, config) -> eq_input solver entry point
source
GeneralizedPerturbedEquilibrium.Equilibrium.DirectIngest — Type
DirectIngest

Raw arrays and scalars captured by a direct-equilibrium reader (read_efit, read_imas), enough to rebuild a DirectRunInput's splines via build_direct_from_ingest. Written to gpec.h5 so a run can be replayed without the original source.

Fields

  • sq_xs::Vector{Float64} — normalized-ψ knots for the 1D profile spline
  • sq_fs::Matrix{Float64} — 1D profile node values (F, μ₀P, q, √ψ_norm)
  • psi_xs::Vector{Float64} — R grid for the 2D flux map [m]
  • psi_ys::Vector{Float64} — Z grid for the 2D flux map [m]
  • psi_rz::Matrix{Float64} — processed poloidal flux on the (R, Z) grid [Wb/rad]
  • rmin/rmax/zmin/zmax::Float64 — computational-grid bounds [m]
  • psio::Float64 — total flux difference |ψaxis - ψboundary| [Wb/rad]
  • bt_sign::Int — sign of the toroidal field (+1 or -1)
  • ip_sign::Int — sign of the plasma current (+1 or -1) as the source file states it
source
GeneralizedPerturbedEquilibrium.Equilibrium.DirectRunInput — Type
DirectRunInput(...)

Inputs to direct_run, built by a direct-equilibrium reader from the raw data.

Fields

  • config::EquilibriumConfig — the equilibrium configuration
  • sq_in — 1D spline in normalized ψ of |F| = R·|B_t| (m·T), μ₀P clipped at zero (T²), q, √ψ_norm
  • psi_in — 2D interpolant of the poloidal flux on (R, Z), ψ_boundary - ψ signed positive at the axis (Wb/rad)
  • psi_in_xs::Vector{Float64} — R coordinate grid for psi_in [m]
  • psi_in_ys::Vector{Float64} — Z coordinate grid for psi_in [m]
  • rmin::Float64 — Minimum R-coordinate of the computational grid [m]
  • rmax::Float64 — Maximum R-coordinate of the computational grid [m]
  • zmin::Float64 — Minimum Z-coordinate of the computational grid [m]
  • zmax::Float64 — Maximum Z-coordinate of the computational grid [m]
  • psio::Float64 — Total flux difference |ψ_axis - ψ_boundary| [Wb/rad]
  • bt_sign::Int — Sign of the toroidal field (+1 or -1), from the sign of F
  • ip_sign::Int — Sign of the plasma current (+1 or -1) as the source states it (g-file current, IMAS global_quantities.ip); the internal flux is always positive at the axis, so this sign, not the computed current, sets the SFL→machine handedness helicity = bt_sign × ip_sign
  • ingest::EquilibriumIngest — captured raw arrays for the gpec.h5 rerun snapshot (a DirectIngest for file-based reads, or nothing for analytic equilibria)
  • psihigh_resolved::Float64 — outer flux limit the solvers build their ψ grid on: config.psihigh, clamped to the outermost closed flux surface by resolve_psihigh! for efit-family equilibria (not IMAS)
source
GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumConfig — Type
EquilibriumConfig(...)

An immutable struct containing configuration parameters for equilibrium reconstruction specified in the input.

Fields

  • eq_type::String - Type of equilibrium file ("efit", "chease", "ifile", "imas", ...); an analytic config implies its own
  • eq_filename::String - Path to equilibrium input file
  • jac_type::String - Jacobian coordinate type ("hamada", "pest", "equal_arc", "boozer", "park", "custom")
  • power_bp::Int - Poloidal field power exponent for Jacobian (internal, derived from jac_type; not a deck key)
  • power_b::Int - Total field power exponent for Jacobian (internal, derived from jac_type; not a deck key)
  • power_r::Int - Major radius power exponent for Jacobian (internal, derived from jac_type; not a deck key)
  • power_rc::Int - Minor radius (rfac = √((R-R₀)²+(Z-Z₀)²)) power exponent for Jacobian (internal, derived from jac_type; not a deck key)
  • jac_custom_power_bp::Int - Poloidal-field exponent for a custom Jacobian J = Bp^bp · B^b / (R^r · rfac^rc); read only when jac_type = "custom", ignored for named types
  • jac_custom_power_b::Int - Total-field exponent for a custom Jacobian; read only when jac_type = "custom", ignored for named types
  • jac_custom_power_r::Int - Major-radius exponent for a custom Jacobian; read only when jac_type = "custom", ignored for named types
  • jac_custom_power_rc::Int - Minor-radius (rfac) exponent for a custom Jacobian; read only when jac_type = "custom", ignored for named types
  • r0_norm::Float64 - Major radius normalization for CHEASE/EQDSK [m]
  • b0_norm::Float64 - On-axis toroidal field normalization for CHEASE/EQDSK [T]
  • grid_type::String - Grid type for flux surface discretization ("auto" — two-pass measured-curvature refinement when mpsi=0, three-region log layout when mpsi>0; "coreedgepacked" (sin² spacing, dense at axis and edge), "pow1", "uniform"; inverse equilibria also "rho" (uniform in √ψ from psilow to psihigh) and "original" (the input file's own ψ nodes between psilow and psihigh; ignores mpsi))
  • psilow::Float64 - Lower limit of normalized flux coordinate
  • psihigh::Float64 - Requested upper limit of normalized flux coordinate; the value the equilibrium is actually formed on is EquilibriumParameters.psihigh_resolved.
  • mpsi::Int - Number of radial grid intervals; 0 with gridtype="auto" selects the two-pass auto grid. Standalone PlasmaEquilibrium callers get the coarse pass-1 grid unless they refine via `refinedpsigrid+overridepsi_nodes`.
  • psi_accuracy::Float64 - Target relative accuracy τ of splined profile derivatives for the two-pass auto grid (knot count scales as τ^(-1/3))
  • mtheta::Int - Number of poloidal grid points
  • newq0::Float64 - Target on-axis safety factor q(0); the q and F profiles are rescaled to meet it (0 = use input value); q is positive, so negative values are rejected
  • flux_surface_rtol::Float64 - Relative tolerance of the ODE solves that trace each flux surface; their absolute tolerance is equil_abstol(flux_surface_rtol), i.e. flux_surface_rtol capped at EQUIL_ABSTOL_MAX
  • imas_cocos::Int - Expected COCOS convention of an IMAS dd.equilibrium input (11 = IMAS standard, 2 = GPEC internal)
  • kinetic_file::String - Kinetic-profile file read once into PlasmaEquilibrium.kinetic (see read_kinetic_file); empty for none. Every kinetic consumer (NTV, tearing, the layer-overlap scan, grid refinement) derives its view from it.
  • kinetic_group::String - HDF5 group of kinetic_file holding the profiles
  • kinetic_format::String - Column layout of an ASCII kinetic_file: "legacy" (6 columns) or "rates-v1" (9 columns, appending supplied lnLambda nu_i nu_e); see read_kinetic_file
  • ion_species, impurity_charge, impurity_mass, zeff_default, chi_e_default, chi_i_default, chi_phi_default, tau_E, resistivity_model, lnLambda_form - The plasma composition, profile defaults and resistivity closure applied to the profiles of kinetic_file (see KineticProfileData); nothing keeps the KineticProfileData default. Setting any of them needs kinetic_file.
source
GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumParameters — Type
EquilibriumParameters

A mutable struct containing computed equilibrium parameters and diagnostic flags.

Fields

  • ro::Union{Nothing,Float64} - R-coordinate of the magnetic axis [m]
  • zo::Union{Nothing,Float64} - Z-coordinate of the magnetic axis [m]
  • psio::Union{Nothing,Float64} - Total flux difference |ψaxis - ψboundary| [Wb/rad]
  • psihigh_resolved::Union{Nothing,Float64} - Outer flux limit the equilibrium was formed on (the outermost ψ node); the plasma edge downstream of PlasmaEquilibrium.
  • rsep::Union{Nothing,Vector{Float64}} - R-coordinates of the plasma boundary [m]
  • zsep::Union{Nothing,Vector{Float64}} - Z-coordinates of the plasma boundary [m]
  • rext::Union{Nothing,Vector{Float64}} - R-coordinates of the plasma edge [m]
  • zext::Union{Nothing,Vector{Float64}} - Z-coordinates of the plasma edge [m]
  • psi0::Union{Nothing,Float64} - Normalized poloidal flux at reference location
  • b0::Union{Nothing,Float64} - Total magnetic field strength at the axis [T]
  • q0::Union{Nothing,Float64} - Safety factor at the axis
  • qmin::Union{Nothing,Float64} - Minimum safety factor in the plasma
  • qmax::Union{Nothing,Float64} - Maximum safety factor in the plasma
  • qa::Union{Nothing,Float64} - Safety factor at the plasma edge
  • q95::Union{Nothing,Float64} - Safety factor at 95% flux surface
  • qextrema_psi::Union{Nothing,Vector{Float64}} - Normalized flux values at q extrema
  • qextrema_q::Union{Nothing,Vector{Float64}} - Safety factor values at extrema
  • mextrema::Union{Nothing,Int} - Number of extrema in q-profile
  • psi_norm::Union{Nothing,Float64} - Normalized poloidal flux
  • psi_axis::Union{Nothing,Float64} - Poloidal flux at the axis
  • psi_boundary::Union{Nothing,Float64} - Poloidal flux at the boundary
  • psi_boundary_norm::Union{Nothing,Float64} - Normalized boundary flux
  • psi_boundary_offset::Union{Nothing,Float64} - Boundary flux offset
  • psi_axis_offset::Union{Nothing,Float64} - Axis flux offset
  • psi_boundary_sign::Union{Nothing,Int} - Sign of boundary flux
  • psi_axis_sign::Union{Nothing,Int} - Sign of axis flux
  • psi_boundary_zero::Union{Nothing,Bool} - Whether boundary flux is zero
  • rmean::Union{Nothing,Float64} - Mean major radius [m]
  • amean::Union{Nothing,Float64} - Mean minor radius [m]
  • aratio::Union{Nothing,Float64} - Aspect ratio (R0/a)
  • kappa::Union{Nothing,Float64} - Plasma elongation
  • delta1::Union{Nothing,Float64} - Upper triangularity
  • delta2::Union{Nothing,Float64} - Lower triangularity
  • bt0::Union{Nothing,Float64} - Vacuum toroidal field at the mean major radius, Fedge/Rmean, in T
  • crnt::Union{Nothing,Float64} - Plasma current in MA, always positive
  • bt_sign::Int - Sign of the toroidal field (+1 or -1; bt0 is always positive)
  • ip_sign::Int - Sign of the plasma current as the source file states it (+1 or -1)
  • bwall::Union{Nothing,Float64} - Poloidal field scale μ₀I_p/(2π a) at the mean minor radius, in T
  • verbose::Bool - Enable verbose output
  • diagnose_src::Bool - Enable source data diagnostics
  • diagnose_maxima::Bool - Enable extrema diagnostics
  • volume::Union{Nothing,Float64} - Plasma volume [m³]
  • betat::Union{Nothing,Float64} - Toroidal beta
  • betan::Union{Nothing,Float64} - Normalized beta
  • betaj::Union{Nothing,Float64} - Total beta
  • betap1::Union{Nothing,Float64} - Poloidal beta (definition 1)
  • betap2::Union{Nothing,Float64} - Poloidal beta (definition 2)
  • betap3::Union{Nothing,Float64} - Poloidal beta (definition 3)
  • li1::Union{Nothing,Float64} - Internal inductance (definition 1)
  • li2::Union{Nothing,Float64} - Internal inductance (definition 2)
  • li3::Union{Nothing,Float64} - Internal inductance (definition 3)
source
GeneralizedPerturbedEquilibrium.Equilibrium.GeometryProfileSplines — Type
GeometryProfileSplines

Named 1D cubic spline interpolants for flux-surface-averaged geometric quantities. Built once during equilibrium construction so they are available to every downstream module without per-caller recomputation.

Fields

  • xs::Vector{Float64}: Shared ψ axis (matches rzphi_xs)
  • area_spline: Flux-surface area ∫ dA(ψ) [m²]
  • avg_r_spline: Surface-average minor radius ⟨r⟩(ψ) [m]
  • avg_R_spline: Surface-average major radius ⟨R⟩(ψ) [m]
source
GeneralizedPerturbedEquilibrium.Equilibrium.InverseIngest — Type
InverseIngest

Raw arrays and scalars captured by an inverse-equilibrium reader (read_chease_ascii, read_chease_binary, read_ifile), enough to rebuild an InverseRunInput's splines via build_inverse_from_ingest. The inverse counterpart of DirectIngest.

Fields

  • sq_xs::Vector{Float64} — normalized-ψ knots for the 1D profile spline
  • sq_fs::Matrix{Float64} — 1D profile node values
  • rz_xs::Vector{Float64} — ψ grid for the R, Z maps
  • rz_ys::Vector{Float64} — θ grid for the R, Z maps
  • R_nodes::Matrix{Float64} — R node values on the (ψ, θ) grid [m]
  • Z_nodes::Matrix{Float64} — Z node values on the (ψ, θ) grid [m]
  • ro::Float64 — R of magnetic axis [m]
  • zo::Float64 — Z of magnetic axis [m]
  • psio::Float64 — total flux difference |ψaxis - ψboundary| [Wb/rad]
source
GeneralizedPerturbedEquilibrium.Equilibrium.InverseRunInput — Type
InverseRunInput(...)

Inputs to inverse_run, built by an inverse-equilibrium reader.

Fields

  • config::EquilibriumConfig - The equilibrium configuration object
  • sq_in::CubicSeriesInterpolant - 1D profile spline for F, P, q
  • rz_in_xs::Vector{Float64} - ψ coordinate grid for rz_in
  • rz_in_ys::Vector{Float64} - θ coordinate grid for rz_in
  • rz_in_R::CubicInterpolantND - R coordinate interpolant [m]
  • rz_in_Z::CubicInterpolantND - Z coordinate interpolant [m]
  • ro::Float64 - R-coordinate of magnetic axis [m]
  • zo::Float64 - Z-coordinate of magnetic axis [m]
  • psio::Float64 - Total flux difference |ψaxis - ψboundary| [Wb/rad]
  • ingest::EquilibriumIngest - captured raw arrays for the gpec.h5 rerun snapshot (an InverseIngest for file-based reads, or nothing for analytic equilibria)
  • psihigh_resolved::Float64 - outer flux limit the solvers build their ψ grid on: config.psihigh, clamped to the outermost input surface for i-files and reruns (resolve_psihigh!); efit_by_inversion forwards the value clamped on its DirectRunInput
source
GeneralizedPerturbedEquilibrium.Equilibrium.IonSpecies — Type
IonSpecies(; z, m, fraction=NaN, density="")

One main-ion species of the plasma. z/m are the charge (e) and mass (proton masses). The density is given by exactly one of fraction or density, which select a fraction of the total n_i profile or an explicit per-species profile (n_* dataset) in the kinetic file.

source
GeneralizedPerturbedEquilibrium.Equilibrium.KineticProfileData — Type
KineticProfileData

The kinetic description of the plasma: the raw profile columns read from a kinetic file (HDF5 or ASCII), before resampling and spline construction, plus the plasma's species composition, the values that stand in for profiles the file omits, and the resistivity closure. psi (normalized poloidal flux) is always present; every profile field is nothing when the source omits it, so each consumer validates only the fields it needs. Units: densities m⁻³, temperatures eV, frequencies rad/s, diffusivities m²/s. Every consumer (KineticForces, the tearing layers, the layer-overlap scan) reads the composition and closure from here, so they all see one plasma.

fieldmeaning
n_imain-ion density
n_eelectron density
T_i/T_eion / electron temperature
omega_EExB rotation
omega_tortoroidal rotation (optional)
chi_eelectron perpendicular heat diffusivity χ⊥,e
chi_iion perpendicular heat diffusivity χ⊥,i
chi_phitoroidal momentum diffusivity χ_φ
zeffeffective charge Z_eff(ψ) supplied directly (optional); the resistive-layer analysis prefers it to its closure
lnLambdaCoulomb logarithm supplied directly (optional); replaces the internal one in the NTV collision model
nu_i/nu_emain-ion / electron collision rates in 1/s supplied directly (optional); replace the internal collision model
species_densitiesnamed per-species densities (e.g. "n_D", "n_T") for explicit multi-ion input; nothing for ASCII / no extras
provenanceshort string recording the source file/format
ion_speciesmain-ion species, a Vector{IonSpecies}; default one deuterium ion carrying all of n_i
impurity_chargecharge of the single impurity species that closes quasi-neutrality (default 6, carbon)
impurity_massimpurity mass in proton masses (default 12)
zeff_defaultZeff used where neither a zeff profile nor `ni/n_e` gives one (default 1)
chi_e_defaultχ⊥,e used where the file has no usable chi_e (default 1)
chi_i_defaultχ⊥,i used where the file has no usable chi_i; nothing (default) makes a model that needs it fail
chi_phi_defaultχφ used where the file has no usable `chiphi` (default 1)
tau_Ewhole-plasma energy confinement time in s; nothing (default) when unknown
resistivity_modelparallel-resistivity closure: :sauter (default), :redl, :spitzer, :spitzer_harm
lnLambda_formCoulomb-logarithm form of the closure: :nrl (default), :sauter, :wesson

A profile dataset that is absent or all-zero counts as not provided, so its *_default applies. Build a copy with different settings with KineticProfileData(data; ion_species=..., ...).

source
GeneralizedPerturbedEquilibrium.Equilibrium.KineticProfileSplines — Type
KineticProfileSplines

Named 1D spline interpolants for kinetic profiles (densities, temperatures, ExB rotation, collisional diagnostics) on the regular kinetic ψ grid, with derivative views of the densities and temperatures for the diamagnetic frequencies of the NTV kernel. The Coulomb logarithm and collision frequencies are monotone (pchip) interpolants, so a steep cold edge cannot ring below zero.

Fields

  • xs::Vector{Float64}: Shared ψ axis (the regular kinetic grid)
  • ni_spline, ne_spline: Ion / electron number densities [m⁻³]
  • Ti_spline, Te_spline: Ion / electron temperatures [J]
  • omegaE_spline: ExB rotation ω_E [rad/s]
  • loglam_spline: Coulomb logarithm
  • nui_spline, nue_spline: Krook collision frequencies [s⁻¹]
  • zeff_spline: Effective charge Z_eff
  • ni_deriv, ne_deriv, Ti_deriv, Te_deriv: Derivative views for ψ-derivative access
source
GeneralizedPerturbedEquilibrium.Equilibrium.KineticProfileSplines — Method
KineticProfileSplines(xs, ni, ne, Ti, Te, omegaE, loglam, nui, nue, zeff;
                      extrap=ExtendExtrap())

Build the kinetic profile splines from arrays of values defined on the shared ψ grid xs. Uses CubicFit boundary conditions to match ProfileSplines, and pchip for the Coulomb logarithm and collision frequencies as Fortran PENTRC. Temperatures must already be in Joules.

source
GeneralizedPerturbedEquilibrium.Equilibrium.LargeAspectRatioConfig — Type
LargeAspectRatioConfig(...)

A struct holding parameters for the Large Aspect Ratio (LAR) plasma equilibrium model.

Fields:

  • r0: The major radius of the plasma [m].
  • a: The minor radius of the plasma [m].
  • beta0: The beta value on axis (normalized pressure).
  • q0: The safety factor on axis.
  • qa: Edge safety factor; not used by any current sigma_type.
  • B0: On-axis toroidal field in T (scales F and P).
  • p_pres: The exponent for the pressure profile, defined as p00 * (1 - (r / a)^2)^p_pres.
  • p_sig: The exponent that determines the shape of the current-related function profile.
  • sigma_type: The sigma profile, "default", "wesson" (sigma0 * (1 - (r / a)^2)^p_sig) or "hollow" (sigma0 * (1 + hollow * (r / a)^2) * (1 - (r / a)^2)^p_sig, reversed shear when hollow is large enough).
  • hollow: The off-axis current enhancement of the "hollow" sigma profile (unused by the other profiles).
  • mtheta: The number of grid points in the poloidal direction.
  • ma: The number of grid points in the radial direction.
  • zeroth: If set to true, it neglects the Shafranov shift
source
GeneralizedPerturbedEquilibrium.Equilibrium.PlasmaEquilibrium — Type
PlasmaEquilibrium(eq_config::EquilibriumConfig, source=nothing; override_psi_nodes=nothing, kinetic=nothing) -> PlasmaEquilibrium

Form the equilibrium eq_config describes from source (see run_input), run the solver, and return it with global parameters, q-profile, and GSE diagnostics. Every other constructor ends here.

override_psi_nodes bypasses the config-driven radial grid (grid_type/mpsi) and forms the equilibrium on the given strictly increasing ψN node vector, whose endpoints must match psilow/psihigh (used by reform). The kinetic profiles named by `kineticfileare read and attached, unlesskinetic` passes already-read ones.

source
GeneralizedPerturbedEquilibrium.Equilibrium.PlasmaEquilibrium — Type
PlasmaEquilibrium(...)

The final, self-contained result of the equilibrium reconstruction, in flux coordinates.

Fields

  • config::EquilibriumConfig: The equilibrium configuration object used for the reconstruction.

  • params::EquilibriumParameters: Computed equilibrium parameters and diagnostics.

  • profiles::ProfileSplines: Named 1D profile splines (F, P, dV/dψ, q) on normalized psi grid. Access values at grid points via profiles.F_spline.y[i], etc. Access derivatives via profiles.F_deriv.y[i] or profiles.F_deriv(psi).

  • geometry::GeometryProfileSplines: Named 1D splines for flux-surface-averaged geometry (area, ⟨r⟩, ⟨R⟩), populated automatically by compute_geometry_profiles during construction.

  • Grid coordinates (shared by all rzphi/eqfun interpolants):

    • rzphi_xs::Vector{Float64}: ψ coordinates (length mpsi+1)
    • rzphi_ys::Vector{Float64}: θ coordinates (length mtheta+1)
  • Geometric quantities (rzphi, 4 interpolants): 2D cubic interpolants for flux-coordinate mapping with periodic BC in theta.

    • x value: normalized ψ
    • y value: SFL poloidal angle ∈ [0, 1]
    • rzphi_rsquared::CubicInterpolantND: r_coord² = (R - ro)² + (Z - zo)²
    • rzphi_offset::CubicInterpolantND: η/(2π) - θₙₑw (angle offset)
    • rzphi_nu::CubicInterpolantND: ν in ϕ = 2πζ + ν(ψ, θ)
    • rzphi_jac::CubicInterpolantND: Jacobian
  • Physics quantities (eqfun, 3 interpolants): 2D cubic interpolants storing local physics and geometric quantities.

    • x value: normalized ψ
    • y value: SFL poloidal angle θₙₑw
    • eqfun_B::CubicInterpolantND: Total magnetic field strength [T]
    • eqfun_metric1::CubicInterpolantND: (e₁⋅e₂ + q⋅e₃⋅e₁)/(J⋅B²)
    • eqfun_metric2::CubicInterpolantND: (e₂⋅e₃ + q⋅e₃⋅e₃)/(J⋅B²)
  • ro::Float64: R-coordinate of the magnetic axis [m]

  • zo::Float64: Z-coordinate of the magnetic axis [m]

  • psio::Float64: Total flux difference |Ψaxis - Ψboundary| [Weber/radian]

  • ingest::EquilibriumIngest: raw arrays forwarded from the equilibrium input for the gpec.h5 rerun snapshot — a DirectIngest/InverseIngest for file-based equilibria, or nothing for analytic ones (regenerated from their deck section on replay)

  • analytic::Union{Nothing,AnalyticEquilibriumConfig}: the parameters an analytic kind (sol, lar, tj_analytic) was solved from, so reform can re-solve it on a new grid; nothing for file-based and IMAS equilibria.

  • kinetic::Union{Nothing,KineticProfileData}: the raw kinetic profiles of config.kinetic_file (or of attach_kinetic_profiles!), on the file's own ψ grid; nothing when none are attached

source
GeneralizedPerturbedEquilibrium.Equilibrium.PlasmaEquilibrium — Method
PlasmaEquilibrium(path::AbstractString; eq_type="efit", kwargs...) -> PlasmaEquilibrium

Read the equilibrium file at path and return the processed equilibrium. Convenience entry point of the scripting API: kwargs are EquilibriumConfig fields, so PlasmaEquilibrium("g000001.00001"; jac_type="hamada", mpsi=128) is the whole setup.

Only file-based equilibria go through this constructor. Analytic and IMAS equilibria have their own PlasmaEquilibrium(::AnalyticEquilibriumConfig) and PlasmaEquilibrium(::IMASdd.dd) forms.

eq = PlasmaEquilibrium("input.geqdsk"; jac_type="hamada")
source
GeneralizedPerturbedEquilibrium.Equilibrium.ProfileSplines — Type
ProfileSplines

Named 1D cubic spline interpolants for equilibrium profiles.

Fields

  • xs::Vector{Float64}: Shared x-axis (normalized psi)
  • F_spline: 2π*F (toroidal flux function, where F = R * B_toroidal)
  • P_spline: μ₀*P (plasma pressure × μ₀)
  • dVdpsi_spline: dV/dψ (volume derivative)
  • q_spline: q (safety factor)

Derivative Interpolants (for continuous derivative evaluation)

  • F_deriv, P_deriv, dVdpsi_deriv, q_deriv: First derivative interpolants

Notes

  • Node values at grid points: Access via spline.y[i]
  • Derivative at any point: Call deriv(x) (derivative views are callable)
  • Grid: Access via xs field or spline.cache.x
source
GeneralizedPerturbedEquilibrium.Equilibrium.ResolvedNTVSpecies — Type
ResolvedNTVSpecies{P}

One fully-resolved species in the NTV sum — a main ion, the neutrality-closing impurity, or the electrons. Fields: charge z, mass m (proton masses), electron flag, label, and profiles (a KineticProfileSplines view carrying this species' density as ni_spline and its full-composition collision frequency as nui_spline). Produced by resolve_ntv_species; both NTV paths — the KineticForces ψ-quadrature and the self-consistent kinetic-matrix build — iterate this and sum τ = Σs τs.

source
GeneralizedPerturbedEquilibrium.Equilibrium.SolovevConfig — Type
SolovevConfig(...)

A struct holding parameters for the Solov'ev (SOL) plasma equilibrium model.

Fields:

  • mr: number of radial grid zones
  • mz: number of axial grid zones
  • ma: number of flux grid zones
  • elongation: elongation
  • a: minor radius
  • r0: major radius
  • q0: safety factor at the o-point
  • p0fac: scale on-axis pressure (P-> P+P0*p0fac. beta changes. Phi,q constant)
  • b0fac: scale toroidal field at constant beta (sPhi,sf,s^2*P. bt changes. Shape,beta constant)
  • f0fac: scale toroidal field at constant pressure (s*f. beta,q changes. Phi,p,bp constant)
source
GeneralizedPerturbedEquilibrium.Equilibrium.TJAnalyticConfig — Type
TJAnalyticConfig(...)

Parameters for the TJ-analytic cylindrical large-aspect-ratio equilibrium, a GPEC adaptation of the analytic profile family of R. Fitzpatrick's TJ code (https://github.com/rfitzp/TJ), not a re-implementation of TJ. The q profile is

f1(r) = [1 - (1-r²)^ν] / (ν·q0)
q(r)  = r² / f1(r)

with the current peaking ν solved so q matches qa at the edge (ν = qa/q0 at lowest order). The pressure is p₂(r) = p0·(1-r²)^μ with μ = pressure_peaking. Lengths are normalized to R₀, fields to B₀. solver picks the pipeline: :inverse feeds the flux-surface geometry to the inverse solver, :direct builds ψ(R, Z) for the direct solver.

source
GeneralizedPerturbedEquilibrium.Equilibrium.TJAnalyticShapeParams — Type

Internal parameter bundle for the TJ-analytic shape ODE (ψ, g₂, H₁, H₁', f₃) — GPEC adaptation of the analytic shape ODE used in R. Fitzpatrick's TJ code (https://github.com/rfitzp/TJ), shared by the inverse and direct pipelines.

Fields:

  • physical: a, R0, qc, mu, pc, B0
  • derived: epsa2 = (a/R0)²
  • near-axis BC constants: rmin, x0 = rmin, r0 = rmin·a, f1c = 1/qc, p2ppc = d²p₂/dx²|_0 = −2·μ·pc
source
GeneralizedPerturbedEquilibrium.Equilibrium._axis_bisection_seed — Method
_axis_bisection_seed(rp, bfield, sq_in_deriv, r, z, halfwidth; passes) -> (r, z, failure)

Seed for the Newton restart: alternate 1-D bisections on B_Z along R and on B_R along Z, each bracketed by doubling halfwidth up to the grid edges. The sweep is a nonlinear Gauss–Seidel iteration that contracts by ψRZ²/(ψRR ψZZ) per pass, so stopping once a pass moves the point by less than `AXISSEEDCELLTOLcells leaves it within about a cell of the axis for contractions up to 0.9.failurenames a missing sign change or a sweep that did not settle inpasses` passes.

source
GeneralizedPerturbedEquilibrium.Equilibrium._axis_failure — Method
_axis_failure(rp, bfield, sq_in_deriv, r, z; bound_residual) -> failure

Why (r, z) is not an acceptable magnetic axis, or nothing. It must lie on the ψ grid (a root off it is an artifact of spline extrapolation), be an O-point (det ∂(B_R,B_Z)/∂(R,Z) = det(Hess ψ)/R² > 0; an X-point has det < 0) that is a maximum of ψ (ψ_RR < 0 and ψ > 0), and carry ψ within AXIS_PSI_RATIO of ψ₀, which rejects a secondary maximum elsewhere in the grid. With bound_residual, |B_p| ≤ AXIS_RESIDUAL_RTOL × B_scale must hold as well.

source
GeneralizedPerturbedEquilibrium.Equilibrium._axis_newton — Method
_axis_newton(rp, bfield, sq_in_deriv, r, z, cap) -> (r, z, failure)

Newton iteration for the O-point B_R = B_Z = 0, each step capped at cap. failure is nothing once a step passes |δR|, |δZ| ≤ AXIS_STEP_RTOL × R, else why the iteration stopped. A singular Jacobian stops it, where the Fortran divides by the determinant unguarded.

source
GeneralizedPerturbedEquilibrium.Equilibrium._density_from_curvature! — Method
_density_from_curvature!(rho, d4, f_scale, tau; xs=nothing)

Accumulate (in place, by max) the knot density implied by the h³ derivative error model for one quantity: ρ = 1/htarget with htarget = (24·τ·fscale/|f''''|)^(1/3), clamped to [`HTARGETMIN,HTARGETMAX]. Normalized curvature below the noise floor is ignored; whenxsis given the floor grows asNODENOISEREL`/hlocal⁴ on tightly packed sample grids, where divided differences amplify nodal noise.

source
GeneralizedPerturbedEquilibrium.Equilibrium._find_magnetic_axis — Method
_find_magnetic_axis(rp, bfield, sq_in_deriv, r0, z0, march_step) -> (r, z)

The magnetic axis, by the first attempt whose Newton result passes _axis_failure: plain Newton from the midplane guess (r0, z0), accepted on the step test alone, then Newton restarted from a bisection seed with steps capped at one march step and the residual bound added. A restart warns with the field at the axis; two failures error.

source
GeneralizedPerturbedEquilibrium.Equilibrium._fourth_derivative_nodes — Method
_fourth_derivative_nodes(xs, ys) -> Vector{Float64}

Estimate |f''''| at each node of a (possibly nonuniform) grid by 5-point Newton divided differences: f'''' ≈ 4!·f[x{i-2},…,x{i+2}]. The two nodes at each boundary reuse the nearest interior stencil. Returns zeros when fewer than 5 nodes are available.

source
GeneralizedPerturbedEquilibrium.Equilibrium._knot_density — Method
_knot_density(equil::PlasmaEquilibrium; tau, kin=nothing) -> Vector{Float64}

Knot density ρ(ψ) (knots per unit ψN) at the pass-1 nodes equil.profiles.xs: the max of the measured curvature density of the 1D profiles (F, P, dV/dψ, q), the four rzphi geometry channels (every `THETASTRIDE-th θ-line), and the kinetic profiles whenkin` is given, smoothed by a running max over ±1 node, then the core and edge model regions and a global minimum density.

source
GeneralizedPerturbedEquilibrium.Equilibrium._separatrix_crossing — Method
_separatrix_crossing(rp, bfield, sq_in_deriv, ro, zo, r_edge, label) -> r

Midplane separatrix crossing on the r_edge side of the axis: unbracketed Newton δR = −ψ/ψ_R toward ψ = 0 of the renormalized spline, as in the Fortran, so that it extrapolates past the grid edge for limited equilibria whose box hugs the LCFS. Each failed attempt moves the initial guess, a blend of r_edge and the axis, inward.

source
GeneralizedPerturbedEquilibrium.Equilibrium._winding_number_verts — Method
_winding_number_verts(verts, r_test, z_test)

Winding number point-in-polygon test (Sunday algorithm) on a Ctr.vertices vector. Returns the signed winding count; nonzero means the test point is inside the polygon. More robust than ray-casting for near-collinear edges (e.g., surfaces near an x-point).

source
GeneralizedPerturbedEquilibrium.Equilibrium.adaptive_grid_params — Method
adaptive_grid_params(raw_profile, ro, zo, r_lo, r_hi, z_lo, z_hi,
                     psilow, Δψ, bbox_curve) → (nr, nz, β_r, β_z)

Physics-based Cartesian grid sizing for contour-tracing equilibrium reconstruction.

Computes required cell widths from the bilinear interpolation error bound δψ ≈ (dR²·|ψRR| + dZ²·|ψZZ|)/8 ≤ Δψ → dRreq = √(8Δψ/|ψRR|) sampled at each LCFS vertex (reusing bbox_curve), plus an axis constraint ensuring the innermost surface (psilow) has ≥ 5 cells per semi-axis on the global grid.

β = acosh(hmax/hmin) from the ratio of coarsest to finest required cell widths. n = 1 + ⌈span·sinch(β)/h_min⌉ where sinch(β) = β/sinh(β).

source
GeneralizedPerturbedEquilibrium.Equilibrium.arclength_fieldline_der! — Method
arclength_fieldline_der!(dy, y, params, s)

RHS for the arc-length-parameterized level-set ODE.

State y = [R, Z, ∫dl/Bp, ∫dl/(R²Bp), ∫jac·dl/Bp]. The independent variable s is arc length, in m.

The tangent direction (dR/ds, dZ/ds) = (∂ψ/∂Z, −∂ψ/∂R) / |∇ψ| follows the ψ = const level set counterclockwise, staying on the flux surface without correction.

Near x-points where Bp → 0, the position integration (dy[1:2]) remains well-behaved because grad_norm never appears in the denominator alone. dy[3:5] use abstol=1e20 so the solver never restricts step size for them.

source
GeneralizedPerturbedEquilibrium.Equilibrium.arclength_fieldline_int — Method
arclength_fieldline_int(psifac, raw_profile, ro, zo, rs2, theta_nodes) -> (y_out, bfield)

Arc-length-parameterized flux surface integration. Drop-in replacement for direct_fieldline_int with identical return format, sampled at the straight-fieldline angles theta_nodes (see sample_trace_at_sfl_angles):

  • y_out[:, 1]: geometric angle η ∈ 0 to 2π (CCW from outboard midplane)
  • y_out[:, 2]: accumulated ∫dl/Bp
  • y_out[:, 3]: rfac = √((R−ro)² + (Z−zo)²)
  • y_out[:, 4]: accumulated ∫dl/(R²Bp)
  • y_out[:, 5]: accumulated ∫jac·dl/Bp

The ODE is terminated by a ContinuousCallback that detects the return to the outboard midplane (Z = zo, R > ro) after a minimum arc-length guard.

source
GeneralizedPerturbedEquilibrium.Equilibrium.attach_kinetic_profiles! — Method
attach_kinetic_profiles!(equil, path; group="/", format="legacy", kwargs...) -> equil
attach_kinetic_profiles!(equil, data::KineticProfileData) -> equil

Attach kinetic profiles to equil as equil.kinetic. Every kinetic consumer (the NTV torque, the calculated kinetic matrices, tearing, the layer-overlap scan and the two-pass grid refinement) derives its own view from them, so the file is read once. Equilibria built from a config with kinetic_file set attach it on construction; use this for analytic or IMAS equilibria built without it, or in-memory data. Keywords are the composition, default and closure fields of KineticProfileData, e.g. ion_species, impurity_charge, chi_e_default, resistivity_model.

source
GeneralizedPerturbedEquilibrium.Equilibrium.bracket_mandatory_nodes — Method
bracket_mandatory_nodes(grid, centers, min_half_widths, min_spacing; collapse_atol=1e-7) -> Vector{Float64}

Center each rational centers[i] inside a single clean spline interval by replacing the knots straddling it with a symmetric pair at centers[i] ± w, so the cubic 3rd derivative the Δ′ extraction samples does not jump mid-stencil. w is the larger of min_half_widths[i] (the Δ′-stencil floor) and half the local grid spacing, capped at half the distance to neighboring centers (and, for the stencil part, to the nearer domain edge). Knots within w of the center or within min_spacing of a new bracket knot are dropped; endpoints always win. Warns when a cap cuts a bracket below its stencil floor, since Δ′ there is less accurate.

source
GeneralizedPerturbedEquilibrium.Equilibrium.classify_topology — Method
classify_topology(raw_profile, psio; xpt_threshold=0.05) → Symbol

Classify the plasma topology as :limited, :sn_lower, :sn_upper, or :double_null by evaluating ψ on the (R, Z) grid and finding the minimum in each Z half-domain.

An x-point is detected when the minimum ψ in a half-domain falls below xpt_threshold * psio.

source
GeneralizedPerturbedEquilibrium.Equilibrium.compute_geometry_profiles — Method
compute_geometry_profiles(rzphi_xs, rzphi_ys,
                          rzphi_rsquared, rzphi_offset, rzphi_jac, ro)
    → GeometryProfileSplines

Build named cubic splines for flux-surface-averaged area, ⟨r⟩, and ⟨R⟩ from the equilibrium's 2D rzphi interpolants, by trapezoidal sums over the θ nodes at the bicubic's nodal values.

source
GeneralizedPerturbedEquilibrium.Equilibrium.compute_jac_delpsi — Method
compute_jac_delpsi(equil, psi, mtheta) -> Vector{Float64}

Compute J·|∇ψ| at mtheta equally-spaced θ points on the flux surface at psi. This is the area weight function that maps a bare field component b(θ) to its area-weighted form J|∇ψ|·b(θ) in θ-space, the flux per unit-norm cell.

source
GeneralizedPerturbedEquilibrium.Equilibrium.compute_sqrtamat — Method
compute_sqrtamat(equil, psi, ft) -> Matrix{ComplexF64}

Build the √A convolution matrix sqrtamat. Produces a Hermitian Toeplitz matrix with entries sqrtamat[m',k] = ŵ{mk − m'} where ŵn = (1/N)Σ wj exp(+inθ_j) and w(θ) = √(J·|∇ψ|).

For Fourier coefficients b_fft of a field b it satisfies ‖sqrtamat·b_fft‖² = ∫ |b|² · J|∇ψ| dθ (θ normalized to one period), which is Jacobian-invariant on a given flux surface. sqrtamat/√jarea is the matrix Fortran GPEC writes as J_surf_2.

source
GeneralizedPerturbedEquilibrium.Equilibrium.direct_fieldline_der! — Method
direct_fieldline_der!(dy, y, params, eta)

Right-hand side of the geometric-angle field-line ODE, with state y = [∫dl/Bp, rfac, ∫dl/(R²Bp), ∫jac·dl/Bp] and independent variable the geometric angle eta. Port of Fortran direct_fl_der, guarded against a vanishing denominator.

source
GeneralizedPerturbedEquilibrium.Equilibrium.direct_fieldline_int — Method
direct_fieldline_int(psifac, raw_profile, ro, zo, rs2, theta_nodes) -> (y_out, bfield)

Traces the flux surface psifac (ψ_norm) in the geometric angle η from the outboard midplane, refining onto the surface after every step.

Arguments

  • ro, zo: magnetic axis coordinates, in m
  • rs2: R of the outboard separatrix crossing, in m
  • theta_nodes: straight-fieldline angles (0 to 1) at which to sample the surface

Returns

  • y_out: rows at theta_nodes (see sample_trace_at_sfl_angles), columns η, ∫dl/Bp, rfac (distance from the axis), ∫dl/(R²Bp), ∫jac·dl/Bp
  • bfield: the DirectBField at the start point
source
GeneralizedPerturbedEquilibrium.Equilibrium.direct_get_bfield! — Method
direct_get_bfield!(bf_out, r, z, psi_in, sq_in, sq_in_deriv, psio; derivs=0)

Evaluates ψ, the profiles F and P, and the poloidal field with its derivatives at (R, Z), in place in bf_out. Port of Fortran direct_get_bfield.

Arguments

  • psi_in: 2D cubic interpolant of the poloidal flux ψ(R,Z)
  • sq_in, sq_in_deriv: profile series F(ψ_norm), P(ψ_norm) and its derivative
  • psio: ψ at the magnetic axis; ψ_norm = 1 - ψ/psio
  • derivs: number of ψ derivatives to evaluate (0, 1, or 2)
source
GeneralizedPerturbedEquilibrium.Equilibrium.direct_position! — Method
direct_position!(raw_profile)

Finds the magnetic axis (O-point, see _find_magnetic_axis) and the inboard and outboard separatrix crossings on its midplane, and replaces the ψ(R, Z) spline in raw_profile by one renormalized so that ψ at the axis equals ψ₀. A g-file whose header signs disagree with its ψ grid errors here.

Returns

  • ro, zo: magnetic axis coordinates, in m
  • rs1, rs2: R of the inboard and outboard separatrix crossings, in m
source
GeneralizedPerturbedEquilibrium.Equilibrium.edge_q_law — Method
edge_q_law(equil; psi_max, psi_min=EDGE_MODEL_PSI_MIN, min_knots=EDGE_FIT_MIN_KNOTS,
           min_r2=EDGE_FIT_MIN_R2, shear_ratio=EDGE_FIT_SHEAR_RATIO)
    -> nothing | (; A, q_bar, u_bar, n_knots, r2_log, r2_linear)

Least-squares fit of the separatrix edge law q = q̄ + A·(ln(1−ψ) − ū) over the equilibrium's outer knots. It only gates the grid-refinement edge density floor; placing surfaces beyond the grid is separatrix_q_law, and geometric X-point detection is classify_topology.

Returns nothing when the diverging model does not describe the edge:

  • fewer than min_knots knots in the band;
  • A ≥ 0, i.e. q not rising toward ψ = 1;
  • r2_log < min_r2;
  • r2_log ≤ r2_linear (a linear-in-ψ fit does at least as well, as for a limited plasma);
  • the fitted A and the measured -(1−ψ)·q′ differ by more than shear_ratio.
source
GeneralizedPerturbedEquilibrium.Equilibrium.equilibrium_gse! — Method
equilibrium_gse!(equil::PlasmaEquilibrium)

Computes the Grad-Shafranov residual on the grid and, with diagnose_src, writes it to HDF5 files. Port of Fortran equil_out_gse.

Returns (; xs, ys, flux_x, flux_y, source, total, error, errori) on the rzphi (ψ, θ) nodes: the two flux-divergence terms, the source, the residual total = flux_x - flux_y + source, error = |total| over the largest term on the grid, and errori, the magnitude of the θ-integrated residual on each surface.

source
GeneralizedPerturbedEquilibrium.Equilibrium.equilibrium_solver — Function
equilibrium_solver(raw_profile, fieldline_int=direct_fieldline_int; override_psi_nodes=nothing) -> PlasmaEquilibrium

Direct equilibrium driver: locates the axis, traces each flux surface with fieldline_int, and builds the profile, rzphi coordinate and eqfun splines in straight-fieldline coordinates.

Arguments

  • fieldline_int: flux-surface tracer, called as fieldline_int(psifac, raw_profile, ro, zo, rs2, theta_nodes) -> (y_out, bfield) with y_out sampled at theta_nodes through sample_trace_at_sfl_angles
  • override_psi_nodes: explicit ψ grid used instead of the configured one
source
GeneralizedPerturbedEquilibrium.Equilibrium.equilibrium_solver_by_inversion — Method
equilibrium_solver_by_inversion(raw_profile; resolution_factor=4.0, override_psi_nodes=nothing) -> PlasmaEquilibrium

Driver for contour-tracing equilibrium reconstruction.

Grid parameters (n and β in each direction) are computed adaptively from the bilinear interpolation error bound along the LCFS and an axis constraint. resolution_factor scales both n values uniformly (higher → more points, same β).

Select via eq_type = "efit_by_inversion" in gpec.toml.

source
GeneralizedPerturbedEquilibrium.Equilibrium.flux_surface_metric — Method
flux_surface_metric(equil, psi, theta; hint=(Ref(1), Ref(1))) -> (; r, jac, delpsi)

Evaluate the flux-surface geometry at (psi, theta): major radius r, Jacobian jac, and the flux-gradient magnitude delpsi = |∇ψ|, by metric_from_primitives on the bicubic at that point.

source
GeneralizedPerturbedEquilibrium.Equilibrium.gfile_fpol_single_precision — Method
gfile_fpol_single_precision(filename) -> Bool

Whether the g-file's FPOL column was written in single precision: every value lies within 1e-8 (relative) of its Float32 rounding. Double-precision values printed to the format's ten digits sit about 1.5e-8 from it on average, so a whole column below 1e-8 is single precision.

source
GeneralizedPerturbedEquilibrium.Equilibrium.inverse_extrap — Method
inverse_extrap(xx::Matrix{Float64}, ff::Matrix{Float64}, x::Float64) -> Vector{Float64}

Component-wise Lagrange extrapolation of a vector-valued function to x.

Arguments

  • xx: m × n abscissae, row i holding the x-values of point i for each of the n components
  • ff: m × n function values at xx
source
GeneralizedPerturbedEquilibrium.Equilibrium.kinetic_profile_splines — Method
kinetic_profile_splines(data::KineticProfileData;
                        zi::Int=1, zimp::Int=6, mi::Int=2, mimp::Int=12,
                        density_factor::Float64=1.0, temperature_factor::Float64=1.0,
                        ExB_rotation_factor::Float64=1.0, toroidal_rotation_factor::Float64=1.0,
                        chi1::Union{Nothing,Float64}=nothing)
    → KineticProfileSplines

The NTV view of raw kinetic profiles (e.g. equil.kinetic): interpolate onto a regular 101-point ψ grid, optionally apply profile scaling knobs, derive collisional / Z_eff diagnostics, and return a KineticProfileSplines of named splines (pchip for lnΛ and ν, cubic otherwise).

Needs n_e, T_i, T_e and omega_E; n_i defaults to n_e. Supplied lnLambda, nu_i and nu_e replace the model's values and are not rescaled by the scaling factors. See read_kinetic_file for the file formats.

Arguments

  • data: Raw kinetic profiles (KineticProfileData)
  • zi, zimp: Main ion and impurity charge numbers
  • mi, mimp: Main ion and impurity mass numbers (in proton masses)
  • density_factor: Density scaling factor (applied to ni, ne)
  • temperature_factor: Temperature scaling factor (applied to Ti, Te)
  • ExB_rotation_factor: ExB rotation scaling factor (applied to omegaE after rotation reform)
  • toroidal_rotation_factor: Toroidal rotation scaling factor (scales total wphi = omegaE + wdian + wdiat)
  • chi1: Poloidal flux normalization 2π·ψ₀ — required when density_factor, temperature_factor, or toroidal_rotation_factor differ from 1.0

Scaling

When density_factor, temperature_factor or toroidal_rotation_factor differ from 1, the total rotation wphi = omegaE + wdian + wdiat is held from the unscaled profiles, the diamagnetic frequencies scale with temperature_factor (density_factor cancels), and omegaE is reformed as toroidal_rotation_factor * wphi - wdian - wdiat. ExB_rotation_factor then multiplies omegaE.

Collisionality is recomputed from the scaled profiles (unlike Fortran PENTRC); use nufac (in KineticForcesControl) to scale collisionality independently.

source
GeneralizedPerturbedEquilibrium.Equilibrium.lar_init_conditions — Method
lar_init_conditions(rmin, lar_input) -> (r, y)

Initializes the starting radius and state vector for solving the LAR ODE system.

Arguments:

  • rmin: Normalized starting radius (as a fraction of lar_a).
  • lar_input: A LargeAspectRatioConfig object containing equilibrium parameters.

Returns:

  • r: Physical radius corresponding to rmin * lar_a.
  • y: Initial state vector of length 5.
source
GeneralizedPerturbedEquilibrium.Equilibrium.make_multi_stretched_grid — Method
make_multi_stretched_grid(lo, hi, centers, n, β) → Vector{Float64}

Build a 1D grid of length n on [lo, hi] with sinh-stretching toward each point in centers. The domain is split at each interior concentration point; each resulting sub-interval uses:

  • symmetric (double-ended) sinh when both endpoints are concentration points
  • one-sided sinh fine at the concentration-point end otherwise

Domain boundaries (lo, hi) are concentration points only if they appear in centers, as x-points do on the clipped plasma bounding box. Returns a uniform grid if β ≤ 0.

source
GeneralizedPerturbedEquilibrium.Equilibrium.make_optimal_psi_grid — Method
make_optimal_psi_grid(psilow, psihigh, N_core, N_mid, N_edge; psi_split_core, psi_split_edge)

Build a three-region ψ grid with (Ncore + Nmid + N_edge)+1 knots, using the counts directly as provided — core and edge are geometric in log(ψ) and log(1−ψ) respectively; middle is uniform in ψ.

source
GeneralizedPerturbedEquilibrium.Equilibrium.make_stretched_z_grid — Method
make_stretched_z_grid(z_lo, z_hi, zo, nz, topology, β_z) → Vector{Float64}

Grid of nz points on [z_lo, z_hi] concentrated near zo (magnetic axis) and near each x-point boundary (at z_lo for :sn_lower/:double_null, at z_hi for :sn_upper/:double_null). Thin wrapper around make_multi_stretched_grid.

source
GeneralizedPerturbedEquilibrium.Equilibrium.merge_mandatory_nodes — Method
merge_mandatory_nodes(grid, mandatory; delta_frac=0.25, collapse_atol=1e-7) -> Vector{Float64}

Insert mandatory knots into a base grid without moving them: non-mandatory nodes within δmin = `deltafrac× (containing base-grid interval) of a mandatory node are dropped. Endpoints always win, so mandatory nodes outside the open span or within δ_min of an endpoint are discarded. Mandatory nodes withincollapse_atol` of an earlier one are treated as duplicates and collapsed.

source
GeneralizedPerturbedEquilibrium.Equilibrium.metric_from_primitives — Method
metric_from_primitives(ro, theta, p) -> (; rfac, r, jac, delpsi)

The gpout.f flux-surface metric at one point from the rzphi primitives p (the fields of rzphi_primitives): minor radius rfac = √r², major radius r, Jacobian jac and delpsi = |∇ψ|. The primitives may come from evaluating the bicubic or from its nodal values.

source
GeneralizedPerturbedEquilibrium.Equilibrium.multi_ion_composition — Method
multi_ion_composition(zs, ns, ne; zimp, mimp) -> (zeff, zpitch, n_main, n_imp)

Full-composition effective charge and pitch-angle enhancement at one ψ point for a plasma with an arbitrary number of main-ion species:

  • zs, ns: main-ion charges and number densities (one entry per species)
  • ne: electron density
  • zimp, mimp: single trailing impurity charge / mass; its density closes quasineutrality

Composition (per point):

n_main = Σ_s n_s                       total main-ion number density
n_imp  = (n_e − Σ_s z_s n_s) / z_imp   impurity density from quasineutrality
Zeff   = (Σ_s z_s² n_s + z_imp² n_imp) / n_e
zpitch = 1 + (1+m_imp)/(2 m_imp)·z_imp·(Zeff−1)/(z_imp−Zeff)   momentum-restoring closure

Reduces exactly to the single-ion form Zeff = z_imp − (n_i/n_e)·z_i·(z_imp−z_i) for one main-ion species.

source
GeneralizedPerturbedEquilibrium.Equilibrium.read_ifile — Method
read_ifile(config) -> InverseRunInput

Read an inverse i-file, such as TokaMaker save_ifile writes: little-endian Fortran unformatted records, reals as real8 or real4, axis first, θ fastest.

  • mx, my (int32); psi(mx) [Wb/rad], f(mx) = R·Bt [T·m], p(mx) [Pa], q(mx)
  • r(my, mx), z(my, mx) [m], with the periodic θ point duplicated
  • optional FF′(mx), p′(mx) per Wb/rad, skipped
  • optional [ψ_axis, ψ_LCFS]: ψN is then normalized to this LCFS, so the last file surface (written just inside it) sits below ψN = 1

Port of Fortran read_eq_ldp_i.

source
GeneralizedPerturbedEquilibrium.Equilibrium.read_imas — Method
read_imas(config::EquilibriumConfig, dd) -> DirectRunInput

Load an equilibrium from an IMAS data dictionary and return a DirectRunInput.

The dd.equilibrium.time_slice[] is used (active time slice). Poloidal flux is converted from the IMAS COCOS convention (set by config.imas_cocos) to the internal COCOS 2 convention:

  • imas_cocos = 11 (default, IMAS standard): divide ψ by 2π
  • imas_cocos = 2 (GPEC internal): no conversion

Arguments

  • config: EquilibriumConfig with eq_type = "imas" and imas_cocos set.

  • dd: populated IMASdd.dd with dd.equilibrium.time_slice[] containing:

    • global_quantities.psi_axis, global_quantities.psi_boundary
    • profiles_1d.psi, profiles_1d.f, profiles_1d.pressure, profiles_1d.q
    • the profiles_2d entry with grid_type.index == 1 (rectangular), supplying grid.dim1 (R), grid.dim2 (Z) and psi
source
GeneralizedPerturbedEquilibrium.Equilibrium.read_kinetic_file — Method
read_kinetic_file(path; group="/", format="legacy") -> KineticProfileData

Read a kinetic-profile file, dispatching on extension: HDF5 (.h5/.hdf5) via the GPEC kinetic schema, otherwise an ASCII table (.gpeckf/.kin/.dat) whose layout format names: "legacy", 6 columns psi_n n_i n_e T_i[eV] T_e[eV] omega_E, or "rates-v1", 9 columns that append lnLambda nu_i[1/s] nu_e[1/s] (the Fortran PENTRC rates-v1 table). Returns the raw columns; downstream consumers validate the fields they require.

source
GeneralizedPerturbedEquilibrium.Equilibrium.refined_psi_grid — Method
refined_psi_grid(equil::PlasmaEquilibrium; tau, kin=nothing, mandatory=Float64[], pinned=Float64[],
                 singfac_min=5e-4, n_min=1, bracket_coef=BRACKET_COEF,
                 min_spacing=MIN_KNOT_SPACING, N_cap=REFINED_N_CAP) -> Vector{Float64}

Build the refined pass-2 ψ grid from a formed pass-1 equilibrium: knot density, equidistribution, enforce_min_spacing, then bracket_mandatory_nodes around rational surfaces.

Arguments

  • tau - target interpolation accuracy (psi_accuracy)
  • kin - optional kinetic profiles whose gradients attract knots
  • mandatory - rational-surface ψ values to bracket (never knotted on)
  • pinned - ψ values inserted as plain knots without a cleared zone
  • singfac_min, n_min - set each surface's half-stencil dpsi = singfac_min/(n_min·|q′|); the bracket half-width is bracket_coef·dpsi, floored at min_spacing
source
GeneralizedPerturbedEquilibrium.Equilibrium.reform — Method
reform(equil::PlasmaEquilibrium, psi_nodes::Vector{Float64}) -> PlasmaEquilibrium

Re-form equil on the ψN nodes `psinodesfrom the source it remembers: the storedanalyticconfig, else its rawingest, so no file is re-read; with neither it re-readsconfig.eq_filename. Its kinetic profiles carry over. The node endpoints must matchpsilow/psihigh`.

source
GeneralizedPerturbedEquilibrium.Equilibrium.resample_contour_to_theta_grid! — Method
resample_contour_to_theta_grid!(R_out, Z_out, curve, ro, zo, theta_grid)

Resample a Contour.jl curve onto the geometric-angle grid theta_grid (in turns), writing into R_out and Z_out. Fits a periodic cubic spline to log ρ(η) about the axis (ro, zo), so the resampled radius stays positive and the curve cannot self-intersect, which keeps it robust near x-points where R(η), Z(η) splines overshoot.

source
GeneralizedPerturbedEquilibrium.Equilibrium.resolve_ntv_species — Method
resolve_ntv_species(data::KineticProfileData, ion_species; electron, zimp, mimp, ...) -> Vector{ResolvedNTVSpecies}

Resolve the full NTV species set for a multi-ion run: the main ions, the neutrality-closing impurity (zimp, mimp, density from quasineutrality), and the electrons if electron. Both NTV paths (the KineticForces quadrature and the self-consistent kinetic-matrix build) loop over and sum this set. Errors on any negative density.

Each descriptor's profiles carries that species' density as ni_spline and its full-composition Krook collision frequency (Logan & Park 2013 Eq. 6) as nui_spline, or, when nu_i is supplied, that rate scaled by (zs/z₁)²·√(m₁/ms); the other profiles are shared. A main ion's density is fraction · n_i (n_i is the total main-ion density) or the named n_* dataset given by density (e.g. "n_D"). In a mixed fraction/density list the impurity content is set by the file's ni/ne deficit. The zpitch closure is exact for z=1 main ions and approximate otherwise. Reduces to kinetic_profile_splines for one z=1 main ion with fraction=1.

source
GeneralizedPerturbedEquilibrium.Equilibrium.rootarea_to_area_weight — Method
rootarea_to_area_weight(equil, psi, ft) -> Matrix{ComplexF64}

Build the root-area-weighted → area-weighted field operator Σ/√A = sqrtamat ./ √jarea at the flux surface psi, where jarea = ∫ J|∇ψ| dθ is the scalar flux-surface area. It maps the coordinate-invariant root-area-weighted field b̃ to the area-weighted field b̄: b̄ = (Σ/√A)·b̃ (both in tesla); b̄ is not coordinate-invariant and serves only to recover field or flux (Φ = A·b̄). Pharr 2026.

source
GeneralizedPerturbedEquilibrium.Equilibrium.rzphi_primitives — Method
rzphi_primitives(equil, psi, theta; hint=(Ref(1), Ref(1))) -> (; r2, deta, jac, r2_y, deta_y)

Evaluate the smooth rzphi primitives at (psi, theta): r², the η-offset, the Jacobian and the θ-derivatives of r² and the offset; metric_from_primitives turns them into the metric. ψ-derivatives are not provided because the bicubic is only C¹ in ψ; differentiate a ψ-resample instead.

source
GeneralizedPerturbedEquilibrium.Equilibrium.sample_trace_at_sfl_angles — Method
sample_trace_at_sfl_angles(sol, y_out, sfl_index, theta_nodes, state_row) -> Matrix{Float64}

Sample a traced flux surface at the straight-fieldline angles theta_nodes (0 to 1). Row i is state_row(sol(t), t, lo) at the time t where the normalised SFL angle reaches theta_nodes[i] (see sfl_sample_time), in the 5-column y_out layout. The last row is the saved closed endpoint, so the surface totals y_out[end, :] are exact. Every surface sharing the same abscissae keeps the resample error from varying between neighbouring surfaces. Every field-line tracer must return its surface through this function.

source
GeneralizedPerturbedEquilibrium.Equilibrium.separatrix_q_law — Method
separatrix_q_law(equil; psi_max=equil.profiles.xs[end], shear_ratio=SEPARATRIX_SHEAR_RATIO)
    -> nothing | (; psi_x, A, r_x, z_x, psi_anchor, q_anchor, shear_ratio)

Safety factor beyond the equilibrium's ψ grid from the X-point(s) on its last closed flux surface:

q(ψ) = q_anchor + Σ_i A_i ln[(psi_x_i − psi_anchor) / (psi_x_i − ψ)]

psi_x are the normalized fluxes of the selected saddles (ascending, so psi_x[1] is where q diverges), A their logarithmic coefficients F / (2π R_X sqrt(−det H)), r_x/z_x their positions, and the anchor is the traced q at psi_max. psi_x[1] need not equal 1: a reconstruction may place its boundary slightly inside the X-point flux.

Returns nothing when the law does not apply or cannot be trusted:

  • the equilibrium is not a direct (2D flux) one — an inverse equilibrium carries its own q;
  • no minimum of the poloidal field on the outermost surface leads to a saddle outside the grid (a plasma with no X-point nearby; a limited plasma that has one still gets a law);
  • q is not rising at the anchor;
  • the law's dq/dψ and the traced profile's differ by more than shear_ratio over the outer knots (returned as shear_ratio, law over traced).
source
GeneralizedPerturbedEquilibrium.Equilibrium.sfl_sample_time — Method
sfl_sample_time(sol, ts, sfl, sfl_index, x) -> (t, lo)

Solver time t at which the normalised straight-fieldline angle reaches x ∈ [0, 1], and the index lo of the saved step that starts its bracket. sfl is the SFL integral ∫jac·dl/Bp at the saved times ts; it is monotone, so it brackets the root to one step, and Brent finishes on component sfl_index of the dense solution.

source
GeneralizedPerturbedEquilibrium.Equilibrium.shift_exb_rotation — Method
shift_exb_rotation(kp::KineticProfileSplines, Δω::Real) -> KineticProfileSplines

The same kinetic profiles with the E×B rotation rigidly shifted, ω_E(ψ) + Δω (rad/s), and every other profile unchanged. A rotation change moves the E×B frequency and leaves the diamagnetic frequencies, which the torque kernel derives from the density and temperature gradients, where they are; this is the scan variable of a torque-versus-rotation table.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_f1 — Method
tj_analytic_f1(x, nu, qc)

TJ-analytic poloidal flux function f1(x) where x = r/a, following the analytic-profile parameterization of R. Fitzpatrick's TJ code (https://github.com/rfitzp/TJ). Uses a Taylor expansion near the axis for numerical stability.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_find_nu — Method

TJ-analytic ν root-find (Fitzpatrick's Setnu / GetNu in https://github.com/rfitzp/TJ): solve for ν so that q₂(x=1) matches qa_target.

q₂ = x²·(1+εa²·g₂)·exp(−εa²·f3/f1)/f1; at x=1 and low β this picks up an O(εa²) correction relative to the lowest-order guess ν = qa/qc, which matters for the TJ-analytic benchmark at large ε. Falls back to the lowest-order ν if the root-find has no bracket or does not converge; an error from a trial shaping solve propagates.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_run_direct — Method
tj_analytic_run_direct(equil_input, tj_input; nrbox=257, nzbox=257, rc=1.2)

Build ψ(R, Z) on an nrbox × nzbox grid from the TJ-analytic model and return it as direct-solver input, so q and δW are recomputed from the 2D geometry instead of taken from the prescribed q₂ (the inverse pipeline under-drives the external kink at large ε). Each grid point is mapped to (r, w) by the fixed-point iteration of TJ's EFIT writer; ψ comes from the radial ψ-ODE for r < 1, TJ's vacuum solution GetPSIvac for 1 ≤ r < rc, and that value at rc scaled by r²/rc² beyond (r, rc in units of a). Edge shaping is Hna = Vna = 0, so only the H₁ Shafranov shift contributes.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_run_inverse — Method
tj_analytic_run_inverse(equil_input, tj_input)

Build the TJ-analytic equilibrium of tj as inverse-solver input. With zero edge shaping (Hna = Vna = 0, the TJ benchmark configuration) the flux surfaces are shifted circles

R(r,θ) = R₀ + Δ(r) + α(r)·r·cos θ
Z(r,θ) =            α(r)·r·sin θ

with Δ = R₀·εa²·H₁(x), α = 1 − εa²·(x²/8 − H₁/2), εa = a/R₀ and x = r/a, from the shaping ODE. The output profiles are F = R₀·B₀·(1 + εa²·g₂) and q₂ = x²·(1 + εa²·g₂)·exp(−εa²·f₃/f1)/f1. The n ≥ 2 shaping harmonics Hₙ, Vₙ are not included.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_shape_rhs! — Method

RHS for the TJ-analytic shape ODE (R. Fitzpatrick's TJ code parameterization, https://github.com/rfitzp/TJ). State: y[1]=ψ, y[2]=g₂, y[3]=H₁, y[4]=H₁', y[5]=f₃. The original derivation is written in x = r/a; we advance in physical r = a·x so d/dr = (1/a)·d/dx.

The params argument carries TJAnalyticShapeParams fields plus the current nu.

source
GeneralizedPerturbedEquilibrium.Equilibrium.tj_analytic_shape_solve — Method

Integrate the TJ-analytic shape ODE for the given ν. Pass saveat to collect output on a prescribed dense grid (used by tj_analytic_run_direct so the downstream Hₙ / ψ splines sit on uniform nodes); leave it nothing for the default adaptive save pattern used by tj_analytic_run_inverse. reltol and abstol go to the Vern9 solve; abstol defaults to equil_abstol(reltol).

source
GeneralizedPerturbedEquilibrium.Equilibrium.write_kinetic_h5 — Method
write_kinetic_h5(path, data; group="/", schema_version="1.0", provenance=data.provenance)

Write a KineticProfileData to the GPEC HDF5 kinetic schema. Each present field is written as a dataset with a units attribute; absent (nothing) fields are skipped. Named per-species densities (species_densities, n_* datasets) round-trip with read_kinetic_file. The group carries schema_version and provenance attributes.

source