Initialization

In the following, we will discuss how to initialise the various models from a common set of initial data, namely

  • the guiding center position $X$ in physical coordinates,
  • the particle energy $W$ in eV,
  • the particle mass $m$ in kg,
  • the particle charge number,
  • the gyro angle $\theta \in [0, 2\pi]$,
  • the pitch angle $\alpha \in [0, \pi / 2]$.

For charged particles we need to convert the energy into a velocity vector. For the Pauli particle we need to compute the coordinates of the guiding centre $X$ of the particle and construct a velocity vector that only holds the component of the velocity that is parallel to the magnetic field, while the perpendicular component goes into the magnetic moment $\mu$. For the guiding center, we need the same coordinate transformation as for the Pauli particle, but we only need the absolute value of the velocity in direction of the magnetic field $u$ and the magnetic moment $\mu$.

Make sure to read about the Normalization before proceeding.

Velocities

Set $e = e' \hat{e}$ with $e' = 1.602 176 634 \cdot 10^{-19}$ and $\hat{e} = \mathrm{C}$ and similarly $m = m' \hat{m}$ with $\hat{m} = \mathrm{kg}$. Some common values for the mass are

ParticleNormalised Mass $m'$
electron$9.1093837015 \cdot 10^{-31}$
proton$1.6726219237 \cdot 10^{-27}$
deuteron$3.3435837724 \cdot 10^{-27}$
alpha$6.6446573357 \cdot 10^{-27}$

The absolute value of the velocity is obtained from the particle energy by $\vert v \vert^2 = 2 W / m$. In normalised units, we have $W = W' \hat{W}$ and $v = v' \hat{v}$ where $\hat{W} = e \mathrm{V}$ and $\hat{v} = \hat{l} \hat{\omega}_c = \hat{l} \hat{B} e / m$.

Let us compute the normalised kinetic energy,

\[\frac{\vert v' \vert^2}{2} = \frac{W' \hat{W}}{m \hat{v}^2} = \frac{W' e \mathrm{V} m^2}{m \hat{l}^2 \hat{B}^2 e^2} .\]

Usually, we have $\hat{B} = T = \mathrm{kg} / \mathrm{C}\,\mathrm{s}$. Recall that $\mathrm{V} = \mathrm{kg}\,\mathrm{m}^2 / \mathrm{C}\,\mathrm{s}^2$ and let us set $\hat{l} = l_0 \mathrm{m}$, then

\[\frac{\vert v' \vert^2}{2} = \frac{m' W'}{e' l_0^2} .\]

Thus for the absolute value of the velocity we have

\[\vert v' \vert = \frac{1}{l_0} \sqrt{ 2 W' \, \frac{m'}{e'} } .\]

The pitch angle $\alpha$ determines the distribution of the kinetic energy into the perpendicular and parallel components by

\[\begin{aligned} W_{\perp}' &= W' \sin \alpha , \qquad W_{\parallel}' &= W' \, (1 - \sin \alpha) . \end{aligned}\]

Note that this is not the textbook pitch-angle convention $W_{\perp} = W \sin^{2} \alpha$, $W_{\parallel} = W \cos^{2} \alpha$; it is however self-consistent with the inverse relation $\alpha = \arcsin (W_{\perp}' / W')$ used by InitialConditionsGC to recover the pitch angle from $(u, \mu)$. and accordingly

\[\begin{aligned} \vert v_{\perp}' \vert &= \frac{1}{l_0} \sqrt{ 2 W_{\perp}' \, \frac{m'}{e'} } , \qquad \vert v_{\parallel}' \vert &= \frac{1}{l_0} \sqrt{ 2 W_{\parallel}' \, \frac{m'}{e'} } . \end{aligned}\]

For each equilibrium, the ElectromagneticFields.jl package generates an orthonormal triad $(a, b, c)$, where $b$ is the unit vector of the magnetic field and $a$ and $c$ span the plane perpendicular to it. The triad is exposed in three different component representations, which coincide only in Cartesian coordinates:

FunctionsComponents
a(t,x), b(t,x), c(t,x)covariant
aₚ(t,x), bₚ(t,x), cₚ(t,x)physical
a⃗(t,x), b⃗(t,x), c⃗(t,x)contravariant

The velocity vector $v$ is assembled in physical coordinates, that is from aₚ, bₚ and cₚ, and subsequently transformed to contravariant coordinates with the inverse Jacobian DF̄. The function bₚ returns the unit vector of the magnetic field, thus

\[v_{\parallel}' = \vert v' \vert \, \sqrt{1 - \sin \alpha} \, b .\]

The functions aₚ and cₚ return two unit vectors that span the plane perpendicular to the magnetic field, thus

\[v_{\perp}' = \vert v' \vert \, \sqrt{\sin \alpha} \, ( - a \, \sin \theta - c \, \cos \theta ) ,\]

where $\theta$ is the gyro angle. The magnetic moment is computed as

\[\mu = \frac{ \vert v_{\perp}' \vert^2 }{2 \vert B' \vert} = \frac{ \vert v' \vert^2 \sin \alpha }{2 \vert B' \vert} .\]

Gyro-radius Vector and Position

In order to compute the particle position, we need to construct the gyro radius vector $\rho$, which is given by

\[\rho = \frac{b \times v}{\omega_c} = \frac{b \times \hat{v} v'}{\hat{\omega}_c \omega_c'} = \hat{l} \, \frac{b \times v'}{\vert B' \vert} .\]

Here we used $\hat{v} / \hat{\omega}_c = \hat{l}$, which follows from $\hat{v} = \hat{l} \hat{\omega}_c$, and recall that $\hat{l} = l_0 \mathrm{m}$. Note that

\[\omega_c = \frac{e \vert B \vert}{m} = \frac{e \vert \hat{B} B' \vert}{m} = \frac{e \vert \hat{B} \vert}{m} \vert B' \vert = \hat{\omega}_c \omega_c' ,\]

as

\[\hat{\omega}_c = \frac{e \vert \hat{B} \vert}{m} ,\]

so that

\[\omega_c' = \vert B' \vert .\]

The normalized gyro radius vector reads

\[\rho' = \frac{\rho}{\hat{l}} = \frac{b \times v'}{\vert B' \vert} ,\]

so that the normalised particle position is

\[x' = X' + \rho' .\]

The gyro phase $\theta$ is defined as the angle, measured in the clockwise sense, between $a$ and $\rho$, so that

\[\frac{b \times v'}{\vert v' \vert \, \sin \alpha} = a \, \cos \theta - c \, \sin \theta .\]

Guiding Center Coordinates

Instead of the particle energy $W$ and pitch angle $\alpha$, we can also compute all initial conditions from the guiding center initial data, i.e., parallel velocity $u = \vert v_{\parallel} \vert$, magnetic moment $\mu$ and gyro angle $\theta$.

Start by computing the absolute value of the perpendicular velocity by

\[\vert v_\perp \vert = \sqrt{ 2 \mu \vert B \vert } ,\]

and the total velocity by

\[\vert v \vert = \sqrt{ \vert v_{\parallel} \vert^2 + \vert v_\perp \vert^2 } .\]

With that, we can compute the perpendicular and total energy,

\[\begin{aligned} W_{\perp}' &= \frac{e l_0^2 \vert v_\perp \vert^2}{2m} , \qquad W' &= \frac{e l_0^2 \vert v \vert^2}{2m} . \end{aligned}\]

The pitch angle is obtained as

\[\alpha = \arcsin \frac{W_{\perp}'}{W'} .\]

With that, the rest of the quantities can be computed in the same way as above.

Initial Conditions

ChargedParticleDynamics.jl provides the InitialConditions module for the computation of the above quantities. Three functions are provided that return the initial conditions for the different models. For charged particles the initial conditions are $(x', v')$, for the Pauli particle we have $(X', v_{\parallel}', \mu)$ and for the guiding center we use $(X', u', \mu)$ with $u' = \vert v_{\parallel}' \vert$.

The equilibrium modules do not use this

Everything on this page describes machinery that is available but not wired up. Each equilibrium module carries its u and μ as hard-coded literals rather than deriving them from a position, a pitch angle and an energy through InitialConditions. The only callers of these functions are this page, the ITER Equilibrium in Cylindrical Coordinates example and scripts/guiding_center_3d.jl.

The literals are also not reproducible from the functions here. For the small tokamak in cartesian coordinates, whose Pauli module declares xᵢ = [1.05, 0, 0] and vᵢ = [2.1e-3, 4.3e-4, 0], the parallel velocity $v \cdot b$ comes out at 0.00042987 against a hard-coded 0.00045136, and $\vert v_{\perp} \vert^{2} / 2B$ at 2.31459e-6 against a hard-coded 2.310e-6 — the latter being a nearby but different number rather than the same one rounded. Where the shipped values came from is not recorded anywhere in the repository, so the per-equilibrium docstrings say so rather than inventing a derivation.

Routing the equilibrium modules through this layer is the fix, and is the task One initial-conditions layer for all models in TODO.md. It would make u and μ derived quantities that a new equilibrium gets for free, at the cost of shifting the shipped values by the percentages above.

ChargedParticleDynamics.InitialConditionsType

Store initial conditions for charged particle, Pauli particle and guiding center models.

Fields:

  • x: particle position
  • X: gyro center position
  • ρ: gyro radius vector
  • vvec: velocity vector
  • vpar: parallel velocity vector
  • vper: perpendicular velocity vector
  • v: absolute value of velocity
  • u: absolute value of parallel velocity
  • μ: magnetic moment
  • θ: gyro angle ∈ [0,2π]
  • α: pitch angle ∈ [0,π/2]
  • ω: gyro frequency
  • mass: mass in kg
  • energy: energy in eV
  • charge: charge number
source
ChargedParticleDynamics.InitialConditionsMethod

Compute initial conditions from the following arguments:

  • X: gyro center position
  • θ: gyro angle
  • α: pitch angle
  • E: energy
  • M: mass
  • C: charge number
  • aₚ, bₚ, cₚ: magnetic field unit vectors in physical coordinates
  • b⃗: magnetic field unit vector in contravariant coordinates
  • B: amplitude of magnetic field
  • : inverse metric coefficients
  • DF̄: inverse Jacobian matrix
  • J: Jacobian determinant
  • l=1: length normalization
source
ChargedParticleDynamics.InitialConditionsGCMethod

Compute initial conditions from the following arguments:

  • X: gyro center position
  • θ: gyro angle
  • u: absolute value of parallel velocity
  • μ: magnetic moment
  • M: mass
  • C: charge number
  • aₚ, bₚ, cₚ: magnetic field unit vectors in physical coordinates
  • b⃗: magnetic field unit vector in contravariant coordinates
  • B: amplitude of magnetic field
  • : inverse metric coefficients
  • DF̄: inverse Jacobian matrix
  • J: Jacobian determinant
  • l=1: length normalization
source
ChargedParticleDynamics.charged_particleMethod

Extracts the charged particle initial conditions and returns the tuple (x,v). If the keyword argument noncanonical is set to true, the functions returns the vector vcat(x,v).

source
ChargedParticleDynamics.pauli_particleMethod

Extracts the Pauli particle initial conditions and returns the tuple (X,vpar,μ). If the keyword argument noncanonical is set to true, the functions returns the tuple (vcat(X,vpar),μ).

source

Example

As an example, let us consider a deuteron in an ITER-like analytical equilibrium (obtained from ElectromagneticFields.SolovevITER). The guiding center position is $[7, 0, 0]$, the energy is $1 \, \mathrm{MeV}$, and the pitch angle is $\pi / 2$.

FieldsValue
x[1.129032258064516, -0.005902625716371612, 1.1084431084484276e-5]
X[1.129032258064516, 0.0, 0.0]
ρ[-2.351759717330926e-21, -0.005902625716371612, 1.1084431084484276e-5]
v⃗[-0.004469150989175999, 6.09832718338012e-6, 0.002547591892668252]
v∥[0.0, 6.09832718338012e-6, 0.002547591892668252]
v⟂[-0.004469150989175999, 0.0, 0.0]
v0.032951426156967195
u0.017833183330406035
μ0.0005070194648182154
θ0.0
α0.7853981633974483
ω3.6280811350854e7
M3.3435837724e-27
E1.0e6
C1

Below we plot the guiding center position (in red) and the particle position (in blue) in the poloidal plane for various gyro angles $\in [0, 2\pi]$. The right panel zooms into the white box around the guiding center.