Skip to content

Nuclear Networks, Rates & Neutrinos (chem, ionization, neu, rates, net)

This reference page documents the five nuclear and microphysical reaction subpackages: nuclide catalogs and solar abundance scales (flexmesa.chem), partial ionization and effective ionic charges (flexmesa.ionization), thermal neutrino cooling (flexmesa.neu), thermonuclear REACLIB rates and plasma screening (flexmesa.rates), and nuclear reaction networks and stiff 1-zone burners (flexmesa.net).

For governing equations and diagnostic plots, see Nuclear Networks, Rates & Neutrinos.


Quick Usage Example

import numpy as np
import flexmesa.chem as chem
import flexmesa.net as net
import flexmesa.neu as neu

# 1. Solar mixture composition moments on basic.net (8 isotopes)
net_info = net.get_net_info("basic.net")
xa = np.array([0.70, 2.0e-5, 0.28, 3.0e-3, 1.0e-3, 6.0e-3, 2.0e-3, 9.98e-3])
comp = chem.get_composition_info(net_info.chem_id, xa)

# 2. Thermal neutrino loss rate (Itoh et al. 1996)
neu_out = neu.neu_get(
    t=1.0e8,
    log10_t=8.0,
    rho=1.0e4,
    log10_rho=4.0,
    abar=float(comp.abar),
    zbar=float(comp.zbar),
)

# 3. Nuclear reaction network RHS and analytical Jacobian
net_out = net.eval_net(
    "basic.net",
    x=xa,
    temp=8.0e7,
    rho=100.0,
    abar=float(comp.abar),
    zbar=float(comp.zbar),
    z2bar=float(comp.z2bar),
    ye=float(comp.ye),
    screening_mode="extended",
)
print(
    f"abar={comp.abar:.4f}, eps_neu={neu_out.loss[0]:.3e} erg/g/s, "
    f"eps_nuc={net_out.eps_nuc:.3e} erg/g/s"
)

Nuclide Catalog & Solar Abundance Scales (flexmesa.chem)

flexmesa.chem provides 347 built-in reference nuclides (plus full isotopes.data parsing), 286 solar isotopic abundances, 10 standard solar abundance compilations (AG89, GS98, L03, AGS05, AGSS09, L09, A09_Prz, MB22_phot, AAG21_phot, AAG21), and composition moment reductions (\(\bar{A}, \bar{Z}, \overline{Z^2}, Y_e, \mu\)).

flexmesa.chem.catalog

Element tables, nuclide catalogs, solar abundance scales, and reaction Q.

Exposes the canonical Safe Rust (flexmesa-chem) catalogs and energetics via flexmesa._rust, matching upstream MESA chem_def.f90 and chem_lib.f90.

Index and Memory-Order Contract
  • Element IDs (e_h = 1 .. e_cn = 112) and nuclide IDs (chem_id >= 1) preserve upstream 1-based MESA integer identifiers (0 for neut).
  • Solar metal mass-fraction arrays (solar_element_zfrac) have shape (112,) in float64, where 0-based index z - 1 corresponds to atomic number z (\(Z \in [1, 112]\)).

NuclideInfo dataclass

Properties of a single nuclear species in the built-in catalog.

Attributes:

Name Type Description
chem_id int

1-based MESA nuclide identifier in isotopes.data.

name str

Trimmed isotope symbol (such as "o16" or "fe56").

z int

Proton number \(Z_i\) (dimensionless integer).

n int

Neutron number \(N_i\) (dimensionless integer).

spin float

Ground-state nuclear spin \(J_i\) (dimensionless).

mass_excess float

Tabulated atomic mass excess \(\Delta M_i\) (\(\mathrm{MeV}\)).

binding_energy float

Nuclear binding energy \(B_i\) (\(\mathrm{MeV}\)).

w float

Recomputed double-precision atomic weight \(W_i\) (\(\mathrm{g/mol}\)).

z53 float

Pre-calculated Coulomb screening power \(Z_i^{5/3}\).

isomeric_state int

Isomeric state index (0 for ground state).

a property

a

Total baryon number \(A_i = Z_i + N_i\).

chem_get_element_id

chem_get_element_id(name)

Return the 1-based atomic number \(Z \in [1, 112]\) for an element symbol.

Parameters:

Name Type Description Default
name str

Case-insensitive element symbol (e.g. "h", "he").

required

Returns:

Type Description
int

1-based element ID \(Z \in [1, 112]\), or -1 if name is not found.

element_name

element_name(z)

Return the short element symbol for atomic number \(Z \in [0, 112]\).

Parameters:

Name Type Description Default
z int

Atomic number \(Z \in [0, 112]\) (0 returns "neut").

required

Returns:

Type Description
str

Short element symbol (e.g. "he" for \(Z = 2\)).

Raises:

Type Description
ValueError

If z is outside [0, 112].

element_long_name

element_long_name(z)

Return the full element name for atomic number \(Z \in [0, 112]\).

Parameters:

Name Type Description Default
z int

Atomic number \(Z \in [0, 112]\).

required

Returns:

Type Description
str

Full element name (e.g. "helium" for \(Z = 2\)).

Raises:

Type Description
ValueError

If z is outside [0, 112].

element_main_iso_name

element_main_iso_name(z)

Return the dominant solar isotope name for \(Z \in [1, 112]\).

Parameters:

Name Type Description Default
z int

Atomic number \(Z \in [1, 112]\).

required

Returns:

Type Description
str

Dominant isotope name (e.g. "fe56" for \(Z = 26\)).

Raises:

Type Description
ValueError

If z is outside [1, 112].

category_id

category_id(name)

Return the 1-based reaction category ID (\(1..=24\)) or 0 if unknown.

Parameters:

Name Type Description Default
name str

Reaction category name (e.g. "pp", "cno").

required

Returns:

Type Description
int

1-based category index (\(1..=24\)), or 0 if not found.

category_name

category_name(cat_id)

Return the reaction category name for 1-based cat_id (\(1..=24\)).

Parameters:

Name Type Description Default
cat_id int

1-based category index (\(1..=24\)).

required

Returns:

Type Description
str

Category name string.

Raises:

Type Description
ValueError

If cat_id is outside [1, 24].

get_partition_fcn_indx

get_partition_fcn_indx(t9)

Return the 1-based partition function temperature bracket index.

Parameters:

Name Type Description Default
t9 float

Temperature \(T_9 = T / 10^9\,\mathrm{K}\) in \(\mathrm{GK}\).

required

Returns:

Type Description
int

1-based lower bracket index in 0..=24 on T_PART.

generate_nuclide_names

generate_nuclide_names(z, a)

Generate short nuclide names from parallel \((Z, A)\) sequences.

Parameters:

Name Type Description Default
z Sequence[int]

Sequence of proton numbers \(Z_i\).

required
a Sequence[int]

Sequence of baryon numbers \(A_i\).

required

Returns:

Type Description
list[str]

List of short nuclide identifiers (e.g. ["c12", "fe56"]).

generate_long_nuclide_names

generate_long_nuclide_names(z, a)

Generate long nuclide names from parallel \((Z, A)\) sequences.

Parameters:

Name Type Description Default
z Sequence[int]

Sequence of proton numbers \(Z_i\).

required
a Sequence[int]

Sequence of baryon numbers \(A_i\).

required

Returns:

Type Description
list[str]

List of long nuclide names (e.g. ["carbon-12", "iron-56"]).

get_nuclide_index

get_nuclide_index(name)

Return the 1-based chem_id for a nuclide name (get_nuclide_index).

Parameters:

Name Type Description Default
name str

Nuclide name (such as "h1", "c12", "o16", "fe56").

required

Returns:

Type Description
int

1-based MESA chem_id in isotopes.data, or -1 if not found.

get_nuclide_info

get_nuclide_info(iso)

Return the NuclideInfo record for a chem_id or isotope name.

Parameters:

Name Type Description Default
iso int | str

1-based integer chem_id or string isotope name (e.g. "o16").

required

Returns:

Type Description
NuclideInfo

NuclideInfo dataclass with atomic weight, binding energy, and spin.

Raises:

Type Description
ValueError

If iso is not present in the catalog.

ag89_zsol

ag89_zsol()

Return the Anders & Grevesse (1989) bulk solar metallicity zsol.

Returns:

Type Description
float

Solar metallicity \(Z_\odot = 1.8987109631891819 \times 10^{-2}\).

ag89_yesol

ag89_yesol()

Return the Anders & Grevesse (1989) solar electron fraction yesol.

Returns:

Type Description
float

Solar electron-to-baryon ratio \(Y_{e,\odot} = 0.85280190902027331\).

chem_xsol

chem_xsol(name)

Return the Anders & Grevesse (1989) solar mass fraction for name.

Parameters:

Name Type Description Default
name str

Isotope name ("h1", "c12") or alias ("p", "d").

required

Returns:

Type Description
float

Solar mass fraction \(X_{\odot}(\text{name})\) or 0.0 if absent.

chem_get_solar

chem_get_solar(name)

Look up (Z, A, X_sol) for name in the Anders & Grevesse (1989) list.

Parameters:

Name Type Description Default
name str

Isotope name or alias ("p", "d").

required

Returns:

Type Description
tuple[float, float, float] | None

Tuple (z, a, x_sol) in float64, or None if absent.

lodders03_element_atom_percent

lodders03_element_atom_percent(nuclei)

Return the Lodders (2003, Table 6) isotopic atom percent for nuclei.

Parameters:

Name Type Description Default
nuclei str

Isotope name (such as "h1", "fe56", "u238").

required

Returns:

Type Description
float

Atom percentage within the parent element (\([0, 100]\)), or 0.0.

ag89_namsol

ag89_namsol()

Return the ordered list of 286 solar isotope names (namsol(1:286)).

Returns:

Type Description
list[str]

List of 286 trimmed isotope names from "h1" to "u238".

get_stable_mass_frac

get_stable_mass_frac(z, a, abun_in)

Map unstable network abundances onto the 286 stable solar isotopes.

Parameters:

Name Type Description Default
z Sequence[int]

Sequence of proton numbers \(Z_i\) of length n_species.

required
a Sequence[int]

Sequence of baryon numbers \(A_i\) of length n_species.

required
abun_in Sequence[float] | NDArray[float64]

Input mass fractions \(X_i\) of shape (n_species,).

required

Returns:

Type Description
NDArray[float64]

1D float64 NumPy array of shape (286,) on ag89_namsol().

solar_element_zfrac

solar_element_zfrac(scale='AGSS09')

Return the 112-element solar metal mass-fraction array.

Parameters:

Name Type Description Default
scale str

Solar scale name ("AG89" through "AAG21").

'AGSS09'

Returns:

Type Description
NDArray[float64]

1D float64 NumPy array of shape (112,) indexed by z - 1.

Raises:

Type Description
ValueError

If scale is not a recognized solar scale name.

solar_cno_fraction

solar_cno_fraction(scale='AGSS09')

Return the CNO mass fraction of metallicity (\(Z_{\mathrm{CNO}} / Z\)).

Parameters:

Name Type Description Default
scale str

Solar scale identifier (e.g. "GS98", "AGSS09").

'AGSS09'

Returns:

Type Description
float

Dimensionless CNO fraction of \(Z\).

Raises:

Type Description
ValueError

If scale is not a recognized solar scale name.

chem_m_div_h

chem_m_div_h(x, z, scale='AGSS09')

Compute logarithmic metallicity [M/H] (chem_M_div_h).

Parameters:

Name Type Description Default
x float

Hydrogen mass fraction \(X > 0\) (dimensionless).

required
z float

Metal mass fraction \(Z > 0\) (dimensionless).

required
scale str

Solar abundance scale name.

'AGSS09'

Returns:

Type Description
float

Logarithmic metallicity \([\mathrm{M/H}]\) in dex.

Raises:

Type Description
ValueError

If x <= 0, z <= 0, or scale is unknown.

reaction_qtotal

reaction_qtotal(num_in, num_out, reactants)

Compute total reaction \(Q\)-value (reaction_Qtotal) in \(\mathrm{MeV}\).

Parameters:

Name Type Description Default
num_in int

Number of incoming reactant species \(N_{\mathrm{in}}\).

required
num_out int

Number of outgoing product species \(N_{\mathrm{out}}\).

required
reactants Sequence[int | str]

Sequence of length num_in + num_out of chem_id or names.

required

Returns:

Type Description
float

Total energy release \(Q_{\mathrm{total}}\) in \(\mathrm{MeV}\).

Raises:

Type Description
ValueError

If any nuclide name or chem_id is unknown.

flexmesa.chem.composition

Differentiable composition moments and multi-zone kernels (chem).

Implements composition moment evaluators (get_composition_info, basic_composition_info, composition_info, get_composition_info_jax, and get_composition_info_zones), routing between canonical Safe Rust (flexmesa._rust + persistent 4-thread rayon worker pool) and the derived branchless float64 @jax.jit kernel get_composition_info_jax, compatible with jax.jit, jax.vmap, jax.grad, and jax.jacrev.

Index and Memory-Order Contract
  • Species lists (chem_ids) accept either 1-based MESA integer chem_ids or trimmed isotope names (such as "h1", "c12", "fe56").
  • Single-zone abundance vectors x have shape (n_species,) in float64.
  • Multi-zone abundance arrays x_zones have row-major C-contiguous shape (n_zones, n_species) in float64.
  • get_composition_info_zones returns a 2D array of shape (n_zones, 10) with columns: [xh, xhe, xz, abar, zbar, z2bar, z53bar, ye, mass_correction, sumx].

CompositionInfo dataclass

Single-zone or batched composition moments and analytical partials.

Attributes:

Name Type Description
xh float

Hydrogen mass fraction \(X_\mathrm{H} = \sum_{Z_i = 1} X_i\) (dimensionless).

xhe float

Helium mass fraction \(X_\mathrm{He} = \sum_{Z_i = 2} X_i\) (dimensionless).

xz float

Metal mass fraction \(Z = \max(0, \min(1, 1 - (X_\mathrm{H} + X_\mathrm{He})))\) (dimensionless).

abar float

Mean nucleon number \(\bar{A} = (\sum_i X_i) / (\sum_i Y_i)\) (dimensionless).

zbar float

Mean proton number \(\bar{Z} = \bar{A} \sum_i Y_i Z_i\) (dimensionless).

z2bar float

Mean squared charge \(\overline{Z^2} = \bar{A} \sum_i Y_i Z_i^2\) (dimensionless).

z53bar float

Mean \(5/3\)-power charge \(\overline{Z^{5/3}} = \bar{A} \sum_i Y_i Z_i^{5/3}\) (dimensionless).

ye float

Electron-to-baryon ratio \(Y_e = \bar{Z} / \bar{A}\) (dimensionless).

mass_correction float

Atomic mass correction \(\sum_i Y_i W_i\) (dimensionless).

sumx float

Sum of baryon mass fractions \(\sum_i X_i\) (dimensionless).

dabar_dx NDArray[float64]

Partial derivatives \(\partial \bar{A} / \partial X_i\) of shape (n_species,) (or (0,) when skip_partials=True).

dzbar_dx NDArray[float64]

Partial derivatives \(\partial \bar{Z} / \partial X_i\) of shape (n_species,) (or (0,) when skip_partials=True).

dmc_dx NDArray[float64]

Partial derivatives \(\partial (\text{mass\_correction}) / \partial X_i\) of shape (n_species,) (or (0,) when skip_partials=True).

get_composition_info_jax

get_composition_info_jax(chem_ids, x)

Evaluate differentiable composition moments and partials in JAX.

Parameters:

Name Type Description Default
chem_ids Sequence[int | str]

Sequence of length n_species containing 1-based chem_id integers or isotope names (e.g. ["c12", "fe56"]).

required
x Array | NDArray[float64]

Mass fractions \(X_i\) of shape (n_species,) or (*batch, n_species) in float64 (dimensionless).

required

Returns:

Type Description
Array

Tuple (moments, dabar_dx, dzbar_dx, dmc_dx) of jax.Array tensors in

Array

float64, where moments has shape (*batch, 10) (`[xh, xhe, xz,

Array

abar, zbar, z2bar, z53bar, ye, mass_correction, sumx]`) and each

Array

partial derivative array has shape (*batch, n_species).

Raises:

Type Description
ValueError

If chem_ids is empty, any species is unknown, or x.shape[-1] != len(chem_ids).

get_composition_info

get_composition_info(
    chem_ids, x, *, skip_partials=False, backend="auto"
)

Compute composition moments and optional partial derivatives.

Parameters:

Name Type Description Default
chem_ids Sequence[int | str]

Sequence of 1-based chem_id integers or isotope names.

required
x Sequence[float] | NDArray[float64] | Array

Mass-fraction vector \(X_i\) of shape (n_species,) (dimensionless).

required
skip_partials bool

If True, skip computing dabar_dx, dzbar_dx, and dmc_dx (returning empty (0,) arrays).

False
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
CompositionInfo

CompositionInfo dataclass with all 10 moments and 3 derivative arrays.

Raises:

Type Description
ValueError

If chem_ids is empty, x.shape != (len(chem_ids),), or any species or backend is invalid.

basic_composition_info

basic_composition_info(chem_ids, x, *, backend='auto')

Compute composition moments without partial derivatives.

Parameters:

Name Type Description Default
chem_ids Sequence[int | str]

Sequence of 1-based chem_id integers or isotope names.

required
x Sequence[float] | NDArray[float64] | Array

Mass-fraction vector \(X_i\) of shape (n_species,).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
CompositionInfo

CompositionInfo with empty (0,) partial derivative arrays.

Raises:

Type Description
ValueError

If chem_ids or x has invalid shape or species.

composition_info

composition_info(chem_ids, x, *, backend='auto')

Compute composition moments and analytical partial derivatives.

Parameters:

Name Type Description Default
chem_ids Sequence[int | str]

Sequence of 1-based chem_id integers or isotope names.

required
x Sequence[float] | NDArray[float64] | Array

Mass-fraction vector \(X_i\) of shape (n_species,).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
CompositionInfo

CompositionInfo including dabar_dx, dzbar_dx, and dmc_dx.

Raises:

Type Description
ValueError

If chem_ids or x has invalid shape or species.

get_composition_info_zones

get_composition_info_zones(
    chem_ids, x_zones, *, parallel=True, backend="auto"
)

Evaluate the 10 composition moments across n_zones stellar zones.

Parameters:

Name Type Description Default
chem_ids Sequence[int | str]

Sequence of length n_species of 1-based chem_ids or names.

required
x_zones NDArray[float64] | Array

2D abundance array of shape (n_zones, n_species) in float64.

required
parallel bool

When using the "rust" backend, evaluate across the persistent 4-thread rayon worker pool when n_zones >= 64.

True
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
NDArray[float64] | Array

2D float64 array of shape (n_zones, 10) containing columns

NDArray[float64] | Array

[xh, xhe, xz, abar, zbar, z2bar, z53bar, ye, mass_correction, sumx].

Raises:

Type Description
ValueError

If x_zones.ndim != 2 or x_zones.shape[1] != len(chem_ids).


Partial Ionization & Effective Ionic Charge (flexmesa.ionization)

flexmesa.ionization evaluates effective ionic charge states \(Z_{\mathrm{eff}}(T, \rho)\) for trace heavy elements (including \(\mathrm{Fe}^{56}\) in \(\mathrm{He}^4\) via pre-validated 2D bicubic splines and general \(Z \in [1, 30]\) depression-of-continuum ionization) used in atomic diffusion and gravitational settling.

flexmesa.ionization.typical_charge

Continuum depression and typical diffusion charges (mod_typical_charge).

Implements the continuum-depression and typical ionic charge routines from mod_ionization.f90 and star/private/mod_typical_charge.f90 in canonical Safe Rust and derived float64 JAX kernels: - chi_info, chi_info_jax, chi_effective, chi_effective_jax: Paquette et al. (1986, Eq. 20) and Dupuis et al. (1992, Eq. 3) continuum-depression ionization threshold in \(\mathrm{eV}\). - eval_typical_charge, ionization_potential: Whole-number typical ionic charge against the Allen (1973) ionization potentials (\(Z \in [1, 30]\)).

ionization_potential

ionization_potential(z, stage)

Return the Allen (1973) ionization potential \(I_{Z, k}\) (\(\mathrm{eV}\)).

Parameters:

Name Type Description Default
z int

Atomic number \(Z \in [1, 30]\).

required
stage int

1-based ionization stage \(k \in [1, Z]\).

required

Returns:

Type Description
float

Ionization potential \(I_{Z, k}\) in \(\mathrm{eV}\).

Raises:

Type Description
ValueError

If z is outside [1, 30] or stage is outside [1, z].

chi_info_jax

chi_info_jax(a1, z1, t, log10_t, rho, log10_rho)

Compute \((\chi, c_0, c_1, c_2)\) in \(\mathrm{eV}\) in JAX (chi_info).

Parameters:

Name Type Description Default
a1 Array | float

Mean background nucleon number \(\bar{A}\) (dimensionless).

required
z1 Array | float

Mean background charge \(\bar{Z} = \bar{A} Y_e\) (dimensionless).

required
t Array | float

Temperature \(T\) in \(\mathrm{K}\).

required
log10_t Array | float

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

required
rho Array | float

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
log10_rho Array | float

Base-10 log mass density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

required

Returns:

Type Description
Array

Tuple (chi, c0, c1, c2) of float64 jax.Array tensors in

Array

\(\mathrm{eV}\).

chi_effective_jax

chi_effective_jax(chi, c0, c1, c2, z1, z2)

Compute \(\chi_{\mathrm{eff}}\) in \(\mathrm{eV}\) in JAX (chi_effective).

Parameters:

Name Type Description Default
chi Array | float

Base ionization threshold \(\chi\) in \(\mathrm{eV}\).

required
c0 Array | float

Continuum-depression coefficient \(c_0\) in \(\mathrm{eV}\).

required
c1 Array | float

Continuum-depression coefficient \(c_1\) in \(\mathrm{eV}\).

required
c2 Array | float

Continuum-depression coefficient \(c_2\) in \(\mathrm{eV}\).

required
z1 Array | float

Background charge \(z_1\) (dimensionless).

required
z2 Array | float

Trial ion charge \(z_2\) (dimensionless).

required

Returns:

Type Description
Array

Effective ionization threshold \(\chi_{\mathrm{eff}}\) in \(\mathrm{eV}\).

chi_info

chi_info(
    a1, z1, t, log10_t, rho, log10_rho, *, backend="auto"
)

Compute \((\chi, c_0, c_1, c_2)\) in \(\mathrm{eV}\) (chi_info).

Parameters:

Name Type Description Default
a1 float | Array

Mean background nucleon number \(\bar{A}\) (dimensionless).

required
z1 float | Array

Mean background charge \(\bar{Z} = \bar{A} Y_e\) (dimensionless).

required
t float | Array

Temperature \(T\) in \(\mathrm{K}\).

required
log10_t float | Array

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

required
rho float | Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
log10_rho float | Array

Base-10 log mass density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
tuple[float | Array, float | Array, float | Array, float | Array]

Tuple (chi, c0, c1, c2) in \(\mathrm{eV}\).

chi_effective

chi_effective(chi, c0, c1, c2, z1, z2, *, backend='auto')

Compute \(\chi_{\mathrm{eff}}\) in \(\mathrm{eV}\) (chi_effective).

Parameters:

Name Type Description Default
chi float | Array

Base threshold \(\chi\) in \(\mathrm{eV}\).

required
c0 float | Array

Coefficient \(c_0\) in \(\mathrm{eV}\).

required
c1 float | Array

Coefficient \(c_1\) in \(\mathrm{eV}\).

required
c2 float | Array

Coefficient \(c_2\) in \(\mathrm{eV}\).

required
z1 float | Array

Background charge \(z_1\) (dimensionless).

required
z2 float | Array

Trial ion charge \(z_2\) (dimensionless).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
float | Array

Effective ionization threshold \(\chi_{\mathrm{eff}}\) in \(\mathrm{eV}\).

eval_typical_charge

eval_typical_charge(
    cid,
    abar,
    free_e,
    t,
    log10_t,
    rho,
    log10_rho,
    *,
    backend="auto",
)

Compute the whole-number typical ionic charge (eval_typical_charge).

Parameters:

Name Type Description Default
cid int | str

1-based chem_id or nuclide name (e.g. "c12", "fe56").

required
abar float | Array

Mean background nucleon number \(\bar{A}\) (dimensionless).

required
free_e float | Array

Free electrons per nucleon \(Y_e\) (dimensionless).

required
t float | Array

Temperature \(T\) in \(\mathrm{K}\).

required
log10_t float | Array

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

required
rho float | Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
log10_rho float | Array

Base-10 log mass density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
float | Array

Whole-number ionic charge \(Z_{\mathrm{typ}} \in [1, Z_{\max}]\).

Raises:

Type Description
ValueError

If cid is not a recognized nuclide.

flexmesa.ionization.fe56_he4

Effective charge of \(\mathrm{Fe56}\) in \(\mathrm{He4}\) (mod_ionization).

Implements the 2D not-a-knot bicubic spline interpolator (eval_charge_of_fe56_in_he4, eval_charge_of_fe56_in_he4_jax, and eval_charge_of_fe56_in_he4_zones) in canonical Safe Rust and derived float64 JAX over the \(105 \times 30\) Thomas-Fermi-Dirac-Hubbard \((\log_{10} n_e, \log_{10} T)\) grid from upstream MESA mod_ionization.f90.

eval_charge_of_fe56_in_he4_jax

eval_charge_of_fe56_in_he4_jax(log10_ne, log10_t)

Evaluate (z, dz_dlog10_ne, dz_dlog10_t) for \(\mathrm{Fe56}\) in JAX.

Parameters:

Name Type Description Default
log10_ne Array | float

Base-10 log electron density \(\log_{10}(n_e / \mathrm{cm^{-3}})\) of shape (*batch,).

required
log10_t Array | float

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\) of shape (*batch,).

required

Returns:

Type Description
tuple[Array, Array, Array]

Tuple (z, dz_dlog10_ne, dz_dlog10_t) of float64 jax.Array tensors.

eval_charge_of_fe56_in_he4

eval_charge_of_fe56_in_he4(
    log10_ne, log10_t, *, backend="auto"
)

Evaluate the effective charge \(Z(\mathrm{Fe56})\) in \({}^4\mathrm{He}\).

Parameters:

Name Type Description Default
log10_ne float | Array

Base-10 log electron density \(\log_{10}(n_e / \mathrm{cm^{-3}})\).

required
log10_t float | Array

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
float | Array

Effective ionic charge \(Z(\mathrm{Fe56})\) (dimensionless).

Raises:

Type Description
ValueError

If log10_ne or log10_t is outside the table domain.

eval_charge_of_fe56_in_he4_zones

eval_charge_of_fe56_in_he4_zones(
    log10_ne, log10_t, *, parallel=True, backend="auto"
)

Evaluate [z, dz_dlog10_ne, dz_dlog10_t] across n_zones zones.

Parameters:

Name Type Description Default
log10_ne NDArray[float64] | Array

1D array of \(\log_{10}(n_e / \mathrm{cm^{-3}})\) of shape (n_zones,).

required
log10_t NDArray[float64] | Array

1D array of \(\log_{10}(T / \mathrm{K})\) of shape (n_zones,).

required
parallel bool

When using "rust", evaluate across the persistent 4-thread rayon worker pool when n_zones >= 64.

True
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
NDArray[float64] | Array

2D float64 array of shape (n_zones, 3) with columns

NDArray[float64] | Array

[z, dz_dlog10_ne, dz_dlog10_t].

Raises:

Type Description
ValueError

If log10_ne and log10_t are not 1D arrays of equal length.

flexmesa.ionization.tables

Four-dimensional \((Z, X, \log Q, \log T)\) ionization table evaluators.

Implements the 3-stage interpolator (eval_ionization, eval_ionization_jax, eval_ionization_zones) in canonical Safe Rust and derived float64 JAX kernels matching upstream MESA ion_tables_eval.f90: 1. Stage 1 (\((\log Q, \log T)\) bicubic spline): Evaluates not-a-knot bicubic splines with silent boundary clamping (Locate_logQ, Locate_logT with \(+10^{-4}\) index bias). 2. Stage 2 (\(X\) interpolation): 3-point quadratic Lagrange near edges or 4-point blended quadratic-cubic on interior intervals. 3. Stage 3 (\(Z\) interpolation): 3-point quadratic Lagrange on \(Z \in [0, 0.04]\) or cosine-smoothed \(0.5[1 - \cos(\pi\alpha)]\) blending on \(Z \in (0.04, 1.0]\).

IonizationResult dataclass

Structured 28-channel output of eval_ionization.

Attributes:

Name Type Description
values NDArray[float64] | Array

Raw 1D float64 NumPy or JAX array of shape (28,) in ION_RESULT_NAMES order.

log_pgas float

Base-10 log gas pressure \(\log_{10}(P_{\mathrm{gas}} / \mathrm{dyn\,cm^{-2}})\).

logpp NDArray[float64] | Array

9-element float64 array of log partial pressures (H..Fe).

z_ion NDArray[float64] | Array

9-element float64 array of mean ionic charges (H..Fe).

fneut NDArray[float64] | Array

9-element float64 array of neutral fractions (H..Fe).

log_pgas property

log_pgas

Base-10 log gas pressure \(\log_{10} P_{\mathrm{gas}}\).

logpp property

logpp

Log partial pressures logpp_H..Fe of shape (9,).

z_ion property

z_ion

Mean ionic charges Z_H..Fe of shape (9,).

fneut property

fneut

Neutral fractions fneut_H..Fe of shape (9,).

__getitem__

__getitem__(key)

Index by 0-based integer channel 0..27 or channel name.

eval_ionization_jax

eval_ionization_jax(z, x, log10_rho, log10_t)

Evaluate all 28 ionization channels in JAX (eval_ionization).

Parameters:

Name Type Description Default
z Array | float

Metallicity mass fraction \(Z\) of shape () or (n_zones,).

required
x Array | float

Hydrogen mass fraction \(X\) of shape () or (n_zones,).

required
log10_rho Array | float

Base-10 log density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

required
log10_t Array | float

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

required

Returns:

Type Description
Array

float64 jax.Array of shape (28,) for scalar inputs or

Array

(n_zones, 28) for 1D inputs.

eval_ionization

eval_ionization(
    z,
    x,
    *,
    rho=None,
    log10_rho=None,
    t=None,
    log10_t=None,
    backend="auto",
)

Evaluate the 28-channel 4D ionization state (eval_ionization).

Parameters:

Name Type Description Default
z float | Array

Metallicity mass fraction \(Z\) (dimensionless).

required
x float | Array

Hydrogen mass fraction \(X\) (dimensionless).

required
rho float | Array | None

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\) (optional if log10_rho is supplied).

None
log10_rho float | Array | None

Base-10 log density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

None
t float | Array | None

Temperature \(T\) in \(\mathrm{K}\) (optional if log10_t is supplied).

None
log10_t float | Array | None

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

None
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
IonizationResult

IonizationResult wrapping the 28 output quantities.

Raises:

Type Description
ValueError

If neither linear nor log10 density/temperature is provided, or if inputs are non-positive or non-finite.

eval_ionization_zones

eval_ionization_zones(
    z,
    x,
    log10_rho,
    log10_t,
    *,
    parallel=True,
    backend="auto",
)

Evaluate all 28 ionization channels across n_zones stellar zones.

Parameters:

Name Type Description Default
z NDArray[float64] | Array

1D array of metallicities \(Z\) of shape (n_zones,).

required
x NDArray[float64] | Array

1D array of hydrogen mass fractions \(X\) of shape (n_zones,).

required
log10_rho NDArray[float64] | Array

1D array of \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\) of shape (n_zones,).

required
log10_t NDArray[float64] | Array

1D array of \(\log_{10}(T / \mathrm{K})\) of shape (n_zones,).

required
parallel bool

When using "rust", evaluate across the persistent 4-thread rayon worker pool when n_zones >= 64.

True
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
NDArray[float64] | Array

2D float64 array of shape (n_zones, 28) in ION_RESULT_NAMES

NDArray[float64] | Array

column order.

Raises:

Type Description
ValueError

If input arrays are not 1D of equal length.


Thermal Neutrino Cooling (flexmesa.neu)

flexmesa.neu ports the Itoh et al. (1996) fitting formulae across all five thermal neutrino emission channels (pair, plasmon, photoneutrino, bremsstrahlung, and recombination) with exact \((\rho, T, \bar{A}, \bar{Z})\) partial derivatives.

flexmesa.neu.driver

Top-level thermal neutrino loss driver (neu_get) and JAX float64 kernel.

Ports neu_get (neu/public/neu_lib.f90 and neutrinos in neu/private/mod_neu.f90) and provides a pure-JAX float64 differentiable pair + plasmon neutrino loss function neu_pair_plas_jax compatible with jax.jit, jax.vmap, and jax.grad.

Index and Memory-Order Contract
  • Upstream 1-based channel indices (pair_neu_type = 1 .. reco_neu_type = 5) map to 0-based NeuChannel (PAIR = 0 .. RECO = 4).
  • Upstream 1-based derivative indices (ineu = 1 .. idneu_dzbar = 5) map to NeuRate fields (val, d_t, d_rho, d_abar, d_zbar) and 0-based row-major sources of shape (5, 5) (sources[channel, deriv]).

NeuChannel

Bases: IntEnum

0-based thermal neutrino reaction channel index.

Attributes:

Name Type Description
PAIR

Pair production (\(e^+ + e^- \to \nu + \bar{\nu}\), index 0).

PLAS

Plasmon decay (\(\tilde{\gamma} \to \nu + \bar{\nu}\), index 1).

PHOT

Photoneutrino (\(e^\pm + \gamma \to e^\pm + \nu + \bar{\nu}\), index 2).

BREM

Bremsstrahlung (\(e^- + (Z, A) \to e^- + (Z, A) + \nu + \bar{\nu}\), index 3).

RECO

Recombination (\(e^-_{\mathrm{cont}} \to e^-_{\mathrm{bound}} + \nu + \bar{\nu}\), index 4).

NeuFlags dataclass

Per-channel enable flags (flags(num_neu_types) in neu_def.f90).

Attributes:

Name Type Description
pair bool

Enable pair-production neutrino losses (pair_neu_type).

plas bool

Enable plasmon-decay neutrino losses (plas_neu_type).

phot bool

Enable photoneutrino losses (phot_neu_type).

brem bool

Enable bremsstrahlung neutrino losses (brem_neu_type).

reco bool

Enable recombination neutrino losses (reco_neu_type).

all classmethod

all()

Enables all five neutrino reaction channels.

Returns:

Type Description
NeuFlags

NeuFlags with all five channels set to True.

none classmethod

none()

Disables all five neutrino reaction channels.

Returns:

Type Description
NeuFlags

NeuFlags with all five channels set to False.

default_stellar classmethod

default_stellar()

Standard stellar-evolution default (reco = False, others True).

Returns:

Type Description
NeuFlags

NeuFlags with pair, plas, phot, brem enabled.

as_tuple

as_tuple()

Return channels as (pair, plas, phot, brem, reco).

NeuResult dataclass

Complete thermal neutrino loss output (loss and sources).

Attributes:

Name Type Description
total NeuRate

Total specific neutrino energy loss rate (NeuRate).

pair NeuRate

Pair-production channel rate (NeuRate).

plas NeuRate

Plasmon-decay channel rate (NeuRate).

phot NeuRate

Photoneutrino channel rate (NeuRate).

brem NeuRate

Bremsstrahlung channel rate (NeuRate).

reco NeuRate

Recombination channel rate (NeuRate).

loss ndarray

1D float64 NumPy array of shape (5,) containing [val, d_t, d_rho, d_abar, d_zbar].

sources ndarray

2D row-major float64 NumPy array of shape (5, 5) indexed as sources[channel, deriv].

channel

channel(ch)

Returns the NeuRate for the requested NeuChannel.

Parameters:

Name Type Description Default
ch NeuChannel

Channel index (NeuChannel).

required

Returns:

Type Description
NeuRate

Corresponding NeuRate structure.

neu_get

neu_get(
    t=None,
    log10_t=None,
    rho=None,
    log10_rho=None,
    abar=1.0,
    zbar=1.0,
    log10_tlim=7.5,
    flags=None,
    *,
    backend="auto",
)

Evaluates specific thermal neutrino energy loss rates and derivatives.

Ports neu_get (neu_lib.f90) and neutrinos (mod_neu.f90). Accepts either linear or base-10 logarithmic temperature and density (computing whichever is omitted via IEEE-754 log10 or exp10).

Parameters:

Name Type Description Default
t float | Array | None

Temperature \(T\) in Kelvin (\(\mathrm{K}\)), or None if log10_t is provided.

None
log10_t float | Array | None

Base-10 logarithm \(\log_{10}(T / \mathrm{K})\), or None if t is provided.

None
rho float | Array | None

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\), or None if log10_rho is provided.

None
log10_rho float | Array | None

Base-10 logarithm \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\), or None if rho is provided.

None
abar float | Array

Mean atomic weight \(\bar{A} > 0\) (dimensionless).

1.0
zbar float | Array

Mean ionic charge \(\bar{Z} > 0\) (dimensionless).

1.0
log10_tlim float | Array

Upper bound of smooth cosine cutoff window in \(\log_{10}(T / \mathrm{K})\) (default 7.5).

7.5
flags NeuFlags | None

Per-channel enable flags (NeuFlags, defaults to NeuFlags.all()).

None
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
NeuResult

NeuResult containing total and per-channel NeuRate values and

NeuResult

row-major float64 arrays loss (5,) and sources (5, 5).

Raises:

Type Description
ValueError

If neither t nor log10_t is provided, neither rho nor log10_rho is provided, or any input is non-positive, non-finite, or exceeds \(\log_{10} = 20\).

neu_pair_plas_jax

neu_pair_plas_jax(t, rho, abar, zbar)

Evaluates specific pair + plasmon neutrino loss in JAX float64.

Pure-JAX float64 implementation of pair_neu + plas_neu divided by \(\rho\), supporting jax.jit, jax.vmap, and jax.grad automatic differentiation with respect to (t, rho, abar, zbar).

Parameters:

Name Type Description Default
t Array

Temperature \(T\) in Kelvin (\(\mathrm{K}\), scalar or (*batch,)).

required
rho Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
abar Array

Mean atomic weight \(\bar{A}\).

required
zbar Array

Mean ionic charge \(\bar{Z}\).

required

Returns:

Type Description
Array

Specific neutrino loss rate \(\epsilon_{\mathrm{pair+plas}}\) in

Array

\(\mathrm{erg\,g^{-1}\,s^{-1}}\) (jax.Array in float64).

flexmesa.neu.inputs

Precomputed thermodynamic, composition, and weak-coupling invariants (neu).

Ports the electroweak coupling constants (c_v, c_a, tfac0..tfac6) and shared thermodynamic/composition scaling quantities (xl, rm, zeta and their analytical partial derivatives) from neu/private/mod_neu.f90.

Physical Units and Conventions
  • Temperature temp in Kelvin (\(\mathrm{K}\)), with scaled temperatures \(T_9 = T / 10^9\,\mathrm{K}\) and \(\lambda = T / (5.9302 \times 10^9\,\mathrm{K})\).
  • Mass density den in \(\mathrm{g\,cm^{-3}}\), with electron density factor \(\rho / \mu_e = \rho\,\bar{Z} / \bar{A}\) (rm).
  • Dimensionless relativistic degeneracy parameter \(\xi = (10^{-9} \rho Y_e)^{1/3} / \lambda\) (zeta) and its analytical partial derivatives with respect to \((T, \rho, \bar{A}, \bar{Z})\).

NeuRate dataclass

Specific or volumetric neutrino energy loss rate and partial derivatives.

Attributes:

Name Type Description
val float

Energy loss rate \(\epsilon_\nu\) (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)) or volumetric rate \(Q_\nu\) (\(\mathrm{erg\,cm^{-3}\,s^{-1}}\)).

d_t float

Partial derivative \(\partial / \partial T\) (\(\mathrm{erg\,g^{-1}\,s^{-1}\,K^{-1}}\)).

d_rho float

Partial derivative \(\partial / \partial \rho\) (\(\mathrm{erg\,g^{-1}\,s^{-1}\,cm^3\,g^{-1}}\)).

d_abar float

Partial derivative \(\partial / \partial \bar{A}\) (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

d_zbar float

Partial derivative \(\partial / \partial \bar{Z}\) (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

to_specific

to_specific(deni)

Converts volumetric rate \(Q\) to specific rate \(Q / \rho\).

Parameters:

Name Type Description Default
deni float

Reciprocal mass density \(1 / \rho\) (\(\mathrm{cm^3\,g^{-1}}\)).

required

Returns:

Type Description
NeuRate

Specific energy loss rate NeuRate

NeuRate

(\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

with_cutoff

with_cutoff(f_cut, df_dt)

Applies smooth low-temperature cosine cutoff factor \(f(T)\).

Parameters:

Name Type Description Default
f_cut float

Dimensionless cutoff multiplier \(f(T) \in [0, 1]\).

required
df_dt float

Temperature derivative \(df / dT\) (\(\mathrm{K^{-1}}\)).

required

Returns:

Type Description
NeuRate

Cutoff-attenuated NeuRate with product-rule derivative.

to_tuple

to_tuple()

Returns (val, d_t, d_rho, d_abar, d_zbar) as a 5-tuple.

Returns:

Type Description
tuple[float, float, float, float, float]

Tuple (val, d_t, d_rho, d_abar, d_zbar) in float64.

NeuInputs dataclass

Precomputed thermodynamic and composition invariants for neu channels.

Attributes:

Name Type Description
temp float

Temperature \(T\) (\(\mathrm{K}\)).

logtemp float

Base-10 log temperature \(\log_{10}(T / \mathrm{K})\).

den float

Mass density \(\rho\) (\(\mathrm{g\,cm^{-3}}\)).

logden float

Base-10 log density \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

abar float

Mean atomic weight \(\bar{A}\).

zbar float

Mean ionic charge \(\bar{Z}\).

tempi float

Reciprocal temperature \(1 / T\) (\(\mathrm{K^{-1}}\)).

deni float

Reciprocal density \(1 / \rho\) (\(\mathrm{cm^3\,g^{-1}}\)).

abari float

Reciprocal mean atomic weight \(1 / \bar{A}\).

zbari float

Reciprocal mean ionic charge \(1 / \bar{Z}\).

t9 float

Scaled temperature \(T_9 = T / 10^9\,\mathrm{K}\).

den6 float

Scaled density \(\rho_6 = \rho / 10^6\,\mathrm{g\,cm^{-3}}\).

ye float

Electron mole fraction \(Y_e = \bar{Z} / \bar{A}\).

xl float

Relativistic temperature \(\lambda = T / (5.9302 \times 10^9)\).

xl2 float

Power \(\lambda^2\).

xl3 float

Power \(\lambda^3\).

xl4 float

Power \(\lambda^4\).

xl5 float

Power \(\lambda^5\).

xl6 float

Power \(\lambda^6\).

xl7 float

Power \(\lambda^7\).

xl8 float

Power \(\lambda^8\).

xl9 float

Power \(\lambda^9\).

xldt float

Derivative \(d\lambda / dT = (5.9302 \times 10^9)^{-1}\).

xlm1 float

Inverse power \(\lambda^{-1}\).

xlm2 float

Inverse power \(\lambda^{-2}\).

xlm3 float

Inverse power \(\lambda^{-3}\).

xlm4 float

Inverse power \(\lambda^{-4}\).

xlp5 float

Fractional power \(\lambda^{1/2}\).

xlmp5 float

Fractional power \(\lambda^{-1/2}\).

rm float

Electron mass density \(\rho Y_e\) (\(\mathrm{g\,cm^{-3}}\)).

rmi float

Reciprocal \(1 / (\rho Y_e)\).

rmdd float

Derivative \(\partial(\rho Y_e)/\partial \rho = Y_e\).

rmda float

Derivative \(\partial(\rho Y_e)/\partial \bar{A}\).

rmdz float

Derivative \(\partial(\rho Y_e)/\partial \bar{Z}\).

zeta float

Degeneracy parameter \(\xi = (10^{-9}\rho Y_e)^{1/3} / \lambda\).

zeta2 float

Power \(\xi^2\).

zeta3 float

Power \(\xi^3\).

zetadt float

Derivative \(\partial \xi / \partial T\).

zetadd float

Derivative \(\partial \xi / \partial \rho\).

zetada float

Derivative \(\partial \xi / \partial \bar{A}\).

zetadz float

Derivative \(\partial \xi / \partial \bar{Z}\).

create classmethod

create(temp, logtemp, den, logden, abar, zbar)

Constructs precomputed NeuInputs from thermodynamic state.

Parameters:

Name Type Description Default
temp float

Temperature \(T\) (\(\mathrm{K}\)).

required
logtemp float

Base-10 log of temperature \(\log_{10}(T / \mathrm{K})\).

required
den float

Mass density \(\rho\) (\(\mathrm{g\,cm^{-3}}\)).

required
logden float

Base-10 logarithm of density \(\log_{10}(\rho)\).

required
abar float

Mean atomic weight \(\bar{A}\).

required
zbar float

Mean ionic charge \(\bar{Z}\).

required

Returns:

Type Description
NeuInputs

Populated NeuInputs instance.

flexmesa.neu.pair_plas

Pair-production (pair_neu) and plasmon-decay (plas_neu) neutrino losses.

Ports pair_neu (Itoh et al. 1996, ApJS, 102, 411, eqs. 2.1-2.8) and plas_neu (eqs. 4.1, 4.5-4.11) from neu/private/mod_neu.f90.

Physical Regimes
  • Pair Production (pair_neu): Dominant at high temperature (\(T \gtrsim 10^9\,\mathrm{K}\)) and low-to-moderate density where thermal photons create \(e^+ e^-\) pairs that annihilate into \(\nu \bar{\nu}\) pairs. Separates fit coefficients at \(T_9 = 10\) (\(T = 10^{10}\,\mathrm{K}\)).
  • Plasmon Decay (plas_neu): Dominant at high electron degeneracy where transverse (ft), longitudinal (fl), and mixed (fxy) collective plasma excitations decay into \(\nu_e \bar{\nu}_e\) pairs.

pair_neu

pair_neu(inp)

Evaluates volumetric pair-neutrino energy loss rate and derivatives.

Implements Itoh et al. (1996) eqs. 2.1-2.8 (pair_neu in mod_neu.f90): $\(Q_{\mathrm{pair}} = \mathrm{TFAC4}\,(1 + \mathrm{TFAC3}\,q_{\mathrm{pair}})\,g(\lambda)\,e^{-2/\lambda} \,f_{\mathrm{pair}}(\lambda, \xi)\)$

Parameters:

Name Type Description Default
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\) before

NeuRate

dividing by \(\rho\).

plas_neu

plas_neu(inp)

Evaluates volumetric plasmon-decay neutrino energy loss rate.

Implements Itoh et al. (1996) eqs. 4.1 and 4.5-4.11 (plas_neu in mod_neu.f90): $\(Q_{\mathrm{plas}} = C_V^2 \left(3.0 \times 10^{21}\,\lambda^9\right) \gamma^6 e^{-\gamma}\left(f_T + f_L\right) f_{xy}(x, y)\)$

Parameters:

Name Type Description Default
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\) before

NeuRate

dividing by \(\rho\).

flexmesa.neu.phot

Photoneutrino (phot_neu) energy loss rates and analytical derivatives.

Ports phot_neu (Itoh et al. 1996, ApJS, 102, 411, eqs. 3.2-3.8 and Table 2) from neu/private/mod_neu.f90.

Fourier Expansion Across Temperature Regimes

Evaluates the 5-harmonic Fourier series for \(a_0(\tau), a_1(\tau), a_2(\tau)\) across three temperature intervals: - \(10^7 \le T < 10^8\,\mathrm{K}\) (\(\tau = \log_{10} T - 7\), \(c = 0.5654 + \tau\)) - \(10^8 \le T < 10^9\,\mathrm{K}\) (\(\tau = \log_{10} T - 8\), \(c = 1.5654\)) - \(T \ge 10^9\,\mathrm{K}\) (\(\tau = \log_{10} T - 9\), \(c = 1.5654\))

PhotBandCoeffs dataclass

Table 2 Fourier coefficients (c_j[0..7], d_j[0..5]) for \(j = 0, 1, 2\).

Attributes:

Name Type Description
c0 tuple[float, ...]

Cosine harmonic coefficients \(c_{0,0 \dots 6}\) for \(a_0(\tau)\).

d0 tuple[float, ...]

Sine harmonic coefficients \(d_{0,1 \dots 5}\) for \(a_0(\tau)\).

c1 tuple[float, ...]

Cosine harmonic coefficients \(c_{1,0 \dots 6}\) for \(a_1(\tau)\).

d1 tuple[float, ...]

Sine harmonic coefficients \(d_{1,1 \dots 5}\) for \(a_1(\tau)\).

c2 tuple[float, ...]

Cosine harmonic coefficients \(c_{2,0 \dots 6}\) for \(a_2(\tau)\).

d2 tuple[float, ...]

Sine harmonic coefficients \(d_{2,1 \dots 5}\) for \(a_2(\tau)\).

phot_neu

phot_neu(inp)

Evaluates volumetric photoneutrino energy loss rate and derivatives.

Implements Itoh et al. (1996) eqs. 3.2-3.8 (phot_neu in mod_neu.f90): $\(Q_{\mathrm{phot}} = \mathrm{TFAC4}\,(1 - \mathrm{TFAC3}\,q_{\mathrm{phot}})\,(\rho Y_e)\,\lambda^5 f_{\mathrm{phot}}(\lambda, \xi)\)$

Parameters:

Name Type Description Default
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\) before

NeuRate

dividing by \(\rho\), or zero when \(T \le 10^7\,\mathrm{K}\).

flexmesa.neu.brem

Bremsstrahlung (brem_neu) neutrino energy loss rates and derivatives.

Ports brem_neu_weak_degen, brem_neu_liquid_metal, and brem_neu (Itoh et al. 1996, ApJS, 102, 411, Section 5) from neu/private/mod_neu.f90.

Degeneracy Blending Strategy
  • For \(T \ge 0.3\,T_F\), evaluates the weakly degenerate electron gas fit (brem_neu_weak_degen, eqs. 5.1-5.9).
  • For \(T \le 0.05\,T_F\), evaluates the strongly degenerate liquid-metal fit (brem_neu_liquid_metal, eqs. 5.16-5.26).
  • For \(0.05\,T_F < T < 0.3\,T_F\), blends both regimes via the smooth cosine ramp \(\alpha = \tfrac{1}{2}(1 - \cos(\pi\,\mathrm{tfrac}))\) with exact chain-rule partial derivatives with respect to \((T, \rho, \bar{A}, \bar{Z})\).

brem_neu_weak_degen

brem_neu_weak_degen(t8, inp)

Evaluates weakly degenerate bremsstrahlung fit (brem_neu_weak_degen).

Implements Itoh et al. (1996) eqs. 5.1-5.9 for \(T \ge 0.3\,T_F\), combining weakly degenerate vector (fbrem) and axial-vector (gbrem) structure factors.

Parameters:

Name Type Description Default
t8 float

Scaled temperature \(T_8 = T / 10^8\,\mathrm{K}\).

required
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\).

brem_neu_liquid_metal

brem_neu_liquid_metal(t8, inp)

Evaluates strongly degenerate liquid-metal fit (brem_neu_liquid_metal).

Implements Itoh et al. (1996) eqs. 5.16-5.26 for \(T \le 0.05\,T_F\), where ions form a strongly coupled Coulomb liquid (\(1 \le \Gamma < 180\)).

Parameters:

Name Type Description Default
t8 float

Scaled temperature \(T_8 = T / 10^8\,\mathrm{K}\).

required
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\).

brem_neu

brem_neu(inp)

Evaluates volumetric bremsstrahlung neutrino energy loss rate.

Blends brem_neu_weak_degen (\(T \ge 0.3\,T_F\)) and brem_neu_liquid_metal (\(T \le 0.05\,T_F\)) across \(0.05\,T_F < T < 0.3\,T_F\).

Parameters:

Name Type Description Default
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\) before

NeuRate

dividing by \(\rho\).

flexmesa.neu.reco

Recombination (reco_neu) neutrino energy loss rates and Antia (1993) fits.

Ports ifermi12, zfermim12 (Antia 1993, ApJS, 84, 101), and reco_neu (Itoh et al. 1996, ApJS, 102, 411, Section 6) from neu/private/mod_neu.f90.

Fermi-Dirac Inversion and Recombination Rate
  • ifermi12 evaluates the inverse Fermi-Dirac integral \(F_{1/2}^{-1}(f)\) to relative accuracy \(4.19 \times 10^{-9}\) across non-degenerate (\(f < 4\)) and degenerate (\(f \ge 4\)) regimes.
  • zfermim12 evaluates \(F_{-1/2}(\nu) = 2\,dF_{1/2}/d\nu\) to relative accuracy \(1.23 \times 10^{-12}\).
  • reco_neu evaluates free-bound electron capture neutrino emission over electron degeneracy parameter \(\nu \in [-20, 10]\).

ifermi12

ifermi12(f)

Evaluates inverse Fermi-Dirac integral \(F_{1/2}^{-1}(f)\) (Antia 1993).

Uses two minimax rational approximations (ifermi12 in mod_neu.f90): - For \(f < 4\): \(\nu = \ln(f\,P_4(f)/Q_3(f))\) - For \(f \ge 4\): \(\nu = f^{2/3}\,P_6(f^{-2/3})/Q_5(f^{-2/3})\)

Parameters:

Name Type Description Default
f float

Dimensionless Fermi-Dirac integral value \(F_{1/2}(\nu) > 0\).

required

Returns:

Type Description
float

Dimensionless electron chemical potential \(\nu = \mu_e / (k_B T)\).

zfermim12

zfermim12(x)

Evaluates Fermi-Dirac integral \(F_{-1/2}(x)\) (Antia 1993).

Uses two minimax rational approximations (zfermim12 in mod_neu.f90): - For \(x < 2\): \(F_{-1/2}(x) = e^x\,P_7(e^x)/Q_7(e^x)\) - For \(x \ge 2\): \(F_{-1/2}(x) = \sqrt{x}\,P_{11}(x^{-2})/Q_{11}(x^{-2})\)

Parameters:

Name Type Description Default
x float

Dimensionless electron chemical potential \(\nu = \mu_e / (k_B T)\).

required

Returns:

Type Description
float

Fermi-Dirac integral value \(F_{-1/2}(x) = 2\,dF_{1/2}/dx\).

reco_neu

reco_neu(inp)

Evaluates volumetric recombination neutrino energy loss rate.

Implements Itoh et al. (1996) Section 6 (reco_neu in mod_neu.f90), evaluating the bound-free electron capture fit \(J(\zeta, \nu)\) and its partial derivatives over \(\nu \in [-20, 10]\).

Parameters:

Name Type Description Default
inp NeuInputs

Precomputed thermodynamic and composition invariants (NeuInputs).

required

Returns:

Type Description
NeuRate

Volumetric rate NeuRate in \(\mathrm{erg\,cm^{-3}\,s^{-1}}\) before

NeuRate

dividing by \(\rho\), or zero when \(\nu \notin [-20, 10]\).


Thermonuclear Rates, Weak Reactions & Screening (flexmesa.rates)

flexmesa.rates evaluates 316 built-in JINA REACLIB 7-parameter thermonuclear rates, weak electron-capture and \(\beta\)-decay tables, and Salpeter (1954), Dewitt, Graboske & Cooper (1973), Alastuey & Jancovici (1978), Itoh (1979) (extended), and Chugunov et al. (2007) plasma screening factors.

flexmesa.rates.core

Core nuclear reaction rate (rates) lookup and evaluation routines.

Provides reaction catalog queries (reaction_id_by_name, reaction_name_by_id, reaction_info), REACLIB handle evaluators (eval_reaclib_handle), raw unscreened rate dispatchers (set_raw_rate, set_raw_rates, set_raw_rates_zones), Fushiki & Lamb (1987) pycnonuclear triple-alpha (eval_fl_epsnuc_3alf), and interp_pm rate-table evaluation (eval_rate_table).

ReactionInfo dataclass

Metadata for a single MESA nuclear reaction (1..=316).

Attributes:

Name Type Description
id int

1-based reaction ID (1..=316).

name str

Canonical MESA reaction handle (e.g. "r1212", "rpp_to_he3").

op_code int

Evaluator dispatch code (0 = REACLIB default, 1 = table, 2 = -1, 3..=28 = analytic ratelib, 29..=31 = JINA).

is_reverse bool

True if evaluating a reverse reaction channel.

target_handle str

Underlying REACLIB reaction handle.

ye_exp int

Electron mole fraction exponent \(p\) (\(Y_e^p\)).

rho_exp int

Density exponent \(N_{\mathrm{in}} - 1\) (\(\rho^{N_{\mathrm{in}}-1}\)).

category int

1-based MESA energy-generation category (1..=22).

std_q float

Total nuclear \(Q\)-value in \(\mathrm{MeV}\).

std_qneu float

Standard neutrino energy loss \(Q_{\nu}\) in \(\mathrm{MeV}\).

weak_lowt_rate float

Low-temperature (\(T_9 \le 0.01\)) weak decay rate in \(\mathrm{s}^{-1}\) (or negative sentinel if strong).

reaction_id_by_name

reaction_id_by_name(name)

Look up the 1-based MESA reaction ID (1..=316) for name.

Parameters:

Name Type Description Default
name str

Reaction handle string (e.g. "rpp_to_he3", "r_c12_ag_o16").

required

Returns:

Type Description
int

1-based integer reaction ID (1..=316).

reaction_name_by_id

reaction_name_by_id(ir)

Look up the canonical MESA reaction handle for 1-based ID ir.

Parameters:

Name Type Description Default
ir int

1-based reaction ID (1..=316).

required

Returns:

Type Description
str

Canonical reaction handle string.

reaction_info

reaction_info(ir)

Return [ReactionInfo] metadata for a 1-based reaction ID or handle.

Parameters:

Name Type Description Default
ir int | str

1-based reaction ID (1..=316) or reaction name string.

required

Returns:

Type Description
ReactionInfo

Populated [ReactionInfo] instance.

eval_reaclib_handle

eval_reaclib_handle(
    handle, t9, *, check_e_flag=True, backend="auto"
)

Evaluate a REACLIB reaction handle at \(T_9 = T / 10^9\,\mathrm{K}\).

Parameters:

Name Type Description Default
handle str

REACLIB reaction handle (e.g. "r_he4_he4_he4_to_c12").

required
t9 float | Array

Temperature \(T_9\) in \(10^9\,\mathrm{K}\).

required
check_e_flag bool

Whether to exempt 'e'-flagged REACLIB terms from the low-\(T_9\) cutoff.

True
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
tuple[float, float, float, float] | tuple[Array, Array, Array, Array]

Tuple (forward_rate, dforward_dlnT, reverse_rate, dreverse_dlnT) as

tuple[float, float, float, float] | tuple[Array, Array, Array, Array]

Python floats on "rust" backend or differentiable JAX float64

tuple[float, float, float, float] | tuple[Array, Array, Array, Array]

arrays on "jax" backend.

set_raw_rate

set_raw_rate(ir, temp, *, log_t=None)

Evaluate the unscreened reaction rate set_raw_rate for reaction ir.

Parameters:

Name Type Description Default
ir int | str

1-based reaction ID (1..=316) or reaction name string.

required
temp float

Temperature \(T\) in \(\mathrm{K}\).

required
log_t float | None

Optional \(\log_{10}(T / \mathrm{K})\) matching tfactors.

None

Returns:

Type Description
float

Unscreened nuclear reaction rate in CGS/molar units.

set_raw_rates

set_raw_rates(irs, temp, *, log_t=None)

Evaluate set_raw_rate across a 1D sequence of 1-based reaction IDs.

Parameters:

Name Type Description Default
irs ArrayLike

1D sequence of 1-based reaction IDs (N_rxns,) in 1..=316.

required
temp float

Temperature \(T\) in \(\mathrm{K}\).

required
log_t float | None

Optional \(\log_{10}(T / \mathrm{K})\).

None

Returns:

Type Description
NDArray[float64]

1D float64 NumPy array of shape (N_rxns,) with raw reaction rates.

set_raw_rates_zones

set_raw_rates_zones(irs, temps, *, log_ts=None)

Evaluate set_raw_rates across N_zones stellar zones.

Parameters:

Name Type Description Default
irs ArrayLike

1D sequence of 1-based reaction IDs (N_rxns,).

required
temps ArrayLike

1D array of zone temperatures (N_zones,) in \(\mathrm{K}\).

required
log_ts ArrayLike | None

Optional 1D array of \(\log_{10}(T / \mathrm{K})\) (N_zones,).

None

Returns:

Type Description
NDArray[float64]

2D float64 NumPy array of shape (N_zones, N_rxns).

eval_fl_epsnuc_3alf

eval_fl_epsnuc_3alf(
    temp, rho, y_he4, mu_e=2.0, *, backend="auto"
)

Evaluate Fushiki & Lamb (1987) pycnonuclear 3-alpha energy rate.

Parameters:

Name Type Description Default
temp float | Array

Temperature \(T\) in \(\mathrm{K}\).

required
rho float | Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
y_he4 float | Array

Helium-4 mass fraction \(Y\).

required
mu_e float | Array

Electron molecular weight \(\mu_e \approx 1 / Y_e\) (default 2.0).

2.0
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
float | Array

Specific energy generation rate \(\epsilon_{3\alpha}\) in

float | Array

\(\mathrm{erg\,g^{-1}\,s^{-1}}\).

eval_rate_table

eval_rate_table(ir, temp)

Evaluate a 1D interp_pm cubic rate table (rate, drate_dt).

Parameters:

Name Type Description Default
ir int | str

1-based reaction ID (1..=316) or reaction name (e.g. "r3").

required
temp float

Temperature \(T\) in \(\mathrm{K}\).

required

Returns:

Type Description
tuple[float, float]

Tuple (rate, drate_dt) in CGS units and \(\mathrm{K}^{-1}\).

flexmesa.rates.screening

Plasma electrostatic screening (no_screening, salpeter, extended).

Provides unified Safe Rust and JAX (float64) dispatchers for single-pair and multi-zone plasma screening enhancement factors and \((T, \rho)\) derivatives.

ScreenEval dataclass

Plasma electrostatic screening evaluation result.

Attributes:

Name Type Description
scor float

Screening enhancement factor \(F_{\mathrm{sc}} = \exp(H_{12})\) (dimensionless).

dscor_dt float

Temperature partial derivative \(\partial F_{\mathrm{sc}} / \partial T\) (\(\mathrm{K}^{-1}\)).

dscor_dd float

Density partial derivative \(\partial F_{\mathrm{sc}} / \partial \rho\) (\(\mathrm{cm^3\,g^{-1}}\)).

__iter__

__iter__()

Iterate over (scor, dscor_dt, dscor_dd).

__getitem__

__getitem__(idx)

Index into (scor, dscor_dt, dscor_dd).

screen_pair

screen_pair(
    mode,
    temp,
    den,
    zbar,
    abar,
    z2bar,
    a1,
    z1,
    a2,
    z2,
    *,
    backend="auto",
)

Evaluate plasma screening for reacting pair (a1, z1) + (a2, z2).

Parameters:

Name Type Description Default
mode str

Screening mode ("no_screening", "salpeter", "extended", or "chugunov").

required
temp float | Array

Temperature \(T\) in \(\mathrm{K}\).

required
den float | Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
zbar float | Array

Mean ionic charge \(\bar{Z}\).

required
abar float | Array

Mean atomic weight \(\bar{A}\).

required
z2bar float | Array

Mean square charge \(\overline{Z^2}\).

required
a1 float

Reactant 1 atomic weight \(A_1\) (\(\mathrm{g\,mol^{-1}}\)).

required
z1 float

Reactant 1 atomic number \(Z_1\).

required
a2 float

Reactant 2 atomic weight \(A_2\) (\(\mathrm{g\,mol^{-1}}\)).

required
z2 float

Reactant 2 atomic number \(Z_2\).

required
backend Backend

Execution backend ("auto", "rust", or "jax").

'auto'

Returns:

Type Description
ScreenEval | tuple[Array, Array, Array]

[ScreenEval] on "rust" backend, or (scor, dscor_dt, dscor_dd) JAX

ScreenEval | tuple[Array, Array, Array]

float64 arrays on "jax" backend.

screen_pair_zones

screen_pair_zones(
    mode, temps, dens, zbars, abars, z2bars, a1, z1, a2, z2
)

Evaluate plasma screening across N_zones stellar zones in parallel.

Parameters:

Name Type Description Default
mode str

Screening mode ("no_screening", "salpeter", "extended", or "chugunov").

required
temps ArrayLike

1D array of temperatures (N_zones,) in \(\mathrm{K}\).

required
dens ArrayLike

1D array of densities (N_zones,) in \(\mathrm{g\,cm^{-3}}\).

required
zbars ArrayLike

1D array of mean ionic charges (N_zones,).

required
abars ArrayLike

1D array of mean atomic weights (N_zones,).

required
z2bars ArrayLike

1D array of mean square charges (N_zones,).

required
a1 float

Reactant 1 atomic weight \(A_1\).

required
z1 float

Reactant 1 atomic number \(Z_1\).

required
a2 float

Reactant 2 atomic weight \(A_2\).

required
z2 float

Reactant 2 atomic number \(Z_2\).

required

Returns:

Type Description
NDArray[float64]

2D float64 NumPy array of shape (N_zones, 3) with columns

NDArray[float64]

[scor, dscor_dt, dscor_dd].

flexmesa.rates.weak

Tabulated weak nuclear rates (weaklib, Suzuki2016) and ecapture.

Provides Python interfaces to MESA's 463 weak reaction tables (weakreactions.tables + S13_r_be7_wk_li7.h5), sd-shell Suzuki2016.h5 tables, weak_info.list half-lives, Coulomb chemical potential corrections (PCR2009, Itoh2002), and on-the-fly relativistic Fermi-Dirac electron capture / beta-decay phase-space integrals (eval_ecapture_pair).

WeakRateEval dataclass

Evaluated weak nuclear reaction rate and neutrino loss.

Attributes:

Name Type Description
lambda_rate float

Total weak transition rate \(\lambda = \lambda_{\mathrm{dec}} + \lambda_{\mathrm{cap}}\) (\(\mathrm{s}^{-1}\)).

dlambda_dln_t float

\(\partial \lambda / \partial \ln T\) (\(\mathrm{s}^{-1}\)).

dlambda_dln_rho float

\(\partial \lambda / \partial \ln(\rho Y_e)\) (\(\mathrm{s}^{-1}\)).

q float

Total nuclear \(Q\)-value \(\Delta M_{\mathrm{lhs}} - \Delta M_{\mathrm{rhs}}\) (\(\mathrm{MeV}\)).

dq_dln_t float

\(\partial Q / \partial \ln T\) (\(\mathrm{MeV}\)).

dq_dln_rho float

\(\partial Q / \partial \ln(\rho Y_e)\) (\(\mathrm{MeV}\)).

qneu float

Mean neutrino energy loss \(Q_\nu\) (\(\mathrm{MeV}\)).

dqneu_dln_t float

\(\partial Q_\nu / \partial \ln T\) (\(\mathrm{MeV}\)).

dqneu_dln_rho float

\(\partial Q_\nu / \partial \ln(\rho Y_e)\) (\(\mathrm{MeV}\)).

from_seq classmethod

from_seq(vals)

Construct a [WeakRateEval] from a 9-element sequence.

eval_coulomb

eval_coulomb(
    temp,
    den,
    zbar,
    abar,
    z1,
    z2,
    *,
    which_mui="pcr2009",
    which_vs="itoh2002",
)

Evaluate Coulomb chemical potentials and electron screening shift.

Parameters:

Name Type Description Default
temp float

Temperature \(T\) in \(\mathrm{K}\).

required
den float

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
zbar float

Mean ionic charge \(\bar{Z}\).

required
abar float

Mean atomic weight \(\bar{A}\).

required
z1 float

Parent ion atomic number \(Z_1\).

required
z2 float

Daughter ion atomic number \(Z_2\).

required
which_mui str

Ion chemical potential option ("none", "dcw1973", "dgc1973", "slr1982", "i1993", "pcr2009").

'pcr2009'
which_vs str

Electron screening shift option ("none", "throwe1983", "thomasfermi", "thomas_fermi", "itoh2002").

'itoh2002'

Returns:

Type Description
float

Tuple (mu1, mu2, dmu_eV, vs) where mu1 and mu2 are dimensionless

float

\(\mu_{\mathrm{I}} / (k_{\mathrm{B}} T)\), dmu_eV is

float

\(|\Delta \mu_{\mathrm{I}}|\) in \(\mathrm{eV}\), and vs is the

float

dimensionless screening shift \(V_s\).

eval_weak_pair

eval_weak_pair(
    lhs_name, rhs_name, t9, ye_rho, *, use_suzuki=False
)

Evaluate a tabulated weak reaction rate (weaklib or Suzuki2016).

Parameters:

Name Type Description Default
lhs_name str

Parent nuclide name (e.g. "mg24").

required
rhs_name str

Daughter nuclide name (e.g. "na24").

required
t9 float

Temperature \(T_9 = T / 10^9\,\mathrm{K}\).

required
ye_rho float

Electron-weighted density \(\rho Y_e\) (\(\mathrm{g\,cm^{-3}}\)).

required
use_suzuki bool

Whether to prefer Suzuki2016.h5 over weaklib.

False

Returns:

Type Description
WeakRateEval

Populated [WeakRateEval] instance.

eval_ecapture_pair

eval_ecapture_pair(
    lhs_name,
    rhs_name,
    t9,
    ye_rho,
    eta_k,
    *,
    which_mui="pcr2009",
    which_vs="itoh2002",
    zbar=10.909090909090908,
    abar=21.818181818181817,
)

Evaluate an on-the-fly Fermi-Dirac electron-capture / beta-decay rate.

Parameters:

Name Type Description Default
lhs_name str

Parent nuclide name (e.g. "mg24").

required
rhs_name str

Daughter nuclide name (e.g. "na24").

required
t9 float

Temperature \(T_9 = T / 10^9\,\mathrm{K}\).

required
ye_rho float

Electron-weighted density \(\rho Y_e\) (\(\mathrm{g\,cm^{-3}}\)).

required
eta_k float

Electron degeneracy parameter \(\eta_e = \mu_e / (k_{\mathrm{B}} T)\) excluding rest mass.

required
which_mui str

Ion Coulomb chemical potential option ("none", "dcw1973", "dgc1973", "slr1982", "i1993", "pcr2009").

'pcr2009'
which_vs str

Electron screening shift option ("none", "throwe1983", "thomasfermi", "thomas_fermi", "itoh2002").

'itoh2002'
zbar float

Mean ionic charge \(\bar{Z}\).

10.909090909090908
abar float

Mean atomic weight \(\bar{A}\).

21.818181818181817

Returns:

Type Description
WeakRateEval

Populated [WeakRateEval] instance.

weak_info_by_names

weak_info_by_names(lhs_name, rhs_name)

Look up (halflife_sec, qneu_mev) from weak_info.list.

Parameters:

Name Type Description Default
lhs_name str

Parent nuclide name (e.g. "o14").

required
rhs_name str

Daughter nuclide name (e.g. "n14").

required

Returns:

Type Description
tuple[float, float]

Tuple (halflife_sec, qneu_mev) in \(\mathrm{s}\) and \(\mathrm{MeV}\).

eval_weak_table_index

eval_weak_table_index(idx, t9, l_ye_rho)

Evaluate the idx-th (1..=463) weak table at (t9, l_ye_rho).

Parameters:

Name Type Description Default
idx int

1-based weak table index (1..=463).

required
t9 float

Temperature \(T_9 = T / 10^9\,\mathrm{K}\).

required
l_ye_rho float

\(\log_{10}(\rho Y_e / \mathrm{g\,cm^{-3}})\).

required

Returns:

Type Description
tuple[str, str, WeakRateEval]

Tuple (lhs_name, rhs_name, WeakRateEval).

flexmesa.rates.jax_kernels

Branchless JAX/XLA (float64) kernels for nuclear reaction rates (rates).

Provides differentiable @jax.jit evaluators for: - 7-parameter REACLIB forward and detailed-balance reverse rate expansions (eval_reaclib_jax, eval_reaclib_terms_jax), - Salpeter (1954), Graboske/Alastuey/Itoh (screen5), and Chugunov et al. (2007) plasma electrostatic screening (screen_salpeter_jax, screen_extended_jax, screen_chugunov_jax), and - Fushiki & Lamb (1987) pycnonuclear + thermally enhanced triple-alpha energy generation (eval_fl_epsnuc_3alf_jax).

eval_reaclib_jax

eval_reaclib_jax(coeffs, t9)

Evaluate a 7-parameter REACLIB forward rate expansion in JAX (float64).

Parameters:

Name Type Description Default
coeffs Array

Array of shape (N_terms, 7) or (7,) containing REACLIB polynomial coefficients \(a_0 \dots a_6\).

required
t9 Array

Temperature \(T_9 = T / 10^9\,\mathrm{K}\) (scalar or (N,)).

required

Returns:

Type Description
Array

Tuple (rate, drate_dln_t) of float64 JAX arrays with the shape of

Array

t9, in CGS molar reaction units.

eval_reaclib_terms_jax

eval_reaclib_terms_jax(
    coeffs,
    inv_exps,
    inv_c1s,
    inv_c2s,
    inv_parts,
    rflags,
    t9,
    check_e_flag,
)

Evaluate forward and detailed-balance reverse REACLIB rates in JAX.

Parameters:

Name Type Description Default
coeffs Array

(N_terms, 7) REACLIB polynomial coefficients.

required
inv_exps Array

(N_terms,) detailed-balance exponent \(\Delta N\).

required
inv_c1s Array

(N_terms,) first reverse coefficient \(c_1\).

required
inv_c2s Array

(N_terms,) second reverse coefficient \(c_2\).

required
inv_parts Array

(N_terms, 24) partition-function ratios on TPART.

required
rflags Array

(N_terms,) ASCII byte codes for reaction flags.

required
t9 Array

Temperature \(T_9 = T / 10^9\,\mathrm{K}\).

required
check_e_flag Array

Boolean flag exempting 'e' terms from low-\(T_9\) cutoff.

required

Returns:

Type Description
tuple[Array, Array, Array, Array]

Tuple (lam, dlam_dln_t, rlam, drlam_dln_t) of float64 JAX arrays.

eval_fl_epsnuc_3alf_jax

eval_fl_epsnuc_3alf_jax(temp, rho, y_he4, mu_e)

Evaluate Fushiki & Lamb (1987) pycnonuclear 3-alpha rate in JAX.

Parameters:

Name Type Description Default
temp Array

Temperature \(T\) in \(\mathrm{K}\).

required
rho Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
y_he4 Array

Helium-4 mass fraction \(Y\).

required
mu_e Array

Electron molecular weight \(\mu_e \approx 1 / Y_e\).

required

Returns:

Type Description
Array

Specific nuclear energy generation rate \(\epsilon_{3\alpha}\) in

Array

\(\mathrm{erg\,g^{-1}\,s^{-1}}\).

flexmesa.rates.jax_screening

Branchless JAX/XLA (float64) plasma electrostatic screening kernels.

Provides differentiable @jax.jit evaluators for Salpeter (1954), Graboske/Alastuey/Itoh (fxt_screen5), and Chugunov et al. (2007) screening.

screen_salpeter_jax

screen_salpeter_jax(temp, den, zbar, abar, z2bar, z1, z2)

Evaluate Salpeter (1954) weak plasma screening in JAX (float64).

Parameters:

Name Type Description Default
temp Array

Temperature \(T\) in \(\mathrm{K}\) (scalar or (N,)).

required
den Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
zbar Array

Mean ionic charge \(\bar{Z}\) (scalar or (N,)).

required
abar Array

Mean atomic weight \(\bar{A}\) (scalar or (N,)).

required
z2bar Array

Mean square charge \(\overline{Z^2}\) (scalar or (N,)).

required
z1 Array

Reactant 1 atomic number \(Z_1\).

required
z2 Array

Reactant 2 atomic number \(Z_2\).

required

Returns:

Type Description
Array

Tuple (scor, dscor_dt, dscor_dd) of screening enhancement factor and

Array

its partial derivatives with respect to \(T\) (\(\mathrm{K}^{-1}\)) and

Array

\(\rho\) (\(\mathrm{cm^3\,g^{-1}}\)).

screen_extended_jax

screen_extended_jax(
    temp, den, zbar, abar, z2bar, a1, z1, a2, z2
)

Evaluate Graboske/Alastuey/Itoh (fxt_screen5) plasma screening in JAX.

Parameters:

Name Type Description Default
temp Array

Temperature \(T\) in \(\mathrm{K}\) (scalar or (N,)).

required
den Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
zbar Array

Mean ionic charge \(\bar{Z}\) (scalar or (N,)).

required
abar Array

Mean atomic weight \(\bar{A}\) (scalar or (N,)).

required
z2bar Array

Mean square charge \(\overline{Z^2}\) (scalar or (N,)).

required
a1 Array

Reactant 1 atomic mass \(A_1\) (\(\mathrm{g\,mol^{-1}}\)).

required
z1 Array

Reactant 1 atomic number \(Z_1\).

required
a2 Array

Reactant 2 atomic mass \(A_2\) (\(\mathrm{g\,mol^{-1}}\)).

required
z2 Array

Reactant 2 atomic number \(Z_2\).

required

Returns:

Type Description
Array

Tuple (scor, dscor_dt, dscor_dd) of screening enhancement factor and

Array

its partial derivatives with respect to \(T\) and \(\rho\).

screen_chugunov_jax

screen_chugunov_jax(temp, den, zbar, abar, z1, z2)

Evaluate Chugunov, DeWitt & Yakovlev (2007) plasma screening in JAX.

Parameters:

Name Type Description Default
temp Array

Temperature \(T\) in \(\mathrm{K}\) (scalar or (N,)).

required
den Array

Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\).

required
zbar Array

Mean ionic charge \(\bar{Z}\) (scalar or (N,)).

required
abar Array

Mean atomic weight \(\bar{A}\) (scalar or (N,)).

required
z1 Array

Reactant 1 atomic number \(Z_1\).

required
z2 Array

Reactant 2 atomic number \(Z_2\).

required

Returns:

Type Description
Array

Tuple (scor, dscor_dt, dscor_dd) of screening enhancement factor and

Array

its partial derivatives with respect to \(T\) and \(\rho\).


Nuclear Reaction Networks & Stiff Burners (flexmesa.net)

flexmesa.net constructs arbitrary reaction topologies (basic.net, pp_and_cno_extras.net, co_burn.net, approx21.net, mesa_80.net), evaluates specific nuclear energy generation \(\epsilon_{\mathrm{nuc}}\), reaction neutrino losses \(\epsilon_{\nu,\mathrm{nuc}}\), molar abundance derivatives \(dY_i/dt\), and exact analytical sparse/dense Jacobians \(\partial(dY_i/dt)/\partial Y_j\) backed by deterministic NetGeneralInfo::identity_id-keyed thread-local NetWorkState buffers, and integrates stiff 1-zone prescribed-trajectory (burn_1_zone), constant-density variable-temperature (burn_1_zone_const_density), and constant-pressure (burn_1_zone_const_p) networks via semi-implicit Bader-Deuflhard and Rosenbrock time stepping.

flexmesa.net._core

Nuclear reaction networks, Jacobians, and one-zone burners (net).

NetInfo dataclass

Metadata for a compiled nuclear reaction network (NetGeneralInfo).

Attributes:

Name Type Description
net_name str

Network filename (e.g., "basic.net", "approx21.net").

num_isos int

Number of active nuclides (S).

num_reactions int

Number of active reactions (R).

chem_id tuple[int, ...]

1-based catalog indices of the active nuclides ([S]).

iso_names tuple[str, ...]

Nuclide names ([S]).

reaction_names tuple[str, ...]

Reaction handle names ([R]).

NetEvalOutput dataclass

Single-zone nuclear reaction network evaluation (NetEvalResult).

Attributes:

Name Type Description
eps_nuc float

Net nuclear energy generation rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

d_eps_nuc_drho float

Partial derivative \(\partial \epsilon_{\mathrm{nuc}} / \partial \rho\).

d_eps_nuc_dt float

Partial derivative \(\partial \epsilon_{\mathrm{nuc}} / \partial T\).

d_eps_nuc_dx _ArrF64

Partial derivatives \(\partial \epsilon_{\mathrm{nuc}} / \partial X_i\) ((S,)).

dxdt _ArrF64

Mass-fraction time derivatives \(dX_i / dt\) ((S,), \(\mathrm{s^{-1}}\)).

d_dxdt_drho _ArrF64

Partial derivatives \(\partial(dX_i/dt)/\partial \rho\) ((S,)).

d_dxdt_dt _ArrF64

Partial derivatives \(\partial(dX_i/dt)/\partial T\) ((S,)).

d_dxdt_dx _ArrF64

Analytical mass-fraction Jacobian \(\partial(dX_i/dt)/\partial X_j\) ((S, S)).

eps_nuc_categories _ArrF64

Category-resolved nuclear energy rates ((24,)).

eps_neu_total float

Neutrino energy loss rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

rate_raw _ArrF64

Unscreened reaction rates ((R,)).

rate_screened _ArrF64

Plasma-screened reaction rates ((R,)).

Burn1ZoneOutput dataclass

Output of a prescribed-\((T, \rho)\) one-zone burn (burn_1_zone).

Attributes:

Name Type Description
ending_x _ArrF64

Final mass fractions ((S,)).

eps_nuc_categories _ArrF64

Final category-resolved energy rates ((24,)).

avg_eps_nuc float

Time-averaged net nuclear energy rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

eps_neu_total float

Final neutrino loss rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

nfcn int

Total right-hand-side evaluations.

njac int

Total Jacobian evaluations.

nstep int

Total integration substeps.

naccpt int

Accepted substeps.

nrejct int

Rejected substeps.

BurnConstDensityOutput dataclass

Output of burn_1_zone_const_density (constant-density variable-T burn).

Attributes:

Name Type Description
ending_x _ArrF64

Final mass fractions ((S,)).

ending_log10_t float

Final \(\log_{10}(T_{\mathrm{end}} / \mathrm{K})\).

eps_nuc_categories _ArrF64

Final category-resolved energy rates ((24,)).

avg_eps_nuc float

Time-averaged net nuclear energy rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

eps_neu_total float

Final neutrino loss rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).

nfcn int

Total right-hand-side evaluations.

njac int

Total Jacobian evaluations.

nstep int

Total integration substeps.

naccpt int

Accepted substeps.

nrejct int

Rejected substeps.

BurnConstPOutput dataclass

Output of a constant-pressure one-zone burn (burn_1_zone_const_p).

Attributes:

Name Type Description
ending_x _ArrF64

Final mass fractions ((S,)).

ending_temp float

Final temperature \(T\) (\(\mathrm{K}\)).

ending_rho float

Final density \(\rho\) (\(\mathrm{g\,cm^{-3}}\)).

ending_ln_s float

Final natural log of specific entropy \(\ln S\).

initial_rho float

Initial density \(\rho_0\) (\(\mathrm{g\,cm^{-3}}\)).

initial_ln_s float

Initial natural log of specific entropy \(\ln S_0\).

nfcn int

Total right-hand-side evaluations.

njac int

Total Jacobian evaluations.

nstep int

Total Rosenbrock steps.

naccpt int

Accepted Rosenbrock steps.

nrejct int

Rejected Rosenbrock steps.

list_networks

list_networks()

Return sorted list of built-in .net nuclear network filenames.

get_net_info

get_net_info(net_name='basic.net')

Return nuclide and reaction metadata for net_name.

Parameters:

Name Type Description Default
net_name str

Built-in .net filename (e.g., "basic.net").

'basic.net'

Returns:

Type Description
NetInfo

Populated NetInfo dataclass.

eval_net

eval_net(
    net_name,
    x,
    temp,
    rho,
    abar,
    zbar,
    z2bar,
    ye,
    eta=0.0,
    d_eta_dlnt=0.0,
    d_eta_dlnrho=0.0,
    log_t=None,
    log_rho=None,
    rate_factors=None,
    weak_rate_factor=1.0,
    screening_mode="extended",
    skip_jacobian=False,
)

Evaluate a nuclear reaction network at a single thermodynamic state.

Parameters:

Name Type Description Default
net_name str

Network filename (e.g., "basic.net", "approx21.net").

required
x ArrayLike

Mass fractions ((S,)).

required
temp float

Temperature \(T\) (\(\mathrm{K}\)).

required
rho float

Mass density \(\rho\) (\(\mathrm{g\,cm^{-3}}\)).

required
abar float

Mean atomic mass number \(\bar{A}\).

required
zbar float

Mean atomic charge number \(\bar{Z}\).

required
z2bar float

Mean squared atomic charge \(\overline{Z^2}\).

required
ye float

Electron-to-baryon fraction \(Y_e\).

required
eta float

Electron degeneracy parameter \(\eta\).

0.0
d_eta_dlnt float

\((\partial \eta / \partial \ln T)_\rho\).

0.0
d_eta_dlnrho float

\((\partial \eta / \partial \ln \rho)_T\).

0.0
log_t float | None

Optional \(\log_{10}(T / \mathrm{K})\).

None
log_rho float | None

Optional \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

None
rate_factors ArrayLike | None

Optional per-reaction multipliers ((R,)).

None
weak_rate_factor float

Global weak-rate multiplier.

1.0
screening_mode str

"extended", "salpeter", "chugunov", "classic", or "none".

'extended'
skip_jacobian bool

If True, skip Jacobian assembly.

False

Returns:

Type Description
NetEvalOutput

Populated NetEvalOutput dataclass.

burn_1_zone

burn_1_zone(
    net_name,
    t_start,
    t_end,
    starting_x,
    times,
    log10_ts,
    log10_rhos,
    etas=None,
    rate_factors=None,
    weak_rate_factor=1.0,
    screening_mode="extended",
    stptry_in=0.0,
    max_steps=10000,
    eps=1e-08,
    odescal=1e-12,
)

Integrate a one-zone burn along \((T(t), \rho(t))\) via Bader-Deuflhard.

Parameters:

Name Type Description Default
net_name str

Network filename (e.g., "basic.net", "approx21.net").

required
t_start float

Starting time \(t_{\mathrm{start}}\) (\(\mathrm{s}\)).

required
t_end float

Ending time \(t_{\mathrm{end}}\) (\(\mathrm{s}\)).

required
starting_x ArrayLike

Initial mass fractions ((S,)).

required
times ArrayLike

Time knot array ((N_t,)).

required
log10_ts ArrayLike

\(\log_{10}(T / \mathrm{K})\) at each time knot ((N_t,)).

required
log10_rhos ArrayLike

\(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\) at each knot ((N_t,)).

required
etas ArrayLike | None

Optional electron degeneracy \(\eta\) at each time knot ((N_t,)).

None
rate_factors ArrayLike | None

Optional per-reaction multipliers ((R,)).

None
weak_rate_factor float

Global weak-rate multiplier.

1.0
screening_mode str

Plasma screening mode.

'extended'
stptry_in float

Initial step size guess (0.0 for automatic).

0.0
max_steps int

Maximum allowed substeps.

10000
eps float

Relative error tolerance.

1e-08
odescal float

Abundance scaling floor.

1e-12

Returns:

Type Description
Burn1ZoneOutput

Populated Burn1ZoneOutput dataclass.

burn_1_zone_const_density

burn_1_zone_const_density(
    net_name,
    t_start,
    t_end,
    starting_x,
    starting_log10_t,
    log10_rho,
    rate_factors=None,
    weak_rate_factor=1.0,
    screening_mode="extended",
    stptry_in=0.0,
    max_steps=10000,
    eps=1e-05,
    odescal=1e-05,
)

Integrate a constant-density variable-T burn via Bader-Deuflhard.

Co-evolves molar abundances \(Y_i = X_i / A_i\) and \(\ln T\) at fixed mass density \(\rho = 10^{\log_{10}\rho}\) using \(d\ln T / dt = \epsilon_{\mathrm{nuc}} / (c_V T)\).

Parameters:

Name Type Description Default
net_name str

Network filename (e.g., "basic.net", "approx21.net").

required
t_start float

Starting time \(t_{\mathrm{start}}\) (\(\mathrm{s}\)).

required
t_end float

Ending time \(t_{\mathrm{end}}\) (\(\mathrm{s}\)).

required
starting_x ArrayLike

Initial mass fractions ((S,)).

required
starting_log10_t float

Initial \(\log_{10}(T_0 / \mathrm{K})\).

required
log10_rho float

Fixed \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\).

required
rate_factors ArrayLike | None

Optional per-reaction multipliers ((R,)).

None
weak_rate_factor float

Global weak-rate multiplier.

1.0
screening_mode str

Plasma screening mode.

'extended'
stptry_in float

Initial step size guess (0.0 for automatic).

0.0
max_steps int

Maximum allowed substeps.

10000
eps float

Relative integration error tolerance.

1e-05
odescal float

Abundance scaling floor.

1e-05

Returns:

Type Description
BurnConstDensityOutput

Populated BurnConstDensityOutput dataclass.

burn_1_zone_const_p

burn_1_zone_const_p(
    net_name,
    starting_temp,
    starting_x,
    t_end,
    pressure,
    solver="rodas4",
    clip=False,
    rate_factors=None,
    weak_rate_factor=1.0,
    screening_mode="extended",
    h0=1e-06,
    max_step_size=1.0,
    max_steps=1000,
    rtol=1e-07,
    atol=1e-08,
    x_min=-1e-10,
)

Integrate a constant-pressure one-zone burn via Rosenbrock (rodas4).

Parameters:

Name Type Description Default
net_name str

Network filename (e.g., "approx21.net").

required
starting_temp float

Initial temperature \(T_0\) (\(\mathrm{K}\)).

required
starting_x ArrayLike

Initial mass fractions ((S,)).

required
t_end float

Integration duration \(t_{\mathrm{end}}\) (\(\mathrm{s}\)).

required
pressure float

Constant total pressure \(P\) (\(\mathrm{dyn\,cm^{-2}}\)).

required
solver str

Rosenbrock variant ("rodas4", "rodasp", "ros3p", "ros3pl").

'rodas4'
clip bool

Whether to clip negative abundances during integration.

False
rate_factors ArrayLike | None

Optional per-reaction multipliers ((R,)).

None
weak_rate_factor float

Global weak-rate multiplier.

1.0
screening_mode str

Plasma screening mode.

'extended'
h0 float

Initial step size (\(\mathrm{s}\)).

1e-06
max_step_size float

Maximum step size (\(\mathrm{s}\)).

1.0
max_steps int

Maximum Rosenbrock steps.

1000
rtol float

Relative tolerance.

1e-07
atol float

Absolute tolerance.

1e-08
x_min float

Minimum allowed mass fraction before step rejection.

-1e-10

Returns:

Type Description
BurnConstPOutput

Populated BurnConstPOutput dataclass.

flexmesa.net._jax

Differentiable JAX wrappers for nuclear reaction networks (net).

Implements eval_net_jax with an exact jax.custom_vjp rule backed by the analytical Jacobians (d_eps_nuc_dx, d_eps_nuc_dt, d_eps_nuc_drho, d_dxdt_dx, d_dxdt_dt, d_dxdt_drho) computed in Safe Rust (flexmesa-net).

eval_net_jax

eval_net_jax(
    net_name,
    x,
    temp,
    rho,
    abar,
    zbar,
    z2bar,
    ye,
    eta=0.0,
    d_eta_dlnt=0.0,
    d_eta_dlnrho=0.0,
    weak_rate_factor=1.0,
    screening_mode="extended",
)

Evaluate differentiable (eps_nuc, dxdt) with jax.custom_vjp.

Propagates reverse-mode sensitivities with respect to (x, temp, rho) using the exact analytical derivatives d_eps_nuc_dx, d_eps_nuc_dt, d_eps_nuc_drho, d_dxdt_dx, d_dxdt_dt, and d_dxdt_drho from flexmesa._rust.net_eval.

Parameters:

Name Type Description Default
net_name str

Network filename (e.g., "basic.net", "approx21.net").

required
x Array

Mass fractions ((S,)).

required
temp Array

Temperature \(T\) (\(\mathrm{K}\)).

required
rho Array

Mass density \(\rho\) (\(\mathrm{g\,cm^{-3}}\)).

required
abar float

Mean atomic mass number \(\bar{A}\).

required
zbar float

Mean atomic charge number \(\bar{Z}\).

required
z2bar float

Mean squared atomic charge \(\overline{Z^2}\).

required
ye float

Electron-to-baryon fraction \(Y_e\).

required
eta float

Electron degeneracy parameter \(\eta\).

0.0
d_eta_dlnt float

\((\partial \eta / \partial \ln T)_\rho\).

0.0
d_eta_dlnrho float

\((\partial \eta / \partial \ln \rho)_T\).

0.0
weak_rate_factor float

Global weak-rate multiplier.

1.0
screening_mode str

Plasma screening mode.

'extended'

Returns:

Type Description
Array

Tuple (eps_nuc, dxdt) where eps_nuc is a scalar JAX float64 array

Array

and dxdt has shape (S,).


Compiled Rust Extension Bridge (flexmesa._rust)

Low-level Safe Rust PyO3 bindings exposed via flexmesa._rust for nuclide catalogs, ionization, thermal neutrinos, nuclear reaction rates, screening, and reaction networks (_ArrF64 denotes a float64 NumPy ndarray).

chem_py

  • py_chem_ag89_namsol (() -> list[str]): Returns the ordered 286 isotope names (namsol(1:286)) in the Anders & Grevesse (1989) table.
  • py_chem_ag89_yesol (() -> float): Returns the Anders & Grevesse (1989) solar electron fraction yesol.
  • py_chem_ag89_zsol (() -> float): Returns the Anders & Grevesse (1989) bulk solar metallicity zsol.
  • py_chem_category_id ((name: str) -> int): Returns the 1-based reaction category ID (1..=24) or 0 if unknown.
  • py_chem_category_name ((id: int) -> str | None): Returns the reaction category name for 1-based id (1..=24).
  • py_chem_element_long_name ((z: int) -> str | None): Returns the full element name for \(Z \in [0, 112]\).
  • py_chem_element_main_iso_name ((z: int) -> str | None): Returns the dominant isotope name for \(Z \in [1, 112]\).
  • py_chem_element_name ((z: int) -> str | None): Returns the short element symbol for \(Z \in [0, 112]\).
  • py_chem_generate_long_nuclide_names ((z: Sequence[int], a: Sequence[int]) -> list[str]): Generates long nuclide names from \((Z, A)\) arrays.
  • py_chem_generate_nuclide_names ((z: Sequence[int], a: Sequence[int]) -> list[str]): Generates short nuclide names from \((Z, A)\) arrays.
  • py_chem_get_composition_info ((chem_ids: Sequence[int], x: Sequence[float], skip_partials: bool) -> tuple[tuple[float, ...], list[float], list[float], list[float]]): Computes single-zone composition moments and optional partial derivatives, returning ((xh, xhe, xz, abar, zbar, z2bar, z53bar, ye, mass_correction, sumx), dabar_dx, dzbar_dx, dmc_dx).
  • py_chem_get_composition_info_zones ((chem_ids: Sequence[int], x_zones: _ArrF64, parallel: bool = False) -> _ArrF64): Evaluates 10 composition moment columns (xh, xhe, xz, abar, zbar, z2bar, z53bar, ye, mass_correction, sumx) across nz zones (x_zones of shape (nz, n_species)).
  • py_chem_get_element_id ((name: str) -> int | None): Looks up the 1-based atomic number \(Z \in [1, 112]\) for an element symbol.
  • py_chem_get_nuclide_index ((name: str) -> int | None): Returns the 1-based chem_id for a nuclide name ("o16", "fe56", etc.).
  • py_chem_get_partition_fcn_indx ((t9: float) -> int): Returns the 1-based partition function temperature index for \(T_9\) (\(\mathrm{GK}\)).
  • py_chem_get_solar ((name: str) -> tuple[float, float, float] | None): Returns (Z, A, X_sol) for name in the Anders & Grevesse (1989) table.
  • py_chem_get_stable_mass_frac ((z: Sequence[int], a: Sequence[int], abun_in: Sequence[float]) -> list[float]): Maps unstable nuclear network abundances onto the 286 stable solar isotopes.
  • py_chem_lodders03_atom_percent ((name: str) -> float): Returns the Lodders (2003, Table 6) isotopic atom percentage for name.
  • py_chem_m_div_h ((x: float, z: float, scale: str) -> float): Computes [M/H] (chem_M_div_h) for hydrogen fraction x, metallicity z, and solar scale scale.
  • py_chem_nuclide_info ((chem_id: int) -> tuple[int, str, int, int, float, float, float, float, float, int]): Returns (chem_id, name, z, n, spin, mass_excess, binding_energy, w, z53, isomeric_state) for a 1-based chem_id, raising ValueError if unknown.
  • py_chem_reaction_qtotal ((num_in: int, num_out: int, reactants: Sequence[int]) -> float): Computes the total reaction \(Q\)-value (\(\mathrm{MeV}\)) for num_in incoming and num_out outgoing species.
  • py_chem_solar_cno_fraction ((scale: str) -> float): Returns the CNO mass fraction of \(Z\) for scale.
  • py_chem_solar_element_zfrac ((scale: str) -> list[float]): Returns the 112-element solar metal mass-fraction list for scale, raising ValueError if unsupported.
  • py_chem_species_props ((chem_ids: Sequence[int]) -> tuple[list[int], list[float], list[float], list[float], list[float]]): Returns (z_int, z, a, w, z53) vectors for 1-based chem_ids used by flexmesa.chem.composition.
  • py_chem_xsol ((name: str) -> float): Returns the Anders & Grevesse (1989) solar mass fraction for name.

ionization_py

  • py_ion_builtin_cell_grid (() -> tuple[float, float, int, float, float, int, _ArrF64]): Returns (log_q_min, del_log_q, num_log_qs, log_t_min, del_log_t, num_log_ts, coeffs) for IonTableGrid::builtin, where coeffs has shape (5 * 6 * 28, num_log_qs * num_log_ts * 4).
  • py_ion_charge_of_fe56_in_he4 ((log10_ne: float, log10_t: float) -> tuple[float, float, float]): Evaluates (z, dz_dlog10_ne, dz_dlog10_t) for \({}^{56}\mathrm{Fe}\) in \({}^4\mathrm{He}\) at \((\log_{10} n_e, \log_{10} T)\) on the \(105 \times 30\) Thomas-Fermi-Dirac-Hubbard grid (eval_charge_of_Fe56_in_He4).
  • py_ion_charge_of_fe56_in_he4_zones ((log10_ne: _ArrF64, log10_t: _ArrF64, parallel: bool = False) -> _ArrF64): Evaluates [z, dz_dlog10_ne, dz_dlog10_t] across n_zones zones, dispatching to the 4-thread rayon worker pool when parallel=True and n_zones >= 64.
  • py_ion_chi_effective ((chi: float, c0: float, c1: float, c2: float, z1: float, z2: float) -> float): Computes \(\chi_{\mathrm{eff}}(z_2) = \chi + c_0 / z_2^3 + \min[c_1 z_2, c_2 ((z_2 / z_1)^{2/3} + 0.6)]\) in \(\mathrm{eV}\) (chi_effective).
  • py_ion_chi_info ((a1: float, z1: float, t: float, log10_t: float, rho: float, log10_rho: float) -> tuple[float, float, float, float]): Computes \((\chi, c_0, c_1, c_2)\) continuum-depression parameters in \(\mathrm{eV}\) (chi_info).
  • py_ion_eval_ionization ((z: float, x: float, rho: float | None = None, log10_rho: float | None = None, t: float | None = None, log10_t: float | None = None) -> list[float]): Evaluates all 28 eval_ionization channels for a single zone from either linear or log10 inputs.
  • py_ion_eval_ionization_dual ((z: float, x: float, log10_rho: float, log10_t: float) -> tuple[_ArrF64, _ArrF64]): Evaluates all 28 eval_ionization channels and their \(28 \times 4\) Jacobian with respect to (z, x, log10_rho, log10_t) via DualOrder1<4>.
  • py_ion_eval_ionization_zones ((z: _ArrF64, x: _ArrF64, log10_rho: _ArrF64, log10_t: _ArrF64, parallel: bool = False) -> _ArrF64): Evaluates all 28 eval_ionization channels across n_zones zones, dispatching to the 4-thread rayon worker pool when parallel=True and n_zones >= 64.
  • py_ion_eval_typical_charge ((cid: int, abar: float, free_e: float, t: float, log10_t: float, rho: float, log10_rho: float) -> float): Computes whole-number typical charge (eval_typical_charge) against Allen (1973) ionization potentials (IONIZATION_POTENTIALS) for nuclide cid (\(1 \le Z \le 30\)).
  • py_ion_fe56_he4_grid (() -> tuple[_ArrF64, _ArrF64, _ArrF64]): Returns (log_ne, log_t, coeffs) for the built-in \(105 \times 30\) Fe56He4Table (coeffs shape (105 * 30, 4)).
  • py_ion_potentials_table (() -> _ArrF64): Returns the (30, 30) Allen (1973) ionization potential table in \(\mathrm{eV}\).
  • py_ion_result_names (() -> list[str]): Returns the ordered list of 28 eval_ionization output channel names (logPgas, logpp_H..Fe, Z_H..Fe, fneut_H..Fe).

neu_py

  • neu_get_batch ((t: _ArrF64, log10_t: _ArrF64, rho: _ArrF64, log10_rho: _ArrF64, abar: _ArrF64, zbar: _ArrF64, log10_tlim: float = 7.5, flags: Sequence[bool] = (True, True, True, True, True), parallel: bool = False) -> _ArrF64): Evaluates neu_get across 1D arrays (t, log10_t, rho, log10_rho, abar, zbar) of shape (nz,), returning a (nz, 5) array of [sneu, dsneu_dT, dsneu_dRho, dsneu_dAbar, dsneu_dZbar] (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)) and partials, dispatching across the persistent 4-thread rayon pool when parallel=True and nz >= 64.
  • neu_get_full_zones ((log10_t: _ArrF64, log10_rho: _ArrF64, abar: _ArrF64, zbar: _ArrF64, log10_tlim: float = 7.5, flags: Sequence[bool] = (True, True, True, True, True), parallel: bool = False) -> _ArrF64): Evaluates neu_get across 1D arrays (log10_t, log10_rho, abar, zbar) of shape (nz,), returning a (nz, 30) array packing loss[0..5] followed by Fortran column-major sources (d_idx outer 0..5, channel inner 0..5).

rates_py

  • rates_compute_rev_ratio_coeff1 ((w_in: Sequence[float], spin_in: Sequence[float], w_out: Sequence[float], spin_out: Sequence[float]) -> float): Computes detailed-balance first reverse coefficient inverse_coefficients(1) from nuclear masses w (\(\mathrm{AMU}\)) and ground-state spins spin.
  • rates_eval_coulomb ((which_mui: str, which_vs: str, temp: float, den: float, zbar: float, abar: float, z1: float, z2: float) -> tuple[float, float, float, float]): Evaluates Coulomb chemical potential and electron screening shift (mu1, mu2, dmu_eV, vs).
  • rates_eval_ecapture_pair ((lhs_name: str, rhs_name: str, t9: float, ye_rho: float, eta_k: float, which_mui: str = "pcr2009", which_vs: str = "itoh2002", zbar: float = 10.909090909090908, abar: float = 21.818181818181817) -> list[float]): Evaluates on-the-fly relativistic Fermi-Dirac electron-capture / beta-decay rate.
  • rates_eval_fl_epsnuc_3alf ((t: float, rho: float, y: float, ue: float) -> float): Evaluates Fushiki & Lamb (1987) pycnonuclear 3-alpha energy generation rate.
  • rates_eval_rate_table ((ir: int, temp: float) -> tuple[float, float]): Evaluates an interp_pm 1D cubic rate table (rate, drate_dt) for reaction ID ir.
  • rates_eval_reaclib_handle ((handle: str, t9: float, check_e_flag: bool = True) -> tuple[float, float, float, float]): Evaluates a REACLIB handle (forward_rate, dforward_dlnT, reverse_rate, dreverse_dlnT).
  • rates_eval_reaclib_screen_zones ((handle: str, mode: str, temps: _ArrF64, dens: _ArrF64, zbar: float, abar: float, z2bar: float, a1: float, z1: float, a2: float, z2: float, parallel: bool = True) -> _ArrF64): Evaluates a REACLIB handle and plasma screening across n_zones zones, returning an (n_zones, 3) array [safe_log10(fw * scor), fw, scor].
  • rates_eval_weak_pair ((lhs_name: str, rhs_name: str, t9: float, ye_rho: float, use_suzuki: bool = False) -> list[float]): Evaluates tabulated weak reaction rate (weaklib or Suzuki2016), returning a 9-element list.
  • rates_eval_weak_table_index ((idx: int, t9: float, l_ye_rho: float) -> tuple[str, str, list[float]]): Evaluates the idx-th (1..=463) weak table at (t9, l_ye_rho).
  • rates_reaclib_terms ((handle: str) -> tuple[bool, list[tuple[int, int, int, list[float], float, float, list[float]]]]): Returns (is_reverse, terms) for a REACLIB reaction handle, where each term is (chapter, rflag, inv_exp, coeffs[7], inv_c1, inv_c2, inv_part[24]).
  • rates_reaction_id_by_name ((name: str) -> int): Looks up the 1-based reaction ID (1..=316) for a reaction name.
  • rates_reaction_info ((ir: int) -> tuple[str, int, bool, str, int, int, int, float, float, float]): Returns metadata (name, op_code, is_reverse, target_handle, ye_exp, rho_exp, category, std_q, std_qneu, weak_lowt_rate) for 1-based reaction ID ir.
  • rates_reaction_name_by_id ((ir: int) -> str): Looks up the reaction name for a 1-based reaction ID (1..=316).
  • rates_screen_pair ((mode: str, temp: float, den: float, zbar: float, abar: float, z2bar: float, a1: float, z1: float, a2: float, z2: float) -> tuple[float, float, float]): Evaluates plasma electrostatic screening (scor, dscor_dt, dscor_dd) for a reacting pair.
  • rates_screen_pair_zones ((mode: str, temps: _ArrF64, dens: _ArrF64, zbars: _ArrF64, abars: _ArrF64, z2bars: _ArrF64, a1: float, z1: float, a2: float, z2: float) -> _ArrF64): Evaluates plasma screening across n_zones, returning an (n_zones, 3) array.
  • rates_set_raw_rate ((ir: int, temp: float, log_t: float | None = None) -> float): Evaluates set_raw_rate for a single 1-based reaction ID ir (1..=316).
  • rates_set_raw_rates ((irs: npt.NDArray[np.uintp], temp: float, log_t: float | None = None) -> _ArrF64): Evaluates set_raw_rates for a 1D array of 1-based reaction IDs irs.
  • rates_set_raw_rates_zones ((irs: npt.NDArray[np.uintp], temps: _ArrF64, log_ts: _ArrF64 | None = None) -> _ArrF64): Evaluates set_raw_rates across n_zones temperatures, returning an (n_zones, n_rxns) array.
  • rates_weak_info_by_names ((lhs_name: str, rhs_name: str) -> tuple[float, float]): Looks up (halflife_sec, qneu_mev) from weak_info.list by isotope names.

net_py

  • net_burn_1_zone ((net_name: str, t_start: float, t_end: float, starting_x: _ArrF64, times: _ArrF64, log10_ts: _ArrF64, log10_rhos: _ArrF64, etas: _ArrF64, rate_factors: _ArrF64 | None = None, weak_rate_factor: float = 1.0, screening_mode: str = "extended", stptry_in: float = 0.0, max_steps: int = 10000, eps: float = 1.0e-8, odescal: float = 1.0e-12) -> tuple[_ArrF64, _ArrF64, float, float, int, int, int, int, int]): Integrates a one-zone burn at constant or prescribed \((T(t), \rho(t))\) (burn_1_zone).
  • net_burn_1_zone_const_density ((net_name: str, t_start: float, t_end: float, starting_x: _ArrF64, starting_log10_t: float, log10_rho: float, rate_factors: _ArrF64 | None = None, weak_rate_factor: float = 1.0, screening_mode: str = "extended", stptry_in: float = 0.0, max_steps: int = 10000, eps: float = 1.0e-5, odescal: float = 1.0e-5) -> tuple[_ArrF64, float, _ArrF64, float, float, int, int, int, int, int]): Integrates a constant-density variable-temperature one-zone burn (burn_1_zone_const_density).
  • net_burn_1_zone_const_p ((net_name: str, starting_temp: float, starting_x: _ArrF64, t_end: float, pressure: float, solver: str = "rodas4", clip: bool = False, rate_factors: _ArrF64 | None = None, weak_rate_factor: float = 1.0, screening_mode: str = "extended", h0: float = 1.0e-6, max_step_size: float = 1.0, max_steps: int = 1000, rtol: float = 1.0e-7, atol: float = 1.0e-8, x_min: float = -1.0e-10) -> tuple[_ArrF64, float, float, float, float, float, int, int, int, int, int]): Integrates a constant-pressure one-zone burn (burn_1_zone_const_p).
  • net_eval ((net_name: str, x: _ArrF64, temp: float, log_t: float, rho: float, log_rho: float, abar: float, zbar: float, z2bar: float, ye: float, eta: float = 0.0, d_eta_dlnt: float = 0.0, d_eta_dlnrho: float = 0.0, rate_factors: _ArrF64 | None = None, weak_rate_factor: float = 1.0, screening_mode: str = "extended", skip_jacobian: bool = False) -> tuple[float, float, float, _ArrF64, _ArrF64, _ArrF64, _ArrF64, _ArrF64, _ArrF64, float, _ArrF64, _ArrF64]): Evaluates net_get at a single thermodynamic and composition state, returning (eps_nuc, d_eps_nuc_drho, d_eps_nuc_dt, d_eps_nuc_dx, dxdt, d_dxdt_drho, d_dxdt_dt, d_dxdt_dx, eps_nuc_categories, eps_neu_total, rate_raw, rate_screened).
  • net_eval_zones ((net_name: str, x: _ArrF64, temps: _ArrF64, log_ts: _ArrF64, rhos: _ArrF64, log_rhos: _ArrF64, abar: float, zbar: float, z2bar: float, ye: float, eta: float = 0.0, d_eta_dlnt: float = 0.0, d_eta_dlnrho: float = 0.0, weak_rate_factor: float = 1.0, screening_mode: str = "extended", skip_jacobian: bool = False, parallel: bool = True) -> _ArrF64): Evaluates eval_net_with_work across n_zones zones, returning an (n_zones, 4) array [log10_eps_nuc, eps_nuc, d_eps_dt, d_eps_drho].
  • net_info ((net_name: str) -> tuple[int, int, list[int], list[str], list[str]]): Returns (num_isos, num_reactions, chem_id, iso_names, reaction_names) for a built-in network.
  • net_list_networks (() -> list[str]): Lists all built-in .net nuclear network definition filenames.