Error Fields
ErrorFields turns a coil-driven perturbed equilibrium into an error-field tolerance assessment: how much resonant field each coil set drives when it is misaligned, how likely the assembled machine is to lock for given manufacturing tolerances, and how much correction current an error-field correction array may and must carry. Once one plasma solve exists the resonant drive is linear in each coil's motion, so the module linearizes it once and everything downstream is linear algebra on a small table.
What it computes
- Coil sensitivities (
[ErrorFields],ErrorFields/CoilSensitivities/): the resonant spectrum of each coil set as built and its derivatives with respect to rigid shifts and tilts. - Tolerances (
tolerance_file): the manufacturing tolerances of each coil set, in their own TOML file. - Monte Carlo (
[ErrorFields.MonteCarlo],ErrorFields/MonteCarlo/): the distribution of the dominant-mode overlap $|\delta|$ over sampled misalignments, intrinsic and with error-field correction. - Locking risk (
[ErrorFields.scenario],[ErrorFields.Risk],ErrorFields/Risk/): the overlap distribution against the empirical penetration-threshold scaling, giving the locking probability and its scan against tolerance scale, from which the allowable tolerance follows. - Correction limits (
[ErrorFields.NTV],ErrorFields/NTV/): how much correction current each array may carry before the NTV torque of its non-resonant field spends the rotation budget, and how much it needs.
For every named coil set of a coil-forced run the stage evaluates the root-area-weighted control-surface spectrum $\tilde b$ of the set as built and its central-difference derivatives with respect to the six rigid-body degrees of freedom, the shifts $(\Delta x, \Delta y, \Delta z)$ in metres and the rotations $(\theta_x, \theta_y, \theta_z)$ about the machine axes in degrees, placed on the run's (m, n) ordering so that they are exactly the vectors the resonant coupling matrix and its singular vectors act on (see Dominant resonant-coupling mode). The stored primitive is the linearization of the spectrum, not a scalar, so the resonant surfaces retained, the singular mode and the normalization are post-hoc choices, and every later step can be re-evaluated from gpec.h5 without a new plasma solve. In the snippets below EF is GeneralizedPerturbedEquilibrium.ErrorFields and AEF is GeneralizedPerturbedEquilibrium.Analysis.ErrorFields.
Governing equations
The overlap of a coil set with singular mode $k$ of the coupling matrix, normalized by the axis toroidal field, is the dimensionless
\[\delta = \frac{V_k^{\mathrm{H}}\,\tilde{b}}{B_{T0}},\]
and because the projection is linear, a rigid shift $(\Delta x, \Delta y)$ moves it by $S_x \Delta x + S_y \Delta y$ with the complex sensitivities $S_x = \partial\delta/\partial\Delta x$, $S_y = \partial\delta/\partial\Delta y$, exact for any coil shape; for an axisymmetric coil $S_y = \pm i S_x$ and the response reduces to one magnitude with a free phase. Over sampled misalignments the overlap of the machine is the coherent sum over coil sets of $S\,(\Delta + u) + T\,(\theta + v)$ for each coil's draw $(\Delta, \theta)$ and placement uncertainty $(u, v)$, plus one shared draw per coherent group and a random-direction unattributed budget; no field is recomputed, so a million samples take about a second.
An overlap distribution becomes a locking risk through the empirical ITPA penetration-threshold scalings of Logan et al. (2020) for n = 1 and n = 2 and Bursch et al. (2026) for n = 1,
\[\delta_\mathrm{thresh} = 10^{\alpha_c}\, n_e^{\alpha_n}\, B_T^{\alpha_B}\, R_0^{\alpha_R}\, (\beta_N/l_i)^{\alpha_\beta}\, I_p^{\alpha_I},\]
with $n_e$ in 10¹⁹ m⁻³, $B_T$ in T, $R_0$ in m and $I_p$ in MA (the current term only in the 2026 fits). Sampling the fitted exponents within their standard errors turns the threshold into a distribution whose cumulative distribution is the probability $P(\mathrm{lock}\,|\,\delta)$ that an overlap locks, and the locking probability of the assembled machine is $100 \int \mathrm{pdf}(\delta)\, P(\mathrm{lock}\,|\,\delta)\, d\delta$ over the Monte Carlo bins, per batch.
A correction array cancels the dominant-mode overlap at $C_c$ per kilo-ampere-turn, but the non-resonant remainder of its field drives an NTV torque $T I^2$ that a perfect correction does not remove. With a torque budget $T_0$ and the threshold taken to fall in proportion to the torque spent, the current that corrects an intrinsic overlap $\delta_\mathrm{EF}$ solves
\[\delta_\mathrm{EF} - C_c I = s\,\delta_\mathrm{thresh}\left(1 - \frac{T_\mathrm{residual} I^2}{T_0}\right),\]
the model of Logan et al. (2026) for SPARC and Leuthold et al. (2026) for ARC. It holds only while the plasma still rotates, so the current is capped at $I_\max = \sqrt{T_0/T_\mathrm{residual}}$, and the largest correctable overlap is the peak of the quadratic or the overlap cancelled at $I_\max$, whichever comes first; the two zero-rotation limits $C_c\sqrt{T_0/T_\mathrm{residual}}$ and $C_c\sqrt{T_0/T_\mathrm{full}}$ are reported beside it.
Running it
The stage needs a [PerturbedEquilibrium] run with forcing_data_format = "coil" and the singular coupling computed; examples/DIIID-like_error_field_example is the complete case, with the DIII-D C-coil as the n = 1 source and the eighteen F coils as single-filament hoops whose error-field content is entirely their sensitivity to misalignment. From its deck:
[ErrorFields]
fd_step_shift_m = 1e-3 # central-difference step of the rigid shifts [m]
fd_step_tilt_deg = 0.1 # central-difference step of the rigid tilts [degrees]
rotation_center = "conductor" # tilt pivot: each conductor's own centre, or "set" for the whole set's
exclude_coils = [] # coil sets that are not error-field sources (the NTV efc_coils are excluded automatically)
tolerance_file = "tolerances.toml" # manufacturing tolerances, relative to the deck directory
[ErrorFields.MonteCarlo]
nsample = 200000 # samples per batch
nbatch = 10 # independent batches; their spread is the statistical error bar
seed = 1
nbins = 300 # histogram bins on [0, delta_max]; delta_max = 0 is 1.5 × the worst-case bound
[ErrorFields.scenario]
n_e = 5.0 # electron density of the threshold scaling [1e19 m^-3]; B_T, R_0, beta_N, l_i and I_p default from the equilibrium
[ErrorFields.Risk]
year = 2020 # threshold fit: 2020 (n = 1 and 2) or 2026 (n = 1)
dataset = "O,L" # ITPA dataset of the fit ("O,L", "O,L,H", ...)
fit = "WLS" # "OLS", "DSOLS" or "WLS"
nsample_threshold = 1000000
scan_scales = [0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0] # tolerance multipliers of the allowable-tolerance scan
[ErrorFields.NTV]
efc_coils = ["d3d_c"] # the correction arrays; never error-field sources
method = "fgar" # KineticForces torque method, enabled in [KineticForces]
rotation_scan = true # tabulate the torques against a rigid E×B rotation shift
rotation_scan_points = 5
rotation_scan_max_points = 9
rotation_scan_tolerance = 0.05
rotation_span_factor = 1.0
rotation_offset_factor = 2.0[ErrorFields.MonteCarlo] also takes tolerance_scale (multiplies every tolerance, for scans; scale_subset and scale_map restrict it) and coil_subset (the coil sets sampled; empty samples all), and [ErrorFields.Risk] takes distribution, how the fit exponents are sampled ("normal", "flat", "normal_truncated").
The tilt pivot matters for multi-filament winding packs: "conductor" rotates each filament about its own centre, "set" rotates the pack rigidly about its common centre, which is what an engineering axis-line tolerance constrains. A coil set that is not an error-field source (a correction array or anything in exclude_coils) is swept like the others but left out of the as-designed field, the Monte Carlo and the scans; a tolerance that names it is an error. The NTV limits need a [KineticForces] section, since each array's torque per kAt² is one kinetic torque evaluation of its unit-current spectrum, with and without the dominant mode projected out. With several ion species or electron = true, that torque is the same species sum as the NTV diagnostics; the reference rotation is the main ion's.
The tolerances are engineering data, reviewed independently of any run, so they live in their own file, echoed into Input/RawInputs/ErrorFields/tolerance_toml_raw for replay; every key is checked against the schema. Its tables are [ErrorFields.defaults] (fallbacks for every coil block), one [[ErrorFields.coil]] per coil set that moves on its own, [[ErrorFields.coherent_group]] for coil sets that move together, [ErrorFields.correctability] and [ErrorFields.other_field]:
[ErrorFields.defaults]
shift_sigma_mm = 0.0 # Gaussian placement uncertainty added to the sampled shift [mm]
tilt_sigma = 0.0 # the same for the tilt, in tilt_units
tilt_units = "deg" # "deg", or "m" for a rim displacement converted through the coil's major radius
radial_shape = "hollow" # radial sampling density on the disk: flat, uniform_area, hollow or ring
tolerance_model = "additive" # "additive" (independent shift and tilt) or "cylinder" (correlated axis line)
current_factor = 1.0 # current as built relative to the run's; 0 switches a coil off
[[ErrorFields.coil]]
name = "PF1U" # must match a [[ForcingTerms.coil_set]] of the run
shift_tol_mm = 0.5 # radius of the disk the coil centre may lie in [mm]
tilt_tol = 0.019 # tilt tolerance, in tilt_units
tolerance_model = "cylinder"
cylinder_half_height_m = 1.5 # sets the tilt reachable at the given radius
[[ErrorFields.coherent_group]]
name = "upper_pf_brace"
members = ["PF1U", "PF2U"] # one shared draw per sample
shift_tol_mm = 2.0
tilt_tol = 0.0
phase_group = "braces" # groups naming the same phase_group share the random direction
rotation_center_z_m = 0.0 # pivot of the group's rigid rotation on the machine axis [m]
[ErrorFields.correctability]
uncorrectable_coils = ["EFCC_U"] # coil sets the error-field correction cannot reduce
efc_factor = 2.0 # divisor applied to correctable contributions under correction
[ErrorFields.other_field]
magnitude = 8.2e-6 # overlap budget of sources not attributed to any coil
sigma = 0.0
radial_shape = "ring"A coherent group's tilt is a rigid rotation of its members about the pivot, so a member at height $z$ also shifts by $(z - z_\mathrm{pivot})\,\theta$; coil sets without a tolerance block contribute their as-designed overlap only; a coil's current_factor scales its overlap and sensitivities together, the knob for a risk against the current in an uncorrectable coil.
From a script the stage is one call on the plasma response and the coil sets, and every product is re-evaluated post hoc from the file for any surface window, mode, fit, tolerance scale or coil subset:
ef = error_fields(resp, pe.coil_sets, ForcingTerms.CoilConfig(ft_ctrl); # ft_ctrl: the [ForcingTerms] control
tolerances=EF.read_tolerance_toml("tolerances.toml"),
scenario=EF.ScenarioParameters(ffs.equil; n_e=5.0))
save_to_hdf5("gpec.h5", ef)
table = EF.sensitivity_table("gpec.h5"; psi_low=0.5) # overlaps and sensitivities per coil set, edge window
mc = EF.run_monte_carlo("gpec.h5"; psi_low=0.5, tolerance_scale=2.0) # |δ| distribution, intrinsic and corrected
risk = EF.locking_risk("gpec.h5"; n_e=5.0, risk_ctrl=EF.RiskControl(; year=2026, fit="OLS"))
EF.allowable_tolerance(EF.ToleranceScan("gpec.h5"), 1.0; corrected=true) # tolerance multiplier at 1% locking risk
EF.max_correctable_overlap(EF.read_efc_couplings("gpec.h5")[1]; delta_threshold=1.4e-4, torque_budget=4.0)
AEF.plot_error_field_summary("gpec.h5"; save_path="error_field_summary.png")correction_requirement gives the current each array needs, by the dominant mode or jointly over every rational surface in the least-squares sense, and uncorrectable_probability the fraction of the Monte Carlo overlap beyond what the NTV-limited array can correct; phasing_map evaluates the dominant-mode field per kilo-ampere-turn over the relative phases of several arrays; ResonantDriveContext and coil_overlaps assess a new coil design against the stored run at one Biot–Savart pass per coil set, with combine_overlaps applying a design current pattern afterwards. Analysis.ErrorFields plots each product, and every plotting function takes label => path pairs so coil-design revisions overplot on one axis.
Outputs
| Dataset | Meaning |
|---|---|
ErrorFields/CoilSensitivities/field_as_designed, shift_sensitivity_per_m, tilt_sensitivity_per_deg | the control-surface spectrum of each coil set as built and its derivatives with respect to the rigid shifts and tilts, with the current pattern they were evaluated at and the finite-difference linearity residual per tap |
ErrorFields/CoilSensitivities/DominantMode/delta_as_designed, … | the overlaps and sensitivities projected onto the run's full-window dominant mode, their direction-averaged in-plane magnitudes, and the shift and tilt that would cancel the as-designed overlap |
ErrorFields/MonteCarlo/abs_delta_pdf, abs_delta_efc_pdf, abs_delta_bin_edges | the intrinsic and corrected $\lvert\delta\rvert$ histograms over the sampled tolerances, per batch and averaged |
ErrorFields/MonteCarlo/abs_delta_total_as_designed, abs_delta_worst_case | the overlap of the design as built and the worst-case bound with every term at its tolerance edge and in phase |
ErrorFields/Risk/locking_probability_given_delta, threshold density | ``P(\mathrm{lock}\, |
ErrorFields/Risk/locking_probability_percent, locking_probability_efc_percent, *_batches_percent, locking_probability_as_designed_percent, locking_probability_fit_threshold_percent | the locking probability of the intrinsic and corrected distributions with per-batch values, of the design as built, and at the sharp fitted threshold |
ErrorFields/Risk/ToleranceScan/ | the same against tolerance_scale; the allowable tolerance at a target risk is its inversion |
ErrorFields/NTV/ | each correction array's dominant-mode coupling $C_c$, resonant fraction and NTV torque per kAt² for its full field and with the dominant mode projected out |
Every dataset name follows one grammar, <quantity>[_<instance>][_efc][_<statistic>][_<unit>]: delta is the overlap and abs_delta its magnitude; _as_designed, _sampled, _worst_case name the geometry; _efc marks error-field correction applied; a probability stored as a percentage carries _percent.
Numerical notes
- The sensitivities assume the overlap is linear in the misalignments out to the tolerance edge; the run checks it only at the finite-difference step, and
linearity_checkdisplaces each coil set by±scale × toleranceand recomputes its overlap to report the relative error of the linear model at the largest scale a tolerance scan will use (one Biot–Savart pass per row). - Monte Carlo batches are seeded individually, so results are bit-identical for any thread count;
risk_convergencerepeats the Monte Carlo over sample and bin counts, and the batch spread must fall as $1/\sqrt{n_\mathrm{sample}}$ while the value must not move with the bin count by more than the spread. - A threshold scaling is fitted for one toroidal mode number, so the risk refuses a run that spans several; project onto one n's coupling first.
- A coil set whose field at the run's toroidal mode is round-off (an axisymmetric hoop at n = 1) has no resonant fraction and reports
NaNrather than the ratio of two noise vectors. - The NTV torques are stored with their sign and the limits consume the budget with their magnitude; the torque budget is the plasma's intrinsic torque and an analysis choice.
API reference
GeneralizedPerturbedEquilibrium.ErrorFields.MIN_NZETA_PER_PERIOD — Constant
Minimum toroidal boundary points per field period below which a post-hoc evaluation warns. Helical windings alias on a coarse toroidal grid; 16 points per period is about 1 % off, 32 is converged.
GeneralizedPerturbedEquilibrium.ErrorFields.TORQUE_ROTATION_SIGN — Constant
Sign relating the kinetic torque to the rotation it acts on: −1 means a positive T_φ lowers the E×B rotation shift Δω (the kernel reports braking as positive). A property of the kinetic kernel's sign convention, fixed empirically on the DIII-D error-field example; no run checks it.
GeneralizedPerturbedEquilibrium.ErrorFields.CoherentGroupTolerance — Type
CoherentGroupToleranceTolerance of a set of coils that move together: every member receives the same displacement (and the same rotation about a common pivot) from one random draw per sample. Groups that name the same phase_group share the random direction of that draw while keeping independent amplitudes.
Fields
name: label of the groupmembers: coil set names moving togethershift_tol_m,tilt_tol,tilt_units,radial_shape,tolerance_model,cylinder_half_height_m: as inCoilTolerance, applied to the shared drawphase_group: groups with equal labels share the random direction; defaults tonamerotation_center_z_m: height of the pivot of the group's rigid rotation on the machine axis, metres; a member at heightztilted by θ also shifts laterally by(z − z_pivot)·θtilt_lever_arm_m: the lever arm, metres, that converts a tilt tolerance given in metres into the group's rotation angle (asin(tilt_tol / lever_arm));NaNuses the members' common major radius
GeneralizedPerturbedEquilibrium.ErrorFields.CoilOverlap — Type
CoilOverlapField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
How strongly one coil set drives the resonant field, in every normalization it is quoted in.
Fields
coil_name: name of the coil setmode: index of the singular mode projected onto (1 is the dominant mode)delta:Vᴴb̃ / B_T0, the dimensionless overlapresonant_field_t:Vᴴb̃, tesla, the same projection unnormalizedresonant_fraction_percent:100·|Vᴴb̃| / ‖b̃‖, how much of this set's own spectrum is resonant;NaNwhen the set's field at the run's toroidal mode is round-off (seeresonant_fraction_percent)spectrum_norm_t:‖b̃‖in teslab_t0: the axis toroidal field the normalization used, teslaampere_turns_kat: the set's current in kilo-ampere-turns,|winding multiplier| × max |conductor current| / 1000;NaNfor a combination of setsspectrum: b̃ itself, on theResonantCouplingcolumn ordering
GeneralizedPerturbedEquilibrium.ErrorFields.CoilSensitivities — Type
CoilSensitivitiesField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
Linearization of each coil set's control-surface spectrum with respect to its six rigid-body degrees of freedom, on the (m, n) column ordering of the ResonantCoupling it was built against. Spectra are root-area-weighted fields b̃ in tesla, the vector the coupling matrix and its singular vectors act on, so projecting any of them onto a mode is one inner product.
Shifts are Cartesian translations of the whole set; tilts are rotations about the machine x, y, z axes through the pivot selected by ErrorFieldsControl.rotation_center. A coil set's spectrum is proportional to its currents, so the table is specific to the current pattern it was evaluated with; peak_current and winding_multiplier let a user renormalize per ampere-turn.
Fields
coil_names: name of each coil set[ncoil_set]m_modes,n_modes: poloidal and toroidal mode number of each spectrum entry[numpert_total]b_t0: toroidal field magnitude on axis, tesla — the normalization that makes the overlap a dimensionless δfield_as_designed: b̃ of each set as built, tesla[numpert_total × ncoil_set]shift_sensitivity_per_m: ∂b̃/∂(Δx, Δy, Δz), tesla per metre[numpert_total × 3 × ncoil_set]tilt_sensitivity_per_deg: ∂b̃/∂(θx, θy, θz), tesla per degree[numpert_total × 3 × ncoil_set]shift_linearity_residual,tilt_linearity_residual: ‖b̃(+h) + b̃(−h) − 2b̃(0)‖ of each tap relative to the set's largest first difference ‖b̃(+h) − b̃(−h)‖ over all six taps, a window-independent measure of how much second-order response the linearization drops at the step taken[3 × ncoil_set]peak_current: largest conductor current magnitude of each set, amperes[ncoil_set]winding_multiplier: turns per conductor element of each set[ncoil_set]major_radius_m: arc-length-weighted major radius of each set, metres[ncoil_set]— the lever arm that turns a tilt angle into the rim displacement engineering tolerances are written in
GeneralizedPerturbedEquilibrium.ErrorFields.CoilSensitivities — Method
CoilSensitivities(h5path::AbstractString)Read the coil linearization back from a gpec.h5 written with an [ErrorFields] section, with the mode labels from Info/mn_index and the normalization field from Equilibrium/B_T_axis.
GeneralizedPerturbedEquilibrium.ErrorFields.CoilTolerance — Type
CoilToleranceManufacturing tolerance of one coil set that moves independently. Lengths are in metres and the tilt tolerance in tilt_units; convert it to the degrees the sensitivities are stored in with tilt_tolerance_deg.
Fields
name: coil set name; must match a coil set of the runshift_tol_m: radius of the in-plane displacement disk the coil centre may lie in, metresshift_sigma_m: Gaussian uncertainty added to the sampled shift, metrestilt_tol: tilt tolerance, intilt_unitstilt_sigma: Gaussian uncertainty added to the sampled tilt, intilt_unitstilt_units:"deg", or"m"for a rim displacement converted through the coil's nominal major radiusradial_shape: radial sampling density on the disk:"flat"(uniform in radius),"uniform_area","hollow"(peaked toward the edge), or"ring"(always at the edge)tolerance_model:"additive"(independent shift and tilt draws) or"cylinder"(the coil axis line confined to a cylinder of radiusshift_tol_m, shift and tilt drawn together)cylinder_half_height_m: half-height of that cylinder, metres; sets the tilt reachable at the given radiuscurrent_factor: multiplier on the coil set's current as built relative to the run, applied to its as-designed overlap and its sensitivities alike (the spectrum is linear in current);1is the run's current,0switches the coil off, a negative value reverses it
GeneralizedPerturbedEquilibrium.ErrorFields.CorrectionRequirement — Type
CorrectionRequirementField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
The linear correction requirement of one error-field source against a set of correction arrays, on the rational surfaces of one run. Each needed current is given as a complex factor on the array's current as given (−1 on an array identical to the source cancels it exactly) and in kilo-ampere-turns.
Fields
source_name,array_names: the coil sets,[narray]for the arraysrational_psi,rational_q,rational_m,rational_n: the surfaces,[nsurface]current_factor_dominant: the factor on each array alone that cancels the source's dominant-mode overlap,−δ_source / δ_array;NaNfor an array with no overlap[narray]. Not a joint solution: for two or more arrays the dominant-mode condition leaves an(narray − 1)-dimensional family of solutionscurrent_factor_dominant_minimum_norm: the member of that family with the smallest total currentΣ|I_k|²[narray],I_k = −δ_source · conj(δ_k/a_k) / Σ|δ/a|²witha_kthe array's ampere-turns (a_k = 1when any array's ampere-turns are unknown)current_factor_least_squares: the factors on every array together that minimize the resonant field on every surface,argmin ‖C·(b̃_source + Σ_k f_k b̃_k)‖[narray]; unique whenleast_squares_rank == narray, otherwise the minimizer with the smallest total current in the same senseleast_squares_rank: rank of thensurface × narraysystem the least squares solvescurrent_dominant_kat,current_dominant_minimum_norm_kat,current_least_squares_kat: the three factors times each array'sampere_turns_kat, complex kilo-ampere-turns (magnitude and toroidal phase)[narray];NaNfor an array whose ampere-turns are unknownresonant_field_source_t: the source's resonant field on each surface,C·b̃_source, tesla[nsurface]resonant_field_dominant_t: the same after each array's dominant-mode correction alone, tesla[nsurface × narray]resonant_field_least_squares_t: the same after the joint least-squares correction, tesla[nsurface]cosine_similarity:|⟨b̃_array, b̃_source⟩| / (‖b̃_array‖ ‖b̃_source‖), how much of the source's spectrum each array can see at all;NaNfor a round-off field[narray]
GeneralizedPerturbedEquilibrium.ErrorFields.EFCCoupling — Type
EFCCouplingField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
The couplings of one correction coil array, per kilo-ampere-turn of its current pattern.
Fields
coil_name: the arraydelta_per_kat: dominant-mode overlap|δ|per kAt (C_c)resonant_fraction_percent: resonant fraction of the array's field,100·|Vᴴb̃|/‖b̃‖torque_full_per_kat2: NTV torque of the whole field per kAt², N·m, with its sign, at the nominal rotationtorque_residual_per_kat2: NTV torque of the field with the dominant mode projected out, per kAt², N·m, with its sign, at the nominal rotationrotation_shift: the scanned rigid E×B rotation shiftsΔω, rad/s, sorted and containing 0 (a single 0 when no scan was made)torque_full_scan,torque_residual_scan: the two torques at each shift, N·m per kAt²omega_reference: the reference rotationω_ref, rad/s, the ion toroidal rotation weighted by density and volume;NaNwithout a scanomega_offset_estimate: the rough neoclassical offset used to size the scan, rad/s;NaNwithout a scanpsi: kinetic ψ_N grid of the torque profiles (empty without a scan)torque_full_profile,torque_residual_profile: cumulative torqueT(ψ)at each shift,length(psi) × length(rotation_shift), N·m per kAt²
The constructor that omits the rotation-scan fields builds a coupling with no scan, the nominal torques only.
GeneralizedPerturbedEquilibrium.ErrorFields.ErrorFieldsControl — Type
ErrorFieldsControlControl parameters for the [ErrorFields] TOML section. The sweep needs a coil-forced perturbed-equilibrium solve (forcing_data_format = "coil" with the singular-coupling step on); everything here concerns only how the coil linearization is taken and where it is written. Analysis choices (which resonant surfaces count, which singular mode, which normalization) are never inputs: the full spectra are stored and projected post hoc with sensitivity_table.
Fields
fd_step_shift_m: central-difference step for the rigid shifts, in metresfd_step_tilt_deg: central-difference step for the rigid tilts, in degreesrotation_center: pivot of the tilt taps —"conductor"rotates every conductor of a set about its own arc-length centre,"set"rotates the whole set rigidly about its common arc-length centre (a winding pack moving as one body)exclude_coils: coil sets of the run that are not error-field sources (e.g. a correction array). Their sensitivities are tabulated, but they are left out of the error field, Monte Carlo, worst-case bound and scans, and no tolerance may name them.[ErrorFields.NTV] efc_coilsare always excluded
GeneralizedPerturbedEquilibrium.ErrorFields.ErrorFieldsResult — Type
ErrorFieldsResultThe error-field assessment of a plasma response, from error_fields. Products that were not requested are nothing.
Fields
sensitivities::CoilSensitivities- The coil sets' rigid-body sensitivities on the control surface.dominant::DominantCoupling- The singular modes of the resonant coupling the overlaps project on.tolerances::Union{Nothing,ToleranceSet}- The manufacturing tolerances, validated against the coil sets.monte_carlo::Union{Nothing,MonteCarloResult}- The tolerance Monte Carlo; needstolerances.risk::Union{Nothing,RiskResult}- The locking risk; needs the Monte Carlo and ascenario.scan::Union{Nothing,ToleranceScan}- The locking risk against a tolerance scale; needsRiskControl.scan_scales.couplings::Union{Nothing,Vector{EFCCoupling}}- The correction arrays' couplings and NTV torques; needsNTVControl.efc_coils.response::PerturbedEquilibrium.PlasmaResponse- The plasma response the assessment was made on.settings::NamedTuple- The settings it was made with:ctrl,monte_carlo,risk,ntv,kinetic,scenarioandregularization_width, as given toerror_fields.
GeneralizedPerturbedEquilibrium.ErrorFields.Flat — Type
Flat <: RadialDistributionUniform in radius (p = 1): the density of |Δ| is constant on [0, R], the OMFIT tool's flat shape. Note this is not uniform over the disk area — see UniformArea.
GeneralizedPerturbedEquilibrium.ErrorFields.Hollow — Type
Hollow <: RadialDistributionPeaked toward the edge (p = 1/3, radial CDF (r/R)³): the OMFIT tool's default, standing in for a manufacturing process that uses most of its tolerance.
GeneralizedPerturbedEquilibrium.ErrorFields.LinearityCheck — Type
LinearityCheckField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
The linear sensitivity model against finite rigid displacements, one row per coil set (or coherent group), degree of freedom, scale and sign. Vectors are all [nrow].
Fields
name: coil set or coherent groupkind::shiftor:tiltaxis: 1 for x, 2 for y (a group's rows use axis 1)scale: the displacement as a multiple of the tolerancedisplacement: the signed displacement applied, metres for a shift and degrees for a tiltdelta_as_designed: δ of the undisplaced geometrydelta_linear: the model's predictionδ_as_designed + S·Δ(orT·θ, with a group's lateral rotation term as the Monte Carlo applies it)delta_actual: δ of the displaced geometry from a fresh Biot–Savart passrelative_error:|δ_actual − δ_linear| / |δ_linear − δ_as_designed|, the error of the predicted change;NaNwhere the linear change vanishes
GeneralizedPerturbedEquilibrium.ErrorFields.MonteCarloControl — Type
MonteCarloControlSettings of the tolerance Monte Carlo, the [ErrorFields.MonteCarlo] TOML table.
Fields
nsample: samples per batchnbatch: independent batches; their spread is the statistical error bar of every derived quantityseed: base seed; batchbusesXoshiro(hash((seed, b))), so results are bit-identical for any thread countnbins: histogram bins, linear on[0, delta_max]delta_max: upper edge of the histogram;0means1.5 ×the worst-case alignmentΣ(|δ_as_designed| + tolerance × |sensitivity|), which the tolerance draws cannot exceed (only the Gaussian uncertainties and the unattributed budget can, and those land in the last bin)tolerance_scale: multiplies every shift and tilt tolerance, for allowable-tolerance scans; uncertainties and the unattributed budget are not scaledcoil_subset: coil set names whose tolerances are sampled; every other coil set contributes only its as-designed overlap, and a coherent group is sampled only if all its members are listed. Empty means allscale_subset: coil set and group names thattolerance_scaleapplies to; every other name keeps its own tolerance (scale 1). Empty meanstolerance_scaleapplies to all. This is how one class of coils is scanned while another holds its tolerancescale_map: an explicit multiplier per coil set or group name, applied on top oftolerance_scale; names absent from the map are unscaled by it. A name inscale_subsetorscale_mapthat is neither a coil set of the run nor a group of the tolerance file is an error
The effective multiplier of a name is (name in scale_subset or scale_subset empty ? tolerance_scale : 1) × get(scale_map, name, 1). None of these change which random numbers are drawn.
GeneralizedPerturbedEquilibrium.ErrorFields.MonteCarloResult — Type
MonteCarloResultField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
Histograms of the dominant-mode overlap magnitude over the sampled misalignments.
Fields
abs_delta_bin_edges:|δ|bin edges[nbins + 1]; samples above the last edge are counted in the last binabs_delta_pdf,abs_delta_efc_pdf: probability density of the intrinsic and of the corrected|δ|, averaged over batches[nbins]abs_delta_pdf_batches,abs_delta_efc_pdf_batches: the same per batch[nbins × nbatch]abs_delta_total_as_designed:|Σ δ_as_designed|, the as-designed overlap with every coil at its design positionabs_delta_worst_case: the worst-case alignment bound used to size the histogramabs_delta_sampled_mean,abs_delta_efc_sampled_mean: sample means of the two magnitudesclamped_fraction: fraction of samples whose intrinsic|δ|landed beyondabs_delta_bin_edges[end](the corrected histogram clamps too but is not separately tallied)nsample,nbatch,seed: as run
GeneralizedPerturbedEquilibrium.ErrorFields.MonteCarloResult — Method
MonteCarloResult(h5path::AbstractString)Read the tolerance Monte Carlo of a run back from its gpec.h5, with the sampling settings from the [ErrorFields.MonteCarlo] table of the stored deck.
GeneralizedPerturbedEquilibrium.ErrorFields.NTVControl — Type
NTVControlSettings of the correction-coil NTV evaluation, the [ErrorFields.NTV] TOML table.
Fields
efc_coils: coil set names of the correction arrays to evaluate (empty: stage off)method: KineticForces torque method to use ("fgar"by default; it must be enabled in[KineticForces])rotation_scan: tabulate the torques against a rigid E×B rotation shift (true);falseevaluates only the nominal rotation (:linearmodel only)rotation_scan_points: points of the initial symmetric shift grid (made odd so that the unshifted point is one of them)rotation_scan_max_points: cap on the number of kinetic evaluations per spectrum after adaptive refinementrotation_scan_tolerance: refinement stops when every interval's midpoint prediction error is below this fraction of the torque rangerotation_span_factor: the scan covers±span_factor × max(|ω_E|, offset_factor·|ω_*T|)evaluated at the innermost kinetic surfacerotation_offset_factor: neoclassical offset in units of the ion temperature-gradient diamagnetic frequencyω_*T(about 2, Park, Boozer and Menard 2009), sizes the scan
GeneralizedPerturbedEquilibrium.ErrorFields.OtherFieldBudget — Type
OtherFieldBudgetOverlap budget for error-field sources not attributed to any coil, sampled once per Monte Carlo sample as an incoherent contribution with a random direction.
Fields
magnitude: dimensionless overlap magnitude of the budgetsigma: Gaussian uncertainty on that magnituderadial_shape: radial sampling density of the magnitude, as inCoilTolerance
GeneralizedPerturbedEquilibrium.ErrorFields.PhasingMap — Type
PhasingMapField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
Dominant-mode overlap of N coil arrays against the N − 1 relative phases of their current patterns, from phasing_map. Array 1 sets the reference; array k > 1 is rotated by the cumulative phase Δφ_2 + … + Δφ_k, so axis k − 1 of the maps is the phase of array k relative to array k − 1 (the two-row EFCC convention Δφ_ML, Δφ_UM).
Fields
coil_names: the arrays in order[N]phase_deg: grid of each relative phase, degrees[N − 1]vectorsdelta_per_kat:|δ|per kilo-ampere-turn of every array at each grid point[n_1 × … × n_{N−1}]resonant_fraction_percent:100·|Vᴴb̃| / ‖b̃‖, the fraction of the applied root-area-weighted field that lies along the dominant mode, at each grid pointdelta_per_kat_each:|δ_k|per kilo-ampere-turn of each array alone[N]
GeneralizedPerturbedEquilibrium.ErrorFields.PowerLaw — Type
PowerLaw(p) <: RadialDistributionr = R·u^p for a user-chosen exponent p ≥ 0.
GeneralizedPerturbedEquilibrium.ErrorFields.RadialDistribution — Type
RadialDistributionRadial density of a point drawn in a disk of radius R: r = R·u^p with u uniform on [0, 1] and p = randpow(d). Subtypes: Flat (p = 1, uniform in radius), UniformArea (p = 1/2, uniform over the disk area), Hollow (p = 1/3, peaked toward the edge), Ring (p = 0, always on the edge), and PowerLaw for any exponent. The radial cumulative distribution is (r/R)^(1/p).
GeneralizedPerturbedEquilibrium.ErrorFields.ResonantDriveContext — Type
ResonantDriveContextEverything from a finished run needed to evaluate the resonant field any coil geometry drives, built once and independent of the coils. Build it with the gpec.h5 constructor and hand it to coil_overlaps or compute_coil_sensitivities.
Fields
equil: the run's equilibrium, rebuilt on its own ψ gridpsilim: the control surface the solve integrated tocfg: coil configuration, with any grid or directory override already appliedrc: the resonant coupling matrix and its mode orderingdom: the singular decomposition over the requested ψ windowb_t0: axis toroidal field magnitude, teslagrids: one boundary sampling per toroidal mode, shared by every coil set evaluated
GeneralizedPerturbedEquilibrium.ErrorFields.ResonantDriveContext — Method
ResonantDriveContext(equil, rc, cfg; psilim, b_t0, psi_low=CORE_PSI_LOW, psi_high=CORE_PSI_HIGH,
mtheta_coil=nothing, nzeta_coil=nothing)
ResonantDriveContext(h5path; psi_low=CORE_PSI_LOW, psi_high=CORE_PSI_HIGH, mtheta_coil=nothing,
nzeta_coil=nothing, dat_dir=nothing)Assemble the context. The ψ window selects which rational surfaces the dominant mode is built from. mtheta_coil and nzeta_coil override the boundary resolution from the stored deck; a toroidal grid coarser than MIN_NZETA_PER_PERIOD warns. The h5path method lives in Rerun.jl.
GeneralizedPerturbedEquilibrium.ErrorFields.Ring — Type
Ring <: RadialDistributionAlways on the edge (p = 0, r = R): the worst-case magnitude with a random direction.
GeneralizedPerturbedEquilibrium.ErrorFields.RiskControl — Type
RiskControlSettings of the locking-risk evaluation, the [ErrorFields.Risk] TOML table.
Fields
year,dataset,fit: which ITPA threshold fit to use (the toroidal mode number is the run's). n = 1,year = 2020:"O,L"or"O,L,H"with"OLS","DSOLS"or"WLS"; n = 1,year = 2026:"O,L"with"OLS"or"WLS"(with a plasma-current term); n = 2,year = 2020:"O,L","O,L,-C"or"O,L,N"with"WLS"distribution: how the fit exponents are sampled —"normal","flat", or"normal_truncated"nsample_threshold: threshold samplesseed: seed of the threshold samplingscan_scales: tolerance multipliers of the allowable-tolerance scan (empty: no scan); each is a fresh Monte Carlo with every shift and tilt tolerance multiplied by the scale
GeneralizedPerturbedEquilibrium.ErrorFields.RiskResult — Type
RiskResultField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
The locking risk of a Monte Carlo overlap distribution under one threshold scaling. All probabilities are percentages.
Fields
abs_delta_bin_edges: the Monte Carlo's|δ|grid[nbins + 1]threshold_pdf: probability density of the sampled penetration threshold on that grid[nbins]locking_probability_given_delta: probability that an overlap equal to each bin edge locks, the threshold's cumulative distribution[nbins + 1]threshold_fit: the threshold at the fitted exponentslocking_probability_percent,locking_probability_efc_percent: locking probability of the intrinsic and of the corrected distribution,100 ∫ pdf(δ) P(lock|δ) dδ, batch averageslocking_probability_batches_percent,locking_probability_efc_batches_percent: the same per Monte Carlo batch[nbatch]; their ranges are the statistical error barslocking_probability_as_designed_percent: locking probability of the as-designed machine,100 P(lock | |Σ δ_as_designed|)locking_probability_fit_threshold_percent: locking probability if the threshold were exactly its fitted value,100 P(|δ| > threshold_fit)scaling: the threshold fit used
GeneralizedPerturbedEquilibrium.ErrorFields.ScenarioParameters — Type
ScenarioParametersOperating point the threshold scaling is evaluated at. Density is not an ideal-MHD equilibrium output and must be given; the others default from the equilibrium when built with ScenarioParameters(equil; n_e). The plasma current only enters the fits that carry a current term, so the keyword constructor leaves it NaN unless given and those fits refuse to evaluate without it.
Fields
n_e: electron density, 10¹⁹ m⁻³b_t0: toroidal field magnitude on axis, teslar_0: major radius of the magnetic axis, metresbeta_n: normalized betal_i: normalized internal inductance (l_i(1))i_p: plasma current magnitude, MA (NaN: not given)
GeneralizedPerturbedEquilibrium.ErrorFields.ScenarioParameters — Method
ScenarioParameters(equil::PlasmaEquilibrium; n_e, b_t0=equil.params.bt0, r_0=equil.ro, beta_n=equil.params.betan, l_i=equil.params.li1, i_p=equil.params.crnt)
ScenarioParameters(h5path; n_e, kwargs...)Build the operating point from an equilibrium (or a run's Equilibrium/ scalars), with the density supplied and any other parameter overridable. The current is the equilibrium's computed crnt (Equilibrium/I_p), a positive magnitude in MA.
GeneralizedPerturbedEquilibrium.ErrorFields.SensitivityTable — Type
SensitivityTableField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
A CoilSensitivities projected onto one singular mode of a DominantCoupling and normalized by the axis toroidal field: the dimensionless overlap δ of each coil set and its derivatives, which is all a tolerance Monte Carlo consumes. Built by sensitivity_table.
With S = (S_x, S_y) the in-plane shift sensitivities, a rigid shift (Δx, Δy) moves the overlap by S_x·Δx + S_y·Δy; the same holds for the tilts. Singular vectors carry an arbitrary phase, so only magnitudes and relative phases within one table are meaningful.
Fields
coil_names: name of each coil set[ncoil_set]mode: index of the singular mode projected onto (1 is the dominant mode)delta_as_designed: overlap of each set as built[ncoil_set]shift_sensitivity_per_m: ∂δ/∂(Δx, Δy, Δz), per metre[3 × ncoil_set]tilt_sensitivity_per_deg: ∂δ/∂(θx, θy, θz), per degree[3 × ncoil_set]abs_delta_shift_per_mm: direction-averaged in-plane magnitude√((|S_x|² + |S_y|²)/2)of the shift sensitivity, per millimetre[ncoil_set]— the single-number sensitivity to placementabs_delta_tilt_per_deg: the same average over the tilt sensitivities, per degree[ncoil_set]abs_delta_rim_per_mm: that tilt sensitivity expressed as rim displacement atmajor_radius_m, per millimetre[ncoil_set]— the unit mechanical tolerances usually arrive incancelling_shift_m: the in-plane shift(Δx, Δy)that cancelsdelta_as_designed, metres[2 × ncoil_set], seecancelling_offsetcancelling_tilt_deg: the in-plane tilt(θx, θy)that cancelsdelta_as_designed, degrees[2 × ncoil_set]
GeneralizedPerturbedEquilibrium.ErrorFields.ThresholdScaling — Type
ThresholdScalingOne fit of the ITPA error-field penetration threshold, δ_thresh = 10^α_c · n_e^α_n · B_T^α_B · R_0^α_R · (β_N/l_i)^α_β · I_p^α_I, with n_e in 10¹⁹ m⁻³, B_T in tesla, R_0 in metres and I_p in MA. Each exponent carries the fit's standard error. Only the 2026 fits have a current term; the 2020 fits carry α_I = (0, 0).
Fields
n: toroidal mode number of the scalingyear: publication year of the fit,2020or2026; the two years fit different databasesdataset: plasma dataset the fit was made on ("O,L"ohmic and L-mode,"O,L,H"with H-modes, ...)fit: fitting method ("OLS","DSOLS"downsampled,"WLS"weighted)alpha_c,alpha_n,alpha_b,alpha_r,alpha_beta,alpha_ip:(value, standard error)of each exponent
GeneralizedPerturbedEquilibrium.ErrorFields.ToleranceScan — Type
ToleranceScanField names follow the ErrorFields result grammar <quantity>[_instance][_efc][_statistic][_unit] (see the manual's "Result names"); every field name is also its HDF5 dataset name.
Locking risk against a multiplier of every shift and tilt tolerance, from repeated Monte Carlos on the same sensitivities. Percentages throughout.
Fields
tolerance_scale: tolerance multipliers[nscale]locking_probability_percent,locking_probability_efc_percent: locking probability at each scale, batch averageslocking_probability_spread_percent,locking_probability_efc_spread_percent: range of the batch values at each scalelocking_probability_as_designed_percent: risk of the as-designed machine (independent of the scale)
GeneralizedPerturbedEquilibrium.ErrorFields.ToleranceScan — Method
ToleranceScan(h5path::AbstractString)Read a run's tolerance scan back from ErrorFields/Risk/ToleranceScan/.
GeneralizedPerturbedEquilibrium.ErrorFields.ToleranceSet — Type
ToleranceSetEverything a tolerance TOML file specifies, parsed and validated by read_tolerance_toml.
Fields
coils: independently moving coil sets[ncoil]groups: coherently moving groups[ngroup]uncorrectable_coils: coil set names whose error field the correction system cannot reduceefc_factor: divisor applied to the correctable contributions when error-field correction is onother_field: the unattributed budgetraw: the file's text, echoed into the output for replay
GeneralizedPerturbedEquilibrium.ErrorFields.UniformArea — Type
UniformArea <: RadialDistributionUniform over the disk area (p = 1/2): every patch of the tolerance disk is equally likely.
GeneralizedPerturbedEquilibrium.ErrorFields._rigidly_perturbed — Method
_rigidly_perturbed(cs, kind, axis, h, pivot) -> CoilSetThe coil set moved rigidly by h along one degree of freedom: kind = :shift translates every conductor by h metres along axis (x, y, z); kind = :tilt rotates every conductor by h degrees about axis through pivot, or about its own arc-length centre when pivot === nothing. Both go through apply_transforms with the toroidal modulation that makes the motion rigid (n_tilt = 0 for the shift, n_tilt = 1 for the tilt).
GeneralizedPerturbedEquilibrium.ErrorFields._set_center — Method
_set_center(cs::CoilSet) -> (x0, y0, z0)Arc-length-weighted centre of the whole coil set, over every conductor and strand: the pivot of a rigid tilt of a multi-filament winding pack.
GeneralizedPerturbedEquilibrium.ErrorFields.allowable_tolerance — Method
allowable_tolerance(scan::ToleranceScan, target_percent; corrected=false) -> Float64The tolerance multiplier at which the locking risk reaches target_percent, by linear interpolation in the logarithms of both the scale and the risk between the two scan points that bracket the target (the scan need not be monotonic; the first bracketing pair from the smallest scale is used). A pair that starts at scale 0 is interpolated linearly in the scale. Returns NaN when no pair brackets the target. corrected reads the error-field-corrected curve.
GeneralizedPerturbedEquilibrium.ErrorFields.applied_spectrum — Method
applied_spectrum(cs::CoilSet, rc::ResonantCoupling, grids) -> Vector{ComplexF64}The root-area-weighted control-surface field b̃ that one coil set drives, on rc's (m, n) column ordering: Biot-Savart on each grid of grids, Fourier decomposition, then the conform through rootarea_field.
GeneralizedPerturbedEquilibrium.ErrorFields.apply_current_factors — Method
apply_current_factors(table::SensitivityTable, ts::ToleranceSet) -> SensitivityTableThe table with every coil set's as-designed overlap and sensitivities multiplied by its current_factor from the tolerance file. The spectrum is linear in current, so the nominal overlap, the worst-case bound and every sampled overlap scale together; the cancelling offsets do not change, since they are ratios. Returns the table itself when every factor is 1.
GeneralizedPerturbedEquilibrium.ErrorFields.cancelling_offset — Method
cancelling_offset(δ_as_designed, S_x, S_y) -> (Δx, Δy)The real in-plane displacement that cancels a coil set's nominal overlap to linear order, S_x·Δx + S_y·Δy = −δ_as_designed, as the least-squares solution of the 2×2 real system on the real and imaginary parts. For an axisymmetric hoop (S_y = −i·S_x) the solution is conj(−δ_as_designed / S_x); dropping the conjugate mirrors the offset about the x axis. A degenerate pair returns the minimum-norm solution.
GeneralizedPerturbedEquilibrium.ErrorFields.check_excluded_tolerances — Method
check_excluded_tolerances(ts::ToleranceSet, excluded) -> tsThrow if a tolerance, a coherent-group member or an uncorrectable-coil entry names a coil set the run excludes from its error field: a correction array is not an error-field source, so a tolerance on it has nothing to act on.
GeneralizedPerturbedEquilibrium.ErrorFields.coil_overlaps — Method
coil_overlaps(ctx::ResonantDriveContext, coil_sets; mode=1) -> Vector{CoilOverlap}
coil_overlaps(h5path, coil_sets; mode=1, kwargs...) -> Vector{CoilOverlap}Resonant overlap of each coil set against a finished run, evaluated on the run's own control surface. coil_sets is any geometry, not necessarily the run's; no solve is repeated. The h5path method takes ResonantDriveContext's keywords and lives in Rerun.jl. For sensitivities to rigid motion as well, use compute_coil_sensitivities.
GeneralizedPerturbedEquilibrium.ErrorFields.combine_overlaps — Method
combine_overlaps(overlaps, "A" => 20.0, "B" => -15.0; name="combined") -> CoilOverlapCoherent sum of several coil sets' spectra at relative weights, re-derived into the same CoilOverlap. An unmatched coil name is an error.
Weights multiply each spectrum as it was evaluated, not absolute currents: evaluate every conductor at 1 kA and weight by the design current in kA to make the weights read as currents.
GeneralizedPerturbedEquilibrium.ErrorFields.compute_coil_sensitivities — Function
compute_coil_sensitivities(coil_sets, rc, equil, cfg, ctrl=ErrorFieldsControl(); psi, b_t0, verbose=false) -> CoilSensitivitiesLinearize the control-surface spectrum of every coil set in coil_sets with respect to its six rigid-body degrees of freedom, by central differences of the Biot-Savart spectrum on the surface psi (the solve's integration limit, ffs.psilim) sampled once per toroidal mode of rc. The nominal spectrum is evaluated too. Tilt taps rotate about the pivot named by ctrl.rotation_center, in degrees; b_t0 is the axis toroidal field (tesla) for the δ normalization. Errors on a set carrying no current.
Spectra are on rc's (m, n) ordering, conformed with rootarea_field, so coupling_overlap applies directly.
GeneralizedPerturbedEquilibrium.ErrorFields.compute_coil_sensitivities — Function
compute_coil_sensitivities(ctx::ResonantDriveContext, coil_sets, ctrl=ErrorFieldsControl(); verbose=false) -> CoilSensitivitiesSweep coil_sets against an already-assembled ResonantDriveContext, reusing its boundary grids. Equivalent to the five-argument method and the way to apply a grid or ψ-window override.
GeneralizedPerturbedEquilibrium.ErrorFields.correction_current — Method
correction_current(δ_ef, c::EFCCoupling; delta_threshold, torque_budget, safety_factor=1.0, ntv=true,
model=:auto, rotation_exponent=1.0, omega_reference=c.omega_reference) -> Float64Correction current, kAt, that brings an intrinsic overlap δ_ef down to safety_factor × delta_threshold. Without NTV (ntv = false) that is the linear (δ_ef − s·δ_thresh) / C_c, zero when no correction is needed. With NTV the residual torque lowers the threshold by threshold_factor: for the :torque_balance model (the default when the coupling carries a rotation scan) the current is the root of δ_ef − C_c·I − s·δ_thresh·(1 + Δω(I)/ω_ref)^α; for :linear it is the smaller root of the closed-form quadratic, provided the residual torque has not exhausted the budget there. NaN when no such root exists, i.e. the overlap is beyond max_correctable_overlap. The returned current is the lower edge of the correctable window; correction_current_upper gives the upper edge, past which the over-correction is itself above threshold.
GeneralizedPerturbedEquilibrium.ErrorFields.correction_current_upper — Method
correction_current_upper(δ_ef, c::EFCCoupling; delta_threshold, torque_budget, safety_factor=1.0, ntv=true,
model=:auto, rotation_exponent=1.0, omega_reference=c.omega_reference) -> Float64Upper edge of the correctable current window, kAt: the current past which the over-correction C_c·I − δ_ef is itself above safety_factor × delta_threshold, so the field locks again from the other side. Without NTV it is (δ_ef + s·δ_thresh) / C_c. For the :linear model it is the larger root of the same quadratic, capped at I_max; for :torque_balance it is the root of C_c·I − δ_ef − s·δ_thresh·(1 + Δω(I)/ω_ref)^α above the null, or the current at which the balance fails if that comes first. NaN whenever correction_current is NaN.
GeneralizedPerturbedEquilibrium.ErrorFields.correction_requirement — Method
correction_requirement(ctx, source::CoilOverlap, arrays) -> CorrectionRequirement
correction_requirement(h5path, source_name, array_names; mode=1, coil_sets=nothing, kwargs...) -> CorrectionRequirementThe currents a set of arrays needs to correct one error field, and what is left: each array's solo dominant-mode factor, the minimum-current dominant-mode solution, and the joint least-squares factors that minimize the resonant field C·(b̃_source + Σ_k f_k b̃_k) over every rational surface, with the resonant field left after each. Every input is a CoilOverlap, so any geometry can be a source or an array. The h5path form takes names among the run's coil sets (or coil_sets when given) and evaluates them on the run's control surface. See uncorrectable_probability for the NTV-limited counterpart.
GeneralizedPerturbedEquilibrium.ErrorFields.disk_radius — Method
disk_radius(rng, R, p) -> Float64A radius drawn in [0, R] with density exponent p (see RadialDistribution): R·rand()^p, with sqrt/cbrt/identity fast paths for the common exponents.
GeneralizedPerturbedEquilibrium.ErrorFields.efc_couplings — Method
efc_couplings(resp, coil_sets, rc, dom, cfg, kf_ctrl; mode=1, method="fgar", rotation_scan=true, scan_points=9,
scan_max_points=21, scan_tolerance=0.05, span_factor=1.0, offset_factor=2.0,
regularization_width=0.0, verbose=false) -> Vector{EFCCoupling}The couplings of each correction coil array in coil_sets per kilo-ampere-turn: its dominant-mode overlap and resonant fraction from its spectrum on the control surface, and its NTV torque (kinetic method method, with sign) for the whole field and for the field with mode mode of dom projected out, tabulated against the rotation shift when rotation_scan. cfg is the run's [ForcingTerms] coil configuration and rc must be the coupling of resp; the torque uses the kinetic profiles attached to resp.ffs.equil, summed over the resolved species when the run has several or kf_ctrl.electron; the reference rotation is the main ion's. The spectrum is normalized by |nw| × max|I|, keeping the array's winding sense and current pattern as the phase reference.
GeneralizedPerturbedEquilibrium.ErrorFields.efc_current_curve — Method
efc_current_curve(c::EFCCoupling; delta_threshold, torque_budget, safety_factor=1.0, delta_max=15, npoints=500,
model=:auto, rotation_exponent=1.0, omega_reference=c.omega_reference,
torque_rtol=0.0, budget_rtol=0.0) -> NamedTupleThe correction current against the intrinsic overlap from 0 to delta_max × delta_threshold: current_linear (no NTV), current_ntv and current_ntv_upper (the two edges of the correctable window under the model), the threshold_factor along the lower edge, the resolved model, and the limits of max_correctable_overlap spliced in (with_ntv, residual_only, torque_only). Nonzero torque_rtol and budget_rtol (fractional uncertainties of the torque coefficients and of T_0) add current_ntv_pessimistic/current_ntv_optimistic and limits_pessimistic/limits_optimistic: scaling the torques by 1 ± torque_rtol is the same as scaling the budget by its inverse, since both models depend on T/T_0 only.
GeneralizedPerturbedEquilibrium.ErrorFields.error_fields — Method
error_fields(resp, coil_sets, coil_config; ctrl=ErrorFieldsControl(), tolerances=nothing,
monte_carlo=MonteCarloControl(), scenario=nothing, risk=RiskControl(), ntv=NTVControl(),
kinetic=KineticForcesControl(), regularization_width=0.0, verbose=false) -> ErrorFieldsResultAssess the error field of coil_sets on the plasma response resp: the coil sensitivities always; the tolerance Monte Carlo when tolerances (a ToleranceSet) is given; the locking risk when a scenario (a ScenarioParameters) is given too; and the couplings of the correction arrays named in ntv.efc_coils, whose NTV torque uses the kinetic settings and the perturbed-equilibrium regularization_width. coil_config sets the boundary grid the coil spectra are evaluated on. The coil sets in ctrl.exclude_coils and ntv.efc_coils are left out of the error field. Call save_to_hdf5(target, ef) to save the result.
resp = plasma_response(ffs)
ef = error_fields(resp, coil_sets, ForcingTerms.CoilConfig(ft_ctrl); tolerances=read_tolerance_toml("tolerances.toml"))GeneralizedPerturbedEquilibrium.ErrorFields.excluded_coil_names — Method
excluded_coil_names(ef_raw::AbstractDict) -> Vector{String}
excluded_coil_names(h5path::AbstractString) -> Vector{String}The coil sets a run leaves out of its error field: [ErrorFields] exclude_coils together with the correction arrays in [ErrorFields.NTV] efc_coils, read from the parsed [ErrorFields] section of a deck or from the deck recorded in a run file (none when the file carries no deck).
GeneralizedPerturbedEquilibrium.ErrorFields.extreme_phasing — Method
extreme_phasing(map::PhasingMap; quantity=:delta_per_kat, which=:max) -> (value, phases_deg)The largest (or smallest) value of a map and the relative phases, in degrees, where it occurs.
GeneralizedPerturbedEquilibrium.ErrorFields.fitted_threshold — Method
fitted_threshold(sc::ThresholdScaling, scen::ScenarioParameters) -> Float64The penetration threshold at the fitted exponents.
GeneralizedPerturbedEquilibrium.ErrorFields.forcing_grids — Method
forcing_grids(rc::ResonantCoupling, equil, cfg::CoilConfig; psi) -> Vector{Tuple{Int,CoilForcingGrid}}One boundary sampling per toroidal mode of rc, on the surface psi. The grids depend only on the equilibrium and grid dimensions, so they are built once and shared by every coil set.
GeneralizedPerturbedEquilibrium.ErrorFields.group_tilt_deg — Method
group_tilt_deg(g::CoherentGroupTolerance, set_of) -> Float64The rigid rotation angle, in degrees, that a coherent group's tilt tolerance stands for.
A tilt in metres is a rim displacement and names one angle only if the members share a major radius (or tilt_lever_arm_m is set); errors when their radii differ by more than 1%. Declare such a group in degrees.
GeneralizedPerturbedEquilibrium.ErrorFields.has_rotation_scan — Method
has_rotation_scan(c::EFCCoupling) -> BoolWhether the coupling carries a torque-versus-rotation table (more than the nominal point and a finite reference rotation).
GeneralizedPerturbedEquilibrium.ErrorFields.linearity_check — Method
linearity_check(ctx, coil_sets, tolerances; scales=(1.0, 2.0), mode=1, ctrl=ErrorFieldsControl()) -> LinearityCheck
linearity_check(h5path; scales=(1.0, 2.0), mode=1, psi_low=0.0, psi_high=CORE_PSI_HIGH, ctrl=ErrorFieldsControl(), kwargs...) -> LinearityCheckCompare the linear overlap model of sensitivity_table with the overlap recomputed for finite displacements: each toleranced coil set is shifted and tilted in-plane by ±scale × tolerance (a cylinder coil's tilt range is atan(shift_tol / half_height)), and each coherent group is shifted and rigidly rotated about its pivot. Include the largest scale a tolerance scan will use. Costs one Biot–Savart pass per row. The file form rebuilds its inputs from gpec.h5.
GeneralizedPerturbedEquilibrium.ErrorFields.locking_risk — Method
locking_risk(h5path; n_e, psi_low=0.0, psi_high=CORE_PSI_HIGH, mode=1, risk_ctrl=RiskControl(), kwargs...) -> RiskResultPost-hoc locking risk from a run: the Monte Carlo is re-run from the file for the given window and mode with MonteCarloControl kwargs, the threshold fit is chosen by risk_ctrl for the run's toroidal mode number, and the scenario is the run's equilibrium at density n_e.
GeneralizedPerturbedEquilibrium.ErrorFields.locking_risk — Method
locking_risk(mc::MonteCarloResult, sc::ThresholdScaling, scen::ScenarioParameters; ctrl=RiskControl()) -> RiskResult
locking_risk(mc, thresholds::AbstractVector, sc, scen) -> RiskResultConvolve an overlap distribution with the threshold distribution: P(lock|δ) is the fraction of sampled thresholds below δ, and the locking probability is 100 ∫ pdf(δ) P(lock|δ) dδ over the Monte Carlo's bins, evaluated per batch. Thresholds are sampled with ctrl or passed in.
GeneralizedPerturbedEquilibrium.ErrorFields.max_correctable_overlap — Method
max_correctable_overlap(c::EFCCoupling; delta_threshold, torque_budget, safety_factor=1.0, model=:auto,
rotation_exponent=1.0, omega_reference=c.omega_reference) -> (; with_ntv, residual_only, torque_only)The largest intrinsic overlap the array can correct. with_ntv: the overlap beyond which correction_current has no root (for the :linear model in closed form: the quadratic's tangency s·δ_thresh + C_c² T_0 / (4 s δ_thresh T_residual), or C_c √(T_0 / T_residual) when the residual torque exhausts the budget before that; for :torque_balance by bisection). residual_only: the overlap cancelled by the current at which the residual torque alone brings the rotation to rest (C_c √(T_0 / T_residual) for :linear), the zero-rotation limit of Logan et al. (2026) Eq. (7); it coincides with with_ntv whenever the quadratic's vertex lies outside the rotating range. torque_only: the overlap cancelled by the current at which the whole field's torque alone exhausts the budget (C_c √(T_0 / T_full)) or, with the balance, brings the reference rotation to rest or breaks the balance. Inf when there is no limit inside the model's reach.
GeneralizedPerturbedEquilibrium.ErrorFields.needed_current_distribution — Method
needed_current_distribution(mc::MonteCarloResult, array::CoilOverlap) -> NamedTupleThe Monte Carlo's intrinsic |δ| histogram re-expressed as the current on array that cancels each sampled overlap's dominant mode: as the factor |δ| / |δ_array| on the array's current as given, fields current_factor_bin_edges and current_factor_pdf (density per unit factor, integrating to one), and in kilo-ampere-turns through the array's ampere_turns_kat, fields current_bin_edges_kat and current_pdf_per_kat (NaN when the ampere-turns are unknown).
GeneralizedPerturbedEquilibrium.ErrorFields.ntv_torque_state — Method
ntv_torque_state(kf_intr, kf_ctrl, equil, kinetic_profiles, species, Δω; axis_psi_c=0.0) -> KineticForcesStateThe NTV torque of the perturbation held by kf_intr with the E×B rotation rigidly shifted by Δω (rad/s): the main ion on kinetic_profiles when species is nothing, otherwise the sum over the resolved species (KineticForces.ntv_species), each on its own shifted profiles. Δω = 0 uses the profiles unshifted.
GeneralizedPerturbedEquilibrium.ErrorFields.phasing_map — Method
phasing_map(sens::CoilSensitivities, dom::DominantCoupling, coil_names; mode=1, nphase=180) -> PhasingMap
phasing_map(h5path, coil_names; psi_low=0.0, psi_high=CORE_PSI_HIGH, mode=1, nphase=180) -> PhasingMapScan the relative phases of the current patterns of the named coil arrays and evaluate, at each grid point, the dominant-mode overlap per kilo-ampere-turn and the resonant fraction of the applied field. Rotating a current pattern by Δφ multiplies the spectrum by e^{iΔφ} (the phase of the pattern itself, n times the toroidal angle it is rotated through). nphase points per phase axis, spanning [0, 360) degrees.
Each array's spectrum is normalized by the magnitude of its ampere-turns, |winding_multiplier| × peak_current, so the zero of each phase axis is the array's current pattern exactly as the run specified it, winding sign included.
GeneralizedPerturbedEquilibrium.ErrorFields.radial_distribution — Method
radial_distribution(name::AbstractString) -> RadialDistributionThe distribution named by a tolerance file's radial_shape: "flat", "uniform_area", "hollow", or "ring" (the RADIAL_SHAPES the parser accepts).
GeneralizedPerturbedEquilibrium.ErrorFields.randpow — Method
randpow(d::RadialDistribution) -> Float64The exponent p in r = R·u^p of a radial distribution.
GeneralizedPerturbedEquilibrium.ErrorFields.read_efc_couplings — Method
read_efc_couplings(h5path::AbstractString) -> Vector{EFCCoupling}Read a run's correction-coil couplings back from ErrorFields/NTV/, with their torque-versus-rotation tables when the run made them.
GeneralizedPerturbedEquilibrium.ErrorFields.read_tolerance_snapshot — Method
read_tolerance_snapshot(h5path) -> ToleranceSetThe tolerance set a run used, parsed from the raw echo in its gpec.h5; nothing when the run named no tolerance file.
GeneralizedPerturbedEquilibrium.ErrorFields.read_tolerance_toml — Method
read_tolerance_toml(path) -> ToleranceSet
parse_tolerance_toml(text) -> ToleranceSetRead and validate a tolerance TOML file (see the module docstring for the schema). Every key is checked against the schema so a misspelled key errors instead of silently taking a default; tolerances must be non-negative, names unique, enumerated fields one of their allowed values, efc_factor ≥ 1, a cylinder model needs a positive half-height, a current_factor must be finite and a tilt_lever_arm_m positive. Names are checked against the run's coil sets separately by validate_tolerances.
GeneralizedPerturbedEquilibrium.ErrorFields.regrid — Method
regrid(cfg::CoilConfig; mtheta_coil=nothing, nzeta_coil=nothing, dat_dir=nothing) -> CoilConfigcfg with the boundary resolution or geometry directory replaced. Each keyword left as nothing keeps the value cfg already carries.
GeneralizedPerturbedEquilibrium.ErrorFields.residual_spectrum — Method
residual_spectrum(dom::DominantCoupling, b̃; mode=1) -> Vector{ComplexF64}The applied root-area-weighted spectrum with singular mode mode projected out, b̃ − V_k (V_kᴴ b̃): what a perfect single-mode correction leaves behind.
GeneralizedPerturbedEquilibrium.ErrorFields.resonant_fraction_percent — Method
resonant_fraction_percent(raw, nrm, nrm_ref) -> Float64100·|raw| / nrm, the share of a coil set's applied field b̃ (norm nrm) that lies along the dominant mode (raw = Vᴴb̃), or NaN when nrm is below 1e-8 × nrm_ref (the largest norm among the coil sets judged together) or below 1e-12 T, where the field is round-off (e.g. an axisymmetric hoop at n = 1) and the ratio is meaningless.
GeneralizedPerturbedEquilibrium.ErrorFields.risk_convergence — Method
risk_convergence(table, tolerances, coil_sets, sc, scen; nsamples, nbins_list, ctrl=MonteCarloControl(), risk_ctrl=RiskControl()) -> NamedTupleThe locking probability and its batch spread against the Monte Carlo's sample count and bin count, to check a quoted risk is free of sampling and binning bias. Each sweep holds the other control at ctrl's value and reuses one threshold sample. Fields: nsample, locking_probability_percent_by_nsample, locking_probability_spread_percent_by_nsample, nbins, locking_probability_percent_by_nbins, locking_probability_spread_percent_by_nbins.
GeneralizedPerturbedEquilibrium.ErrorFields.rotation_scan_span — Method
rotation_scan_span(omega_e, omega_star_T; span_factor=1.0, offset_factor=2.0) -> (; span, offset_estimate)Half-width of the symmetric rotation-shift scan, span_factor × max(|ω_E|, offset_factor·|ω_*T|), from the E×B and ion temperature-gradient diamagnetic frequencies at the innermost kinetic surface, and the signed rough offset offset_factor·ω_*T it was sized against.
GeneralizedPerturbedEquilibrium.ErrorFields.rotation_shift — Method
rotation_shift(c::EFCCoupling, current; torque_budget, omega_reference=c.omega_reference, field=:residual) -> Float64Steady rotation shift Δω (rad/s) of the zero-dimensional torque balance Δω·T_0/ω_ref = T(Δω)·I² under current kAt of the array, on the branch continuous from the unshifted state: the first root met walking from Δω = 0 in the direction the torque pushes. NaN when no root lies inside the scanned span, which is the rotation bifurcating away (or a span that was too small; the scan settings say which). torque_budget is T_0, N·m; the reference rotation may be overridden, e.g. by the rotation at the dominant rational surface.
GeneralizedPerturbedEquilibrium.ErrorFields.run_monte_carlo — Function
run_monte_carlo(table, tolerances, coil_sets, ctrl=MonteCarloControl()) -> MonteCarloResult
run_monte_carlo(h5path; psi_low=0.0, psi_high=CORE_PSI_HIGH, mode=1, kwargs...) -> MonteCarloResultSample every coil set's misalignment within its tolerance and histogram the dominant-mode overlap. Per sample and coil set c with sensitivities S = (S_x, S_y) per metre and T = (T_x, T_y) per degree,
δ = Σ_c [δ_as_designed,c + S_c·(Δ_c + u_c) + T_c·(θ_c + v_c)] + Σ_g [S_g·(Δ_g + Δ_rot) + T_g·θ_g] + δ_otherwhere (Δ_c, θ_c) is the coil's own draw (additive: independent shift and tilt disks; cylinder: sample_cylinder), u_c, v_c its Gaussian placement uncertainties, (Δ_g, θ_g) one draw shared by every member of coherent group g (groups with equal phase_group share the direction), Δ_rot = −(z_m − z_pivot)·(θy_g + iθx_g) the lateral shift a rigid rotation of the group about its pivot (in the sense apply_transforms uses) gives a member at height z_m, and δ_other the unattributed budget with a random direction. S·Δ means S_x·real(Δ) + S_y·imag(Δ). The corrected histogram divides every correctable term (coils and groups not listed as uncorrectable, and the unattributed budget) by efc_factor.
coil_sets supply the major radii for tilt tolerances given in metres and the heights of group members; coil sets without a tolerance block contribute their nominal overlap only. The file form rebuilds the inputs from gpec.h5; kwargs are MonteCarloControl fields.
GeneralizedPerturbedEquilibrium.ErrorFields.sample_additive — Method
sample_additive(rng, R_shift, p_shift, R_tilt, p_tilt; phase_shift, phase_tilt) -> (shift, tilt)The additive tolerance model: an in-plane shift drawn in the disk of radius R_shift metres and, independently, a tilt drawn in the disk of radius R_tilt degrees, each with its own radial exponent and an optional shared direction. Returns (Δx + iΔy, θx + iθy).
GeneralizedPerturbedEquilibrium.ErrorFields.sample_cylinder — Method
sample_cylinder(rng, R, z_top, p; phase_top, phase_bot) -> (shift, tilt)The cylinder tolerance model: the coil's axis line must lie inside a cylinder of radius R metres and half-height z_top metres centred on the coil. Its two endpoints are drawn independently in the top and bottom disks (radial exponent p, optional fixed directions); the coil then sits at the axis's midplane crossing and is tilted by the axis's lean:
shift = (p_top + p_bot) / 2 # metres, Δx + iΔy
α = atan(|p_top − p_bot|, 2 z_top) # lean angle
tilt = −α · (sin φ_d + i cos φ_d) in degrees, φ_d = arg(p_top − p_bot)Shift and tilt are therefore correlated, and the tilt magnitude never exceeds atan(R / z_top). The tilt is expressed as the rotation angles (θx, θy) about the machine axes that lean the axis top toward the direction φ_d, in the sense apply_transforms uses: a positive θx leans the top toward −y and a positive θy toward −x.
Unlike the OMFIT tool's version, this works in physical units with independent endpoint directions, so it agrees with that tool only in kind.
GeneralizedPerturbedEquilibrium.ErrorFields.sample_disk — Method
sample_disk(rng, R, p; phase=2π·rand(rng)) -> ComplexF64
sample_disk(rng, R, d::RadialDistribution; phase) -> ComplexF64A point in the disk of radius R, as Δx + iΔy: radius from disk_radius and a uniform direction unless phase is given (coherent groups sharing a direction pass one phase and draw their own radii).
GeneralizedPerturbedEquilibrium.ErrorFields.sample_uncertainty — Method
sample_uncertainty(rng, σ; phase=2π·rand(rng)) -> ComplexF64The Gaussian uncertainty on where a coil actually sits, added to the tolerance draw: a signed normal amplitude of standard deviation σ times a uniform direction, σ·randn()·e^{iφ} — the OMFIT tool's construction, whose magnitude is a half-normal rather than the Rayleigh a two-dimensional Gaussian would give. Zero σ returns zero without consuming random numbers.
GeneralizedPerturbedEquilibrium.ErrorFields.scaling_label — Method
scaling_label(sc::ThresholdScaling) -> StringThe fit's key in ITPA_THRESHOLD_SCALINGS, "n=<n> <year> <dataset> <fit>".
GeneralizedPerturbedEquilibrium.ErrorFields.scaling_toroidal_mode — Method
scaling_toroidal_mode(h5path) -> IntThe toroidal mode number whose ITPA threshold scaling applies to a run; errors on a multi-n run (see single_toroidal_mode).
GeneralizedPerturbedEquilibrium.ErrorFields.sensitivity_table — Method
sensitivity_table(sens::CoilSensitivities, dom::DominantCoupling; mode=1) -> SensitivityTable
sensitivity_table(h5path; psi_low=CORE_PSI_LOW, psi_high=CORE_PSI_HIGH, mode=1) -> SensitivityTableProject a coil linearization onto singular mode mode of dom and normalize by the axis toroidal field: δ = dot(V[:, mode], b̃) / B_T0 for the nominal spectrum and each derivative, the dimensionless overlap and its sensitivities per coil set. The window and mode are analysis choices, so re-evaluate freely on the same sens; the file form rebuilds the coupling from gpec.h5, windows it to psi_low ≤ ψ_N ≤ psi_high, and reads the stored linearization.
GeneralizedPerturbedEquilibrium.ErrorFields.single_toroidal_mode — Method
single_toroidal_mode(nlow, nhigh; where="the run") -> nlowThe one toroidal mode number a locking-threshold scaling is fitted for, or an ArgumentError when the run spans several.
GeneralizedPerturbedEquilibrium.ErrorFields.threshold_factor — Method
threshold_factor(c::EFCCoupling, current; torque_budget, rotation_exponent=1.0, omega_reference=c.omega_reference,
model=:torque_balance, field=:residual) -> Float64Factor by which the penetration threshold is reduced under current kAt: (1 + Δω/ω_ref)^α with the balance's rotation shift for model = :torque_balance (NaN past the bifurcation or once the rotation is brought to rest), or 1 − |T|·I²/T_0 for model = :linear; field selects the residual (default) or the whole field's torque.
GeneralizedPerturbedEquilibrium.ErrorFields.threshold_samples — Method
threshold_samples(rng, sc, scen; nsample=1_000_000, dist="normal") -> Vector{Float64}Thresholds with the exponents drawn around their fitted values: "normal" (Gaussian with the standard error), "flat" (uniform within one standard error), or "normal_truncated" (Gaussian, redrawn beyond 1.5 standard errors). The current exponent is drawn only for fits that have one, so the other fits' sample streams do not depend on it.
GeneralizedPerturbedEquilibrium.ErrorFields.threshold_scaling — Method
threshold_scaling(; n=1, year=2020, dataset="O,L", fit="WLS") -> ThresholdScalingLook up a published ITPA fit by toroidal mode number, publication year, dataset and fitting method; the available keys are those of ITPA_THRESHOLD_SCALINGS.
GeneralizedPerturbedEquilibrium.ErrorFields.tilt_tolerance_deg — Method
tilt_tolerance_deg(tilt, tilt_units, cs::CoilSet) -> Float64
tilt_tolerance_deg(tilt, tilt_units, r_nom::Real; name="the coil set") -> Float64
tilt_tolerance_deg(t::CoilTolerance, cs::CoilSet) -> Float64A tilt tolerance in the degrees the stored sensitivities use. "deg" passes through; "m" is a rim displacement converted through the coil set's arc-length-weighted major radius exactly as apply_transforms converts tilt_in_meters: asin(t / R_nom). The radius form takes that radius directly, as a run stores it in ErrorFields/CoilSensitivities/major_radius_m, for readers that have the file but not the geometry.
GeneralizedPerturbedEquilibrium.ErrorFields.tolerance_scan — Method
tolerance_scan(table, ts, coil_sets, mc_ctrl, sc, scen; scales, risk_ctrl=RiskControl()) -> ToleranceScan
tolerance_scan(h5path; scales, psi_low=0.0, psi_high=CORE_PSI_HIGH, mode=1, n_e, risk_ctrl=RiskControl(), kwargs...) -> ToleranceScanRun the Monte Carlo once per tolerance multiplier in scales and evaluate the locking risk of each with one threshold sampling. The file form takes the run's tolerances, coil geometry and equilibrium scalars from gpec.h5; kwargs are MonteCarloControl fields, and the threshold fit is chosen with risk_ctrl.
GeneralizedPerturbedEquilibrium.ErrorFields.torque_at — Method
torque_at(c::EFCCoupling, Δω; field=:residual) -> Float64The tabulated torque, N·m per kAt², at rotation shift Δω from a cubic spline through the scan points; NaN outside the scanned span. Without a scan the nominal torque, for any shift.
GeneralizedPerturbedEquilibrium.ErrorFields.torque_zero_crossings — Method
torque_zero_crossings(c::EFCCoupling; field=:residual) -> Vector{Float64}Rotation shifts at which the tabulated torque changes sign: each sign change between scan points is bracketed and the zero of the cubic spline found inside it. These are the neoclassical offsets of this field, as found rather than estimated.
GeneralizedPerturbedEquilibrium.ErrorFields.uncorrectable_probability — Method
uncorrectable_probability(mc::MonteCarloResult, c::EFCCoupling; delta_threshold, torque_budget, safety_factor=1.0, model=:auto, rotation_exponent=1.0) -> NamedTupleHow often the sampled machine's overlap exceeds what the array can correct: the fraction of the Monte Carlo's intrinsic |δ| beyond max_correctable_overlap's with_ntv limit for the array, as a percentage. The explicit-correction counterpart of the corrected locking probability's efc_factor model. Fields abs_delta_max_correctable, probability_percent, and the model resolved.
GeneralizedPerturbedEquilibrium.ErrorFields.update — Method
update(x; field=value, ...) -> x′A copy of a ToleranceSet, CoilTolerance, CoherentGroupTolerance or OtherFieldBudget with the named fields replaced, for programmatic scans over quantities the TOML fixes: a coil's current_factor or shift_sigma_m, the unattributed magnitude, a group's tilt_lever_arm_m. Unknown fields and an efc_factor below 1 are errors. The copy of a set carries an empty raw text, since the echoed file no longer describes it.
ts2 = update(ts; coils=[c.name == "F6A" ? update(c; current_factor=0.5) : c for c in ts.coils])
ts3 = update(ts; other_field=update(ts.other_field; magnitude=2e-5))GeneralizedPerturbedEquilibrium.ErrorFields.validate_tolerances — Method
validate_tolerances(ts::ToleranceSet, coil_names) -> tsCheck every coil, group member, and uncorrectable-coil name of ts against the coil set names of a run (for instance CoilSensitivities.coil_names), throwing an ArgumentError that lists the unknown names. Coil sets of the run that carry no tolerance are allowed: they contribute only their nominal overlap.
GeneralizedPerturbedEquilibrium.ErrorFields.without_coils — Method
without_coils(table::SensitivityTable, names) -> SensitivityTableThe table with the named coil sets (e.g. correction arrays) dropped, leaving the error-field sources the Monte Carlo, worst case and scans use. Every name must be in the table.
GeneralizedPerturbedEquilibrium.ErrorFields.worst_case_terms — Method
worst_case_terms(table, tolerances, coil_sets; tolerance_scale=1.0) -> NamedTuple
worst_case_terms(h5path; psi_low=0.0, psi_high=CORE_PSI_HIGH, mode=1, tolerance_scale=1.0) -> NamedTupleThe worst-case alignment bound abs_delta_worst_case of run_monte_carlo split into the terms that make it up, so the tolerance budget can be read coil by coil. Per coil set: abs_delta_as_designed is |δ_as_designed|, abs_delta_shift_tolerance is max(|S_x|, |S_y|)·(shift_tol + 3σ_shift) and abs_delta_tilt_tolerance is max(|T_x|, |T_y|)·(tilt_reach + 3σ_tilt), where tilt_reach is the tilt tolerance in degrees or, under the cylinder model, the angle the axis line can reach, atan(shift_tol / half_height). Per coherent group (group_names): abs_delta_group_shift_tolerance and abs_delta_group_tilt_tolerance, the latter including the lateral displacement a rigid rotation gives each member. abs_delta_unattributed is the unattributed budget at magnitude + 3σ. abs_delta_worst_case is the sum of every term. Every coil set is counted (no coil_subset); tolerance_scale, scale_subset, scale_map and current_factor apply as in the Monte Carlo.
GeneralizedPerturbedEquilibrium.ErrorFields.write_tolerance_snapshot! — Method
write_tolerance_snapshot!(h5file, ts::ToleranceSet)Echo the tolerance file's text into Input/RawInputs/ErrorFields/tolerance_toml_raw, the raw input snapshot a replay reads back with read_tolerance_snapshot. Replaces an existing echo.
GeneralizedPerturbedEquilibrium.Utilities.save_to_hdf5 — Method
save_to_hdf5(target, ef::ErrorFieldsResult)Write every product of the error-field assessment: the coil sensitivities with their dominant-mode projections, the tolerance set echoed into Input/RawInputs/, and the Monte Carlo, locking risk and correction-coil couplings when they were computed.
GeneralizedPerturbedEquilibrium.Utilities.save_to_hdf5 — Method
save_to_hdf5(h5file::Union{HDF5.File,HDF5.Group}, sens::CoilSensitivities; dom::DominantCoupling)Write the coil linearization to ErrorFields/CoilSensitivities/ — the spectra and their derivatives, plus a DominantMode/ summary projected onto mode 1 of dom (the run's full-window decomposition). An existing group is replaced. The mode labels are the file's Info/mn_index and the field normalization its Equilibrium/B_T_axis, neither duplicated here.
GeneralizedPerturbedEquilibrium.Utilities.save_to_hdf5 — Method
save_to_hdf5(h5file::Union{HDF5.File,HDF5.Group}, mc::MonteCarloResult)Write the tolerance Monte Carlo histograms to ErrorFields/MonteCarlo/. The sampling settings (nsample, nbatch, seed) live in the run's [ErrorFields.MonteCarlo] table under Input/gpec_toml_raw; the tolerances in Input/RawInputs/ErrorFields/tolerance_toml_raw. An existing group is replaced.
GeneralizedPerturbedEquilibrium.Utilities.save_to_hdf5 — Method
save_to_hdf5(h5file::Union{HDF5.File,HDF5.Group}, risk::RiskResult; scan=nothing)Write the locking risk to ErrorFields/Risk/, with the tolerance scan under ErrorFields/Risk/ToleranceScan/ when given. The threshold fit, scenario and sampling settings live in the run's [ErrorFields.Risk] and [ErrorFields.scenario] tables under Input/gpec_toml_raw. An existing group is replaced.
GeneralizedPerturbedEquilibrium.Utilities.save_to_hdf5 — Method
save_to_hdf5(h5file::Union{HDF5.File,HDF5.Group}, couplings::Vector{EFCCoupling})Write the correction-coil couplings to ErrorFields/NTV/, and the torque-versus-rotation tables of the arrays that have one to ErrorFields/NTV/RotationScan/ (one column per array, shorter scans NaN-padded). The torque budget, threshold, rotation exponent and safety factor that turn them into a correction-current curve are analysis choices left to efc_current_curve. An existing group is replaced.
GeneralizedPerturbedEquilibrium.equilibrium_from_h5 — Function
equilibrium_from_h5(h5path) -> (; equil, inputs, psilim)Restore the processed PlasmaEquilibrium from the profile and geometry arrays saved in gpec.h5, using the native spline constructors without retracing flux surfaces. inputs is the stored TOML and psilim the original control surface (Info/psilim), so post-hoc analyses use one consistent frozen equilibrium and the surface described by the stored response matrices.