ASCOT5
Loading...
Searching...
No Matches
Macros
physlib.h File Reference

Methods to evaluate elementary physical quantities. More...

#include <math.h>
#include "consts.h"

Go to the source code of this file.

Macros

#define physlib_gamma_vnorm(v)
 Evaluate Lorentz factor from velocity norm.
 
#define physlib_vnorm_gamma(gamma)
 Evaluate velocity norm from Lorentz factor.
 
#define physlib_gamma_pnorm(m, p)
 Evaluate Lorentz factor from momentum norm.
 
#define physlib_gamma_vpar(m, mu, vpar, B)
 Evaluate Lorentz factor from parallel velocity.
 
#define physlib_gamma_ppar(m, mu, ppar, B)
 Evaluate Lorentz factor from parallel momentum.
 
#define physlib_Ekin_gamma(m, gamma)   ( ( gamma - 1.0 ) * m * CONST_C2 )
 Evaluate kinetic energy [J] from Lorentz factor.
 
#define physlib_gamma_Ekin(m, ekin)   ( ekin / ( m * CONST_C2 ) + 1.0 )
 Evaluate Lorentz factor from kinetic energy [J].
 
#define physlib_Ekin_pnorm(m, p)
 Evaluate kinetic energy [J] from momentum norm.
 
#define physlib_Ekin_ppar(m, mu, ppar, B)
 Evaluate kinetic energy [J] from parallel momentum.
 
#define physlib_vnorm_pnorm(m, p)
 Evaluate velocity norm [m/s] from momentum norm.
 
#define physlib_pnorm_vnorm(m, v)   ( m * v * physlib_gamma_vnorm(v) )
 Evaluate momentum norm [kg m/s] from velocity norm.
 
#define physlib_gc_ppar(p, xi)   ( p * xi )
 Evaluate guiding center parallel momentum [kg m/s] from momentum norm and pitch.
 
#define physlib_gc_mu(m, p, xi, B)
 Evaluate guiding center magnetic moment [J/T] from momentum norm and pitch.
 
#define physlib_gc_p(m, mu, ppar, B)
 Evaluate guiding center momentum norm [kg m/s] from parallel momentum and magnetic moment.
 
#define physlib_gc_xi(m, mu, ppar, B)
 Evaluate guiding center pitch from parallel momentum and magnetic moment.
 
#define physlib_gyrolength_p(q, p, B)
 Evaluate gyroradius [m] from momentum vector.
 
#define phys_gyrolength_ppar(m, q, mu, ppar, B)
 Evaluate gyroradius [m] from parallel momentum and magnetic moment.
 
#define phys_gyrofreq_pnorm(m, q, p, B)
 Evaluate gyrofrequency [rad/s] from momentum norm.
 
#define phys_gyrofreq_ppar(m, q, mu, ppar, B)
 Evaluate gyrofrequency [rad/s] from parallel momentum and magnetic moment.
 
#define phys_ptoroid_fo(q, R, pphi, psi)
 Evaluate toroidal canonical momentum for particle.
 
#define phys_ptoroid_gc(q, R, ppar, psi, B, Bphi)
 Evaluate toroidal canonical momentum for guiding center.
 

Detailed Description

Methods to evaluate elementary physical quantities.

Definition in file physlib.h.

Macro Definition Documentation

◆ physlib_gamma_vnorm

#define physlib_gamma_vnorm ( v)
Value:
( \
sqrt( 1.0 / ( (1.0 - v / CONST_C) * (1.0 + v / CONST_C) ) ) )
#define CONST_C
Speed of light [m/s]
Definition consts.h:23

Evaluate Lorentz factor from velocity norm.

$ \gamma = \sqrt{\frac{1}{1-v^2/c^2}}$

where

  • $v$ is velocity norm [m/s]

Definition at line 21 of file physlib.h.

◆ physlib_vnorm_gamma

#define physlib_vnorm_gamma ( gamma)
Value:
( \
sqrt( 1.0 - 1.0 / ( gamma * gamma ) ) * CONST_C )

Evaluate velocity norm from Lorentz factor.

$ v = \sqrt{1 - \frac{1}{\gamma^2}}c$

where

  • $v$ is velocity norm [m/s]

Definition at line 33 of file physlib.h.

◆ physlib_gamma_pnorm

#define physlib_gamma_pnorm ( m,
p )
Value:
( \
sqrt(1.0 + ( p * p ) / ( m * m * CONST_C2 ) ) )
#define CONST_C2
Speed of light squared [m^2/s^2]
Definition consts.h:26

Evaluate Lorentz factor from momentum norm.

$\gamma = \sqrt{1 + \left(\frac{p}{mc}\right)^2}$

where

  • $m$ is mass [kg]
  • $p$ is momentum norm [kg m/s]

Definition at line 46 of file physlib.h.

◆ physlib_gamma_vpar

#define physlib_gamma_vpar ( m,
mu,
vpar,
B )
Value:
( \
sqrt( ( 1.0 + (2.0 * mu * B) / ( m * CONST_C2 ) ) / \
( (1.0 - vpar / CONST_C) * (1.0 + vpar / CONST_C) ) ) )

Evaluate Lorentz factor from parallel velocity.

$\gamma = \sqrt{\frac{1 + (2\mu B/mc^2)}{1 - v_\parallel^2/c^2}}$

where

  • $m$ is mass [kg]
  • $\mu$ is magnetic moment [J/T]
  • $v_\parallel$ is parallel velocity [m/s]
  • $B$ is magnetic field norm [T]

Definition at line 61 of file physlib.h.

◆ physlib_gamma_ppar

#define physlib_gamma_ppar ( m,
mu,
ppar,
B )
Value:
( \
sqrt( 1.0 + 2 * mu * B / ( m * CONST_C2 ) + \
ppar * ppar / ( m * m * CONST_C2 ) ) )

Evaluate Lorentz factor from parallel momentum.

$\gamma = \sqrt{1 + 2\mu B/mc^2 + (p_\parallel/mc)^2}$

where

  • $m$ is mass [kg]
  • $\mu$ is magnetic moment [J/T]
  • $p_\parallel$ is parallel momentum [kg m/s]
  • $B$ is magnetic field norm [T]

Definition at line 77 of file physlib.h.

◆ physlib_Ekin_gamma

#define physlib_Ekin_gamma ( m,
gamma )   ( ( gamma - 1.0 ) * m * CONST_C2 )

Evaluate kinetic energy [J] from Lorentz factor.

$E_\mathrm{kin}=(\gamma - 1) * m c^2$

where

  • $m$ is mass [kg]
  • $\gamma$ is the Lorentz factor

Definition at line 91 of file physlib.h.

◆ physlib_gamma_Ekin

#define physlib_gamma_Ekin ( m,
ekin )   ( ekin / ( m * CONST_C2 ) + 1.0 )

Evaluate Lorentz factor from kinetic energy [J].

$\gamma = \frac{E_\mathrm{kin}}{m c^2} + 1$

where

  • $m$ is mass [kg]
  • $\gamma$ is the Lorentz factor

Definition at line 103 of file physlib.h.

◆ physlib_Ekin_pnorm

#define physlib_Ekin_pnorm ( m,
p )
Value:
( \
( physlib_gamma_pnorm(m, p) - 1.0 ) * m * CONST_C2 )
#define physlib_gamma_pnorm(m, p)
Evaluate Lorentz factor from momentum norm.
Definition physlib.h:46

Evaluate kinetic energy [J] from momentum norm.

$E_\mathrm{kin}=(\gamma(p) - 1) * m c^2$

where

  • $m$ is mass [kg]
  • $p$ is momentum norm [kg m/s]

Definition at line 115 of file physlib.h.

◆ physlib_Ekin_ppar

#define physlib_Ekin_ppar ( m,
mu,
ppar,
B )
Value:
( \
( physlib_gamma_ppar(m, mu, ppar, B) - 1.0 ) * m * CONST_C2 )
#define physlib_gamma_ppar(m, mu, ppar, B)
Evaluate Lorentz factor from parallel momentum.
Definition physlib.h:77

Evaluate kinetic energy [J] from parallel momentum.

$E_\mathrm{kin}=(\gamma(m, \mu, p_\parallel, B) - 1) * m c^2$

where

  • $m$ is mass [kg]
  • $p_\parallel$ is parallel momentum [kg m/s]

Definition at line 128 of file physlib.h.

◆ physlib_vnorm_pnorm

#define physlib_vnorm_pnorm ( m,
p )
Value:
( \
p / sqrt(m * m + ( p * p ) / CONST_C2 ) )

Evaluate velocity norm [m/s] from momentum norm.

$v = p/\gamma(p)m$

where

  • $m$ is mass [kg]
  • $p$ is momentum norm [kg m/s]

Definition at line 141 of file physlib.h.

◆ physlib_pnorm_vnorm

#define physlib_pnorm_vnorm ( m,
v )   ( m * v * physlib_gamma_vnorm(v) )

Evaluate momentum norm [kg m/s] from velocity norm.

$p = \gamma(v)mv$

where

  • $m$ is mass [kg]
  • $v$ is velocity norm [m/s]

Definition at line 154 of file physlib.h.

◆ physlib_gc_ppar

#define physlib_gc_ppar ( p,
xi )   ( p * xi )

Evaluate guiding center parallel momentum [kg m/s] from momentum norm and pitch.

$p_\parallel = \xi p$

where

  • $p$ is momentum norm [kg m/s]
  • $\xi$ is pitch

Definition at line 166 of file physlib.h.

◆ physlib_gc_mu

#define physlib_gc_mu ( m,
p,
xi,
B )
Value:
( \
p * p * ( 1.0 - xi * xi ) / ( 2 * B * m ) )

Evaluate guiding center magnetic moment [J/T] from momentum norm and pitch.

$\mu = (1-\xi^2)p/(2mB)$

where

  • $m$ is mass [kg]
  • $p$ is momentum norm [kg m/s]
  • $\xi$ is pitch
  • $B$ is magnetic field norm [T]

Definition at line 180 of file physlib.h.

◆ physlib_gc_p

#define physlib_gc_p ( m,
mu,
ppar,
B )
Value:
( \
m * CONST_C * sqrt( pow( physlib_gamma_ppar(m, mu, ppar, B), 2) - 1 ) )

Evaluate guiding center momentum norm [kg m/s] from parallel momentum and magnetic moment.

$p = \sqrt{\gamma(m,\mu,p_\parallel,B)^2 - 1} m c$

where

  • $m$ is mass [kg]
  • $\mu$ is magnetic moment [J/T]
  • $p_\parallel$ is parallel momentum [kg m/s]
  • $B$ is magnetic field norm [T]

Definition at line 195 of file physlib.h.

◆ physlib_gc_xi

#define physlib_gc_xi ( m,
mu,
ppar,
B )
Value:
( \
ppar / physlib_gc_p(m, mu, ppar, B) )
#define physlib_gc_p(m, mu, ppar, B)
Evaluate guiding center momentum norm [kg m/s] from parallel momentum and magnetic moment.
Definition physlib.h:195

Evaluate guiding center pitch from parallel momentum and magnetic moment.

$\xi = p_\parallel / p(m,\mu,p_\parallel,B) $

where

  • $m$ is mass [kg]
  • $\mu$ is magnetic moment [J/T]
  • $p_\parallel$ is parallel momentum [kg m/s]
  • $B$ is magnetic field [T]

Definition at line 210 of file physlib.h.

◆ physlib_gyrolength_p

#define physlib_gyrolength_p ( q,
p,
B )
Value:
( \
math_dot(p, B) / ( fabs(q) * math_dot(B, B) ) )
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
Definition math.h:28

Evaluate gyroradius [m] from momentum vector.

$\rho_g = \frac{\mathbf{p}\cdot\mathbf{B}}{|q|B^2}$

where

  • $q$ is charge [C]
  • $\mathbf{v}$ is momentum vector [kg m/s]
  • $\mathbf{B}$ is magnetic field vector [T]

Definition at line 224 of file physlib.h.

◆ phys_gyrolength_ppar

#define phys_gyrolength_ppar ( m,
q,
mu,
ppar,
B )
Value:
( \
sqrt( 2 * m * mu * \
physlib_gamma_ppar(m, mu, ppar, B) / B ) / fabs(q) )

Evaluate gyroradius [m] from parallel momentum and magnetic moment.

$\rho_g = \frac{1}{|q|}\sqrt{\frac{2\gamma(m, \mu, p_\parallel, B) m \mu}
            {B}}$

where

  • $m$ is mass [kg]
  • $q$ is charge [C]
  • $\mu$ is magnetic moment [J/T]
  • $p_\parallel$ is parallel momentum [kg m/s]
  • $B$ is magnetic field norm [T]

Definition at line 241 of file physlib.h.

◆ phys_gyrofreq_pnorm

#define phys_gyrofreq_pnorm ( m,
q,
p,
B )
Value:
( \
fabs(q) * B / ( m * physlib_gamma_pnorm(m, p) ) )

Evaluate gyrofrequency [rad/s] from momentum norm.

$\omega_g = \frac{q B}{\gamma(p) m}$

where

  • $m$ is mass [kg]
  • $q$ is charge [C]
  • $p$ is momentum norm [kg m/s]
  • $B$ is magnetic field norm [T]

Definition at line 257 of file physlib.h.

◆ phys_gyrofreq_ppar

#define phys_gyrofreq_ppar ( m,
q,
mu,
ppar,
B )
Value:
( \
fabs(q) * B / ( m * physlib_gamma_ppar(m, mu, ppar, B) ) )

Evaluate gyrofrequency [rad/s] from parallel momentum and magnetic moment.

$\omega_g = \frac{q B}{\gamma(m, \mu, p_\parallel, B) m}$

where

  • $m$ is mass [kg]
  • $q$ is charge [C]
  • $\mu$ is magnetic moment [J/T]
  • $p_\parallel$ is parallel momentum [kg m/s]
  • $B$ is magnetic field norm [T]

Definition at line 273 of file physlib.h.

◆ phys_ptoroid_fo

#define phys_ptoroid_fo ( q,
R,
pphi,
psi )
Value:
( \
R * pphi + q * psi )

Evaluate toroidal canonical momentum for particle.

Definition at line 280 of file physlib.h.

◆ phys_ptoroid_gc

#define phys_ptoroid_gc ( q,
R,
ppar,
psi,
B,
Bphi )
Value:
( \
ppar * R * (Bphi / B) + q * psi )

Evaluate toroidal canonical momentum for guiding center.

Definition at line 287 of file physlib.h.