Constants of motion¶
- Constants of motion related types.
Constants of Motionclass.- Plotting functions.
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:
-
eval–Evaluates the parabola.
-
eval_array1–Evaluates the parabola.
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.EnergyPzetaPlane()
¶
Representation of the COM space \((E, P_\zeta, \mu=const)\).
This type is not to be constructed directly, but through COMs.
Attributes:
-
axis_parabola(Parabola) –The parabola representing the magnetic axis.
-
left_wall_parabola(Parabola) –The parabola representing the left wall.
-
right_wall_parabola(Parabola) –The parabola representing the right wall.
-
tp_pzeta_interval(Array1) –The trapped-passing boundary's \(P_\zeta = [-\psi_{p, last}, 0]\) interval array.
-
tp_upper(Array1) –The trapped-passing boundary's upper curve.
-
tp_lower(Array1) –The trapped-passing boundary's lower curve.
-
mu(float) –The constant magnetic moment \(\mu\).
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
Methods:
-
energy_of_psi_grid–Calculates the Energy on a 2D meshgrid of the \(\psi\) and \(\theta\) arrays, in Normalized Units.
-
energy_of_psip_grid–Calculates the Energy on a 2D meshgrid of the \(\psi_p\) and \(\theta\) arrays, in Normalized Units.
-
build_energy_pzeta_plane–Constructs an
EnergyPzetaPlane.
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
>>> # 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
>>> # 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.
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
FigureandAx.