gbspy.drifts module

Routines for computing drift velocities

This module provides a collection of functions to compute drift velocities appearing the continuity equation. All drift velocities are normalized to the plasma sound speed, \(c_{s0}\).

The following form of the normalized continuity equation is assumed (ignoring sources and sinks due to neutrals),

\[\frac{\partial n}{\partial t} = -\frac{\rho_{\ast}^{-1}}{B}\left[\phi,n\right] + \frac{2}{B}\left[C(p_e)-nC(\phi)\right] - \nabla_{\parallel}(nv_{\parallel{}e}) + D_{\parallel{}n} \nabla^2_{\parallel}n + D_{\perp{}n} \nabla^2_{\perp}n + s_n\]

In the equation above, we identify the

  1. \(E\times{}B\) drift velocity

  2. electron diamagnetic drift velocity

  3. parallel electron velocity

  4. parallel diffusion velocity

  5. perpendicular diffusion velocity

gbspy.drifts.diamagnetic_e_velocity(sim, theta, exptempe)

Computes the normalized electron diamagnetic drift velocity

The radial and vertical components of the electron diamagnetic drift are returned in normalized units,

\[\vec{v}_{de} = \frac{\vec{\nabla}p_e\times{}\vec{b}}{nB}\]
Parameters
Returns

  • v_de_x (numpy.ndarray) – Radial component of the normalized drift velocity

  • v_de_y (numpy.ndarray) – Vertical component of the normalized drift velocity

gbspy.drifts.exb_velocity(sim, strmf)

Computes the normalized ExB drift velocity

The radial and vertical components of the \(E\times{}B\) drift are returned in normalized units,

\[\vec{v}_E = \frac{-\vec{\nabla}\phi\times\vec{b}}{B}\]
Parameters
Returns

  • v_exb_x (numpy.ndarray) – Radial component of the normalized drift velocity

  • v_exb_y (numpy.ndarray) – Vertical component of the normalized drift velocity

gbspy.drifts.parallel_diffusion_velocity(sim, theta, psi_em=None, ignore_em=False)

Computes the normalized parallel diffusion velocity

When considered without electromagnetic effects, the radial and vertical components of the parallel diffusion velocity are returned in normalized units,

\[v_{\parallel{}\text{diff}} \vec{b}_p = -D_{\parallel{}n} \frac{\nabla_{\parallel}n}{n} \left[\hat{e}_{\varphi}\times(\rho_{\ast}\vec{\nabla}\Psi)\right]\]

where \(\Psi\) is the equilibrium magnetic flux function. When introducing electromagnetic perturbations, one has instead

\[v_{\parallel{}\text{diff}} (\vec{b}_p + \delta\vec{b}_p) = -D_{\parallel{}n} \frac{\nabla_{\parallel}n}{n} \left[ \hat{e}_{\varphi}\times(\rho_{\ast}\vec{\nabla}\Psi) - \vec{\nabla}\times(\rho_{\ast}\psi\hat{e}_{\varphi}) \right]\]
Parameters
  • sim (gbspy.pp.Sim) – Simulation object

  • theta (numpy.ndarray) – Logarithmic plasma density as a 4D array

  • psi_em (numpy.ndarray, optional) – Electromagnetic perturbation as a 4D array. This parameter is required if the simulation enables electromagnetic effects and ignore_em=False.

  • ignore_em (bool, optional) – Compute the velocity without electromagnetic corrections even when the simulation ran with such effects enabled.

Returns

  • v_diff_x (numpy.ndarray) – Radial component of the normalized velocity

  • v_diff_y (numpy.ndarray) – Vertical component of the normalized velocity

Raises

AttributeError – If the simulation object has no magnetic field derivatives loaded.

gbspy.drifts.parallel_e_velocity(sim, vpare, psi_em=None, ignore_em=False)

Computes the normalized electron parallel velocity

When considered without electromagnetic effects, the radial and vertical components of the electron parallel velocity are returned in normalized units,

\[v_{\parallel{}e} \vec{b}_p = v_{\parallel{}e} \left[\hat{e}_{\varphi}\times(\rho_{\ast}\vec{\nabla}\Psi)\right]\]

where \(\Psi\) is the equilibrium magnetic flux function. When introducing electromagnetic perturbations, one has instead

\[v_{\parallel{}e} (\vec{b}_p + \delta\vec{b}_p) = v_{\parallel{}e} \left[ \hat{e}_{\varphi}\times(\rho_{\ast}\vec{\nabla}\Psi) - \vec{\nabla}\times(\rho_{\ast}\psi\hat{e}_{\varphi}) \right]\]
Parameters
  • sim (gbspy.pp.Sim) – Simulation object

  • vpare (numpy.ndarray) – Electron parallel velocity as a 4D array

  • psi_em (numpy.ndarray, optional) – Electromagnetic perturbation as a 4D array. This parameter is required if the simulation enables electromagnetic effects and ignore_em=False.

  • ignore_em (bool, optional) – Compute the projected velocity without electromagnetic corrections even when the simulation ran with such effects enabled.

Returns

  • v_par_x (numpy.ndarray) – Radial component of the normalized velocity

  • v_par_y (numpy.ndarray) – Vertical component of the normalized velocity

Raises

AttributeError – If the simulation object has no magnetic field derivatives loaded.

gbspy.drifts.perpendicular_diffusion_velocity(sim, theta)

Computes the normalized perpendicular diffusion velocity

The radial and vertical components of the perpendicular diffusion velocity are returned in normalized units,

\[\vec{v}_{\perp{}\text{diff}} = -\rho_{\ast} D_{\perp{}n} \frac{\vec{\nabla}_{\perp}n}{n}\]
Parameters
Returns

  • v_diff_x (numpy.ndarray) – Radial component of the normalized velocity

  • v_diff_y (numpy.ndarray) – Vertical component of the normalized velocity