Skip to content
Projects

opencr.kinetics.rates

Rate coefficients of every reaction of a network for given conditions.

RateEvaluator prepares each reaction once and then returns the vector of rate coefficients k_r (SI) for any Conditions, or for many electron temperatures at once.

Cross sections, Maxwellian. plasmacoll’s cross sections are linear between their table points and constant beyond the last one, so k(T) = (8 / (pi mu))^1/2 (kT)^-3/2 int sigma(E) E exp(-E / kT) dE is a sum of integrals of quadratics times an exponential, done in closed form per segment: exact for the table, with no integration grid. Each evaluator returns k exp(E_th / T) with the threshold E_th taken out, so that detailed balance never forms exp(+E/T) of a tiny number.

Cross sections, any EEDF. With a non-Maxwellian EEDF, the electron-impact rates are (2 e / m_e)^1/2 int eps sigma F0 deps (plasmacoll.eedf_rate_coefficient) on the distribution’s grid. Rates that are not cross sections use the conditions’ electron temperature (2/3 <eps> from from_eedf).

Detailed balance. The inverse of an electron-impact excitation uses the Klein-Rosseland inverse cross section sigma_inv(eps) = (g_l / g_u) (eps + dE) / eps sigma(eps + dE) for any EEDF, which for a Maxwellian is the Boltzmann relation k_inv = k (g_l / g_u) exp(dE / T) (used in closed form). An inverse with one electron more on the forward product side (three-body recombination from ionization) follows the Saha relation k_inv = k (g_0 / (g_e g_+)) lambda^3 exp(dE / T) with the electron’s thermal de Broglie volume lambda^3, at the electron temperature (the effective one for a non-Maxwellian EEDF). dE and the weights come from the states.

Escape factors multiply the spontaneous emission rates (radiation trapping): the conditions’ value for the reaction if given, else the reaction’s own.

Arrays. Every evaluator is written against cunumpy’s xp (NumPy or CuPy for the whole process, see opencr.backends; the optional JAX backend passes jax.numpy in its place): RateEvaluator.coefficients_batched evaluates all reactions at many electron temperatures at once there, RateEvaluator.coefficients one set of conditions, as floats on the host. A Function rate runs on the host (its temperatures are copied there and the result back); a non-Maxwellian EEDF is integrated on the host by plasmacoll and is not batched.

Classes

NameDescription
MaxwellianIntegralThe exact Maxwellian average of a piecewise-linear cross section.
RateEvaluatorRate coefficients of a network's reactions.

Functions

NameDescription
inverse_cross_sectionReturn the Klein-Rosseland inverse of an electron-impact cross section.

MaxwellianIntegralclassdataclass#

class MaxwellianIntegral(threshold: float, mass: float, y: np.ndarray, c0: np.ndarray, c1: np.ndarray, c2: np.ndarray)

The exact Maxwellian average of a piecewise-linear cross section.

Attributes

NameTypeDescription
thresholdfloatThe threshold in the centre-of-mass frame (eV).
massfloatThe reduced mass (kg).
ynp.ndarrayThe segment boundaries above the threshold (eV), n + 1 values; the last segment continues to infinity with a constant cross section.
c0,(c1, c2)The coefficients of sigma(E) E = c0 + c1 y + c2 y^2 per segment (n + 1 values, the last for the tail with c2 = 0).

Numerics

maxwellian

k(T)=8πμ (kT)−3/2∫Eth∞σ(E) E e−E/kT dEk(T) = \sqrt{\frac{8}{\pi\mu}}\,(kT)^{-3/2} \int_{E_{\mathrm{th}}}^\infty \sigma(E)\,E\,e^{-E/kT}\,dE

segment

y=E−Eth,σ(E) E=c0+c1y+c2y2,σ=a+s y: c0=aEth, c1=a+sEth, c2=sy = E - E_{\mathrm{th}}, \qquad \sigma(E)\,E = c_0 + c_1 y + c_2 y^2, \qquad \sigma = a + s\,y:\ c_0 = a E_{\mathrm{th}},\ c_1 = a + s E_{\mathrm{th}},\ c_2 = s

antiderivative

∫g(y) e−y/T dy=−Te−y/T(g+Tg′+2c2T2)\int g(y)\, e^{-y/T}\, dy = -T e^{-y/T}\big(g + T g' + 2 c_2 T^2\big)

scaled

ln⁡ ⁣(k eEth/T)=ln⁡[8πμ (kT)−3/2 e2∑segments+tail[⋯]]\ln\!\big(k\, e^{E_{\mathrm{th}}/T}\big) = \ln\Big[\sqrt{\tfrac{8}{\pi\mu}}\,(kT)^{-3/2}\, e^2 \sum_{\mathrm{segments} + \mathrm{tail}} \big[\cdots\big]\Big]

Order of accuracy: 2.

Assumptions:

  • exact for the piecewise-linear table, plus the constant tail to infinity (c2=0c_2 = 0); no energy grid
  • the order is that of the table spacing, for a smooth cross section sampled on the table
  • the threshold is taken out (e−E/T=e−Eth/Te−y/Te^{-E/T} = e^{-E_{\mathrm{th}}/T} e^{-y/T}), so detailed balance never forms e+E/Te^{+E/T} of a tiny number; e2e^2 because the integral is in eV2^2 m2^2

c0attributeinstance attribute#

c0: np.ndarray

c1attributeinstance attribute#

c1: np.ndarray

c2attributeinstance attribute#

c2: np.ndarray

massattributeinstance attribute#

mass: float

thresholdattributeinstance attribute#

threshold: float

yattributeinstance attribute#

y: np.ndarray

from_ratemethodclassmethod#

def from_rate(rate: CrossSectionRate) -> MaxwellianIntegral

Prepare the integral of a cross-section rate model.

log_scaledmethod#

def log_scaled(temperature: Any, xp: ModuleType = xp) -> Any

Return log(k exp(E_th / T)) with k in m^3/s at temperature (eV), on xp.

RateEvaluatorclass#

class RateEvaluator(network: ReactionNetwork)

Rate coefficients of a network’s reactions.

Parameters

NameTypeDescription
networkReactionNetworkThe reaction network.

networkattributeinstance attribute#

network = network

namesproperty#

names: tuple[str, ...]

The reaction names, in the order of the coefficient vector.

coefficientsmethod#

def coefficients(conditions: Conditions) -> np.ndarray

Return k_r in SI for every reaction at conditions.

Numerics

scaled

ln⁡k=ln⁡ ⁣(k eEth/T)−EthT,k=0 if ln⁡k<ln⁡(2.2×10−308),ln⁡k≤700\ln k = \ln\!\big(k\, e^{E_{\mathrm{th}}/T}\big) - \frac{E_{\mathrm{th}}}{T}, \qquad k = 0 \ \text{if}\ \ln k < \ln(2.2\times10^{-308}), \qquad \ln k \le 700

inverse

ln⁡kinv=ln⁡ ⁣(kfwd eEth/T)+ln⁡gingout+ΔE−EthT+32 Δe [ln⁡h22πmee−ln⁡T]\ln k_{\mathrm{inv}} = \ln\!\big(k_{\mathrm{fwd}}\, e^{E_{\mathrm{th}}/T}\big) + \ln\frac{g_{\mathrm{in}}}{g_{\mathrm{out}}} + \frac{\Delta E - E_{\mathrm{th}}}{T} + \tfrac32\, \Delta e\, \Big[\ln\frac{h^2}{2\pi m_e e} - \ln T\Big]

boltzmann

kul=klu glgu eΔE/Tk_{ul} = k_{lu}\,\frac{g_l}{g_u}\, e^{\Delta E/T}

saha

k3b=kion g0ge g+ Λ3 eI/T,Λ3=(h22πmekT)3/2k_{3b} = k_{\mathrm{ion}}\,\frac{g_0}{g_e\, g_+}\,\Lambda^3\, e^{I/T}, \qquad \Lambda^3 = \left(\frac{h^2}{2\pi m_e kT}\right)^{3/2}

escape

kr←gr krfor every spontaneous emissionk_r \leftarrow g_r\, k_r \quad \text{for every spontaneous emission}

Assumptions:

  • depends_on picks the temperature: TeT_e (TeffT_{\mathrm{eff}} for a non-Maxwellian EEDF), TiT_i (the gas temperature when not given), TgasT_{\mathrm{gas}}, or none
  • with a non-Maxwellian EEDF only the electron cross sections (and their Klein-Rosseland inverses) are integrated over it (plasmacoll.eedf_rate_coefficient)
  • the escape factor grg_r is Conditions.escape by name, else the reaction’s own escape

References:

Built from:

  • opencr.kinetics.rates.MaxwellianIntegral
  • opencr.kinetics.rates.inverse_cross_section

coefficients_batchedmethod#

def coefficients_batched(conditions: Conditions, electron_temperatures: Any)

Return k of shape (len(electron_temperatures), n_reactions) on xp.

Maxwellian electrons at each temperature; everything else (the heavy temperatures, the escape factors) from conditions. The input is copied to xp and the result stays there (xp.to_numpy brings it back).

Raises

ValueError
A non-Maxwellian EEDF (integrated on the host only), or a temperature that is not positive.

coefficients_scanmethod#

def coefficients_scan(conditions: Conditions, electron_temperatures: np.ndarray) -> np.ndarray

Return k of shape (len(electron_temperatures), n_reactions) on the host.

escape_factorsmethod#

def escape_factors(conditions: Conditions) -> np.ndarray

Return the factor of every reaction: the escape factor of a line, 1 otherwise.

evaluatemethod#

def evaluate(prepared: Sequence[_Prepared], conditions: Conditions, electron_temperatures: Any, xp: ModuleType = xp) -> Any

Return k of shape (..., n_reactions) on the namespace xp.

The core of coefficients_batched, for a given list of prepared reactions (the JAX backend passes its own, with Function rates tabulated) and any array namespace with the NumPy API; conditions gives the heavy temperatures and the escape factors. The Maxwellian integrals of all cross sections are evaluated at once (_Stack), the thresholds and detailed-balance factors as vectors; only Arrhenius, tabulated and function rates go one by one. An intermediate of (..., U, S) numbers (integrals times table points) is formed, so a long batch is better evaluated in chunks.

inverse_cross_sectionfunction#

def inverse_cross_section(cross_section: CrossSection, weight_ratio: float, energy_gap: float) -> CrossSection

Return the Klein-Rosseland inverse of an electron-impact cross section.

sigma_inv(eps) = weight_ratio (eps + dE) / eps sigma(eps + dE) with dE = energy_gap; the table starts just above zero energy.

Numerics

reversibility

gl εl σlu(εl)=gu εu σul(εu),εl=εu+ΔEg_l\,\varepsilon_l\,\sigma_{lu}(\varepsilon_l) = g_u\,\varepsilon_u\,\sigma_{ul}(\varepsilon_u), \qquad \varepsilon_l = \varepsilon_u + \Delta E

klein rosseland

σul(ε)=glgu ε+ΔEε σlu(ε+ΔE)\sigma_{ul}(\varepsilon) = \frac{g_l}{g_u}\,\frac{\varepsilon + \Delta E}{\varepsilon}\,\sigma_{lu}(\varepsilon + \Delta E)

Assumptions:

  • microscopic reversibility, so it holds for any electron energy distribution
  • tabulated on the forward table points shifted down by ΔE\Delta E, from 10−6max⁡(ΔE,10−3)10^{-6}\max(\Delta E, 10^{-3}) eV
  • ΔE\Delta E is the cross section’s threshold (13.6-based for hydrogen); the Maxwellian path uses the state energy gap (13.598-based)

References: