Base Classes#

class gcmotion.tokamak.qfactor.QFactor#

q Factor base class

Methods

psipNU(psi)

Calculates \(\psi_p(\psi)\).

solverqNU(psi)

Calculates \(q(\psi)\).

abstract psipNU(psi: float | ndarray) float | ndarray#

Calculates \(\psi_p(\psi)\). Input and output are both floats or np.ndarrays, in [NU].

Parameters:
psifloat | np.ndarray

Value(s) of \(\psi\) in NU.

Returns:
float | np.ndarray

Calculated \(\psi_p(\psi)\) in NU.

abstract solverqNU(psi: float | ndarray) float | ndarray#

Calculates \(q(\psi)\). Input and output are both floats or np.ndarrays, in [NU].

Used inside the solver.

Parameters:
psifloat | np.ndarray

Value(s) of \(\psi\) in NU.

Returns:
float | np.ndarray

Calculated \(\psi_p(\psi)\) in NU.

class gcmotion.tokamak.qfactor.NumericalQFactor(filename: str)#

Numerical QFactor base class.

Opens the dataset and creates the splines needed for the querry methods.

solverq and psipNU work identically to the analytic QFactor methods.

Parameters:
filenamestr

The “*.nc” file located at gcmotion/tokamak/reconstructed.

Methods

psipNU(psi)

Calculates \(\psi_p(\psi)\).

solverqNU(psi)

Calculates \(q(\psi)\).

class gcmotion.tokamak.bfield.MagneticField#

Magnetic field base class

Methods

bigNU(phi, theta)

Calculates \(B(\psi, \theta), I(\psi, \theta), g(\psi,\ \theta)\).

solverbNU(psi, theta)

Calculates all the values needed by the solver: \(B,I,g\) (by calling self.bigNU()) and the derivatives \(\dfrac{\partial B}{\partial \psi}, \dfrac{\partial B}{\partial\ \theta}\ \dfrac{\partial I}{\partial \psi}\) and \(\dfrac{\partial\ g}{\partial \psi}\).

abstract bigNU(phi: float | ndarray, theta: float | ndarray) float | ndarray#

Calculates \(B(\psi, \theta), I(\psi, \theta), g(\psi,\ \theta)\). Input and output must be both floats or np.ndarrays, in [NU].

Used in energy contour plots.

Parameters:
psifloat | np.ndarray

The \(\psi\) value(s) in [NU].

thetafloat | np.ndarray

The \(\theta\) value(s).

Returns:
float | np.ndarray

The Calculated \(B(\psi, \theta), I(\psi, \theta), g(\psi,\ \theta)\) value(s) in [NU].

abstract solverbNU(psi: float, theta: float) tuple[float]#

Calculates all the values needed by the solver: \(B,I,g\) (by calling self.bigNU()) and the derivatives \(\dfrac{\partial B}{\partial \psi}, \dfrac{\partial B}{\partial\ \theta}\ \dfrac{\partial I}{\partial \psi}\) and \(\dfrac{\partial\ g}{\partial \psi}\).

Input and output must be floats, in [NU].

Used inside the solver.

Warning

The derivatives are calculated with respect to \(\psi\), and not \(\psi_p\), which appear in the differential equations. This is accounted for inside the solver by multiplying by \(q(\psi)\), since \(\dfrac{\partial f}{\partial \psi_p}\ =\dfrac{\partial f}{\partial \psi}\ \dfrac{\partial \psi}{\partial\ \psi_p} = q\dfrac{\partial f}{\partial \psi}\)

Parameters:
psifloat

Value of \(\psi\) in [NU].

thetafloat

Value of \(\theta\) in [NU].

Returns:
3-tuple of floats

Calculated values and derivatives in [NU].

class gcmotion.tokamak.bfield.NumericalMagneticField(filename: str)#

Numerical Magnetic field base class

Opens the dataset and creates the splines needed for the querry methods. Also defines Bmin and Bmax, used in the parabolas.

solverB and bigNU work identically to the analytic Magnetic field methods.

Parameters:
filenamestr

The “*.nc” file located at gcmotion/tokamak/reconstructed.

Attributes:
Bmin, BmaxQuantities

The minimum and maximum magnetic field values.

theta_min, theta_maxQuantities

The \(\theta\) coordinates where the magnetic field takes its minimum/maximum value.

psi_min, psi_maxQuantities

The \(\psi\) coordinates where the magnetic field takes its minimum/maximum value.

Methods

bigNU(psi, theta)

Calculates \(B(\psi, \theta), I(\psi, \theta), g(\psi,\ \theta)\).

solverbNU(psi, theta)

Calculates all the values needed by the solver: \(B,I,g\) (by calling self.bigNU()) and the derivatives \(\dfrac{\partial B}{\partial \psi}, \dfrac{\partial B}{\partial\ \theta}\ \dfrac{\partial I}{\partial \psi}\) and \(\dfrac{\partial\ g}{\partial \psi}\).

class gcmotion.tokamak.efield.ElectricField#

Electric field base class.

Methods

Er(psi, theta)

Calculates the electric field strength in [NU].

PhiNU(psi, theta)

Calculates \(\Phi(\psi, \theta)\).

solverPhiderNU(psi, theta)

Calculates the derivatives of \(\Phi\) with respect to \(\psi_p\) and \(\theta\).

abstract Er(psi: ndarray, theta: ndarray) ndarray#

Calculates the electric field strength in [NU].

Used for plotting.

Parameters:
psinp.ndarray

The \(\psi\) values.

Returns:
np.ndarray

1D numpy array with calculated \(E\) values.

abstract PhiNU(psi: float | ndarray, theta: float | ndarray) float | ndarray#

Calculates \(\Phi(\psi, \theta)\). Input can be either a float or a np.ndarray, but output is always np.ndarray, in [NU].

Used in energy contour plots.

Parameters:
psifloat | np.ndarray

The \(\psi\) value(s) in [NU].

thetafloat | np.ndarray

The \(\psi\) value(s).

Returns:
np.ndarray

The Calculated \(\Phi\) value(s).

abstract solverPhiderNU(psi: float, theta: float) tuple[float]#

Calculates the derivatives of \(\Phi\) with respect to \(\psi_p\) and \(\theta\). Input and output must be floats, in [NU].

Used inside the solver.

Important

The derivatives are calculated with respect to \(\psi\), and not \(\psi_p\), which appear in the differential equations. This is accounted for inside the solver by multiplying by \(q(\psi)\), since \(\dfrac{\partial f}{\partial \psi_p}=\ \dfrac{\partial f}{\partial \psi}\ \dfrac{\partial \psi}{\partial\ \psi_p} = q\dfrac{\partial f}{\partial \psi}\)

Parameters:
psifloat

Value of \(\psi\) in [NU].

thetafloat

Value of \(\theta\) in [NU].

Returns:
2-tuple of floats

Calculated derivatives in [NU].