![]() |
The Open FUSION Toolkit 26.6
An open-source framework for fusion and plasma science and engineering
|
GEQDSK equilibrium with flux-surface-averaged quantities.
Reads a standard g-file and lazily computes magnetic fields, flux-surface contours, averages, geometry, and inductance.
Public Member Functions | |
| __init__ (self, filename, cocos=1, nlevels=None, resample="theta", extrapolate_edge=True) | |
| Initialize GEQDSKEquilibrium by reading a g-file from disk. | |
| cocosify (self, cocos_out, copy=False) | |
| Convert the raw g-file data from the current COCOS to cocos_out. | |
| describe (self, verbose=False) | |
| Print a categorised summary of all available quantities. | |
| flip_Bt_Ip (self, copy=False) | |
| Reverse the signs of \(B_t\) and \(I_p\) in the raw g-file data. | |
| flux_integral (self, psi_N_val, profile) | |
| Total flux integral at a given \(\hat{\psi}\) value (scalar). | |
| from_bytes (cls, raw_bytes, cocos=1, nlevels=None, resample="theta", extrapolate_edge=True) | |
| Construct from in-memory bytes (e.g. | |
| from_raw (cls, raw_dict, cocos=1, nlevels=None, resample="theta", extrapolate_edge=True) | |
| Construct directly from a raw g-file dict (no file I/O). | |
| save (self, filename) | |
| Write the (possibly modified) g-file data to filename. | |
| surface_integral (self, what) | |
| Cross-section (area) integral of a quantity on the FSA grid. | |
| to_bytes (self) | |
| Serialise to in-memory bytes (round-trips with from_bytes). | |
| volume_integral (self, what) | |
| Volume integral of a quantity on the FSA grid. | |
Public Attributes | |
| averages = None | |
| All flux-surface-averaged quantities dict. | |
| B_center = None | |
| Vacuum toroidal field at R_center [T]. | |
| betas = None | |
| Plasma beta values (keys: beta_t, beta_p, beta_n). | |
| boundary_R = None | |
| R coordinates of the plasma boundary [m]. | |
| boundary_Z = None | |
| Z coordinates of the plasma boundary [m]. | |
| cocos = None | |
| Current COCOS convention index. | |
| contours = None | |
| List of (N,2) contour arrays for each \(\hat{\psi}\) level. | |
| ffprim = None | |
| \(F\,dF/d\psi\) on the raw psi_N grid (NW points) [T \(^2\) m \(^2\)/Wb] | |
| fpol = None | |
| \(F = R B_t\) poloidal current function, on the raw psi_N grid (NW points) [T m] | |
| geometry = None | |
| Per-surface geometric quantities dict. | |
| Ip = None | |
| Plasma current \(I_p\) [A]. | |
| j_tor_averaged = None | |
| Flux-surface-averaged toroidal current density \(\langle J_t/R\rangle / \langle 1/R\rangle\) [A/m \(^2\)]. | |
| j_tor_averaged_direct = None | |
| Direct flux-surface average \(\langle J_t\rangle\) from the Grad-Shafranov equation [A/m \(^2\)]. | |
| j_tor_averaged_numerical = None | |
| Numerically flux-surface-averaged \(\langle J_t\rangle\) via \(\nabla\times B / \mu_0\) [A/m \(^2\)]. | |
| j_tor_over_R = None | |
| \(\langle J_t/R\rangle\) from the Grad-Shafranov equation [A/m \(^3\)] | |
| keys = None | |
| Flat list of all available attribute names (scalars + profiles + derived). | |
| li = None | |
| Internal inductance dict (keys: li_from_definition, li(1), li(1)_EFIT, li(1)_TLUCE, li(2), li(3)). | |
| limiter_R = None | |
| R coordinates of the limiter [m]. | |
| limiter_Z = None | |
| Z coordinates of the limiter [m]. | |
| midplane = None | |
| Outboard midplane quantities on the \(\hat{\psi}\) grid (keys: R, Z, Br, Bz, Bp, Bt, Btot). | |
| pprime = None | |
| \(dP/d\psi\) on the raw psi_N grid (NW points) [Pa/Wb] | |
| pres = None | |
| Pressure profile on the raw psi_N grid (NW points) [Pa]. | |
| psi_axis = None | |
| Poloidal flux at the magnetic axis [Wb]. | |
| psi_boundary = None | |
| Poloidal flux at the last closed flux surface [Wb]. | |
| psi_N = None | |
| Normalised raw g-file \(\hat{\psi}\) grid for 1-D profiles (NW points). | |
| psi_N_levels = None | |
| Normalised \(\hat{\psi}\) levels used for flux-surface analysis (nlevels points). | |
| psi_N_RZ = None | |
| 2-D normalised poloidal flux \(\hat{\psi}(R,Z)\) on the (R,Z) grid | |
| psi_RZ = None | |
| 2-D poloidal flux array (NH x NW) [Wb] | |
| q_profile = None | |
| Safety factor from flux-surface averaging. | |
| qpsi = None | |
| Safety factor from the g-file, on the raw psi_N grid (NW points). | |
| R_center = None | |
| Reference geometric center R [m]. | |
| R_grid = None | |
| 1-D R grid [m] | |
| R_mag = None | |
| R of the magnetic axis [m]. | |
| rhovn = None | |
| Normalised toroidal flux coordinate \(\rho = \sqrt{\Phi_{\mathrm{tor}}/\Phi_{\mathrm{tor,edge}}}\). | |
| Z_grid = None | |
| 1-D Z grid [m] | |
| Z_mag = None | |
| Z of the magnetic axis [m]. | |
Protected Member Functions | |
| _compute_fields (self) | |
| Compute \(B_R\), \(B_Z\), \(J_t\) on the full (R,Z) grid. | |
| _copy_for_mutation (self) | |
| _trace_surfaces (self) | |
| Trace flux surfaces and compute all averaged quantities. | |
| _zz_doxygen_dummy (self) | |
| _zz_doxygen_dummy (self) | |
| _zz_doxygen_dummy (self) | |
Protected Attributes | |
| dict | _cache = {} |
| _cocos = _cocos_params(cocos) | |
| _cocos_index = int(cocos) | |
| _extrapolate_edge = bool(extrapolate_edge) | |
| _nlevels = nlevels if nlevels is not None else int(self._raw["NW"]) | |
| _raw = _read_geqdsk(filename) | |
| str | _resample_method = resample |
Static Protected Attributes | |
| list | _CATALOGUE |
| __init__ | ( | self, | |
| filename, | |||
| cocos = 1, | |||
| nlevels = None, | |||
| resample = "theta", | |||
| extrapolate_edge = True ) |
Initialize GEQDSKEquilibrium by reading a g-file from disk.
| filename | Path to the g-file |
| cocos | COCOS convention index (default 1, standard EFIT) |
| nlevels | Number of normalised- \(\psi\) levels for flux-surface analysis (defaults to NW from the g-file) |
| resample | Contour resampling method for near-separatrix surfaces ( \(\hat{\psi} \geq 0.99\)): "theta" or "arc_length" |
| extrapolate_edge | If True (default), extrapolate \(p'\) and \(FF'\) at the separatrix when the g-file has them forced to zero |
|
protected |
Compute \(B_R\), \(B_Z\), \(J_t\) on the full (R,Z) grid.
|
protected |
|
protected |
Trace flux surfaces and compute all averaged quantities.
|
protected |
|
protected |
|
protected |
| cocosify | ( | self, | |
| cocos_out, | |||
| copy = False ) |
Convert the raw g-file data from the current COCOS to cocos_out.
Applies the multiplicative sign / \(2\pi\) factors to every relevant field following Sauter & Medvedev, Comput. Phys. Commun. 184 (2013) 293, Eq. 14/23.
| cocos_out | Target COCOS convention index (1-8 or 11-18) |
| copy | If True, return a new GEQDSKEquilibrium with converted data, leaving this object unchanged. If False (default), convert in place and return self. |
| describe | ( | self, | |
| verbose = False ) |
Print a categorised summary of all available quantities.
Access any listed name as an attribute, e.g. eq.q_profile or eq.geometry['kappa']. Dict-valued entries (geometry, li, etc.) can be inspected with their .keys().
| verbose | If True, also triggers lazy evaluation of derived quantities so actual shapes and sample values are printed. If False (default), shape info is only printed for already-cached quantities to avoid an unexpected flux-surface trace. |
| flip_Bt_Ip | ( | self, | |
| copy = False ) |
Reverse the signs of \(B_t\) and \(I_p\) in the raw g-file data.
Negates BCENTR, FPOL, CURRENT, PSIRZ, SIMAG, SIBRY, PPRIME, and FFPRIM – equivalent to flipping the direction of both the toroidal field and the plasma current while keeping the COCOS index unchanged.
| copy | If True, return a new object; otherwise modify in place |
| flux_integral | ( | self, | |
| psi_N_val, | |||
| profile ) |
Total flux integral at a given \(\hat{\psi}\) value (scalar).
| psi_N_val | Normalised poloidal flux location (0 = axis, 1 = boundary) |
| profile | Array-like of length nlevels to integrate (sampled at self.psi_N_levels) |
| from_bytes | ( | cls, | |
| raw_bytes, | |||
| cocos = 1, | |||
| nlevels = None, | |||
| resample = "theta", | |||
| extrapolate_edge = True ) |
Construct from in-memory bytes (e.g.
from HDF5 storage)
| raw_bytes | Raw content of a g-file |
| cocos | COCOS convention index |
| nlevels | Number of \(\hat{\psi}\) levels |
| resample | Contour resampling method ("theta" or "arc_length") |
| extrapolate_edge | Extrapolate \(p'\) and \(FF'\) at separatrix when forced to zero |
| from_raw | ( | cls, | |
| raw_dict, | |||
| cocos = 1, | |||
| nlevels = None, | |||
| resample = "theta", | |||
| extrapolate_edge = True ) |
Construct directly from a raw g-file dict (no file I/O).
| raw_dict | Dict with standard GEQDSK keys (as returned by _read_geqdsk) |
| cocos | COCOS convention index |
| nlevels | Number of \(\hat{\psi}\) levels |
| resample | Contour resampling method ("theta" or "arc_length") |
| extrapolate_edge | Extrapolate \(p'\) and \(FF'\) at separatrix when forced to zero |
| save | ( | self, | |
| filename ) |
Write the (possibly modified) g-file data to filename.
| filename | Output path for the g-file |
| surface_integral | ( | self, | |
| what ) |
Cross-section (area) integral of a quantity on the FSA grid.
| what | Array-like of length nlevels, sampled at self.psi_N_levels |
| to_bytes | ( | self | ) |
Serialise to in-memory bytes (round-trips with from_bytes).
| volume_integral | ( | self, | |
| what ) |
Volume integral of a quantity on the FSA grid.
| what | Array-like of length nlevels, sampled at self.psi_N_levels |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| averages = None |
All flux-surface-averaged quantities dict.
Keys: R, 1/R, 1/R**2, R**2, Bp, Bp**2, Bt, Bt**2, Btot**2, Jt, Jt/R, Jt/R_num, Jt_GS, vp, q, ip, F, PPRIME, FFPRIM.
Jt/R is the analytic Grad-Shafranov form \(-\sigma_{Bp}(p' + FF'\langle 1/R^2\rangle/\mu_0)(2\pi)^{e_{Bp}}\); Jt_GS is the companion \(\langle J_t\rangle\) analytic form used by j_tor_averaged_direct. Jt and Jt/R_num are the numerical counterparts computed from \(\nabla\times B/\mu_0\) on the contour, retained for cross-checks.
| B_center = None |
Vacuum toroidal field at R_center [T].
| betas = None |
Plasma beta values (keys: beta_t, beta_p, beta_n).
| boundary_R = None |
R coordinates of the plasma boundary [m].
| boundary_Z = None |
Z coordinates of the plasma boundary [m].
| cocos = None |
Current COCOS convention index.
| contours = None |
List of (N,2) contour arrays for each \(\hat{\psi}\) level.
| ffprim = None |
\(F\,dF/d\psi\) on the raw psi_N grid (NW points) [T \(^2\) m \(^2\)/Wb]
| fpol = None |
\(F = R B_t\) poloidal current function, on the raw psi_N grid (NW points) [T m]
| geometry = None |
Per-surface geometric quantities dict.
Keys: R, Z, a, kappa, kapu, kapl, delta, delu, dell, perimeter, surfArea, eps, vol, cxArea
| Ip = None |
Plasma current \(I_p\) [A].
| j_tor_averaged = None |
Flux-surface-averaged toroidal current density \(\langle J_t/R\rangle / \langle 1/R\rangle\) [A/m \(^2\)].
| j_tor_averaged_direct = None |
Direct flux-surface average \(\langle J_t\rangle\) from the Grad-Shafranov equation [A/m \(^2\)].
| j_tor_averaged_numerical = None |
Numerically flux-surface-averaged \(\langle J_t\rangle\) via \(\nabla\times B / \mu_0\) [A/m \(^2\)].
| j_tor_over_R = None |
\(\langle J_t/R\rangle\) from the Grad-Shafranov equation [A/m \(^3\)]
| keys = None |
Flat list of all available attribute names (scalars + profiles + derived).
| li = None |
| limiter_R = None |
R coordinates of the limiter [m].
| limiter_Z = None |
Z coordinates of the limiter [m].
| midplane = None |
Outboard midplane quantities on the \(\hat{\psi}\) grid (keys: R, Z, Br, Bz, Bp, Bt, Btot).
| pprime = None |
\(dP/d\psi\) on the raw psi_N grid (NW points) [Pa/Wb]
| pres = None |
Pressure profile on the raw psi_N grid (NW points) [Pa].
| psi_axis = None |
Poloidal flux at the magnetic axis [Wb].
| psi_boundary = None |
Poloidal flux at the last closed flux surface [Wb].
| psi_N = None |
| psi_N_levels = None |
Normalised \(\hat{\psi}\) levels used for flux-surface analysis (nlevels points).
This is the grid on which lazy FSA quantities (q_profile, j_tor_averaged, geometry[...], averages[...], midplane[...], etc.) are evaluated. Defaults to NW (identical to psi_N) unless a different nlevels was passed at construction.
| psi_N_RZ = None |
2-D normalised poloidal flux \(\hat{\psi}(R,Z)\) on the (R,Z) grid
| psi_RZ = None |
2-D poloidal flux array (NH x NW) [Wb]
| q_profile = None |
Safety factor from flux-surface averaging.
| qpsi = None |
Safety factor from the g-file, on the raw psi_N grid (NW points).
| R_center = None |
Reference geometric center R [m].
| R_grid = None |
1-D R grid [m]
| R_mag = None |
R of the magnetic axis [m].
| rhovn = None |
Normalised toroidal flux coordinate \(\rho = \sqrt{\Phi_{\mathrm{tor}}/\Phi_{\mathrm{tor,edge}}}\).
Always computed from the safety factor profile.
| Z_grid = None |
1-D Z grid [m]
| Z_mag = None |
Z of the magnetic axis [m].