Perturbed Equilibrium

PerturbedEquilibrium computes the response of the plasma to an external non-axisymmetric field: the three-dimensional perturbed equilibrium that the force-free states and the applied field together form. It is the stage that turns a stability calculation into the quantities of error-field and RMP physics: the field that actually reaches each rational surface, the islands it would open, and the energy and torque the perturbation carries.

What it computes

The force-free states of Stability give the displacement inside the plasma for any boundary value, and the Vacuum response gives the field outside it. On the control surface at psilim the two are joined by requiring continuity of the normal field, which fixes the plasma response to an applied spectrum uniquely (Park et al. (2007a), Park et al. (2009)). plasma_response(ffs) builds the operators of that response once, with no reference to a drive; perturbed_equilibrium(resp, rmp) applies them to one external field from Forcing Terms, so a scan over fields reuses one response. compute_perturbed_equilibrium is the lower-level form of the same call.

The resonant part of the response is reported at every rational surface as the singular coupling: the pitch-resonant field and current, the island half-width and the Chirikov overlap parameter. In an ideal solve the plasma shields every rational surface perfectly, so the stored resonant field is the effective one, the field the ideal response would deliver to the surface before shielding; a kinetic solve (kinetic = "KineticForces") gives a finite penetrated field. See the Conventions Reference.

Dominant resonant-coupling mode

The coupling matrix C_resonant_area_weighted_field maps an applied root-area-weighted spectrum $\tilde b$ on the control surface to the resonant field at each rational surface. Its singular-value decomposition over a window of rational surfaces ranks the applied spectra by how strongly they drive resonant field there: the first right singular vector is the dominant mode, the spectrum the plasma is most sensitive to, and the singular values are coordinate-invariant. The run writes the full matrix, so the window is an analysis choice made afterwards: a ResonantCoupling bundles the matrix with its labels and normalization, from the result in memory or from gpec.h5, and dominant_coupling takes the SVD over any window; the run also stores the core-window decomposition ($\psi_N \le$ CORE_PSI_HIGH $= 0.9$) under PerturbedEquilibrium/SingularCoupling/DominantMode/, with forcing_overlap the run's own forcing coefficients $V^H \tilde b_x$.

using GeneralizedPerturbedEquilibrium.PerturbedEquilibrium

rc  = ResonantCoupling("gpec.h5")                        # or ResonantCoupling(resp) in memory
dom = dominant_coupling(rc; psi_low=0.0, psi_high=0.9)   # SVD over the surfaces in the window
c   = coupling_overlap(dom, rootarea_field(rc, coil_modes))   # c[1]: overlap of a forcing with the dominant mode
dom.singular_values[1] * abs(c[1])                       # resonant field the dominant mode drives

Singular vectors carry an arbitrary global phase, so compare abs of overlaps across runs, not the complex value.

In a multi-n run the matrix is block-diagonal in n, so every singular mode has a single n; the ranking spans all n, so the dominant mode, and the stored DominantMode, belong to the most strongly coupled n. For one n, decompose its block, dominant_coupling(rc.C[rows, cols], rc.rational_psi[rows]) with rows = rc.rational_n .== n and cols = rc.n_modes .== n, and project rootarea_field(rc, modes)[cols].

The run writes up to five coupling matrices under PerturbedEquilibrium/SingularCoupling/, each with one row per rational surface and the same applied $\tilde b$ columns:

DatasetMaps $\tilde b$ toUnits
C_resonant_area_weighted_fieldthe resonant field $\bar b^r$dimensionless
C_resonant_currentthe pitch-resonant currentA/T
C_island_width_sqthe squared island half-width1/T
C_penetrated_area_weighted_fieldthe penetrated field, when the run computes itdimensionless
C_Delta_primethe forcing-driven Δ′1/T

ResonantCoupling wraps the first; any of the others decomposes over any window of surfaces through the bare-matrix form of dominant_coupling, with the $\tilde b$ conform taken from a ResonantCoupling of the same file, since the bare matrix carries no (m, n) labels for check_mode_basis to guard the projection:

C, ψr = h5open(f -> (read(f, "PerturbedEquilibrium/SingularCoupling/C_resonant_current"),
                     read(f, "PerturbedEquilibrium/SingularCoupling/rational_psi")), "gpec.h5")
dom = dominant_coupling(C, ψr; psi_low=0.3, psi_high=0.6)
dom.singular_values .* coupling_overlap(dom, rootarea_field(rc, coil_modes))   # in C's units times T

Torque response matrices

A kinetic forward solve (integrator = "Forward", kinetic = "KineticForces") carries the drift-kinetic response inside its Euler–Lagrange energy: the complex plasma energy inside a flux surface has an anti-Hermitian part that is the neoclassical toroidal viscosity torque (Logan et al. (2013)). With compute_torque_response = true, plasma_response refers that quadratic form back to the applied root-area-weighted field $\tilde b$ and stores it at every node as the torque response matrix $T_{xe}(\psi)$, cumulative in ψ, under PerturbedEquilibrium/TorqueResponse/; it is the T_xe of the Fortran GPEC, in the basis of the stored response matrices, in N·m/T². $T_{xe}$ is built on the $+n$ harmonic alone and is therefore twice the physical value, so the cumulative complex torque of an applied spectrum is $T(\psi) = \tilde b^\dagger T_{xe}(\psi)\, \tilde b / 2$ (torque_profile applies the 1/2), with $\operatorname{Re} T$ the toroidal torque inside ψ, equal to Energies/toroidal_torque at the control surface, and $\operatorname{Im} T = 2n\,\delta W$. Only the Hermitian part $(T_{xe} + T_{xe}^\dagger)/2$ contributes to the torque; its eigenvectors are the applied spectra of extremal torque, and the anti-Hermitian part carries the energy. Each perturbed_equilibrium(resp, rmp) call contracts $T_{xe}$ with its field into a TorqueResponse: the applied torque $T_\mathrm{applied}$ and the source form $T_\mathrm{source} = M^\dagger T M$ with one column of $M$ per forcing source, so that driving the sources at scale factors $s$ gives $s^\dagger T_\mathrm{source}\, s / 2$.

Governing equations

The applied field is specified as its normal-flux spectrum $\Phi_x$ on the control surface, one entry per (m, n). The plasma inductance $\Lambda$ relates the total flux to the surface current the plasma response induces, and the surface inductance $L$ is the vacuum inductance of the same surface; the plasma response is the permeability

\[\Phi = P\,\Phi_x, \qquad P = \Lambda L^{-1},\]

and the reluctance $\varrho = L^{-1}(\Lambda^\dagger - L)L^{-1}$ gives the surface current per unit applied flux. The perturbed plasma energy and the toroidal torque of the response are quadratic forms in the total flux,

\[\delta W_\mathrm{plasma} = \tfrac14\,\Phi^\dagger \Lambda^{-1}\Phi, \qquad T_\phi = -\tfrac{2n}{4}\,\operatorname{Im}\!\left(\Phi^\dagger \Lambda^{-1}\Phi\right),\]

with the vacuum and surface energies written alongside them. The stored matrices act on the coordinate-invariant root-area-weighted field $\tilde b$; the area-weighted field $\bar b$ and the flux follow from $\bar b = S\tilde b$ and $\Phi = A\bar b$ with the operator $S$ and the control-surface area $A$ stored next to them (see Field amplitudes and units on the Conventions Reference).

At each rational surface q = m/n the singular coupling evaluates the resonant flux $\Phi^r$ of the response and reports the area-weighted resonant field $\bar b^r = \Phi^r / A^r$ in tesla, the pitch-resonant current, and the island the resonant flux would open in vacuum superposition, with half-width

\[w_s \propto \sqrt{|\delta\psi_s|}\]

in normalized flux, and the Chirikov parameter $\sigma_s = w_s / d_s$, the half-width over the half-distance to the neighbouring rational surface, so $\sigma > 1$ means the islands overlap. The coupling matrices C_* map the applied $\tilde b$ to each of these quantities.

Running it

The response needs a force-free-states solve with integrator = "Forward" and no [Wall]. "Forward" is the only integrator that retains the dense $\xi$ solution the operators are built from: a "Riccati" solve (the deck default) makes plasma_response warn that the response is skipped and return empty operators, so the failure surfaces only when a field is applied, and a "Galerkin" or [Match]ed solve, which publishes no free-boundary δW, is an error. A solve with a wall is an error too, because the surface inductance is the free-space one and $\Lambda$ from a wall run would mix two vacuum models; the wall case of a stability study is therefore a separate deck.

From examples/DIIID-like_ideal_example/gpec.toml, after the [ForceFreeStates] solve and a [ForcingTerms] drive:

[ForceFreeStates]
integrator = "Forward"             # the dense ξ solution the response needs ("Riccati" is the default); no [Wall]

[PerturbedEquilibrium]
compute_singular_coupling = true   # resonant fields, islands and Chirikov parameter
regularization_width = 0.05        # regularization of the ideal response at each rational surface (default 0)

regularization_width is for the NTV torque of an ideal solve only; see Kinetic Forces. compute_torque_response = true adds the torque response matrices of a kinetic forward solve. In a script the same two steps are

using GeneralizedPerturbedEquilibrium

resp = plasma_response(ffs; compute_singular_coupling=true)
pe   = perturbed_equilibrium(resp, rmp; regularization_width=0.05)   # rmp: an RMPField, see the Scripting API
save_to_hdf5("gpec.h5", pe)

with the RMPField built from coils or a file as on the Scripting API page; computing the response does not write a file.

Outputs

DatasetMeaningUnits
PerturbedEquilibrium/mode_m, mode_nthe (m, n) of each entry of the mode axis, m fastest, one block per n
PerturbedEquilibrium/ForcingModes/m, n, amplitudethe applied spectrumT
PerturbedEquilibrium/forcing_b, forcing_b_root_area, forcing_b_areathe applied control-surface spectrum as bare, root-area-weighted and area-weighted normal fieldT
PerturbedEquilibrium/response_b, response_b_root_area, response_b_areathe total (applied plus plasma) spectrum in the same three formsT
PerturbedEquilibrium/ResponseMatrices/plasma_inductance, surface_inductance, permeability, reluctance$\tilde\Lambda$, $\tilde L$, $\tilde P$, $\tilde\varrho$ in root-area-weighted field space
PerturbedEquilibrium/ResponseMatrices/rootarea_to_area_weight_operator, surface_area$S$ and $A$ of the control surfacem² (surface_area)
PerturbedEquilibrium/Response/psithe ψ_N grid of the profiles
PerturbedEquilibrium/Response/xi_n, xi_R, xi_Z, xi_phithe displacement in mode space: normal and cylindrical componentsm
PerturbedEquilibrium/Response/xi_psi, Jxi_*, xi_cov_*, xi_clebsch_*its contravariant, Jacobian-weighted, covariant and Clebsch components
PerturbedEquilibrium/Response/b_n, b_R, b_Z, b_phi, b_psi_area_weightedthe perturbed field in mode space: normal, cylindrical and area-weighted normal componentsT
PerturbedEquilibrium/Response/Jb_*, b_cov_*its Jacobian-weighted and covariant components
PerturbedEquilibrium/SingularCoupling/rational_psi, rational_q, rational_m, rational_n, rational_areathe resonant (surface, n) rows and their surface areasm² (rational_area)
PerturbedEquilibrium/SingularCoupling/resonant_area_weighted_field$\bar b^r$ at each rational surfaceT
PerturbedEquilibrium/SingularCoupling/penetrated_area_weighted_fieldthe penetrated area-weighted fieldT
PerturbedEquilibrium/SingularCoupling/resonant_currentthe pitch-resonant currentA
PerturbedEquilibrium/SingularCoupling/island_width_sq, island_half_width$w_s^2$ and $w_s$ in ψ_N
PerturbedEquilibrium/SingularCoupling/chirikov_parameter$\sigma_s$
PerturbedEquilibrium/SingularCoupling/Delta_primethe forcing-driven tearing Δ′ per surface
PerturbedEquilibrium/SingularCoupling/C_*the coupling matrices from the applied $\tilde b$ to each quantity above
PerturbedEquilibrium/SingularCoupling/DominantMode/singular_values, right_singular_vectors, left_singular_vectors, rational_index, forcing_overlapthe core-window SVD of the resonant-field coupling
PerturbedEquilibrium/Energies/plasma_energy, vacuum_energy, surface_energythe perturbed energiesJ
PerturbedEquilibrium/Energies/toroidal_torquethe boundary-response torque $T_\phi$N·m
PerturbedEquilibrium/TorqueResponse/psi, m, n, T_xe, T_source, T_applied, total_torquethe torque response matrices of a kinetic forward solve and their contraction with the run's forcingN·m/T², N·m

The Analysis module plots these; see Analysis. SingularCoupling/ quantities are indexed by rational-surface index, since with several n one q value can host several resonances; rational_psi and rational_q are attached to that axis as HDF5 dimension scales, so plotting against either is direct (read(g["rational_q"]) in Julia, dset.dims[0]["q_rational"] through h5py).

Numerical notes

With several toroidal modes (nn = [1, 2, ...]) every mode axis in PerturbedEquilibrium/ runs over the full numpert_total = mpert·npert space, m fastest and one block of mpert entries per n, labelled by mode_m and mode_n. The equilibrium is axisymmetric, so different n never couple: $\Lambda$, $L$, $P$ and $\varrho$ are block-diagonal in n with each block equal to the single-n matrix, the energies and the torque are sums of the single-n values evaluated on the diagonal blocks alone, Response/ holds one block of columns per n, and SingularCoupling/ has one row per resonant (surface, n) pair sorted by ψ, so an integer-q surface appears once for each n that resonates there and those rows are not neighbours in the Chirikov parameter. truncate_at_rational_offset is ignored for multi-n runs, so set the edge with qhigh or psihigh away from any rational m/n in the range; KineticForces still takes a single n.

API reference

GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.PlasmaResponse — Type
PlasmaResponse

The source-independent half of a perturbed equilibrium: the control-surface response and singular-coupling operators of one force-free-states result, built once by plasma_response and applied to any number of external fields by perturbed_equilibrium(resp, rmp) (Park et al., Phys. Plasmas 14, 052110 (2007); Park, Phys. Plasmas 16, 056115 (2009)). Operators the result could not supply (no free-boundary energies or no ξ solution) are left empty, and forcing such a response yields only the forcing spectra.

Fields

  • ffs::ForceFreeStatesResult - The result the operators were built from.
  • m_modes, n_modes - Poloidal and toroidal mode number of each entry of a spectrum [numpert_total].
  • unit_edge_basis::Bool - The solution is a MatchProblem one (basis = :unit_edge); the singular coupling then takes Ξ′ from its du_store.
  • compute_singular_coupling::Bool, compute_torque_response::Bool - The plasma_response options it was built with.
  • flux_matrix::Matrix{ComplexF64} - Control-surface flux of the free-boundary eigenmodes [mode × eigenmode].
  • plasma_inductance_flux, surface_inductance_flux, permeability_flux - Λ, L and P = Λ·L⁻¹ acting on the physical control-surface flux Φ_x; the applied quantities and energies are evaluated with these.

Control surface matrices [numperttotal × numperttotal], stored in the coordinate-invariant root-area-weighted field (b̃) space (Pharr 2026). Writing S ≡ rootarea_to_area_weight (b̃→b̄) and A ≡ surface_area, the brief internal flux-conform operator is R = S·A (Φ = R·b̃). Recover the area-weighted (b̄) forms by conforming with S (e.g. L_b̄ = S·L̃·S†); recover flux with Φ = A·b̄.

  • plasma_inductance - Λ̃ = R⁻¹·Λ·R⁻† (wt0-based plasma inductance, congruence)
  • surface_inductance - L̃ = R⁻¹·L·R⁻† (vacuum surface inductance, congruence)
  • permeability - P̃ = R⁻¹·P·R (plasma response operator P=Λ·L⁻¹, similarity)
  • reluctance - ϱ̃ = R†·ϱ·R (ϱ = L⁻¹·(Λ†−L)·L⁻¹, congruence)
  • rootarea_to_area_weight - S = Σ/√A at psilim (b̃→b̄ recovery operator)
  • surface_area - scalar A = ∫J|∇ψ|dθ at psilim (flux recovery Φ = A·b̄)

Coupling matrices [nrational × numperttotal] — one row per resonant (surface, n) pair, mapping the applied root-area-weighted field b̃x to the resonant response at that surface. Matches Fortran `Cfxout,Cixout`, etc. (shape [modeC, m_out]).

  • C_resonant_area_weighted_field - Φ_r/A^r coupling (resonant area-weighted field b^r in tesla; singcoup row 1) [Pharr 2026]
  • C_resonant_current - Resonant current coupling (singcoup row 2)
  • C_island_width_sq - (w/2)² coupling (singcoup row 3)
  • C_penetrated_area_weighted_field - Penetrated area-weighted field coupling (singcoup row 4)
  • C_delta_prime - Δ' coupling (singcoup row 5)
  • coupling_flux::NamedTuple - The same five matrices acting on the physical flux Φx (keys without the `C` prefix), used for the applied resonant vectors; empty when the coupling was not built.
  • C_coeffs::Matrix{ComplexF64} - Edge-to-solution coefficients u_bnd⁻¹·edge_mn of each unit forcing mode.

Metadata [n_rational] — identifies each (surface, n) row:

  • rational_psi, rational_q, rational_m_res, rational_n, rational_surface_idx, rational_area

Dominant resonant-coupling modes — the run summary SVD U·diag(σ)·Vᴴ of C_resonant_area_weighted_field over the core window (window post hoc with dominant_coupling on a ResonantCoupling):

  • dominant_singular_values - σ, descending [rank]
  • dominant_right_singular_vectors - V, applied-b̃ spectra ranked by resonant drive [numpert_total × rank]
  • dominant_left_singular_vectors - U, resonant-field patterns over the retained surfaces [n_retained × rank]
  • dominant_rational_index - rows of the rational_* arrays retained in the window [n_retained]
  • T_xe - ψ-resolved torque response on b̃ of a single-n forward kinetic solve, cumulative in ψ [numperttotal × numperttotal × npsi]; built only when plasma_response is asked for it, else empty. Each perturbed_equilibrium call contracts it with its forcing into a TorqueResponse.
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.PerturbedEquilibriumState — Type
PerturbedEquilibriumState

The perturbed equilibrium driven by one external field: the forcing materialized against a PlasmaResponse and the response, profiles and resonant quantities it produces.

Fields

  • response::PlasmaResponse - The operators this field was applied to.
  • forcing - The ForcingTerms.RMPField applied.
  • forcing_modes::Vector{ForcingMode} - The materialized control-surface forcing Φ_x.
  • coil_sets::Vector{CoilSet} - Coil geometry used (coil-format forcing); captured for the gpec.h5 rerun snapshot.
  • regularization_width::Float64 - Width the profiles were reconstructed with (Fortran reg_spot): 0, no regularization (Fortran reg_flag = f). Set it, typically to 0.05, only to drive KineticForces with an ideal solve, whose 1/(m−nq) divergence leaves the NTV torque integral unconverged; a kinetic solve has none to smooth (Park & Logan, Phys. Plasmas 24, 032505 (2017) §III D).

Response fields (mode space):

  • psi_grid - FFS ODE integration ψ_n values [npsi]
  • xi_modes::Union{Nothing, NamedTuple} - Displacement (psi, theta, zeta) [npsi, numpert_total]
  • b_modes::Union{Nothing, NamedTuple} - Magnetic field; psi=J·b^ψ, bpsiareaweighted=J·b^ψ/⟨J·|∇ψ|⟩θ, theta/zeta=unregularized, thetareg/zetareg=regularized [npsi, numpert_total]
  • b_n_modes::Union{Nothing, Matrix{ComplexF64}} - Physical normal field bn [npsi, numperttotal]
  • xi_n_modes::Union{Nothing, Matrix{ComplexF64}} - Physical normal displacement xin [npsi, numperttotal]

Applied resonant vectors [nrational] = C · forcing, on the rows of response. Matches Fortran `Phires,wisl,Kisl,Delta`.

  • resonant_area_weighted_field, resonant_current, island_width_sq, penetrated_area_weighted_field, delta_prime
  • forcing_solution_weights - C_coeffs·Φ_x, the forcing's weights on the edge-driven solutions

Diagnostics [n_rational]:

  • island_half_width::Vector{Float64} - w/2 = sqrt(|islandwidthsq|) from applied forcing
  • chirikov_parameter::Vector{Float64} - Island overlap metric
  • dominant_forcing_overlap - Vᴴ·b̃_x, the applied forcing's coefficient on each dominant mode [rank]

Control-surface forcing/response spectra [numpert_total], in the three Pharr (2026) field representations (all tesla; no flux/weber is stored):

  • forcing_b/response_b - bare normal field b (Σ⁻¹·b̃)
  • forcing_b_rootarea/response_b_rootarea - root-area-weighted field b̃ (coordinate-invariant)
  • forcing_b_area/response_b_area - area-weighted field b̄ (= S·b̃; flux is Φ = A·b̄)

Energies (Joules; Fortran gpout convention). Congruence-invariant scalars (energy = Φ†·G⁻¹·Φ = b̃†·G̃⁻¹·b̃), evaluated from the brief internal flux vectors Φx, Φtot with the well-conditioned flux-space inductances L, Λ:

  • vacuum_energy - Re( ⟨Φx, L⁻¹·Φx⟩ ) / 4 (energy to perturb the vacuum)
  • surface_energy - Re( ⟨Φtot, L⁻¹·Φtot⟩ ) / 4 (energy at the control surface)
  • plasma_energy - Σₙ Re( ⟨Φtot,n, Λₙₙ⁻¹·Φtot,n⟩ ) / 4 over the diagonal n blocks of Λ (energy to perturb the plasma; Fortran's "total energy")
  • toroidal_torque - Σₙ −2n·Im( ⟨Φtot,n, Λₙₙ⁻¹·Φtot,n⟩ / 4 ) [Park 2011 PoP 18 110702, eq. 1] — the boundary-response torque, zero for ideal (Hermitian) runs. Equals the volume-integrated Euler-Lagrange kinetic torque only for converged self-consistent solutions; distinct from the KineticForces NTV torque.

Torque response (kinetic forward solves with compute_torque_response):

  • torque_response::Union{Nothing,TorqueResponse} - the ψ-resolved torque response matrices on the applied b̃ and on the coil sets, with the run's own forcing contracted; see TorqueResponse
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.plasma_response — Function
plasma_response(ffs; compute_singular_coupling=true, compute_torque_response=false, verbose=false) -> PlasmaResponse

Build the source-independent half of a perturbed equilibrium from a force-free-states result: the control-surface response operators (inductances, permeability, reluctance; Park et al., Phys. Plasmas 14, 052110 (2007)) and, with compute_singular_coupling, the singular-coupling matrices and their dominant modes (Park, Phys. Plasmas 16, 056115 (2009)), and with compute_torque_response the ψ-resolved torque response T_xe of a single-n forward kinetic solve. Apply it to an external field with perturbed_equilibrium(resp, rmp) as many times as needed.

Products the producing integrator could not supply (free-boundary energies, a ξ solution) leave the corresponding operators empty: the step warns and is skipped. Galerkin and :matched results publish no free-boundary δW yet, so building a response from one is an error. So is a solve with a wall: the surface inductance is free-space, and the response needs Λ from the same no-wall vacuum.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.compute_perturbed_equilibrium — Function
compute_perturbed_equilibrium(resp, forcing; regularization_width=0.0, verbose=true,
                              preloaded_coil_sets=CoilSet[])::PerturbedEquilibriumState

Drive the operators of resp with one external field: materialize forcing (a ForcingTermsControl or any ForcingTerms.RMPField) on the control surface, then apply the response and the singular coupling to it, reconstruct the perturbed profiles, and contract any torque response with the forcing sources. Steps whose operators resp does not carry are skipped, leaving only the forcing spectrum.

Arguments

  • regularization_width: width of the ideal 1/(m−nq) smoothing in the profile reconstruction (Fortran reg_spot); must be ≥ 0
  • preloaded_coil_sets: coil geometry to integrate instead of reading it (the gpec.h5 replay path)
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.ResonantCoupling — Type
ResonantCoupling

Everything needed to project an applied control-surface field onto the resonant responses of a perturbed-equilibrium solve, detached from the run that produced it. Build it in memory from a PlasmaResponse, or post hoc from a gpec.h5; then window and decompose it with dominant_coupling and evaluate coil spectra with rootarea_field and coupling_overlap as often as needed without re-running.

Fields

  • C::Matrix{ComplexF64} - coupling from the applied root-area-weighted field b̃ to the resonant area-weighted field, one row per resonant (surface, n) pair [n_rational × numpert_total]
  • rational_psi, rational_q, rational_m, rational_n - row labels [n_rational]
  • m_modes, n_modes - column labels: the poloidal and toroidal mode number of each entry of an applied spectrum [numpert_total]
  • flux_conform::Matrix{ComplexF64} - R = S·A, mapping b̃ to the unit-norm flux the forcing loaders and coil integration produce, Φ_x = R·b̃ [numpert_total × numpert_total]
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.DominantCoupling — Type
DominantCoupling

Singular-value decomposition U·diag(σ)·Vᴴ of a resonant coupling matrix over a set of retained rational surfaces, produced by dominant_coupling.

Fields

  • singular_values - σ, descending [rank]
  • right_singular_vectors - V: applied-b̃ spectra ranked by resonant drive [numpert_total × rank]
  • left_singular_vectors - U: resonant-field patterns over the retained surfaces [n_retained × rank]
  • rational_index - rows of the coupling matrix (and its rational_* labels) that were retained [n_retained]
  • m_modes, n_modes - the (m, n) basis V is expressed on, copied from the coupling it came from [numpert_total]; empty when built from a bare matrix, which carries no labels
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.dominant_coupling — Function
dominant_coupling(rc::ResonantCoupling; psi_low=CORE_PSI_LOW, psi_high=CORE_PSI_HIGH) -> DominantCoupling
dominant_coupling(C, rational_psi; psi_low=CORE_PSI_LOW, psi_high=CORE_PSI_HIGH) -> DominantCoupling

Singular-value decomposition of the resonant coupling matrix restricted to the rational surfaces with psi_low ≤ ψ_N ≤ psi_high, by default the core window ψ_N ≤ 0.9 (CORE_PSI_HIGH). With C_w = U·diag(σ)·Vᴴ on the retained rows, the right singular vectors V[:, k] are the applied-field spectra ordered by how strongly they drive resonant field inside the window, and the singular values are coordinate-invariant. The overlap of an applied spectrum b̃ with mode k is dot(V[:, k], b̃) — see coupling_overlap — and the resonant field it drives is σ[k] times that coefficient; k = 1 is the dominant mode [Park 2007b]. The window is an analysis choice, so re-evaluate it freely on the same rc.

Throws ArgumentError when the window contains no rational surface.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.CORE_PSI_HIGH — Constant

Upper edge of the core window, ψ_N = 0.9, the default window of the dominant-mode SVD. Rational surfaces closer to the edge couple strongly to the applied field on any tokamak and would dominate the decomposition, while the locking physics the overlap feeds concerns the core.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.rootarea_field — Function
rootarea_field(rc::ResonantCoupling, modes) -> Vector{ComplexF64}

Root-area-weighted control-surface field b̃ of an applied spectrum given in the unit-norm (Φx) convention — what the forcing-file loaders and the coil integration produce. modes is a Vector{ForcingMode}, placed on rc's (m, n) column ordering (modes outside the basis are ignored), or an already-ordered amplitude vector. The result is conformed with R⁻¹ (`Φx = R·b̃`) and is the vector the coupling matrix and its singular vectors act on.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.coupling_overlap — Function
coupling_overlap(dom::DominantCoupling, b̃) -> Vector{ComplexF64}
coupling_overlap(dom, rc::ResonantCoupling, modes) -> Vector{ComplexF64}

Coefficients Vᴴ·b̃ of an applied root-area-weighted field on the singular modes of dom; the first entry is the overlap with the dominant mode.

These are unnormalized, in the units of b̃ itself. The dimensionless overlap δ that the error-field literature quotes divides by the axis toroidal field, and the resonant fraction of a coil's own spectrum divides by ‖b̃‖ instead. ErrorFields.CoilOverlap carries all three together so a caller never has to know which normalization a bare number was in. dom.singular_values .* coupling_overlap(dom, b̃) is the resonant field each mode drives, with dom.left_singular_vectors giving its pattern over the retained surfaces. The second form conforms modes through rootarea_field first.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.check_mode_basis — Function
check_mode_basis(dom::DominantCoupling, m_modes, n_modes, what::AbstractString)

Error when dom was decomposed on a different (m, n) ordering than the spectrum being projected.

V is only meaningful against the ordering it was decomposed on, and a decomposition from another equilibrium or another mlow can carry the same number of columns while meaning something else — so a length check passes and the projection returns a plausible number. A no-op when dom carries no basis, which is the bare-matrix construction.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.TorqueResponse — Type
TorqueResponse

ψ-resolved torque response of a forward kinetic Euler-Lagrange solve, expressed on the root-area-weighted control-surface field b̃ (the basis of forcing_b_rootarea and of the stored response matrices). The matrices are cumulative in ψ: T_xe[:, :, k] is the response of the plasma inside psi[k], and the last slice is the total.

The quadratic form b̃†·T_xe(ψ)·b̃ is the complex "2×" torque, matching the Fortran GPEC T_xe array: the physical torque and energy of the applied spectrum b̃ are recovered with a factor 1/2 (torque_profile), T(ψ) = b̃†·T_xe(ψ)·b̃/2, whose real part is the toroidal torque on the plasma inside ψ and whose imaginary part is 2n·δW of that plasma (ideal plus kinetic).

Fields

  • psi::Vector{Float64} - ψ_N of each stored node of the solve [npsi]
  • m_modes, n_modes::Vector{Int} - (m, n) of each row and column of T_xe [numpert_total]
  • T_xe::Array{ComplexF64,3} - torque response on b̃, N·m/T² [numpert_total × numpert_total × npsi]
  • source_names::Vector{String} - name of each forcing source of T_source: the coil sets, or the forcing file [nsource]
  • T_source::Array{ComplexF64,3} - torque response in forcing-source space [nsource × nsource × npsi], N·m per squared scale factor of each source as built: driving the sources at s times their deck currents or file amplitudes gives the complex 2× torque s†·T_source·s. Empty without forcing.
  • T_applied::Vector{ComplexF64} - the run's own forcing contracted, b̃ₓ†·T_xe(ψ)·b̃ₓ/2 [npsi]; empty when no forcing spectrum was supplied
source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.torque_response_matrix — Function
torque_response_matrix(ffs, permeability, flux_conform) -> Array{ComplexF64,3}

ψ-resolved torque response T_xe of a forward kinetic solve from its stored solution. permeability is the flux-space plasma response operator P (Φtot = P·Φx) and flux_conform the b̃ → Φ operator R = S·A, both at the control surface.

Per stored node k, with U₁, U₂ the displacement and momentum blocks of u_store and U₁ₗ the displacement block at the control surface:

T_xe(ψ_k) = K†·[U₁(ψ_k)†·U₂(ψ_k)]·K · 2n·i/(2μ₀),   K = U₁ₗ⁻¹·D·P·R,   D = diag(1/(χ₁·(m − n·q_lim)·2π·i))

K maps an applied b̃ to the coefficients of the solution basis (b̃ → Φx → Φtot → boundary ξ → coefficients), so T_xe is the Fortran gresp chain (dwks, bsurfmat, gind, gres, ptof) with the single edge inverse the stored, globally consistent basis allows.

Errors unless the solve is a single-n forward integration with kinetic matrices; the ideal Euler-Lagrange energy is Hermitian and carries no torque. Warns when the kinetic matrices are the synthetic "fixed" test matrices.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.torque_profile — Function
torque_profile(T_xe::AbstractArray{ComplexF64,3}, b̃) -> Vector{ComplexF64}
torque_profile(tr::TorqueResponse, b̃) -> Vector{ComplexF64}

Contract an applied root-area-weighted spectrum b̃ with a torque response, giving the cumulative complex torque T(ψ_k) = b̃†·T_xe(ψ_k)·b̃/2 at every stored node: real is the toroidal torque on the plasma inside ψ_k in N·m and imag is 2n·δW of that plasma in J.

The factor 1/2 converts the stored "2×" matrix (the Fortran GPEC T_xe array, built on the quadratic form of the +n harmonic alone) to the physical torque of the real field; the last entry then equals the boundary-response toroidal_torque of the same solve. Only the Hermitian part of T_xe contributes to the real part, so the torque is the same whether or not the matrix is symmetrized first.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.coil_flux_spectra — Function
coil_flux_spectra(ffs, coil_sets, cfg) -> Matrix{ComplexF64}

Unit-norm control-surface flux spectrum Φ_x of every coil set as built, one column per set on the solve's (m, n) ordering [numpert_total × ncoil_set]: Biot-Savart on the control surface ffs.psilim sampled with the run's own cfg grid, so the columns sum to the run's coil forcing.

source
GeneralizedPerturbedEquilibrium.PerturbedEquilibrium.apply_torque_response! — Function
apply_torque_response!(state, forcing; verbose=false)

Contract the torque response of state.response with the forcing of state into state.torque_response. Every forcing source is one column of T_source: each coil set (state.coil_sets, on the grid forcing carries) when the forcing is coils, otherwise the applied spectrum as a single source named after its forcing file. A source's Φx column is referred to b̃ through R = S·A, so `Tsource = B̃†·Txe·B̃withB̃ = R⁻¹·Φsource(the Fortrangcoil`).

source