Skip to content

Constants of motion

dexter.Parabola()

Representation of a parabola of the form \(\alpha x^2 + \beta x + \gamma\).

This type is not to be constructed directly, but through EnergyPzetaPlane.

Methods:

Attributes:

  • a (float) –

    The parabolas \(a\) coefficient.

  • b (float) –

    The parabolas \(b\) coefficient.

  • c (float) –

    The parabolas \(c\) coefficient.

dexter.Parabola.a: float property

The parabolas \(a\) coefficient.

dexter.Parabola.b: float property

The parabolas \(b\) coefficient.

dexter.Parabola.c: float property

The parabolas \(c\) coefficient.

dexter.Parabola.eval(x: float) -> float

Evaluates the parabola.

Parameters:

  • x (float) –

    The point to evaluate the parabola.

dexter.Parabola.eval_array1(arr: Array1) -> Array1

Evaluates the parabola.

Parameters:

  • arr (Array1) –

    The array on which to evaluate the parabola.

dexter.EnergyPzetaPlane()

Representation of the COM space \((E, P_\zeta, \mu=const)\).

This type is not to be constructed directly, but through COMs.

Attributes:

dexter.EnergyPzetaPlane.axis_parabola: Parabola property

The parabola representing the magnetic axis.

dexter.EnergyPzetaPlane.left_wall_parabola: Parabola property

The parabola representing the left wall.

dexter.EnergyPzetaPlane.right_wall_parabola: Parabola property

The parabola representing the right wall.

dexter.EnergyPzetaPlane.tp_pzeta_interval: Array1 property

The trapped-passing boundary's \(P_\zeta = [-\psi_{p, last}, 0]\) interval array.

dexter.EnergyPzetaPlane.tp_upper: Array1 property

The trapped-passing boundary's upper curve.

dexter.EnergyPzetaPlane.tp_lower: Array1 property

The trapped-passing boundary's lower curve.

dexter.EnergyPzetaPlane.mu: float property

The constant magnetic moment \(\mu\).

dexter.COMs(energy: Optional[float] = None, pzeta: Optional[float] = None, mu: Optional[float] = None)

The Constants of motion in an unperturbed equilibrium.

Parameters:

  • energy (Optional[float], default: None ) –

    The Energy in Normalized Units.

  • pzeta (Optional[float], default: None ) –

    The canonical momentum \(P_\zeta\) in Normalized Units.

  • mu (Optional[float], default: None ) –

    The magnetic moment \(\mu\) in Normalized Units

Example
COMs creation
>>> coms = dex.COMs(
...     pzeta=-0.025,
...     mu=1e-4,
... )

Methods:

Attributes:

  • energy (float) –

    The Energy in Normalized Units.

  • pzeta (float) –

    The canonical momentum \(P_\zeta\) in Normalized Units.

  • mu (float) –

    The canonical momentum \(\mu\) in Normalized Units.

dexter.COMs.energy: float property

The Energy in Normalized Units.

dexter.COMs.pzeta: float property

The canonical momentum \(P_\zeta\) in Normalized Units.

dexter.COMs.mu: float property

The canonical momentum \(\mu\) in Normalized Units.

dexter.COMs.energy_of_psi_grid(equilibrium: Equilibrium, psi_array: Array1, theta_array: Array1) -> Array2

Calculates the Energy on a 2D meshgrid of the \(\psi\) and \(\theta\) arrays, in Normalized Units.

Note

Both \(P_\zeta\) and \(\mu\) fields must be defined.

Example
COMs creation
>>> # Equilibrium setup
>>> LCFS = dex.LastClosedFluxSurface(kind="Toroidal", value=0.45)
>>> equilibrium = dex.Equilibrium(
...     qfactor=dex.ParabolicQfactor(qaxis=1.1, qlast=4.1, lcfs=LCFS),
...     current=dex.LarCurrent(),
...     bfield=dex.LarBfield(),
... )
>>>
>>> # Constants of Motion definition
>>> coms = dex.COMs(
...     pzeta=-0.025,
...     mu=1e-4,
... )
>>> theta_array = np.linspace(-np.pi, np.pi, 100)
>>> psi_array = np.linspace(0, LCFS.value, 100)
>>>
>>> energy_grid = coms.energy_of_psi_grid(equilibrium, psi_array, theta_array)

dexter.COMs.energy_of_psip_grid(equilibrium: Equilibrium, theta_array: Array1, psip_array: Array1) -> Array2

Calculates the Energy on a 2D meshgrid of the \(\psi_p\) and \(\theta\) arrays, in Normalized Units.

Note

Both \(P_\zeta\) and \(\mu\) fields must be defined.

Note

The Qfactor object is not used in the calculation.

Example
COMs creation
>>> # Equilibrium setup
>>> equilibrium = dex.numerical_equilibrium("./data.nc", "Steffen", "Bicubic")
>>>
>>> # Constants of Motion definition
>>> coms = dex.COMs(
...     pzeta=-0.025,
...     mu=1e-4,
... )
>>> theta_array = np.linspace(-np.pi, np.pi, 100)
>>> psip_array = np.linspace(0, equilibrium.psip_last, 100)
>>>
>>> energy_grid = coms.energy_of_psip_grid(equilibrium, psip_array, theta_array)

dexter.COMs.build_energy_pzeta_plane(equilibrium: Equilibrium) -> EnergyPzetaPlane

Constructs an EnergyPzetaPlane.

Note

The \(\mu\) field must be defined.

Example
EnergyPzetaPlane creation
>>> # Equilibrium setup
>>> equilibrium = dex.numerical_equilibrium("./data.nc", "Steffen", "Bicubic")
>>>
>>> # Constants of Motion definition
>>> coms = dex.COMs(mu=1e-4)
>>>
>>> # Construction
>>> energy_pzeta_plane = coms.build_energy_pzeta_plane(equilibrium)

Plots

dexter.plot_energy_contour(flux_array: Array1, theta_array: Array1, energy_array: Array2, *, levels: int = 30, show: bool = True) -> Canvas

Creates a contour plot of the energy, calculated on a \((\psi/\psi_p, \theta)\) grid.

Parameters:

  • theta_array (Array1) –

    1D array containing the \(\theta\) values.

  • flux_array (Array1) –

    1D array containing the \(\psi/psi_p\) values.

  • energy_array (Array2) –

    2D array containing the Energy values.

Other Parameters:

  • levels (int) –

    The number of energy levels on the contour. Defaults to 30.

  • show (bool) –

    Whether or not to call plt.show(). Defaults to True.

Returns:

  • Canvas

    The produced Figure and Ax.