plasma_plots.theory.parameters
Plasma parameters in SI units: frequencies, lengths, speeds and Struphy’s units.
Densities are in m⁻³, magnetic fields in T, temperatures in eV (k_B T / e, so 1 eV is
11604.5 K) unless a function says otherwise, and the results are in SI units: angular
frequencies in rad/s, lengths in m, speeds in m/s. Ions have the mass mass_number × m_p
(proton masses, as in Struphy and the NRL Plasma Formulary) and the charge
charge_number × e.
Examples
The electron plasma frequency and Debye length of a 1e19 m⁻³, 100 eV plasma:
>>> print(... f"{plasma_frequency(1e19):.3e} rad/s, {debye_length(1e19, 100.0):.3e} m"... )1.784e+11 rad/s, 2.351e-05 mAttributes
| Name | Description |
|---|---|
STRUPHY_UNIT_SYMBOLS | No description. |
boltzmann_constant | No description. |
electron_mass | No description. |
elementary_charge | No description. |
ev_to_joule | No description. |
ev_to_kelvin | No description. |
proton_mass | No description. |
speed_of_light | No description. |
vacuum_permeability | No description. |
vacuum_permittivity | No description. |
Functions
| Name | Description |
|---|---|
alfven_speed | Compute the Alfvén speed v_A = B / √(μ₀ n m_i), with m_i = mass_number × m_p. |
cyclotron_frequency | Compute the cyclotron (gyro-) frequency Ω = q|B|/m. |
debye_length | Compute the electron Debye length λ_D = √(ε₀ T / (n e²)). |
inertial_length | Compute the inertial length (skin depth) d = c / ω_p. |
larmor_radius | Compute the Larmor (gyro-) radius ρ = m v⊥ / (|q| B). |
lower_hybrid_frequency | Compute the lower hybrid frequency, 1/ω_LH² = 1/(Ω_i² + ω_pi²) + 1/(|Ω_e| Ω_i). |
plasma_beta | Compute the plasma beta β = n T / (B²/(2μ₀)), the ratio of thermal to magnetic pressure. |
plasma_frequency | Compute the plasma frequency ω_p = √(n q² / (ε₀ m)). |
plasma_parameter | Compute the plasma parameter N_D = (4π/3) n λ_D³, the number of electrons in a Debye sphere. |
sound_speed | Compute the ion sound speed c_s = √((γ_e Z T_e + γ_i T_i) / m_i). |
struphy_equation_parameters | Compute the equation parameters α, ε and κ of one Struphy species. |
struphy_units | Compute the units of Struphy's normalization from its base units. |
thermal_speed | Compute the thermal speed of a Maxwellian of temperature T. |
upper_hybrid_frequency | Compute the upper hybrid frequency ω_UH = √(ω_pe² + Ω_e²). |
STRUPHY_UNIT_SYMBOLSattributemodule attribute#
STRUPHY_UNIT_SYMBOLS = {
'x': 'm',
'B': 'T',
'n': 'm⁻³',
'kBT': 'keV',
'v': 'm/s',
't': 's',
'frequency': '1/s',
'p': 'Pa',
'rho': 'kg/m³',
'j': 'A/m²'
}boltzmann_constantattributemodule attribute#
boltzmann_constant = 1.380649e-23electron_massattributemodule attribute#
electron_mass = 9.1093837015e-31elementary_chargeattributemodule attribute#
elementary_charge = 1.602176634e-19ev_to_jouleattributemodule attribute#
ev_to_joule = elementary_chargeev_to_kelvinattributemodule attribute#
ev_to_kelvin = elementary_charge / boltzmann_constantproton_massattributemodule attribute#
proton_mass = 1.67262192369e-27speed_of_lightattributemodule attribute#
speed_of_light = 299792458.0vacuum_permeabilityattributemodule attribute#
vacuum_permeability = 1.25663706212e-06vacuum_permittivityattributemodule attribute#
vacuum_permittivity = 8.8541878128e-12alfven_speedfunction#
def alfven_speed(field, density, mass_number=1, relativistic=False)Compute the Alfvén speed v_A = B / √(μ₀ n m_i), with m_i = mass_number × m_p.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
field | float or array_like | required | Magnetic field B, in T. |
density | float or array_like | required | Ion density n, in m⁻³ (the mass density is n m_i; electrons are neglected). |
mass_number | float or array_like | 1 | Ion mass in proton masses, as in Struphy. Default: 1. |
relativistic | bool | False | If true, return the relativistic v_A / √(1 + v_A²/c²). Default: False. |
Returns
float or numpy.ndarray- v_A, in m/s.
Examples
>>> # deuterium, 1 T>>> print(f"{alfven_speed(1.0, 1e20, mass_number=2):.4g} m/s")1.542e+06 m/scyclotron_frequencyfunction#
def cyclotron_frequency(field, mass=electron_mass, charge=elementary_charge)Compute the cyclotron (gyro-) frequency Ω = q|B|/m.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
field | float or array_like | required | Magnetic field B, in T (its sign doesn’t matter). |
mass | float or array_like | electron_mass | Particle mass m, in kg. Default: the electron mass. |
charge | float or array_like | elementary_charge | Particle charge q, in C. Ω has its sign: the default +e gives the magnitude, −e the signed electron frequency (negative, for the left-handed electron gyration). |
Returns
float or numpy.ndarray- Ω in rad/s.
Examples
>>> print(f"{cyclotron_frequency(1.0) / (2 * np.pi):.4g} Hz")2.799e+10 Hz>>> print(f"{cyclotron_frequency(1.0, charge=-elementary_charge):.4g} rad/s")-1.759e+11 rad/sdebye_lengthfunction#
def debye_length(density, temperature)Compute the electron Debye length λ_D = √(ε₀ T / (n e²)).
Parameters
Returns
float or numpy.ndarray- λ_D, in m. With the default
thermal_speed(), λ_D = v_th / ω_pe.
Examples
>>> print(f"{debye_length(1e6, 1.0):.4g} m") # 1 cm⁻³, 1 eV7.434 minertial_lengthfunction#
def inertial_length(density, mass=electron_mass, charge=elementary_charge)Compute the inertial length (skin depth) d = c / ω_p.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
density | float or array_like | required | Number density n of the species, in m⁻³. |
mass | float or array_like | electron_mass | Particle mass m, in kg. Default: the electron mass. |
charge | float or array_like | elementary_charge | Particle charge q, in C. Default: e. |
Returns
float or numpy.ndarray- d, in m. For ions, d_i = v_A / Ω_i.
Examples
>>> print(f"{inertial_length(1e20):.4g} m") # electrons0.0005314 m>>> print(f"{inertial_length(1e20, mass=proton_mass):.4g} m") # protons0.02277 mlarmor_radiusfunction#
def larmor_radius(field, temperature=None, perpendicular_speed=None, mass=electron_mass, charge=elementary_charge)Compute the Larmor (gyro-) radius ρ = m v⊥ / (|q| B).
Give either the temperature, for the thermal Larmor radius with v⊥ = √(T/m), or the perpendicular speed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
field | float or array_like | required | Magnetic field B, in T. |
temperature | float or array_like | None | Temperature T, in eV; then v⊥ = √(T/m) (the NRL convention). |
perpendicular_speed | float or array_like | None | The perpendicular speed v⊥, in m/s. |
mass | float or array_like | electron_mass | Particle mass m, in kg. Default: the electron mass. |
charge | float or array_like | elementary_charge | Particle charge q, in C (its sign doesn’t matter). Default: e. |
Returns
float or numpy.ndarray- ρ, in m.
Raises
ValueError- If not exactly one of
temperatureandperpendicular_speedis given.
Examples
>>> # 1 keV electron, 1 T>>> print(f"{larmor_radius(1.0, temperature=1e3):.4g} m")7.54e-05 m>>> radius = larmor_radius(2.0, perpendicular_speed=1e6, mass=proton_mass)>>> print(f"{radius:.4g} m")0.00522 mlower_hybrid_frequencyfunction#
def lower_hybrid_frequency(density, field, mass_number=1, charge_number=1)Compute the lower hybrid frequency, 1/ω_LH² = 1/(Ω_i² + ω_pi²) + 1/(|Ω_e| Ω_i).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
density | float or array_like | required | Electron density n_e, in m⁻³ (the ion density is n_e / Z). |
field | float or array_like | required | Magnetic field B, in T. |
mass_number | float or array_like | 1 | Ion mass in proton masses. Default: 1. |
charge_number | float or array_like | 1 | Ion charge number Z. Default: 1. |
Returns
float or numpy.ndarray- ω_LH, in rad/s. For ω_pi ≫ Ω_i it tends to √(|Ω_e| Ω_i).
Examples
>>> print(f"{lower_hybrid_frequency(1e20, 1.0) / (2 * np.pi):.4g} Hz")6.237e+08 Hzplasma_betafunction#
def plasma_beta(density, temperature, field)Compute the plasma beta β = n T / (B²/(2μ₀)), the ratio of thermal to magnetic pressure.
For several species, add their β (or pass the summed pressure n T of all species).
Parameters
Returns
float or numpy.ndarray- β (dimensionless).
Examples
>>> print(f"{plasma_beta(1e20, 1e4, 5.0):.4f}") # 10 keV, 5 T0.0161plasma_frequencyfunction#
def plasma_frequency(density, mass=electron_mass, charge=elementary_charge)Compute the plasma frequency ω_p = √(n q² / (ε₀ m)).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
density | float or array_like | required | Number density n of the species, in m⁻³. |
mass | float or array_like | electron_mass | Particle mass m, in kg. Default: the electron mass. |
charge | float or array_like | elementary_charge | Particle charge q, in C (its sign doesn’t matter). Default: e. |
Returns
float or numpy.ndarray- ω_p in rad/s (divide by 2π for Hz).
Examples
>>> print(f"{plasma_frequency(1e18) / (2 * np.pi):.4g} Hz")8.979e+09 Hz>>> # deuterons>>> print(f"{plasma_frequency(1e20, mass=2 * proton_mass):.4g} rad/s")9.309e+09 rad/splasma_parameterfunction#
def plasma_parameter(density, temperature)Compute the plasma parameter N_D = (4π/3) n λ_D³, the number of electrons in a Debye sphere.
Parameters
Returns
float or numpy.ndarray- N_D (dimensionless). A plasma is weakly coupled for N_D ≫ 1.
Examples
>>> print(f"{plasma_parameter(1e6, 1.0):.3g}") # 1 cm⁻³, 1 eV1.72e+09sound_speedfunction#
def sound_speed(electron_temperature, ion_temperature=0.0, mass_number=1, charge_number=1, electron_gamma=1.0, ion_gamma=3.0)Compute the ion sound speed c_s = √((γ_e Z T_e + γ_i T_i) / m_i).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
electron_temperature | float or array_like | required | Electron temperature T_e, in eV. |
ion_temperature | float or array_like | 0.0 | Ion temperature T_i, in eV. Default: 0 (cold ions). |
mass_number | float or array_like | 1 | Ion mass in proton masses. Default: 1. |
charge_number | float or array_like | 1 | Ion charge number Z. Default: 1. |
electron_gamma | float | 1.0 | Adiabatic index γ_e of the electrons. Default: 1 (isothermal electrons). |
ion_gamma | float | 3.0 | Adiabatic index γ_i of the ions. Default: 3 (1-D adiabatic ions). |
Returns
float or numpy.ndarray- c_s, in m/s.
Examples
>>> print(f"{sound_speed(1.0):.4g} m/s")9787 m/sstruphy_equation_parametersfunction#
def struphy_equation_parameters(units, charge_number=1, mass_number=1)Compute the equation parameters α, ε and κ of one Struphy species.
Mirrors struphy.models.species.Species.EquationParameters, with ω_p and Ω_c of the
species at the unit density and unit field: α = ω_p/Ω_c, ε = 1/(Ω_c t) and κ = ω_p t.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
units | dict | required | The units from struphy_units(). |
charge_number | float | 1 | Charge number Z of the species. Default: 1. |
mass_number | float | 1 | Mass number A of the species, in proton masses. Default: 1. |
Returns
dictalpha,epsilonandkappa.
Examples
>>> units = struphy_units(velocity_scale="alfvén", mass_number=1)>>> params = struphy_equation_parameters(units)>>> print({key: f"{value:.4g}" for key, value in params.items()}){'alpha': '137.4', 'epsilon': '0.02277', 'kappa': '6036'}struphy_unitsfunction#
def struphy_units(x=1.0, B=1.0, n=1.0, kBT=None, velocity_scale='light', mass_number=None, charge_number=None)Compute the units of Struphy’s normalization from its base units.
Mirrors struphy.physics.physics.Units.derive_units (the base units are those of
struphy.io.options.BaseUnits in a parameter file, the velocity scale is the model’s
velocity_scale and the mass and charge numbers are those of the model’s bulk species):
- velocity v: c for
"light"; B / √(A m_p n μ₀) for"alfvén"; (Z e B / (A m_p)) x for"cyclotron"; √(kBT / (A m_p)) for"thermal"; 1 m/s forNone, - time t = x / v, and the frequency 1/t (normalized angular frequencies ω t are in rad/t),
- with a bulk species (
mass_numbergiven): pressure p = A m_p n v² (= B²/μ₀ for"alfvén"), mass density ρ = A m_p n, current density j = e n v.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | float | 1.0 | Unit of length, in m (BaseUnits.x). Default: 1. |
B | float | 1.0 | Unit of magnetic field, in T (BaseUnits.B). Default: 1. |
n | float | 1.0 | Unit of number density, in 1e20 m⁻³ as in BaseUnits.n (not in m⁻³). Default: 1. |
kBT | float | None | Unit of thermal energy, in keV as in BaseUnits.kBT; needed for "thermal". |
velocity_scale | ('light', 'alfvén', 'cyclotron', 'thermal', None) | "light" | The model’s velocity scale ("alfven" is accepted too). Default: "light". |
mass_number | float | None | Mass number A of the bulk species, in proton masses; needed except for "light" and
None. |
charge_number | float | None | Charge number Z of the bulk species; needed for "cyclotron". |
Returns
dict- Floats, in SI units except
kBT:x(m),B(T),n(m⁻³),kBT(keV or None),v(m/s),t(s),frequency(1/s),p(Pa),rho(kg/m³) andj(A/m²); the last three are None without a bulk species.STRUPHY_UNIT_SYMBOLSholds these unit names.
Raises
ValueError- If
velocity_scaleis unknown or a quantity it needs is missing.
Examples
>>> units = struphy_units(... x=1.0, B=1.0, n=1.0, velocity_scale="alfvén", mass_number=2... )>>> print(f"v = {units['v']:.4g} m/s, t = {units['t']:.4g} s")v = 1.542e+06 m/s, t = 6.484e-07 s>>> print(f"p = {units['p']:.4g} Pa") # B²/μ₀p = 7.958e+05 Pathermal_speedfunction#
def thermal_speed(temperature, mass=electron_mass, convention='sqrt(T/m)')Compute the thermal speed of a Maxwellian of temperature T.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
temperature | float or array_like | required | Temperature T, in eV. |
mass | float or array_like | electron_mass | Particle mass m, in kg. Default: the electron mass. |
convention | ('sqrt(T/m)', 'sqrt(2T/m)', 'mean') | "sqrt(T/m)" | "sqrt(T/m)": the standard deviation of each velocity component, as in the NRL
formulary and in Struphy’s Maxwellians and velocity_scale="thermal";
"sqrt(2T/m)": the most probable speed, common in kinetic theory; "mean": the mean
speed √(8T/(πm)). Default: "sqrt(T/m)". |
Returns
float or numpy.ndarray- The thermal speed, in m/s.
Raises
ValueError- If
conventionis unknown.
Examples
>>> print(f"{thermal_speed(1.0):.4g} m/s")4.194e+05 m/s>>> print(f"{thermal_speed(1.0, convention='sqrt(2T/m)'):.4g} m/s")5.931e+05 m/supper_hybrid_frequencyfunction#
def upper_hybrid_frequency(density, field)Compute the upper hybrid frequency ω_UH = √(ω_pe² + Ω_e²).
Parameters
Returns
float or numpy.ndarray- ω_UH, in rad/s.
Examples
>>> print(f"{upper_hybrid_frequency(1e19, 1.0):.4g} rad/s")2.505e+11 rad/s