essos.fields¶
Classes¶
VMEC equilibrium from a wout file. |
|
Sum of several magnetic fields, traced as one. |
Functions¶
|
|
|
|
|
|
|
|
|
Interpolate every Fourier mode of a wout table at |
Module Contents¶
- class essos.fields.MagneticField¶
- abstractmethod sqrtg(points)¶
- abstractmethod B(points)¶
- B_covariant(points)¶
- B_contravariant(points)¶
- AbsB(points)¶
- dB_by_dX(points)¶
- dAbsB_by_dX(points)¶
- grad_B_covariant(points)¶
- curl_B(points)¶
- curl_b(points)¶
- kappa(points)¶
- gc_quantities(points)¶
Field quantities of the guiding-center equations at one point.
Returns
(B_covariant, B_contravariant, |B|, grad|B|, curl b, kappa, sqrtg). This generic version calls the individual methods; fields that can form all of them from one evaluation of B and its gradient (seeBiotSavart) override it.
- abstractmethod to_xyz(points)¶
- class essos.fields.BiotSavart(coils)¶
Bases:
MagneticField- coils¶
- _r_axis = None¶
- _z_axis = None¶
- property dofs¶
- sqrtg(points)¶
- gc_quantities(points)¶
Guiding-center field quantities from one pass over the coils.
The separate methods each rebuild B and its Jacobian (
kappaeven recomputescurl_b). Here a single forward-mode Jacobian yields B and dB/dX together, and in Cartesian coordinates (sqrtg = 1) grad|B| = (dB/dX)^T b, curl b = curl B/|B| + B x grad|B|/|B|^2 and kappa = -B x curl b / |B| follow algebraically.
- B(points)¶
- b_cyl(R, phi, Z)¶
Return
(B_R, B_phi, B_Z)on broadcast cylindrical arrays.This field-provider interface lets VMEC/NESTOR evaluate ESSOS coils directly on a changing plasma boundary without writing an mgrid file. It uses the same traceable Biot–Savart graph as
B(), so coil shape and current derivatives are retained.
- property r_axis¶
- property z_axis¶
- to_xyz(points)¶
- _tree_flatten()¶
- classmethod _tree_unflatten(aux_data, children)¶
- essos.fields.d_dtheta_fft(f_theta)¶
- essos.fields.d2_dtheta2_fft(f_theta)¶
- essos.fields.gamma_dash_from_gamma(gamma)¶
- essos.fields.gamma_dashdash_from_gamma(gamma)¶
- class essos.fields.BiotSavart_from_gamma(gamma, gamma_dash=None, gamma_dashdash=None, currents=None)¶
Bases:
MagneticField- currents = None¶
- gamma¶
- _gamma_dash = None¶
- _gamma_dashdash = None¶
- _coils_length = None¶
- _coils_curvature = None¶
- _r_axis = None¶
- _z_axis = None¶
- property gamma_dash¶
- property gamma_dashdash¶
- property coils_length¶
- property coils_curvature¶
- property r_axis¶
- property z_axis¶
- sqrtg(points)¶
- B(points)¶
- to_xyz(points)¶
- essos.fields._radial_interp(s, grid, table, xm, covariant_s=False, half_grid=False, axis_m1=None)¶
Interpolate every Fourier mode of a wout table at
s.tableis on the full grid, or on the half grid with VMEC’s unused first row (half_grid=True); both grids are uniform. Near the magnetic axis the modes of a regular scalar vanish ass**(m/2), and those of B_s (covariant_s=True) one power ofsqrt(s)lower. Each mode is therefore divided bys**p, interpolated linearly and multiplied back, withp = min(m, 2 + m % 2) / 2(less 1 for B_s, at least -1/2; 0 for m = 0). For m > 0 the axis row of a full-grid table is replaced by the extrapolation of the next two rows, or, for m = 1, byaxis_m1when it is given. Interpolating the modes themselves leaves the m > 0 terms finite on the axis, where |B| then depends on theta.
- class essos.fields.Vmec(wout_filename, ntheta=50, nphi=50, close=True, range_torus='full torus', mode_tolerance=0.0)¶
VMEC equilibrium from a wout file.
mode_tolerancedrops a Fourier mode when, in every table of its set, its largest amplitude over the radial grid is below that fraction of the table’s largest: R and Z for the geometry modes, and |B|, sqrt(g) and the B components for the Nyquist modes. Evaluation cost scales with the number of modes kept.- wout_filename¶
- nc¶
- nfp¶
- bmnc¶
- xm¶
- xn¶
- rmnc¶
- zmns¶
- bsubsmns¶
- bsubumnc¶
- bsubvmnc¶
- bsupumnc¶
- bsupvmnc¶
- gmnc¶
- xm_nyq¶
- xn_nyq¶
- len_xm_nyq¶
- ns¶
- s_full_grid = None¶
- ds¶
- s_half_grid¶
- r_axis¶
- z_axis¶
- mpol¶
- ntor¶
- range_torus = 'full torus'¶
- _surface¶
- Aminor_p¶
- _drop_small_modes(tolerance)¶
- property surface¶
- _bsubs_axis_m1()¶
Axis limit of sqrt(s) B_s for the m = 1 modes, from B_theta.
Near the axis the leading m = 1 parts of B_s and B_theta are the gradient of sqrt(s) Psi(theta, phi), so sqrt(s) B_s tends to B_theta / (2 sqrt(s)) and their contributions to the toroidal current cancel. VMEC’s B_s next to the axis misses that limit (by about 10% on an HSX wout), and extrapolating it gave curl B a toroidal component that grew as 1/sqrt(s) on the axis.
- _NYQUIST¶
- _nyquist_series(points)¶
Each Nyquist table’s Fourier sum at
pointsand its (s, theta, phi) gradient.One set of angles, cosines, sines and radial weights serves every table and the gradients are analytic, so |B|, sqrt(g), the B components and their derivatives cost one evaluation between them when traced together, and curl b and the curvature need no automatic differentiation.
- B_covariant(points)¶
- B_contravariant(points)¶
- sqrtg(points)¶
- B(points)¶
- AbsB(points)¶
- dB_by_dX(points)¶
- dAbsB_by_dX(points)¶
- grad_B_covariant(points)¶
- curl_B(points)¶
- curl_b(points)¶
- kappa(points)¶
- to_xyz(points)¶
- class essos.fields.near_axis(*args, **kwargs)¶
- class essos.fields.CombinedField(*fields)¶
Bases:
MagneticFieldSum of several magnetic fields, traced as one.
The usual case is a coil field plus a plasma contribution:
BandB_contravariantadd over the fields, while the geometry helperssqrtgandto_xyzcome from the first field, which is the one that carries the coordinate system.- fields = ()¶
- B(points)¶
- B_contravariant(points)¶
- sqrtg(points)¶
- to_xyz(points)¶
- _tree_flatten()¶
- classmethod _tree_unflatten(aux_data, children)¶