The Open FUSION Toolkit 26.6
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
GEQDSKEquilibrium Class Reference

Detailed Description

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

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
filename,
cocos = 1,
nlevels = None,
resample = "theta",
extrapolate_edge = True )

Initialize GEQDSKEquilibrium by reading a g-file from disk.

Parameters
filenamePath to the g-file
cocosCOCOS convention index (default 1, standard EFIT)
nlevelsNumber of normalised- \(\psi\) levels for flux-surface analysis (defaults to NW from the g-file)
resampleContour resampling method for near-separatrix surfaces ( \(\hat{\psi} \geq 0.99\)): "theta" or "arc_length"
extrapolate_edgeIf True (default), extrapolate \(p'\) and \(FF'\) at the separatrix when the g-file has them forced to zero

Member Function Documentation

◆ _compute_fields()

_compute_fields ( self)
protected

Compute \(B_R\), \(B_Z\), \(J_t\) on the full (R,Z) grid.

◆ _copy_for_mutation()

_copy_for_mutation ( self)
protected

◆ _trace_surfaces()

_trace_surfaces ( self)
protected

Trace flux surfaces and compute all averaged quantities.

◆ _zz_doxygen_dummy() [1/3]

_zz_doxygen_dummy ( self)
protected

◆ _zz_doxygen_dummy() [2/3]

_zz_doxygen_dummy ( self)
protected

◆ _zz_doxygen_dummy() [3/3]

_zz_doxygen_dummy ( self)
protected

◆ cocosify()

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.

Parameters
cocos_outTarget COCOS convention index (1-8 or 11-18)
copyIf True, return a new GEQDSKEquilibrium with converted data, leaving this object unchanged. If False (default), convert in place and return self.
Returns
Converted object (self when copy=False)

◆ describe()

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().

Parameters
verboseIf 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()

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.

Parameters
copyIf True, return a new object; otherwise modify in place
Returns
Modified GEQDSKEquilibrium object

◆ flux_integral()

flux_integral ( self,
psi_N_val,
profile )

Total flux integral at a given \(\hat{\psi}\) value (scalar).

Parameters
psi_N_valNormalised poloidal flux location (0 = axis, 1 = boundary)
profileArray-like of length nlevels to integrate (sampled at self.psi_N_levels)
Returns
Value of the volume integral at psi_N_val

◆ from_bytes()

from_bytes ( cls,
raw_bytes,
cocos = 1,
nlevels = None,
resample = "theta",
extrapolate_edge = True )

Construct from in-memory bytes (e.g.

from HDF5 storage)

Parameters
raw_bytesRaw content of a g-file
cocosCOCOS convention index
nlevelsNumber of \(\hat{\psi}\) levels
resampleContour resampling method ("theta" or "arc_length")
extrapolate_edgeExtrapolate \(p'\) and \(FF'\) at separatrix when forced to zero
Returns
New GEQDSKEquilibrium instance

◆ from_raw()

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).

Parameters
raw_dictDict with standard GEQDSK keys (as returned by _read_geqdsk)
cocosCOCOS convention index
nlevelsNumber of \(\hat{\psi}\) levels
resampleContour resampling method ("theta" or "arc_length")
extrapolate_edgeExtrapolate \(p'\) and \(FF'\) at separatrix when forced to zero
Returns
New GEQDSKEquilibrium instance

◆ save()

save ( self,
filename )

Write the (possibly modified) g-file data to filename.

Parameters
filenameOutput path for the g-file

◆ surface_integral()

surface_integral ( self,
what )

Cross-section (area) integral of a quantity on the FSA grid.

Parameters
whatArray-like of length nlevels, sampled at self.psi_N_levels
Returns
1-D ndarray (nlevels,) cumulative area integral

◆ to_bytes()

to_bytes ( self)

Serialise to in-memory bytes (round-trips with from_bytes).

Returns
Raw g-file content as bytes

◆ volume_integral()

volume_integral ( self,
what )

Volume integral of a quantity on the FSA grid.

Parameters
whatArray-like of length nlevels, sampled at self.psi_N_levels
Returns
1-D ndarray (nlevels,) cumulative integral from core to each surface

Member Data Documentation

◆ _cache

dict _cache = {}
protected

◆ _CATALOGUE

list _CATALOGUE
staticprotected

◆ _cocos

_cocos = _cocos_params(cocos)
protected

◆ _cocos_index

_cocos_index = int(cocos)
protected

◆ _extrapolate_edge

_extrapolate_edge = bool(extrapolate_edge)
protected

◆ _nlevels

_nlevels = nlevels if nlevels is not None else int(self._raw["NW"])
protected

◆ _raw

_raw = _read_geqdsk(filename)
protected

◆ _resample_method

str _resample_method = resample
protected

◆ averages

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

B_center = None

Vacuum toroidal field at R_center [T].

◆ betas

betas = None

Plasma beta values (keys: beta_t, beta_p, beta_n).

◆ boundary_R

boundary_R = None

R coordinates of the plasma boundary [m].

◆ boundary_Z

boundary_Z = None

Z coordinates of the plasma boundary [m].

◆ cocos

cocos = None

Current COCOS convention index.

◆ contours

contours = None

List of (N,2) contour arrays for each \(\hat{\psi}\) level.

◆ ffprim

ffprim = None

\(F\,dF/d\psi\) on the raw psi_N grid (NW points) [T \(^2\) m \(^2\)/Wb]

◆ fpol

fpol = None

\(F = R B_t\) poloidal current function, on the raw psi_N grid (NW points) [T m]

◆ geometry

geometry = None

Per-surface geometric quantities dict.

Keys: R, Z, a, kappa, kapu, kapl, delta, delu, dell, perimeter, surfArea, eps, vol, cxArea

◆ Ip

Ip = None

Plasma current \(I_p\) [A].

◆ j_tor_averaged

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

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

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

j_tor_over_R = None

\(\langle J_t/R\rangle\) from the Grad-Shafranov equation [A/m \(^3\)]

◆ keys

keys = None

Flat list of all available attribute names (scalars + profiles + derived).

◆ li

li = None

Internal inductance dict (keys: li_from_definition, li(1), li(1)_EFIT, li(1)_TLUCE, li(2), li(3)).

◆ limiter_R

limiter_R = None

R coordinates of the limiter [m].

◆ limiter_Z

limiter_Z = None

Z coordinates of the limiter [m].

◆ midplane

midplane = None

Outboard midplane quantities on the \(\hat{\psi}\) grid (keys: R, Z, Br, Bz, Bp, Bt, Btot).

◆ pprime

pprime = None

\(dP/d\psi\) on the raw psi_N grid (NW points) [Pa/Wb]

◆ pres

pres = None

Pressure profile on the raw psi_N grid (NW points) [Pa].

◆ psi_axis

psi_axis = None

Poloidal flux at the magnetic axis [Wb].

◆ psi_boundary

psi_boundary = None

Poloidal flux at the last closed flux surface [Wb].

◆ psi_N

psi_N = None

Normalised raw g-file \(\hat{\psi}\) grid for 1-D profiles (NW points).

Matches the length and spacing of fpol, pres, pprime, ffprim, qpsi, and rhovn. For the flux-surface-analysis grid (used by the derived FSA quantities) see psi_N_levels.

◆ psi_N_levels

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

psi_N_RZ = None

2-D normalised poloidal flux \(\hat{\psi}(R,Z)\) on the (R,Z) grid

◆ psi_RZ

psi_RZ = None

2-D poloidal flux array (NH x NW) [Wb]

◆ q_profile

q_profile = None

Safety factor from flux-surface averaging.

◆ qpsi

qpsi = None

Safety factor from the g-file, on the raw psi_N grid (NW points).

◆ R_center

R_center = None

Reference geometric center R [m].

◆ R_grid

R_grid = None

1-D R grid [m]

◆ R_mag

R_mag = None

R of the magnetic axis [m].

◆ rhovn

rhovn = None

Normalised toroidal flux coordinate \(\rho = \sqrt{\Phi_{\mathrm{tor}}/\Phi_{\mathrm{tor,edge}}}\).

Always computed from the safety factor profile.

◆ Z_grid

Z_grid = None

1-D Z grid [m]

◆ Z_mag

Z_mag = None

Z of the magnetic axis [m].


The documentation for this class was generated from the following file: