PlasmaBO
Installation
using Pkg
Pkg.add("PlasmaBO")Features
- Hermite-Hermite (BO-HH) expansion solver for arbitrary/analytic distributions
- Maxwellian / BiMaxwellian
- Analytic Product-Bi-Kappa (BO-PBK) solver
- Multi-fluid solver
- Integration with
ChargedParticles.jl
Usage Examples
The matrix eigenvalue method (Xie [1], Xie and Xiao [2]) finds all wave modes simultaneously by transforming the dispersion relation into a matrix eigenvalue problem using J-pole approximation for the plasma dispersion function.
This approach is more efficient to find multiple modes at once, and doesn't require initial guesses for the root finder.
Check out the ring beam instability example for detailed usage instructions, also see firehose instability example for using with arbitrary velocity distributions, BO-PBK example for using with kappa distributions (BO-PBK), cold plasma example for comparing kinetic and fluid solvers, and dispersion surface tracking example for 2D scanning and mode tracking.
Solvers
BO-PBK (BOPBK) is an analytic, distribution-aware eigen-solver optimized for kappa plasmas, whereas BO-Arbitrary (BOHH) is a universal but numerically heavier framework that approximates any distribution at the cost of efficiency and low-κ accuracy.
PlasmaBO.BOPBK — Type
BOPBK(; N = 2)Dispersion solver using the PBK matrix formulation.
N controls the truncation order of the cyclotron harmonic index used to build the dispersion matrix.
PlasmaBO.BOHH — Type
BOHH(; N = 2, J = 8)Dispersion solver using the Hermite-Hankel (HH) matrix formulation.
N controls the truncation order of the cyclotron harmonic index. J controls the truncation order of the Hermite expansion used in the solver.
PlasmaBO.BOFluid — Type
BOFluid()Dispersion solver using the multi-fluid electromagnetic matrix formulation.
Notation & Assumptions
The formulation (code) is valid for non-relativistic, arbitrary gyrotropic distributions.
- Coordinates
z: direction parallel to the background magnetic field (B0).x: one perpendicular direction (any perpendicular direction is equivalent).
- Velocities
vz,vx: particle velocity components alongzandx.vdz,vdx: drift/bulk velocity components alongzandx(when present in a distribution parameterization).vtz,vtx: thermal speeds alongzandx.
- Wave vector
θ: propagation angle betweenkandB0.k∥ = k cos(θ),k⊥ = k sin(θ).
References
Xie et al. [3], Xie [4], Xie [5],
- [1]
- H. Xie. Efficient Framework for Solving Plasma Waves with Arbitrary Distributions. Physics of Plasmas 32, 60702 (2025).
- [2]
- H. Xie and Y. Xiao. PDRK: A General Kinetic Dispersion Relation Solver for Magnetized Plasma*. Plasma Science and Technology 18, 97 (2016).
- [3]
- H.-s. Xie, R. Denton, J.-s. Zhao and W. Liu. BO 2.0: Plasma Wave and Instability Analysis with Enhanced Polarization Calculations (Mar 2021), arXiv:2103.16014 [physics].
- [4]
- H.-s. Xie. PDRF: A General Dispersion Relation Solver for Magnetized Multi-Fluid Plasma. Computer Physics Communications 185, 670–675 (2014).
- [5]
- H.-S. (. Xie. Generalized Plasma Dispersion Function: One-Solve-All Treatment, Visualizations, and Application to Landau Damping. Physics of Plasmas 20, 92125 (2013).
- [6]
- T. Umeda, S. Matsukiyo, T. Amano and Y. Miyoshi. A Numerical Electromagnetic Linear Dispersion Relation for Maxwellian Ring-Beam Velocity Distributions. Physics of Plasmas 19, 72107 (2012).
- [7]
- T. Cattaert, M. A. Hellberg and R. L. Mace. Oblique Propagation of Electromagnetic Waves in a Kappa-Maxwellian Plasma. Physics of Plasmas 14, 82111 (2007).
- [8]
API Reference
PlasmaBO.BOFluidPlasmaBO.BOHHPlasmaBO.BOPBKPlasmaBO.BranchPointPlasmaBO.FluidSpeciesPlasmaBO.FluidSpeciesPlasmaBO.JPoleCoefficientsPlasmaBO.funAnPlasmaBO.funBnPlasmaBO.funCnPlasmaBO.funInPlasmaBO.get_jpole_coefficientsPlasmaBO.hermite_HPlasmaBO.hermite_a0_to_aPlasmaBO.hermite_coefficients_matrixPlasmaBO.hermite_expansionPlasmaBO.solve_dispersion_matrixPlasmaBO.track
PlasmaBO.BOFluid — Type
BOFluid()Dispersion solver using the multi-fluid electromagnetic matrix formulation.
PlasmaBO.BOHH — Type
BOHH(; N = 2, J = 8)Dispersion solver using the Hermite-Hankel (HH) matrix formulation.
N controls the truncation order of the cyclotron harmonic index. J controls the truncation order of the Hermite expansion used in the solver.
PlasmaBO.BOPBK — Type
BOPBK(; N = 2)Dispersion solver using the PBK matrix formulation.
N controls the truncation order of the cyclotron harmonic index used to build the dispersion matrix.
PlasmaBO.BranchPoint — Type
BranchPoint{T}
BranchPoint(k, ω)Initial point specification for dispersion branch tracking.
Fields
k: Wave vector at initial pointω: Frequency at initial pointlocator: Callable used to locate the seed eigenvalue at the initial point
Example
# Track unstable branch starting at k=0.03 with γ=0.1721
point1 = BranchPoint(0.03, 0.1721im) # Auto: track by Im
# Track real frequency mode at k=0.5 with ωᵣ=2.5
point2 = BranchPoint(0.5, 2.5) # Auto: track by RePlasmaBO.FluidSpecies — Type
FluidSpecies(n, Tz, Tp = Tz; vdz=0.0, gamma_z=1.0, gamma_p=1.0, particle=:p, ...)PlasmaBO.FluidSpecies — Type
FluidSpecies{T}Fluid species parameters for the multi-fluid dispersion relation solver.
Fields
q: Chargem: Massn: Number density (m⁻³)Tz: Parallel temperature (eV)Tp: Perpendicular temperature (eV)vdz: Parallel drift velocity (in units of c)gamma_z: Parallel polytrope exponent (default: 1.0 for isothermal)gamma_p: Perpendicular polytrope exponent (default: 1.0 for isothermal)
PlasmaBO.JPoleCoefficients — Type
JPoleCoefficients{T}J-pole approximation coefficients for the plasma dispersion function. Z(ζ) ≈ Σⱼ bⱼ/(ζ - cⱼ)
PlasmaBO.funAn — Method
funAn(n, a, d, m, p)Perpendicular integral for Jn²: ∫ Jn²(ay) exp(-(y-d)²) (y-d)^m y^p dy.
PlasmaBO.funBn — Method
funBn(n, a, d, m, p)Perpendicular integral for Jn·Jn': ∫ Jn(ay) Jn'(ay) exp(-(y-d)²) (y-d)^m y^p dy.
PlasmaBO.funCn — Method
funCn(n, a, d, m, p)Perpendicular integral for (Jn')²: ∫ [Jn'(ay)]² exp(-(y-d)²) (y-d)^m y^p dy.
PlasmaBO.funIn — Method
funIn(n)Normalization integral I_n = ∫ v^n exp(-v²) dv / √π.
Returns Γ((n+1)/2)/√π for even n, 0 for odd n.
PlasmaBO.get_jpole_coefficients — Function
get_jpole_coefficients(J=8)Get J-pole approximation coefficients for the plasma dispersion function.
Supported values: J ∈ {4, 6, 8, 10, 12, 16, 20, 24, 28, 32}
PlasmaBO.hermite_H — Method
hermite_H(n::Int, x)Compute physicists' Hermite polynomial H_n(x) using recurrence relation.
Recurrence Relations
- H_0(x) = 1
- H_1(x) = 2x
- H{n+1}(x) = 2x*Hn(x) - 2n*H_{n-1}(x)
Examples
hermite_H(0, 1.5) # Returns 1.0
hermite_H(1, 1.5) # Returns 3.0 (= 2*1.5)
hermite_H(2, 1.5) # Returns 7.0 (= 2*1.5*3.0 - 2*1*1.0)PlasmaBO.hermite_a0_to_a — Method
hermite_a0_to_a(a0lm)Convert normalized Hermite basis coefficients: a0lm -> alm
Transforms expansion:
f(z,x) = Σ_{l,m} a0_{l,m} * ρ_l(z) * u_m(x)to:
f(z,x) = Σ_{l,m} a_{l,m} * g_l(z) * h_m(x)where:
- ρl, um are normalized Hermite functions
- g_l(z) ∝ z^l * exp(-z²/2)
- h_m(x) ∝ x^m * exp(-x²/2)
PlasmaBO.hermite_coefficients_matrix — Method
hermite_coefficients_matrix(nmax)Compute coefficient matrix for expanding Hermite polynomials in power basis given the maximum order nmax.
Returns matrix cHn[n+1, k+1] such that:
H_n(x) / √(2^n n! √π) = Σ_k cHn[n+1, k+1] * x^k / √(2^{n-k} n! √π)This is used to convert between normalized Hermite basis and power-law basis.
Returns
cHn: (nmax+1) × (nmax+1) coefficient matrix
PlasmaBO.hermite_expansion — Method
hermite_expansion(
fv::AbstractMatrix{T},
vz, vx, vtz, vtp;
Nz = 16, Nx = 16,
dz = zero(T), dx = zero(T)
) where {T}Compute Hermite expansion coefficients from gridded distribution function.
Expands arbitrary 2D distribution f(vparallel, vperp) as:
f(vz, vx) = Σ_{l=0}^{Nz} Σ_{m=0}^{Nx} a_{l,m} * ρ_l(vz) * u_m(vx)where ρl and um are normalized Hermite basis functions. Nz, Nx are the maximum parallel and perpendicular Hermite indices, respectively.
Arguments
fv: Distribution function values on (vz, vx) gridvz: Parallel velocity grid (1D or matches fv size)vx: Perpendicular velocity grid (1D or matches fv size)vtz: Parallel thermal velocity (default: 1.0)vtp: Perpendicular thermal velocity (default: 1.0)dz: Parallel drift velocity (default: 0.0)dx: Perpendicular drift velocity (default: 0.0)
Returns
Named tuple with:
alm: (Nz+1) × (Nx+1) coefficient matrix in power-law basisa0lm: (Nz+1) × (Nx+1) coefficient matrix in Hermite basis
Algorithm
Compute a0_{l,m} via numerical integration:
a0_{l,m} = ∫∫ f(z,x) ρ_l(z) u_m(x) dz dx * (2/(Lz*Lx))Normalize by distribution integral
Convert to power-law basis: a{l,m} = hermitea0toa(a0_{l,m})
PlasmaBO.solve_dispersion_matrix — Function
solve_dispersion_matrix(params, kx, kz; N=2, J=8)Solve the kinetic dispersion relation using the matrix eigenvalue method.
Returns all eigenfrequencies ω(k) for the given wave vector (kx, kz).
This method transforms the dispersion relation into a matrix eigenvalue problem using J-pole approximation for the plasma dispersion function, allowing simultaneous computation of all wave modes.
kx: Perpendicular wave vector component (m⁻¹)kz: Parallel wave vector component (m⁻¹)J: Number of poles for Z-function approximation (default: 8)
See also: get_jpole_coefficients
PlasmaBO.track — Method
track(solution, point)Track a single dispersion branch across parameter space from initial point.
The algorithm:
- Start at the k-point nearest to the initial point
- Track bidirectionally using interpolation to predict ω at each k
- Select nearest eigenvalue to prediction
Example
initial = BranchPoint(0.03, 0.1721im)
k_branch, ω_branch = track(solution, initial)See also: BranchPoint