Formula reference: green

This page is generated from the docstrings of vaft/formula/green.py: 16 public functions. The category overview and notation come from the module docstring; every entry below is what vaft.formula.describe("green.<name>") prints. Back to the formula reference index.

Overview

This module provides functions for calculating various Green’s function integrals used in plasma physics calculations.

SymbolMeaningUnit
GGreen's function-
Kcomplete elliptic integral of first kind-
Ecomplete elliptic integral of second kind-

Functions

  • calculate_distance — Euclidean distance between $(r_1, z_1)$ and $(r_2, z_2)$ in the poloidal plane.
  • complete_elliptic_integral_e — Complete elliptic integral of the second kind $E(m)$.
  • complete_elliptic_integral_k — 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 — Field of a unit-current ring, $(B_r, B_z)$ at observer points (legacy elliptic path).
  • green_br_bz_exact — $(B_r, B_z)$ per unit ring current, exact elliptic integrals, broadcasting.
  • green_psi_exact — Poloidal flux per unit ring current, exact elliptic integrals.
  • green_r — Poloidal flux per unit ring current at observer points (legacy elliptic path).
  • greens_function_2d — 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 — 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.

calculate_distance

calculate_distance(r1, r2, z1, z2)

Euclidean distance between $(r_1, z_1)$ and $(r_2, z_2)$ in the poloidal plane.

\[d = \sqrt{(r_2 - r_1)^2 + (z_2 - z_1)^2}\]
ParameterTypeUnitDescription
r1float or np.ndarraym

Radius of the first point(s).

r2float or np.ndarraym

Radius of the second point(s).

z1float or np.ndarraym

Height of the first point(s).

z2float or np.ndarraym

Height of the second point(s).

ReturnsTypeUnitDescription
float or np.ndarraym

Distance, broadcast over the inputs.

Notes.

A distance in the $(R, Z)$ half-plane, not the 3-D distance between points on two current loops.

complete_elliptic_integral_e

complete_elliptic_integral_e(m)

Convention-sensitive.

Complete elliptic integral of the second kind $E(m)$.

\[E(m) = \int_0^{\pi/2}\sqrt{1 - m\sin^2\theta}\,d\theta\]
ParameterTypeUnitDescription
mfloat or np.ndarray-

Parameter $m = k^2$, in $[0, 1]$.

ReturnsTypeUnitDescription
float or np.ndarray-

$E(m)$, from $\pi/2$ at $m = 0$ to 1 at $m = 1$.

Convention.

Takes the parameter $m = k^2$, as scipy.special.ellipe does.

References.

  1. NIST Digital Library of Mathematical Functions, Sec. 19.2(ii), https://dlmf.nist.gov/19.2.
  2. M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, Dover (1972), Sec. 17.3.

complete_elliptic_integral_k

complete_elliptic_integral_k(m)

Convention-sensitive.

Complete elliptic integral of the first kind $K(m)$.

\[K(m) = \int_0^{\pi/2}\frac{d\theta}{\sqrt{1 - m\sin^2\theta}}\]
ParameterTypeUnitDescription
mfloat or np.ndarray-

Parameter $m = k^2$, in $[0, 1)$.

ReturnsTypeUnitDescription
float or np.ndarray-

$K(m)$.

Convention.

Takes the parameter $m = k^2$, as scipy.special.ellipk does, not the modulus $k$; $K \to \infty$ logarithmically as $m \to 1$.

References.

  1. NIST Digital Library of Mathematical Functions, Sec. 19.2(ii), https://dlmf.nist.gov/19.2.
  2. M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, Dover (1972), Sec. 17.3.

elliptic_integral

elliptic_integral(r_obs, z_obs, r_src, z_src)

Polynomial approximations of $K$ and $E$ for a ring source and observer points.

\[m = \frac{4r_{obs}r_{src}}{(r_{obs} + r_{src})^2 + (z_{obs} - z_{src})^2}, \qquad m_1 = 1 - m\]

then the Hastings polynomials $K \approx \sum a_km_1^k + \ln(1/m_1)\sum b_km_1^k$ and $E \approx \sum c_km_1^k + \ln(1/m_1)\sum d_km_1^k$ to fourth order.

ParameterTypeUnitDescription
r_obsnp.ndarraym

Radius of the observation points.

z_obsnp.ndarraym

Height of the observation points.

r_srcfloatm

Radius of the ring source.

z_srcfloatm

Height of the ring source.

ReturnsTypeUnitDescription
eknp.ndarray-

Approximate $K(m)$.

eenp.ndarray-

Approximate $E(m)$.

Validity.

Abramowitz and Stegun 17.3.34 and 17.3.36, absolute error below $2\times10^{-8}$ for $0 \le m < 1$; the legacy path of green_r and green_br_bz, retained so their numbers do not change.

Limitations.

$\ln(1/m_1)$ diverges at a coincident observer and source and a warning is emitted with a bare print rather than warnings.warn (tracked in #356); greens_function_exact uses scipy’s exact integrals instead.

References.

  1. M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, Dover (1972), Eqs. 17.3.34 and 17.3.36.
  2. C. Hastings, Approximations for Digital Computers, Princeton University Press (1955).

green_br_bz

green_br_bz(r_obs, z_obs, r_src, z_src)

Convention-sensitive.

Field of a unit-current ring, $(B_r, B_z)$ at observer points (legacy elliptic path).

\[B_r = \frac{\mu_0}{2\pi r}\,\frac{z - z_0}{\sqrt{(r + r_0)^2 + (z - z_0)^2}} \left[\frac{r^2 + r_0^2 + (z - z_0)^2}{(r - r_0)^2 + (z - z_0)^2}E - K\right], \quad B_z = \frac{\mu_0}{2\pi}\,\frac{1}{\sqrt{(r + r_0)^2 + (z - z_0)^2}} \left[K - \frac{r^2 - r_0^2 + (z - z_0)^2}{(r - r_0)^2 + (z - z_0)^2}E\right]\]
ParameterTypeUnitDescription
r_obsnp.ndarraym

Radius of the observation points.

z_obsnp.ndarraym

Height of the observation points.

r_srcfloatm

Radius of the current ring.

z_srcfloatm

Height of the current ring.

ReturnsTypeUnitDescription
brnp.ndarrayT/A

Radial field per ampere.

bznp.ndarrayT/A

Vertical field per ampere.

Convention.

Right-handed $(r, \varphi, z)$ with the current flowing in $+\varphi$; $B_z$ is positive inside the ring. SI throughout; no $2\pi$ flux ambiguity arises for fields. Uses the approximate elliptic_integral; the exact, broadcasting counterpart is green_br_bz_exact.

Limitations.

Divides by $(r - r_0)^2 + (z - z_0)^2$ and by $r_{obs}$ without guards, so a coincident point or an on-axis observer gives inf/nan (the callers’ shifted-evaluation scheme avoids exact coincidence). Tracked in #356.

References.

  1. W. R. Smythe, Static and Dynamic Electricity, 3rd ed., McGraw-Hill (1968), Sec. 7.10 (field of a circular loop).
  2. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5.

green_br_bz_exact

green_br_bz_exact(r_obs, z_obs, r_src, z_src)

Convention-sensitive.

$(B_r, B_z)$ per unit ring current, exact elliptic integrals, broadcasting.

\[B_r = -\frac{\mu_0}{2\pi r}\,\frac{\partial G}{\partial z}, \qquad B_z = +\frac{\mu_0}{2\pi r}\,\frac{\partial G}{\partial r}\]
ParameterTypeUnitDescription
r_obsarray-likem

Observation major radius.

z_obsarray-likem

Observation height.

r_srcarray-likem

Source major radius.

z_srcarray-likem

Source height.

ReturnsTypeUnitDescription
brnp.ndarrayT/A

Radial field per ampere.

bznp.ndarrayT/A

Vertical field per ampere.

Convention.

Right-handed $(r, \varphi, z)$, current in $+\varphi$; consistent with green_psi_exact through $B_z = (1/r)\,\partial\psi/\partial r \times 1/2\pi$ for a full-weber $\psi$.

Limitations.

Observation points on the geometric axis ($r_{obs} = 0$) return the analytic limits $B_r = 0$, $B_z = \mu_0 r_0^2/(2(r_0^2 + (z - z_0)^2)^{3/2})$; the coincident-point caveat of greens_function_exact applies.

References.

  1. W. R. Smythe, Static and Dynamic Electricity, 3rd ed., McGraw-Hill (1968), Sec. 7.10.

green_psi_exact

green_psi_exact(r_obs, z_obs, r_src, z_src)

Convention-sensitive.

Poloidal flux per unit ring current, exact elliptic integrals.

\[\psi = \mu_0\,G(r, z; r_0, z_0)\]

with $G$ from greens_function_exact.

ParameterTypeUnitDescription
r_obsarray-likem

Observation major radius.

z_obsarray-likem

Observation height.

r_srcarray-likem

Source major radius.

z_srcarray-likem

Source height.

ReturnsTypeUnitDescription
np.ndarrayWb/A

Flux per ampere, broadcast over observation and source arrays.

Convention.

Full weber, the IMAS Data Dictionary storage (COCOS 11-18), same as green_r. The per-radian flux of an EFIT g-file or of vaft.formula.equilibrium.poloidal_field_factor with cocos=None is this divided by $2\pi$; mixing the two silently mis-scales fields by $2\pi$. Tracked in #354.

References.

  1. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5.

green_r

green_r(r_obs, z_obs, r_src, z_src)

Convention-sensitive.

Poloidal flux per unit ring current at observer points (legacy elliptic path).

\[\psi = 2\mu_0\,\frac{\sqrt{r r_0}}{k}\left[\left(1 - \frac{k^2}{2}\right)K - E\right], \qquad k^2 = \frac{4rr_0}{(r + r_0)^2 + (z - z_0)^2}\]
ParameterTypeUnitDescription
r_obsnp.ndarraym

Radius of the observation points.

z_obsnp.ndarraym

Height of the observation points.

r_srcfloatm

Radius of the current ring.

z_srcfloatm

Height of the current ring.

ReturnsTypeUnitDescription
np.ndarrayWb/A

Flux per ampere at each observation point.

Convention.

Full weber ($\psi = \mu_0 G$, identical to green_psi_exact up to the elliptic-integral approximation); divide by $2\pi$ before combining with the per-radian equilibrium helpers. Tracked in #354.

Limitations.

Uses the Hastings polynomials of elliptic_integral; returns 0 on the axis ($r_{obs} = 0$ or $r_{src} = 0$) and clips $k^2$ into $[0, 1]$.

References.

  1. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5, Eq. (5.37).

greens_function_2d

greens_function_2d(R, Z, R0, Z0)

Convention-sensitive.

Axisymmetric kernel $\sqrt{RR_0}\,K(m)$ between a field point and a ring source.

\[G_{2D} = \sqrt{R R_0}\;K(m), \qquad m = \frac{4RR_0}{(R + R_0)^2 + (Z - Z_0)^2}\]
ParameterTypeUnitDescription
Rnp.ndarraym

Major radius of the field points.

Znp.ndarraym

Height of the field points.

R0floatm

Major radius of the ring source.

Z0floatm

Height of the ring source.

ReturnsTypeUnitDescription
np.ndarraym

Kernel value at each field point.

Convention.

This is the leading term of the ring-current flux function, not the flux Green’s function itself: the poloidal flux per unit current is $\mu_0\sqrt{RR_0}\,[(2 - m)K(m) - 2E(m)]/\sqrt{m}$ (greens_function_exact, green_psi_exact). Use those for any physical field; this kernel is kept for the legacy integrals below.

Limitations.

Diverges logarithmically at the source point; no guard.

References.

  1. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5 (vector potential of a circular loop).

greens_function_3d

greens_function_3d(R, Z, phi, R0, Z0, phi0)

Toroidal-angle-resolved variant of the $\sqrt{RR_0}\,K(m)$ kernel.

\[G_{3D} = \sqrt{R R_0}\;K(m), \qquad m = \frac{4RR_0}{(R + R_0)^2 + (Z - Z_0)^2 + 4RR_0\sin^2\!\big(\tfrac{\varphi - \varphi_0}{2}\big)}\]
ParameterTypeUnitDescription
Rnp.ndarraym

Major radius of the field points.

Znp.ndarraym

Height of the field points.

phinp.ndarrayrad

Toroidal angle of the field points.

R0floatm

Major radius of the source.

Z0floatm

Height of the source.

phi0floatrad

Toroidal angle of the source.

ReturnsTypeUnitDescription
np.ndarraym

Kernel value at each field point.

Limitations.

The $\sin^2$ term augments the denominator with the 3-D chord between the two toroidal angles, but the resulting expression is a heuristic generalisation of greens_function_2d without a recorded derivation or source; it is not the Biot-Savart kernel of a point source. Tracked in #356.

References.

  1. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5.

greens_function_exact

greens_function_exact(r, z, r0, z0, mode='psi')

Convention-sensitive.

Exact free-space axisymmetric Green’s function and its derivatives.

\[G(r, z; r_0, z_0) = \frac{\sqrt{rr_0}}{k}\left[(2 - k^2)K(k^2) - 2E(k^2)\right], \qquad k^2 = m = \frac{4rr_0}{(r + r_0)^2 + (z - z_0)^2}\]

so that $\psi = \mu_0 I\,G$ is the poloidal flux of a ring current $I$; mode selects $G$, $\partial G/\partial r$, $\partial G/\partial z$, $\partial^2G/\partial r\partial z$, $\partial^2G/\partial r^2$, or the raw $K$ and $E$.

ParameterTypeUnitDescription
rarray-likem

Observation major radius.

zarray-likem

Observation height.

r0array-likem

Source major radius.

z0array-likem

Source height.

modestr, optionalstr

One of GREEN_EXACT_MODES; default "psi".

ReturnsTypeUnitDescription
np.ndarrayany

Requested quantity, broadcast over all four coordinates. $G$ is in m, its derivatives in m per m, $K$ and $E$ dimensionless.

Raises.

ValueError Unknown mode or coordinates giving $m$ outside $[0, 1]$.

Convention.

Full weber: $\psi = \mu_0 G$ per ampere (same as green_r), and $B_z = +\mu_0/(2\pi r)\,\partial G/\partial r$, $B_r = -\mu_0/(2\pi r)\, \partial G/\partial z$. The equilibrium helpers assume flux per radian by default, so divide by $2\pi$ (or pass cocos) before feeding this flux to vaft.formula.equilibrium.vertical_magnetic_field_from_psi.

Limitations.

Points with $rr_0 = 0$ return their analytic limits (0 for every mode except d2psi_dr2, whose on-axis limit is $\pi r_0^2/(r_0^2 + (z - z_0)^2)^{3/2}$). The elliptic parameter is clamped just below 1, so a coincident observer and source return finite numbers, but those are artifacts of the clamp, not physical limits (the ideal-filament self term diverges): handle genuinely coincident pairs yourself, e.g. with self_inductance or a shifted-evaluation scheme such as compute_br_bz_phi.

Numerical notes.

scipy.special.ellipk/ellipe on the parameter $m$; every $1/k$, $1/m$ and $1/r$ is guarded and overwritten on axis. The d2psi_dr2 branch corrects a sign error in the legacy VFIT getGreenFunction.m case 7 ($-2(r + r_0)A$, from $d(1/D)/dr = -D’/D^2$) and is validated against finite differences of dpsi_dr.

References.

  1. J. D. Jackson, Classical Electrodynamics, 3rd ed., Wiley (1999), Sec. 5.5, Eq. (5.37).
  2. Legacy VFIT getGreenFunction.m (modes 1-7), the reference algorithm.

greens_integral_2d

greens_integral_2d(R, Z, R0, Z0, f)

Line integral along $R$ of the 2-D kernel times a source density.

\[I = \int G_{2D}(R, Z; R_0, Z_0)\,f(R)\,dR\]
ParameterTypeUnitDescription
Rnp.ndarraym

Major radius of the samples, monotonic.

Znp.ndarraym

Height of the samples.

R0floatm

Major radius of the source.

Z0floatm

Height of the source.

fnp.ndarrayany

Source density at the samples.

ReturnsTypeUnitDescription
floatany

Integral in units of f times m^2.

Limitations.

Integrates along the single supplied R array (a line, not an area) with the kernel of greens_function_2d; not a flux or field.

Numerical notes.

Trapezoidal rule.

greens_integral_3d

greens_integral_3d(R, Z, phi, R0, Z0, phi0, f)

Line integral along $R$ of the 3-D kernel times a source density.

\[I = \int G_{3D}(R, Z, \varphi; R_0, Z_0, \varphi_0)\,f(R)\,dR\]
ParameterTypeUnitDescription
Rnp.ndarraym

Major radius of the samples, monotonic.

Znp.ndarraym

Height of the samples.

phinp.ndarrayrad

Toroidal angle of the samples.

R0floatm

Major radius of the source.

Z0floatm

Height of the source.

phi0floatrad

Toroidal angle of the source.

fnp.ndarrayany

Source density at the samples.

ReturnsTypeUnitDescription
floatany

Integral in units of f times m^2.

Limitations.

Same caveats as greens_integral_2d and greens_function_3d.

Numerical notes.

Trapezoidal rule along R only.

mutual_inductance

mutual_inductance(r1, z1, dr1, dz1, r2, z2, dr2, dz2, *, tilt1=0.0, tilt2=0.0, turns1=1.0, turns2=1.0, mu_r=1.0, n_div=5)

Mutual inductance between two rectangular-cross-section ring coils.

\[M = N_1N_2\,\mu_r\mu_0\,\big\langle G(r_i, z_i; r_j, z_j)\big\rangle_{i \in 1,\ j \in 2}\]

the Neumann formula evaluated as the mean flux linkage between midpoint filaments laid over each cross-section.

ParameterTypeUnitDescription
r1floatm

Centre radius of coil 1.

z1floatm

Centre height of coil 1.

dr1floatm

Radial width of coil 1; 0 degenerates to a filament.

dz1floatm

Height of coil 1; 0 degenerates to a filament.

r2floatm

Centre radius of coil 2.

z2floatm

Centre height of coil 2.

dr2floatm

Radial width of coil 2.

dz2floatm

Height of coil 2.

tilt1float, optionalrad

Tilt of cross-section 1 about its centre; default 0.

tilt2float, optionalrad

Tilt of cross-section 2; default 0.

turns1float, optional-

Turns of coil 1; default 1.

turns2float, optional-

Turns of coil 2; default 1.

mu_rfloat, optional-

Relative permeability of the medium, e.g. 1.04 for SUS304; default 1.

n_divint, optional-

Subdivision refinement; default 5. The cell size is half the pair’s characteristic scale over n_div.

ReturnsTypeUnitDescription
floatH

Mutual inductance.

Assumptions.

Axisymmetric coils with uniform current density over the cross-section; the toroidal curvature correction $r \to r\,(1 + (\cos\theta\,\Delta r/r)^2/24)$ is applied to each cell.

Numerical notes.

Midpoint rule over both cross-sections (reference: legacy VFIT getMutualInductanceCoil.m). The cell size uses the $z$-separation $\sqrt{(r_1 + r_2)^2 + (z_1 - z_2)^2}$; the legacy code used $z_1 + z_2$, which is not invariant under a rigid vertical translation. Legacy material codes are intentionally not reproduced: pass mu_r explicitly.

References.

  1. W. R. Smythe, Static and Dynamic Electricity, 3rd ed., McGraw-Hill (1968), Sec. 8.06 (mutual inductance of coaxial circles).
  2. Legacy VFIT getMutualInductanceCoil.m.

self_inductance

self_inductance(r, dr, dz, *, tilt=0.0, turns=1.0, mu_r=1.0, n_div=5)

Self-inductance of a rectangular-cross-section ring coil.

\[L = \frac{N^2}{n^2}\left[\sum_{i \ne j}\mu_r\mu_0\,G(r_i, z_i; r_j, z_j) + \sum_i \mu_r\mu_0\,r_i\left(\ln\frac{8r_i}{s} - \frac{7}{4}\right)\right], \qquad s = \sqrt{\Delta r\,\Delta z/\pi}\]

midpoint subdivision into $n$ cells with the analytic self-term of a circular filament of equivalent radius $s$ on the diagonal.

ParameterTypeUnitDescription
rfloatm

Centre radius, positive.

drfloatm

Radial width, positive.

dzfloatm

Height, positive.

tiltfloat, optionalrad

Tilt of the cross-section; default 0.

turnsfloat, optional-

Number of turns; default 1.

mu_rfloat, optional-

Relative permeability; default 1.

n_divint, optional-

Cells per centre radius; default 5.

ReturnsTypeUnitDescription
floatH

Self-inductance.

Raises.

ValueError For non-positive r, dr or dz.

Assumptions.

Uniform current density; the self-cell term is the low-frequency inductance of a thin ring of wire radius $s$ (internal inductance included, hence $7/4$ rather than 2).

Numerical notes.

Reference: legacy VFIT getSelfInductanceCoil.m; nz is forced even. Convergence in n_div is first order because of the self-cell approximation.

References.

  1. W. R. Smythe, Static and Dynamic Electricity, 3rd ed., McGraw-Hill (1968), Sec. 8.10 (self-inductance of a circular ring).
  2. Legacy VFIT getSelfInductanceCoil.m.

trapz_integral

trapz_integral(x, y)

Trapezoidal integral $\int y\,dx$, local copy for the Green kernels.

\[\int y\,dx \approx \sum_i \frac{y_i + y_{i+1}}{2}\,(x_{i+1} - x_i)\]
ParameterTypeUnitDescription
xnp.ndarrayany

Sample abscissae, monotonic.

ynp.ndarrayany

Integrand at the samples.

ReturnsTypeUnitDescription
floatany

Integral over the sampled range, in units of y times x.

Numerical notes.

Identical to vaft.formula.utils.trapz_integral (numpy.trapezoid via vaft.compat.trapz_compat) but defined here so the Green’s function module does not import the sklearn-heavy utilities; this copy is the one vaft.formula.trapz_integral resolves to.

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 ""