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 (0forneut). - Solar metal mass-fraction arrays (
solar_element_zfrac) have shape(112,)infloat64, where 0-based indexz - 1corresponds to atomic numberz(\(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 |
name |
str
|
Trimmed isotope symbol (such as |
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 ( |
chem_get_element_id
¶
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. |
required |
Returns:
| Type | Description |
|---|---|
int
|
1-based element ID \(Z \in [1, 112]\), or |
element_name
¶
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]\) ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
Short element symbol (e.g. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
element_long_name
¶
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. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
element_main_iso_name
¶
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. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
category_id
¶
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. |
required |
Returns:
| Type | Description |
|---|---|
int
|
1-based category index (\(1..=24\)), or |
category_name
¶
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 |
get_partition_fcn_indx
¶
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 |
generate_nuclide_names
¶
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. |
generate_long_nuclide_names
¶
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. |
get_nuclide_index
¶
Return the 1-based chem_id for a nuclide name (get_nuclide_index).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Nuclide name (such as |
required |
Returns:
| Type | Description |
|---|---|
int
|
1-based MESA |
get_nuclide_info
¶
Return the NuclideInfo record for a chem_id or isotope name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iso
|
int | str
|
1-based integer |
required |
Returns:
| Type | Description |
|---|---|
NuclideInfo
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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
¶
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
¶
Return the Anders & Grevesse (1989) solar mass fraction for name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Isotope name ( |
required |
Returns:
| Type | Description |
|---|---|
float
|
Solar mass fraction \(X_{\odot}(\text{name})\) or |
chem_get_solar
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float] | None
|
Tuple |
lodders03_element_atom_percent
¶
Return the Lodders (2003, Table 6) isotopic atom percent for nuclei.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nuclei
|
str
|
Isotope name (such as |
required |
Returns:
| Type | Description |
|---|---|
float
|
Atom percentage within the parent element (\([0, 100]\)), or |
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 |
get_stable_mass_frac
¶
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 |
required |
a
|
Sequence[int]
|
Sequence of baryon numbers \(A_i\) of length |
required |
abun_in
|
Sequence[float] | NDArray[float64]
|
Input mass fractions \(X_i\) of shape |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
1D |
solar_element_zfrac
¶
Return the 112-element solar metal mass-fraction array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
str
|
Solar scale name ( |
'AGSS09'
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
1D |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
solar_cno_fraction
¶
Return the CNO mass fraction of metallicity (\(Z_{\mathrm{CNO}} / Z\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
str
|
Solar scale identifier (e.g. |
'AGSS09'
|
Returns:
| Type | Description |
|---|---|
float
|
Dimensionless CNO fraction of \(Z\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
chem_m_div_h
¶
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 |
reaction_qtotal
¶
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 |
required |
Returns:
| Type | Description |
|---|---|
float
|
Total energy release \(Q_{\mathrm{total}}\) in \(\mathrm{MeV}\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any nuclide name or |
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 integerchem_ids or trimmed isotope names (such as"h1","c12","fe56"). - Single-zone abundance vectors
xhave shape(n_species,)infloat64. - Multi-zone abundance arrays
x_zoneshave row-major C-contiguous shape(n_zones, n_species)infloat64. get_composition_info_zonesreturns 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 |
dzbar_dx |
NDArray[float64]
|
Partial derivatives \(\partial \bar{Z} / \partial X_i\) of
shape |
dmc_dx |
NDArray[float64]
|
Partial derivatives
\(\partial (\text{mass\_correction}) / \partial X_i\) of shape
|
get_composition_info_jax
¶
Evaluate differentiable composition moments and partials in JAX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chem_ids
|
Sequence[int | str]
|
Sequence of length |
required |
x
|
Array | NDArray[float64]
|
Mass fractions \(X_i\) of shape |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
Array
|
|
Array
|
abar, zbar, z2bar, z53bar, ye, mass_correction, sumx]`) and each |
Array
|
partial derivative array has shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
get_composition_info
¶
Compute composition moments and optional partial derivatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chem_ids
|
Sequence[int | str]
|
Sequence of 1-based |
required |
x
|
Sequence[float] | NDArray[float64] | Array
|
Mass-fraction vector \(X_i\) of shape |
required |
skip_partials
|
bool
|
If |
False
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
CompositionInfo
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
basic_composition_info
¶
Compute composition moments without partial derivatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chem_ids
|
Sequence[int | str]
|
Sequence of 1-based |
required |
x
|
Sequence[float] | NDArray[float64] | Array
|
Mass-fraction vector \(X_i\) of shape |
required |
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
CompositionInfo
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
composition_info
¶
Compute composition moments and analytical partial derivatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chem_ids
|
Sequence[int | str]
|
Sequence of 1-based |
required |
x
|
Sequence[float] | NDArray[float64] | Array
|
Mass-fraction vector \(X_i\) of shape |
required |
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
CompositionInfo
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
get_composition_info_zones
¶
Evaluate the 10 composition moments across n_zones stellar zones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chem_ids
|
Sequence[int | str]
|
Sequence of length |
required |
x_zones
|
NDArray[float64] | Array
|
2D abundance array of shape |
required |
parallel
|
bool
|
When using the |
True
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
NDArray[float64] | Array
|
2D |
NDArray[float64] | Array
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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
¶
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 |
chi_info_jax
¶
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 |
Array
|
\(\mathrm{eV}\). |
chi_effective_jax
¶
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
¶
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'
|
Returns:
| Type | Description |
|---|---|
tuple[float | Array, float | Array, float | Array, float | Array]
|
Tuple |
chi_effective
¶
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'
|
Returns:
| Type | Description |
|---|---|
float | Array
|
Effective ionization threshold \(\chi_{\mathrm{eff}}\) in \(\mathrm{eV}\). |
eval_typical_charge
¶
Compute the whole-number typical ionic charge (eval_typical_charge).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cid
|
int | str
|
1-based |
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'
|
Returns:
| Type | Description |
|---|---|
float | Array
|
Whole-number ionic charge \(Z_{\mathrm{typ}} \in [1, Z_{\max}]\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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
¶
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 |
required |
log10_t
|
Array | float
|
Base-10 log temperature \(\log_{10}(T / \mathrm{K})\) of shape
|
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array, Array]
|
Tuple |
eval_charge_of_fe56_in_he4
¶
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'
|
Returns:
| Type | Description |
|---|---|
float | Array
|
Effective ionic charge \(Z(\mathrm{Fe56})\) (dimensionless). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
eval_charge_of_fe56_in_he4_zones
¶
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
|
required |
log10_t
|
NDArray[float64] | Array
|
1D array of \(\log_{10}(T / \mathrm{K})\) of shape |
required |
parallel
|
bool
|
When using |
True
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
NDArray[float64] | Array
|
2D |
NDArray[float64] | Array
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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 |
log_pgas |
float
|
Base-10 log gas pressure \(\log_{10}(P_{\mathrm{gas}} / \mathrm{dyn\,cm^{-2}})\). |
logpp |
NDArray[float64] | Array
|
9-element |
z_ion |
NDArray[float64] | Array
|
9-element |
fneut |
NDArray[float64] | Array
|
9-element |
eval_ionization_jax
¶
Evaluate all 28 ionization channels in JAX (eval_ionization).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
Array | float
|
Metallicity mass fraction \(Z\) of shape |
required |
x
|
Array | float
|
Hydrogen mass fraction \(X\) of shape |
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
|
|
Array
|
|
eval_ionization
¶
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
|
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 |
None
|
log10_t
|
float | Array | None
|
Base-10 log temperature \(\log_{10}(T / \mathrm{K})\). |
None
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
IonizationResult
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither linear nor |
eval_ionization_zones
¶
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 |
required |
x
|
NDArray[float64] | Array
|
1D array of hydrogen mass fractions \(X\) of shape |
required |
log10_rho
|
NDArray[float64] | Array
|
1D array of \(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\) of shape
|
required |
log10_t
|
NDArray[float64] | Array
|
1D array of \(\log_{10}(T / \mathrm{K})\) of shape |
required |
parallel
|
bool
|
When using |
True
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
NDArray[float64] | Array
|
2D |
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-basedNeuChannel(PAIR = 0 .. RECO = 4). - Upstream 1-based derivative indices (
ineu = 1 .. idneu_dzbar = 5) map toNeuRatefields (val,d_t,d_rho,d_abar,d_zbar) and 0-based row-majorsourcesof 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 ( |
plas |
bool
|
Enable plasmon-decay neutrino losses ( |
phot |
bool
|
Enable photoneutrino losses ( |
brem |
bool
|
Enable bremsstrahlung neutrino losses ( |
reco |
bool
|
Enable recombination neutrino losses ( |
all
classmethod
¶
Enables all five neutrino reaction channels.
Returns:
| Type | Description |
|---|---|
NeuFlags
|
|
none
classmethod
¶
Disables all five neutrino reaction channels.
Returns:
| Type | Description |
|---|---|
NeuFlags
|
|
NeuResult
dataclass
¶
Complete thermal neutrino loss output (loss and sources).
Attributes:
| Name | Type | Description |
|---|---|---|
total |
NeuRate
|
Total specific neutrino energy loss rate ( |
pair |
NeuRate
|
Pair-production channel rate ( |
plas |
NeuRate
|
Plasmon-decay channel rate ( |
phot |
NeuRate
|
Photoneutrino channel rate ( |
brem |
NeuRate
|
Bremsstrahlung channel rate ( |
reco |
NeuRate
|
Recombination channel rate ( |
loss |
ndarray
|
1D |
sources |
ndarray
|
2D row-major |
channel
¶
Returns the NeuRate for the requested NeuChannel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ch
|
NeuChannel
|
Channel index ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Corresponding |
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
|
log10_t
|
float | Array | None
|
Base-10 logarithm \(\log_{10}(T / \mathrm{K})\), or |
None
|
rho
|
float | Array | None
|
Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\), or |
None
|
log10_rho
|
float | Array | None
|
Base-10 logarithm
\(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\), or |
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
|
flags
|
NeuFlags | None
|
Per-channel enable flags ( |
None
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
NeuResult
|
|
NeuResult
|
row-major |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
neu_pair_plas_jax
¶
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 |
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}}\) ( |
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
tempin 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
denin \(\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
¶
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
|
(\(\mathrm{erg\,g^{-1}\,s^{-1}}\)). |
with_cutoff
¶
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 |
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 |
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
¶
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 |
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
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
NeuRate
|
dividing by \(\rho\). |
plas_neu
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
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
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
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
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
brem_neu_liquid_metal
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
brem_neu
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
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
ifermi12evaluates 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.zfermim12evaluates \(F_{-1/2}(\nu) = 2\,dF_{1/2}/d\nu\) to relative accuracy \(1.23 \times 10^{-12}\).reco_neuevaluates free-bound electron capture neutrino emission over electron degeneracy parameter \(\nu \in [-20, 10]\).
ifermi12
¶
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
¶
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
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
NeuRate
|
Volumetric rate |
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 ( |
name |
str
|
Canonical MESA reaction handle (e.g. |
op_code |
int
|
Evaluator dispatch code ( |
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 ( |
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
¶
Look up the 1-based MESA reaction ID (1..=316) for name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Reaction handle string (e.g. |
required |
Returns:
| Type | Description |
|---|---|
int
|
1-based integer reaction ID ( |
reaction_name_by_id
¶
Look up the canonical MESA reaction handle for 1-based ID ir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
int
|
1-based reaction ID ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
Canonical reaction handle string. |
reaction_info
¶
Return [ReactionInfo] metadata for a 1-based reaction ID or handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
int | str
|
1-based reaction ID ( |
required |
Returns:
| Type | Description |
|---|---|
ReactionInfo
|
Populated [ |
eval_reaclib_handle
¶
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. |
required |
t9
|
float | Array
|
Temperature \(T_9\) in \(10^9\,\mathrm{K}\). |
required |
check_e_flag
|
bool
|
Whether to exempt |
True
|
backend
|
Backend
|
Execution backend ( |
'auto'
|
Returns:
| Type | Description |
|---|---|
tuple[float, float, float, float] | tuple[Array, Array, Array, Array]
|
Tuple |
tuple[float, float, float, float] | tuple[Array, Array, Array, Array]
|
Python |
tuple[float, float, float, float] | tuple[Array, Array, Array, Array]
|
arrays on |
set_raw_rate
¶
Evaluate the unscreened reaction rate set_raw_rate for reaction ir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
int | str
|
1-based reaction ID ( |
required |
temp
|
float
|
Temperature \(T\) in \(\mathrm{K}\). |
required |
log_t
|
float | None
|
Optional \(\log_{10}(T / \mathrm{K})\) matching |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Unscreened nuclear reaction rate in CGS/molar units. |
set_raw_rates
¶
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 |
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 |
set_raw_rates_zones
¶
Evaluate set_raw_rates across N_zones stellar zones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
irs
|
ArrayLike
|
1D sequence of 1-based reaction IDs |
required |
temps
|
ArrayLike
|
1D array of zone temperatures |
required |
log_ts
|
ArrayLike | None
|
Optional 1D array of \(\log_{10}(T / \mathrm{K})\) |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
2D |
eval_fl_epsnuc_3alf
¶
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
|
backend
|
Backend
|
Execution backend ( |
'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
¶
Evaluate a 1D interp_pm cubic rate table (rate, drate_dt).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ir
|
int | str
|
1-based reaction ID ( |
required |
temp
|
float
|
Temperature \(T\) in \(\mathrm{K}\). |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple |
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}}\)). |
screen_pair
¶
Evaluate plasma screening for reacting pair (a1, z1) + (a2, z2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Screening mode ( |
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'
|
Returns:
| Type | Description |
|---|---|
ScreenEval | tuple[Array, Array, Array]
|
[ |
ScreenEval | tuple[Array, Array, Array]
|
|
screen_pair_zones
¶
Evaluate plasma screening across N_zones stellar zones in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Screening mode ( |
required |
temps
|
ArrayLike
|
1D array of temperatures |
required |
dens
|
ArrayLike
|
1D array of densities |
required |
zbars
|
ArrayLike
|
1D array of mean ionic charges |
required |
abars
|
ArrayLike
|
1D array of mean atomic weights |
required |
z2bars
|
ArrayLike
|
1D array of mean square charges |
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 |
NDArray[float64]
|
|
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}\)). |
eval_coulomb
¶
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 ( |
'pcr2009'
|
which_vs
|
str
|
Electron screening shift option ( |
'itoh2002'
|
Returns:
| Type | Description |
|---|---|
float
|
Tuple |
float
|
\(\mu_{\mathrm{I}} / (k_{\mathrm{B}} T)\), |
float
|
\(|\Delta \mu_{\mathrm{I}}|\) in \(\mathrm{eV}\), and |
float
|
dimensionless screening shift \(V_s\). |
eval_weak_pair
¶
Evaluate a tabulated weak reaction rate (weaklib or Suzuki2016).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lhs_name
|
str
|
Parent nuclide name (e.g. |
required |
rhs_name
|
str
|
Daughter nuclide name (e.g. |
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 |
False
|
Returns:
| Type | Description |
|---|---|
WeakRateEval
|
Populated [ |
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. |
required |
rhs_name
|
str
|
Daughter nuclide name (e.g. |
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 ( |
'pcr2009'
|
which_vs
|
str
|
Electron screening shift option ( |
'itoh2002'
|
zbar
|
float
|
Mean ionic charge \(\bar{Z}\). |
10.909090909090908
|
abar
|
float
|
Mean atomic weight \(\bar{A}\). |
21.818181818181817
|
Returns:
| Type | Description |
|---|---|
WeakRateEval
|
Populated [ |
weak_info_by_names
¶
Look up (halflife_sec, qneu_mev) from weak_info.list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lhs_name
|
str
|
Parent nuclide name (e.g. |
required |
rhs_name
|
str
|
Daughter nuclide name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple |
eval_weak_table_index
¶
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 ( |
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 |
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
¶
Evaluate a 7-parameter REACLIB forward rate expansion in JAX (float64).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
Array
|
Array of shape |
required |
t9
|
Array
|
Temperature \(T_9 = T / 10^9\,\mathrm{K}\) ( |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
Array
|
|
eval_reaclib_terms_jax
¶
Evaluate forward and detailed-balance reverse REACLIB rates in JAX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
Array
|
|
required |
inv_exps
|
Array
|
|
required |
inv_c1s
|
Array
|
|
required |
inv_c2s
|
Array
|
|
required |
inv_parts
|
Array
|
|
required |
rflags
|
Array
|
|
required |
t9
|
Array
|
Temperature \(T_9 = T / 10^9\,\mathrm{K}\). |
required |
check_e_flag
|
Array
|
Boolean flag exempting |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array, Array, Array]
|
Tuple |
eval_fl_epsnuc_3alf_jax
¶
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
¶
Evaluate Salpeter (1954) weak plasma screening in JAX (float64).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp
|
Array
|
Temperature \(T\) in \(\mathrm{K}\) ( |
required |
den
|
Array
|
Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\). |
required |
zbar
|
Array
|
Mean ionic charge \(\bar{Z}\) ( |
required |
abar
|
Array
|
Mean atomic weight \(\bar{A}\) ( |
required |
z2bar
|
Array
|
Mean square charge \(\overline{Z^2}\) ( |
required |
z1
|
Array
|
Reactant 1 atomic number \(Z_1\). |
required |
z2
|
Array
|
Reactant 2 atomic number \(Z_2\). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
Array
|
its partial derivatives with respect to \(T\) (\(\mathrm{K}^{-1}\)) and |
Array
|
\(\rho\) (\(\mathrm{cm^3\,g^{-1}}\)). |
screen_extended_jax
¶
Evaluate Graboske/Alastuey/Itoh (fxt_screen5) plasma screening in JAX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp
|
Array
|
Temperature \(T\) in \(\mathrm{K}\) ( |
required |
den
|
Array
|
Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\). |
required |
zbar
|
Array
|
Mean ionic charge \(\bar{Z}\) ( |
required |
abar
|
Array
|
Mean atomic weight \(\bar{A}\) ( |
required |
z2bar
|
Array
|
Mean square charge \(\overline{Z^2}\) ( |
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 |
Array
|
its partial derivatives with respect to \(T\) and \(\rho\). |
screen_chugunov_jax
¶
Evaluate Chugunov, DeWitt & Yakovlev (2007) plasma screening in JAX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp
|
Array
|
Temperature \(T\) in \(\mathrm{K}\) ( |
required |
den
|
Array
|
Mass density \(\rho\) in \(\mathrm{g\,cm^{-3}}\). |
required |
zbar
|
Array
|
Mean ionic charge \(\bar{Z}\) ( |
required |
abar
|
Array
|
Mean atomic weight \(\bar{A}\) ( |
required |
z1
|
Array
|
Reactant 1 atomic number \(Z_1\). |
required |
z2
|
Array
|
Reactant 2 atomic number \(Z_2\). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
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., |
num_isos |
int
|
Number of active nuclides ( |
num_reactions |
int
|
Number of active reactions ( |
chem_id |
tuple[int, ...]
|
1-based catalog indices of the active nuclides ( |
iso_names |
tuple[str, ...]
|
Nuclide names ( |
reaction_names |
tuple[str, ...]
|
Reaction handle names ( |
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\) ( |
dxdt |
_ArrF64
|
Mass-fraction time derivatives \(dX_i / dt\)
( |
d_dxdt_drho |
_ArrF64
|
Partial derivatives
\(\partial(dX_i/dt)/\partial \rho\) ( |
d_dxdt_dt |
_ArrF64
|
Partial derivatives
\(\partial(dX_i/dt)/\partial T\) ( |
d_dxdt_dx |
_ArrF64
|
Analytical mass-fraction Jacobian
\(\partial(dX_i/dt)/\partial X_j\) ( |
eps_nuc_categories |
_ArrF64
|
Category-resolved nuclear energy rates ( |
eps_neu_total |
float
|
Neutrino energy loss rate (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)). |
rate_raw |
_ArrF64
|
Unscreened reaction rates ( |
rate_screened |
_ArrF64
|
Plasma-screened reaction rates ( |
Burn1ZoneOutput
dataclass
¶
Output of a prescribed-\((T, \rho)\) one-zone burn (burn_1_zone).
Attributes:
| Name | Type | Description |
|---|---|---|
ending_x |
_ArrF64
|
Final mass fractions ( |
eps_nuc_categories |
_ArrF64
|
Final category-resolved energy rates ( |
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 ( |
ending_log10_t |
float
|
Final \(\log_{10}(T_{\mathrm{end}} / \mathrm{K})\). |
eps_nuc_categories |
_ArrF64
|
Final category-resolved energy rates ( |
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 ( |
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. |
get_net_info
¶
Return nuclide and reaction metadata for net_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net_name
|
str
|
Built-in |
'basic.net'
|
Returns:
| Type | Description |
|---|---|
NetInfo
|
Populated |
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., |
required |
x
|
ArrayLike
|
Mass fractions ( |
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 ( |
None
|
weak_rate_factor
|
float
|
Global weak-rate multiplier. |
1.0
|
screening_mode
|
str
|
|
'extended'
|
skip_jacobian
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
NetEvalOutput
|
Populated |
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., |
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 ( |
required |
times
|
ArrayLike
|
Time knot array ( |
required |
log10_ts
|
ArrayLike
|
\(\log_{10}(T / \mathrm{K})\) at each time knot ( |
required |
log10_rhos
|
ArrayLike
|
\(\log_{10}(\rho / \mathrm{g\,cm^{-3}})\) at each knot
( |
required |
etas
|
ArrayLike | None
|
Optional electron degeneracy \(\eta\) at each time knot ( |
None
|
rate_factors
|
ArrayLike | None
|
Optional per-reaction multipliers ( |
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
|
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 |
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., |
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 ( |
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 ( |
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
|
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 |
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., |
required |
starting_temp
|
float
|
Initial temperature \(T_0\) (\(\mathrm{K}\)). |
required |
starting_x
|
ArrayLike
|
Initial mass fractions ( |
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'
|
clip
|
bool
|
Whether to clip negative abundances during integration. |
False
|
rate_factors
|
ArrayLike | None
|
Optional per-reaction multipliers ( |
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 |
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., |
required |
x
|
Array
|
Mass fractions ( |
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 |
Array
|
and |
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 fractionyesol.py_chem_ag89_zsol(() -> float): Returns the Anders & Grevesse (1989) bulk solar metallicityzsol.py_chem_category_id((name: str) -> int): Returns the 1-based reaction category ID (1..=24) or0if unknown.py_chem_category_name((id: int) -> str | None): Returns the reaction category name for 1-basedid(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)acrossnzzones (x_zonesof 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-basedchem_idfor 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)fornamein 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 forname.py_chem_m_div_h((x: float, z: float, scale: str) -> float): Computes[M/H](chem_M_div_h) for hydrogen fractionx, metallicityz, and solar scalescale.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-basedchem_id, raisingValueErrorif unknown.py_chem_reaction_qtotal((num_in: int, num_out: int, reactants: Sequence[int]) -> float): Computes the total reaction \(Q\)-value (\(\mathrm{MeV}\)) fornum_inincoming andnum_outoutgoing species.py_chem_solar_cno_fraction((scale: str) -> float): Returns the CNO mass fraction of \(Z\) forscale.py_chem_solar_element_zfrac((scale: str) -> list[float]): Returns the 112-element solar metal mass-fraction list forscale, raisingValueErrorif 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-basedchem_idsused byflexmesa.chem.composition.py_chem_xsol((name: str) -> float): Returns the Anders & Grevesse (1989) solar mass fraction forname.
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)forIonTableGrid::builtin, wherecoeffshas 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]acrossn_zoneszones, dispatching to the 4-threadrayonworker pool whenparallel=Trueandn_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 28eval_ionizationchannels for a single zone from either linear orlog10inputs.py_ion_eval_ionization_dual((z: float, x: float, log10_rho: float, log10_t: float) -> tuple[_ArrF64, _ArrF64]): Evaluates all 28eval_ionizationchannels and their \(28 \times 4\) Jacobian with respect to(z, x, log10_rho, log10_t)viaDualOrder1<4>.py_ion_eval_ionization_zones((z: _ArrF64, x: _ArrF64, log10_rho: _ArrF64, log10_t: _ArrF64, parallel: bool = False) -> _ArrF64): Evaluates all 28eval_ionizationchannels acrossn_zoneszones, dispatching to the 4-threadrayonworker pool whenparallel=Trueandn_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 nuclidecid(\(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(coeffsshape(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 28eval_ionizationoutput 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): Evaluatesneu_getacross 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-threadrayonpool whenparallel=Trueandnz >= 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): Evaluatesneu_getacross 1D arrays(log10_t, log10_rho, abar, zbar)of shape(nz,), returning a(nz, 30)array packingloss[0..5]followed by Fortran column-majorsources(d_idxouter0..5,channelinner0..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 coefficientinverse_coefficients(1)from nuclear massesw(\(\mathrm{AMU}\)) and ground-state spinsspin.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 aninterp_pm1D cubic rate table(rate, drate_dt)for reaction IDir.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 acrossn_zoneszones, 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 (weakliborSuzuki2016), returning a 9-element list.rates_eval_weak_table_index((idx: int, t9: float, l_ye_rho: float) -> tuple[str, str, list[float]]): Evaluates theidx-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 IDir.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 acrossn_zones, returning an(n_zones, 3)array.rates_set_raw_rate((ir: int, temp: float, log_t: float | None = None) -> float): Evaluatesset_raw_ratefor a single 1-based reaction IDir(1..=316).rates_set_raw_rates((irs: npt.NDArray[np.uintp], temp: float, log_t: float | None = None) -> _ArrF64): Evaluatesset_raw_ratesfor a 1D array of 1-based reaction IDsirs.rates_set_raw_rates_zones((irs: npt.NDArray[np.uintp], temps: _ArrF64, log_ts: _ArrF64 | None = None) -> _ArrF64): Evaluatesset_raw_ratesacrossn_zonestemperatures, 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)fromweak_info.listby 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]): Evaluatesnet_getat 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): Evaluateseval_net_with_workacrossn_zoneszones, 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.netnuclear network definition filenames.