physlib

Tools for assessing physical quantities and units.

a5py.physlib.anglemod(angle)

Transfer arbitrary angle to between interval [0, 2pi].

a5py.physlib.bouncefrequency(m, ekin, minorradius, majorradius, safetyfactor)

Estimate bounce frequency from energy and aspect ratio.

a5py.physlib.cart2pol(x, y, z=None)

Cartesian x coordinate from cylindrical coordinates.

a5py.physlib.collfreq_ei(mi, qi, ne, Te, clog)

Evaluate electron-ion collision frequency.

a5py.physlib.collfreq_ie(mi, qi, ne, Te, clog)

Evaluate ion-electron collision frequency.

a5py.physlib.energy_gamma(m, gamma)

Evaluate kinetic energy from Lorentz factor.

a5py.physlib.energy_momentum(m, p)

Evaluate kinetic energy from momentum.

a5py.physlib.energy_muppar(m, mu, ppar, b)

Evaluate kinetic energy from magnetic moment and parallel momentum.

a5py.physlib.energy_muvpar(m, mu, vpar, b)

Evaluate kinetic energy from magnetic moment and parallel velocity.

a5py.physlib.energy_velocity(m, v)

Evaluate kinetic energy from velocity.

a5py.physlib.gamma_energy(m, energy)

Evaluate gamma from kinetic energy.

a5py.physlib.gamma_momentum(m, p)

Evaluate gamma from momentum.

a5py.physlib.gamma_muppar(m, mu, ppar, b)

Evaluate gamma from magnetic moment and parallel momentum.

a5py.physlib.gamma_muvpar(m, mu, vpar, b)

Evaluate gamma from magnetic moment and parallel velocity.

a5py.physlib.gamma_velocity(v)

Evaluate gamma from velocity.

a5py.physlib.gyrofrequency(m, q, energy, bnorm)

Evaluate gyrofrequency from energy.

a5py.physlib.gyrolength(m, q, energy, pitch, bnorm)

Evaluate gyrolength from energy and pitch.

a5py.physlib.momentum_muppar(m, mu, ppar, b, zeta=None)

Evaluate momentum from mu and ppar.

If gyroangle zeta is given, return the momentum vector. Otherwise return momentum norm.

a5py.physlib.momentum_velocity(m, v)

Evaluate momentum from velocity.

If v is a vector (scalar) then returned value is a vector (scalar).

a5py.physlib.mu_momentum(m, p, b)

Evaluate magnetic moment from momentum vector.

a5py.physlib.parseunits(strip=False, **units)

Prepare arguments that are expected to have physical units.

This decorator:

  • Makes sure every argument has expected physical dimensions.

  • Assigns units if units were not provided but they were expected.

  • Strips units if asked (after checking/assignment).

Examples:

@parseunits(x="m", strip=True)
def fun(x):
    pass
Parameters:
stripbool, optional

Strip units so that dimensionless quantities (but in expected units) are passed to the function.

**units

Argument in wrapped function and the expected unit as a string.

a5py.physlib.pitch_momentum(p, b)

Evaluate pitch from momentum vector.

a5py.physlib.pitch_muppar(m, mu, ppar, b)

Evaluate pitch from mu and ppar.

a5py.physlib.pnorm_gamma(m, gamma)

Evaluate momentum norm from Lorentz factor.

a5py.physlib.pol2cart(r, phi, z=None)

Cartesian x coordinate from cylindrical coordinates.

a5py.physlib.ppar_momentum(p, b)

Evaluate parallel momentum from momentum vector.

a5py.physlib.torcanangmom_momentum(q, r, p, psi)

Evaluate toroidal canonical angular momentum from momentum.

a5py.physlib.torcanangmom_ppar(q, r, ppar, b, psi)

Evaluate toroidal canonical angular momentum from mu and ppar.

a5py.physlib.velocity_momentum(m, p)

Evaluate velocity from momentum.

If p is a vector (scalar) then returned value is a vector (scalar).

a5py.physlib.velocity_muppar(m, mu, ppar, b, zeta=None)

Evaluate velocity from mu and ppar.

If gyroangle zeta is given, return the velocity vector. Otherwise return velocity norm.

a5py.physlib.vnorm_gamma(gamma)

Evaluate velocity norm from Lorentz factor.

a5py.physlib.vpar_momentum(m, p, b)

Evaluate parallel velocity from momentum vector.

a5py.physlib.vpar_muppar(m, mu, ppar, b)

Evaluate vpar from mu and ppar.