Formula reference

vaft.formula is documented from a single source of truth: every public function carries a standardized docstring (summary, definition, units, convention, assumptions, validity, limitations, numerical notes, references), and these pages are generated from those docstrings by python -m vaft.formula.catalog. Nothing here is written by hand, so the site and vaft.formula.describe("<name>") always agree.

import vaft.formula as F

print(F.describe("greenwald_density"))          # one formula, rendered
F.search("Sauter")                              # every formula whose text mentions it
F.list_formulas(category="stability")           # imports only that submodule

The discovery layer is loaded on first use only; import vaft.formula.stability never touches it.

Categories

CategoryModuleFunctionsContents
constants vaft.formula.constants0Physical constants and the confinement-scaling coefficient table.
utils vaft.formula.utils9Utility functions for plasma physics calculations.
equilibrium vaft.formula.equilibrium96Plasma equilibrium, current, energy, and geometry calculations.
stability vaft.formula.stability19Plasma stability, operational limits, and transport calculations.
green vaft.formula.green16Green's function calculations for plasma physics.
atomic vaft.formula.atomic3Atomic equilibrium and line-radiation formulae backed by OPEN-ADAS ADF11.
statistics vaft.formula.statistics22Pure statistical kernels for residual and convergence diagnostics (issue #186).
magnetics vaft.formula.magnetics2Magnetic-probe geometry shared by every forward model.

Conventions that change the number

Every function whose result depends on a sign, normalisation, COCOS or unit choice carries a Convention section and is marked convention-sensitive on its page; empirical fits open their Validity section with Empirical fit. and name the dataset or publication. The recurring traps:

  • Poloidal flux, Wb versus Wb/rad. The equilibrium helpers default to flux per radian (COCOS 1-8, EFIT g-files, VFIT); the IMAS Data Dictionary and the Green’s functions use full weber (COCOS 11-18). poloidal_field_factor(cocos) carries both the $2\pi$ and the orientation sign; vaft.data.eqdsk.ods_psi_to_wb_per_radian_factor settles which family an ODS holds.
  • Engineering units. The confinement scalings, $n_G$, $\beta_N$ and the Verdoolaege dimensionless parameters are defined in MA, MW, $10^{19}$ m$^{-3}$ and percent; each page states what is converted internally and what is not.
  • Several definitions of one quantity. Three $\nu_$ and three $\rho_$ definitions coexist (tracked in #353); each page names its own.

Constants

Every physics submodule of vaft.formula takes its constants from here so that a value is changed in one place. The electromagnetic and particle constants are CODATA 2018 recommended values [1] (MU0 keeps the pre-2019 exact definition $4\pi\times10^{-7}$, which differs from the 2018 measured value by $5\times10^{-10}$ relative); E_ALPHA is the D-T alpha birth energy [2]. SIGMA_V_COEF, SPITZER_RESISTIVITY_COEF and COLLISIONALITY_COEF are fitted prefactors whose meaning is defined by the single function that uses each of them, documented there.

The private _SCALING_COEFS table holds the engineering-unit confinement scalings (ITER89P, IPB98(y,2), the two NSTX 2006 fits and the Kurskiev 2022 ST fit). Each entry carries its prefactor, exponents, target density definition, source reference and unit-convention notes; the table is read by vaft.formula.equilibrium.confinement_time_from_engineering_parameters, which documents the conventions and cites every entry.

NameMeaningUnit
MU0vacuum permeabilityH/m
EPS0vacuum permittivityF/m
QEelementary chargeC
MEelectron masskg
MI_Pproton masskg
E_ALPHAD-T alpha particle birth energy, 3.5 MeVJ
SIGMA_V_COEFprefactor of the rough D-T reactivity fit 1.1e-24 T_keV^2m^3/s/keV^2
SPITZER_RESISTIVITY_COEFprefactor of eta = 5.2e-5 Z_eff ln(Lambda) / T_eV^1.5Ohm m eV^1.5
COLLISIONALITY_COEFprefactor of the IPB98 nu_star = 6.921e-18 n_19 R / (T_keV^2 B_t) form-

Utils

Utility functions for plasma physics calculations. — 9 functions.

Equilibrium

Plasma equilibrium, current, energy, and geometry calculations. — 96 functions.

Stability

Plasma stability, operational limits, and transport calculations. — 19 functions.

Green

Green’s function calculations for plasma physics. — 16 functions.

  • calculate_distance — Euclidean distance between $(r_1, z_1)$ and $(r_2, z_2)$ in the poloidal plane.
  • complete_elliptic_integral_e (convention) — Complete elliptic integral of the second kind $E(m)$.
  • complete_elliptic_integral_k (convention) — Complete elliptic integral of the first kind $K(m)$.
  • elliptic_integral — Polynomial approximations of $K$ and $E$ for a ring source and observer points.
  • green_br_bz (convention) — Field of a unit-current ring, $(B_r, B_z)$ at observer points (legacy elliptic path).
  • green_br_bz_exact (convention) — $(B_r, B_z)$ per unit ring current, exact elliptic integrals, broadcasting.
  • green_psi_exact (convention) — Poloidal flux per unit ring current, exact elliptic integrals.
  • green_r (convention) — Poloidal flux per unit ring current at observer points (legacy elliptic path).
  • greens_function_2d (convention) — Axisymmetric kernel $\sqrt{RR_0}\,K(m)$ between a field point and a ring source.
  • greens_function_3d — Toroidal-angle-resolved variant of the $\sqrt{RR_0}\,K(m)$ kernel.
  • greens_function_exact (convention) — Exact free-space axisymmetric Green’s function and its derivatives.
  • greens_integral_2d — Line integral along $R$ of the 2-D kernel times a source density.
  • greens_integral_3d — Line integral along $R$ of the 3-D kernel times a source density.
  • mutual_inductance — Mutual inductance between two rectangular-cross-section ring coils.
  • self_inductance — Self-inductance of a rectangular-cross-section ring coil.
  • trapz_integral — Trapezoidal integral $\int y\,dx$, local copy for the Green kernels.

Atomic

Atomic equilibrium and line-radiation formulae backed by OPEN-ADAS ADF11. — 3 functions.

  • fractional_abundances (convention) — Ionisation-equilibrium (coronal) fractional abundances from ACD and SCD tables.
  • interpolate_adf11 (convention) — Interpolate every charge-state block of an ADF11 table at given $(n_e, T_e)$.
  • line_cooling_coefficient (convention) — Equilibrium line-radiation cooling coefficient $L_{line}(n_e, T_e)$ of a species.

Statistics

Pure statistical kernels for residual and convergence diagnostics (issue #186). — 22 functions.

  • bias_standard_error — Standard error of the mean of $n$ unit-variance samples, $1/\sqrt{n}$.
  • chi_squared — Chi-square, $\sum_i (r_i/\sigma_i)^2$ over the finite terms.
  • dynamic_range — Sample range, $\max - \min$ over the finite entries.
  • fractional_rms_improvement — Fractional RMS improvement, $1 - \mathrm{RMS}(r)/\mathrm{RMS}(r_0)$.
  • lag1_autocorrelation — Lag-1 autocorrelation of the finite entries, in the order given.
  • linear_trend — Least-squares slope of $y$ against $x$, in units of $y$ per unit $x$.
  • log10_decay_rate — Least-squares slope of $\log_{10}x$ against iteration index over the tail.
  • median_absolute_deviation
    Median absolute deviation, $\mathrm{median}( x - \mathrm{median}(x) )$.
  • monotonic_fraction — Fraction of consecutive steps in which the sequence decreased.
  • noise_band — Mean and population standard deviation of a reference (effect-free) sample.
  • normalized_residual — Residuals in units of the fitted uncertainty, $z = r\,w/k$.
  • outlier_fraction
    Fraction of finite entries with $ x_i > \mathrm{level}$.
  • pearson_correlation — Pearson correlation of two series over their pairwise-finite samples.
  • percentile_scale — A high percentile of |x| over the finite entries, an amplitude scale one anomalous sample cannot set.
  • reduced_chi_squared — Reduced chi-square, $\chi^2/\nu$ per degree of freedom.
  • relative_spread
    Relative spread, $(\max - \min)/\max x $ over the finite entries.
  • residual_bias — Mean of the finite entries, the systematic offset of a residual sample.
  • rms — Root mean square, $\sqrt{\mathrm{mean}(x_i^2)}$, over the finite entries.
  • robust_z_scores — Deviation from the median in robust sigma units, sample by sample.
  • runs_test_z — Wald-Wolfowitz runs-test z-score for the sign sequence of a sample.
  • sigma_threshold_crossing — First time outside the reference window where the signal leaves its noise band.
  • sigma_unit_factor — Recover the units-of-fit factor $k$ from a fit’s own per-channel chi-square.

Magnetics

Magnetic-probe geometry shared by every forward model. — 2 functions.

  • probe_axis — Direction cosines (c_R, c_Z) of a poloidal-field probe’s sensitive axis.
  • project_poloidal_field — The component of (B_R, B_Z) a probe oriented at poloidal_angle reads.

Refreshing this snapshot

From a checkout of the develop branch, run:

python -m vaft.formula.catalog --output /path/to/vaft-gh/_data/formula_catalog.yml

The snapshot records the SHA-256 of every vaft/formula/*.py source file; documentation validation compares them when VAFT_REGISTRY_SOURCE points to the corresponding source checkout. The same text is available offline as vaft.formula.describe("<name>"), vaft.formula.search("<text>") and vaft.formula.list_formulas(category="<category>").

results matching ""

    No results matching ""