Skip to content

Opacity, Atmospheres & Photometry (kap, atm, colors)

This reference page covers the radiative and conductive opacity subpackage (flexmesa.kap), the surface boundary condition and model atmosphere subpackage (flexmesa.atm), and the synthetic spectral energy distribution and filter photometry subpackage (flexmesa.colors).

For physical derivations and diagnostic plots, see Opacity, Atmospheres & Photometry.


Quick Usage Example

import numpy as np
import flexmesa.atm as atm
import flexmesa.colors as colors
import flexmesa.kap as kap
from flexmesa import constants

# 1. Total Rosseland mean opacity (radiative + electron conduction)
k_res = kap.kap_get_results(
    z=0.02,
    x=0.70,
    zbase=0.02,
    log_rho=-5.0,
    log_t=5.0,
    lnfree_e=20.0,
    zbar=1.10,
)

# 2. Tabulated photospheric surface boundary (P_surf, T_surf)
a_res = atm.eval_table(
    luminosity=constants.LSUN,
    r=constants.RSUN,
    m=constants.MSUN,
    cgrav=constants.STANDARD_CGRAV,
    table_id=atm.ATM_TABLE_PHOTOSPHERE,
    z=0.02,
    skip_partials=False,
    teff=5777.0,
)

# 3. Synthetic Johnson-Cousins colors at Teff = 5777 K, log g = 4.44, [M/H] = 0.0
phot = colors.eval_colors(
    teff=5777.0, log_g=4.44, metallicity=0.0, r=constants.RSUN
)
print(
    f"kappa={k_res.kap:.4f} cm^2/g, T_surf={np.exp(a_res.ln_t):.1f} K, "
    f"M_bol={float(phot[0]):.3f} mag"
)

Radiative, Conductive & Compton Opacities (flexmesa.kap)

flexmesa.kap combines low-temperature molecular (Ferguson/AESOPUS/kapCN) and high-temperature atomic (OPAL Type 1/Type 2 and Opacity Project) Rosseland mean radiative opacities \(\kappa_{\mathrm{rad}}(\log_{10} R, \log_{10} T, X, Z)\) with Poutanen (2017) relativistic Compton scattering and Cassisi et al. (2007) / Blouin et al. (2020) degenerate electron thermal conduction \(\kappa_{\mathrm{cond}}\) via harmonic blending \(\kappa^{-1} = \kappa_{\mathrm{rad}}^{-1} + \kappa_{\mathrm{cond}}^{-1}\). Matching MESA 26.4.1 kap.defaults and kap_eval.f90 (#149, #161), kap_get_results and kap_get_results_jax default to use_type2_opacities=True, use_zbase_for_type1=True, use_blouin_conductive_opacities=True, kap_co_option="gs98_co", and kap_type2_full_off_x=1.0e-3 / kap_type2_full_on_x=1.0e-6, derive Compton and low-\(T\)/high-\(T\) blend boundaries dynamically from the loaded table headers (7.99 on OP_a09 vs. 8.69 on gs98/a09/OP_gs98), and require an explicit zbase >= 0.0 whenever Type 2, kapCN, or AESOPUS opacities are active.

flexmesa.kap.core

Radiative, conductive, and Compton opacity (kap) kernels for FlexMESA.

Ports upstream Fortran MESA's kap module (kap_def.f90, kap_lib.f90, kap_eval.f90, kap_eval_fixed.f90, kap_eval_co.f90, condint.f90, kap_aesopus.f90, and kapcn.f90) with Safe Rust execution via flexmesa._rust and native @jax.jit / jax.custom_jvp differentiable kernels.

KapEvalOutput dataclass

Single-zone opacity evaluation output (kap_get / Get_kap_Results).

Attributes:

Name Type Description
kap float

Total Rosseland mean opacity in cm^2 g^-1.

log10_kap float

Base-10 logarithm of total opacity log10(kap / cm^2 g^-1).

dlnkap_dln_rho float

Partial derivative (d ln kap / d ln rho)_T.

dlnkap_dln_t float

Partial derivative (d ln kap / d ln T)_rho.

kap_fracs ndarray

4-element float64 array [frac_lowT, frac_highT, frac_Type2, frac_Compton].

kap_get_results

kap_get_results(
    z,
    x,
    zbase,
    xc=0.0,
    xn=0.0,
    xo=0.0,
    xne=0.0,
    log_rho=0.0,
    log_t=6.0,
    lnfree_e=0.0,
    d_lnfree_e_dln_rho=0.0,
    d_lnfree_e_dln_t=0.0,
    eta=0.0,
    d_eta_dln_rho=0.0,
    d_eta_dln_t=0.0,
    zbar=1.0,
    *,
    kap_option="gs98",
    kap_co_option="gs98_co",
    kap_low_t_option="lowT_fa05_gs98",
    kap_blend_log_t_upper_bdy=3.88,
    kap_blend_log_t_lower_bdy=3.8,
    cubic_interpolation_in_x=False,
    cubic_interpolation_in_z=False,
    include_electron_conduction=True,
    use_blouin_conductive_opacities=True,
    use_zbase_for_type1=True,
    use_type2_opacities=True,
    kap_type2_full_off_x=0.001,
    kap_type2_full_on_x=1e-06,
    kap_type2_full_off_dz=0.001,
    kap_type2_full_on_dz=0.01,
    backend="auto",
)

Evaluate single-zone radiative + conductive + Compton opacity.

Mirrors Get_kap_Results in kap/private/kap_eval.f90.

Parameters:

Name Type Description Default
z float | Array

Total metal mass fraction Z.

required
x float | Array

Hydrogen mass fraction X.

required
zbase float | Array

Base metallicity Zbase.

required
xc float | Array

Carbon mass fraction XC.

0.0
xn float | Array

Nitrogen mass fraction XN.

0.0
xo float | Array

Oxygen mass fraction XO.

0.0
xne float | Array

Neon mass fraction XNe.

0.0
log_rho float | Array

Base-10 log mass density log10(rho / g cm^-3).

0.0
log_t float | Array

Base-10 log temperature log10(T / K).

6.0
lnfree_e float | Array

Natural log of free electrons per nucleon.

0.0
d_lnfree_e_dln_rho float | Array

Partial (d ln free_e / d ln rho)_T.

0.0
d_lnfree_e_dln_t float | Array

Partial (d ln free_e / d ln T)_rho.

0.0
eta float | Array

Electron degeneracy parameter.

0.0
d_eta_dln_rho float | Array

Partial (d eta / d ln rho)_T.

0.0
d_eta_dln_t float | Array

Partial (d eta / d ln T)_rho.

0.0
zbar float | Array

Mean ionic charge Zbar.

1.0
kap_option str

High-T Type 1 table prefix ("gs98", "a09", etc.).

'gs98'
kap_co_option str

High-T Type 2 table prefix ("gn93_co", "gs98_co", "a09_co").

'gs98_co'
kap_low_t_option str

Low-T table prefix ("lowT_fa05_gs98", "AESOPUS", "kapCN").

'lowT_fa05_gs98'
kap_blend_log_t_upper_bdy float

Upper log10(T/K) for low-T/high-T blend.

3.88
kap_blend_log_t_lower_bdy float

Lower log10(T/K) for low-T/high-T blend.

3.8
cubic_interpolation_in_x bool

Use cubic interpolation in X.

False
cubic_interpolation_in_z bool

Use cubic interpolation in Z.

False
include_electron_conduction bool

Include electron thermal conduction.

True
use_blouin_conductive_opacities bool

Use Blouin et al. (2020) H/He conduction.

True
use_zbase_for_type1 bool

Use min(Z, Zbase) for Type 1 when Type 2 active.

True
use_type2_opacities bool

Enable Type 2 C/O-enhanced tables.

True
kap_type2_full_off_x float

X threshold above which Type 2 is off.

0.001
kap_type2_full_on_x float

X threshold below which Type 2 is fully on.

1e-06
kap_type2_full_off_dz float

Z - Zbase threshold below which Type 2 is off.

0.001
kap_type2_full_on_dz float

Z - Zbase threshold above which Type 2 is on.

0.01
backend Backend

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

'auto'

Returns:

Type Description
KapEvalOutput

[KapEvalOutput] containing kap, log10_kap, dlnkap_dln_rho,

KapEvalOutput

dlnkap_dln_t, and kap_fracs.

kap_get

kap_get(
    chem_id,
    xa,
    log_rho,
    log_t,
    lnfree_e=0.0,
    d_lnfree_e_dln_rho=0.0,
    d_lnfree_e_dln_t=0.0,
    eta=0.0,
    d_eta_dln_rho=0.0,
    d_eta_dln_t=0.0,
    zbase=-1.0,
    **kwargs,
)

Evaluate kap_get from 1-based chem_id and mass-fraction vector xa.

Parameters:

Name Type Description Default
chem_id ndarray

1-based nuclide indices, shape (N_spec,).

required
xa ndarray

Mass fractions, shape (N_spec,).

required
log_rho float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t float

Base-10 log temperature log10(T / K).

required
lnfree_e float

Natural log of free electrons per nucleon.

0.0
d_lnfree_e_dln_rho float

Partial (d ln free_e / d ln rho)_T.

0.0
d_lnfree_e_dln_t float

Partial (d ln free_e / d ln T)_rho.

0.0
eta float

Electron degeneracy parameter.

0.0
d_eta_dln_rho float

Partial (d eta / d ln rho)_T.

0.0
d_eta_dln_t float

Partial (d eta / d ln T)_rho.

0.0
zbase float

Base metallicity Zbase.

-1.0
**kwargs Any

Optional KapConfig overrides.

{}

Returns:

Type Description
KapEvalOutput

[KapEvalOutput] for the given isotopic composition and state.

kap_get_zones

kap_get_zones(
    chem_id,
    xa_zones,
    log_rho_zones,
    log_t_zones,
    lnfree_e_zones,
    d_lnfree_e_dln_rho_zones,
    d_lnfree_e_dln_t_zones,
    eta_zones,
    d_eta_dln_rho_zones,
    d_eta_dln_t_zones,
    zbase=-1.0,
    *,
    parallel=True,
    **kwargs,
)

Evaluate kap_get across N_zones zones in parallel.

Parameters:

Name Type Description Default
chem_id ndarray

1-based nuclide indices, shape (N_spec,).

required
xa_zones ndarray

Zone mass fractions, shape (N_zones, N_spec).

required
log_rho_zones ndarray

Zone log10(rho / g cm^-3), shape (N_zones,).

required
log_t_zones ndarray

Zone log10(T / K), shape (N_zones,).

required
lnfree_e_zones ndarray

Zone ln(free_e), shape (N_zones,).

required
d_lnfree_e_dln_rho_zones ndarray

Zone (d ln free_e / d ln rho)_T, shape (N_zones,).

required
d_lnfree_e_dln_t_zones ndarray

Zone (d ln free_e / d ln T)_rho, shape (N_zones,).

required
eta_zones ndarray

Zone electron degeneracy parameter, shape (N_zones,).

required
d_eta_dln_rho_zones ndarray

Zone (d eta / d ln rho)_T, shape (N_zones,).

required
d_eta_dln_t_zones ndarray

Zone (d eta / d ln T)_rho, shape (N_zones,).

required
zbase float

Base metallicity Zbase.

-1.0
parallel bool

Dispatch across the persistent 4-thread worker pool.

True
**kwargs Any

Optional KapConfig overrides.

{}

Returns:

Type Description
ndarray

Array of shape (N_zones, 7) with columns `[kap, dlnkap_dlnRho,

ndarray

dlnkap_dlnT, frac_lowT, frac_highT, frac_Type2, frac_Compton]`.

flexmesa.kap.submodels

Sub-model opacity evaluation wrappers (flexmesa.kap.submodels).

Exposes direct access to Type 1 fixed-metal tables (kap_get_fixed_metal), Type 2 C/O-enhanced tables (kap_get_co), Marigo & Aringer (2009) AESOPUS low-temperature molecular tables (kap_get_aesopus), Lederer & Aringer (2009) kapCN C/N-varying molecular tables (kap_get_kapcn), Potekhin/Blouin electron thermal conduction (kap_get_elect_cond_opacity), and Poutanen (2017) relativistic/degenerate Compton scattering (kap_get_compton_opacity).

kap_get_elect_cond_opacity

kap_get_elect_cond_opacity(
    zbar, log_rho, log_t, *, use_blouin=True, backend="auto"
)

Evaluate Potekhin / Blouin electron thermal conduction opacity.

Parameters:

Name Type Description Default
zbar Array | float

Mean ionic charge Zbar.

required
log_rho Array | float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t Array | float

Base-10 log temperature log10(T / K).

required
use_blouin bool

Apply Blouin et al. (2020) H/He moderate-coupling correction.

True
backend Backend

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

'auto'

Returns:

Type Description
Array | float

Tuple (kap, dlnkap_dln_rho, dlnkap_dln_t) where kap has units

Array | float

cm^2 g^-1.

kap_get_compton_opacity

kap_get_compton_opacity(
    rho,
    t,
    lnfree_e,
    d_lnfree_e_dln_rho,
    d_lnfree_e_dln_t,
    eta,
    d_eta_dln_rho,
    d_eta_dln_t,
    *,
    backend="auto",
)

Evaluate Poutanen (2017) relativistic/degenerate Compton opacity.

Parameters:

Name Type Description Default
rho Array | float

Mass density in g cm^-3, shape (*batch,).

required
t Array | float

Temperature in K, shape (*batch,).

required
lnfree_e Array | float

Natural log of free electrons per nucleon, shape (*batch,).

required
d_lnfree_e_dln_rho Array | float

Partial (d ln free_e / d ln rho)_T.

required
d_lnfree_e_dln_t Array | float

Partial (d ln free_e / d ln T)_rho.

required
eta Array | float

Electron degeneracy parameter.

required
d_eta_dln_rho Array | float

Partial (d eta / d ln rho)_T.

required
d_eta_dln_t Array | float

Partial (d eta / d ln T)_rho.

required
backend Backend

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

'auto'

Returns:

Type Description
Array | float

Tuple (kap, dlnkap_dln_rho, dlnkap_dln_t). Returns jax.Array

Array | float

outputs when any input is a jax.Array or backend="jax" under

Array | float

JAX tracing, and Python float scalars otherwise.

kap_get_fixed_metal

kap_get_fixed_metal(
    z,
    x,
    log_rho,
    log_t,
    *,
    prefix="gs98",
    cubic_x=False,
    cubic_z=False,
    backend="auto",
)

Evaluate Type 1 fixed-metal opacity.

Parameters:

Name Type Description Default
z Array | float

Total metal mass fraction Z.

required
x Array | float

Hydrogen mass fraction X.

required
log_rho Array | float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t Array | float

Base-10 log temperature log10(T / K).

required
prefix str

Fixed-metal table prefix ("gs98", "a09", etc.).

'gs98'
cubic_x bool

Use cubic interpolation in X.

False
cubic_z bool

Use cubic interpolation in Z.

False
backend Backend

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

'auto'

Returns:

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

Tuple (log10_kap, dlnkap_dln_rho, dlnkap_dln_t).

kap_get_co

kap_get_co(
    zbase,
    x,
    dxc,
    dxo,
    log_rho,
    log_t,
    *,
    kap_co_option="gn93_co",
    cubic_x=False,
    cubic_z=False,
    backend="auto",
)

Evaluate Type 2 C/O-enhanced opacity.

Parameters:

Name Type Description Default
zbase Array | float

Base metallicity Zbase.

required
x Array | float

Hydrogen mass fraction X.

required
dxc Array | float

Carbon enhancement dXC.

required
dxo Array | float

Oxygen enhancement dXO.

required
log_rho Array | float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t Array | float

Base-10 log temperature log10(T / K).

required
kap_co_option str

Type 2 table prefix ("gn93_co", "gs98_co", "a09_co").

'gn93_co'
cubic_x bool

Use cubic interpolation in X.

False
cubic_z bool

Use cubic interpolation in Z.

False
backend Backend

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

'auto'

Returns:

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

Tuple (log10_kap, dlnkap_dln_rho, dlnkap_dln_t).

kap_get_aesopus

kap_get_aesopus(
    zbase, x, xc, xn, xo, log_rho, log_t, *, backend="auto"
)

Evaluate Marigo & Aringer (2009) AESOPUS_AGSS09 low-T opacity.

Parameters:

Name Type Description Default
zbase Array | float

Reference metallicity Zref.

required
x Array | float

Hydrogen mass fraction X.

required
xc Array | float

Carbon mass fraction XC.

required
xn Array | float

Nitrogen mass fraction XN.

required
xo Array | float

Oxygen mass fraction XO.

required
log_rho Array | float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t Array | float

Base-10 log temperature log10(T / K).

required
backend Backend

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

'auto'

Returns:

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

Tuple (kap, dlnkap_dln_rho, dlnkap_dln_t).

kap_get_kapcn

kap_get_kapcn(
    zbase, x, fc, fn_val, log_rho, log_t, *, backend="auto"
)

Evaluate Lederer & Aringer (2009) kapCN low-T opacity.

Parameters:

Name Type Description Default
zbase Array | float

Base metallicity Zbase.

required
x Array | float

Hydrogen mass fraction X.

required
fc Array | float

Dimensionless carbon enhancement factor fC = (X_C / Z) / (X_C / Z)_solar.

required
fn_val Array | float

Dimensionless nitrogen enhancement factor fN = (X_N / Z) / (X_N / Z)_solar.

required
log_rho Array | float

Base-10 log mass density log10(rho / g cm^-3).

required
log_t Array | float

Base-10 log temperature log10(T / K).

required
backend Backend

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

'auto'

Returns:

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

Tuple (kap, dlnkap_dln_rho, dlnkap_dln_t).

flexmesa.kap.jax_kernels

Native @jax.jit (float64) opacity kernels for flexmesa.kap.

Implements Poutanen (2017) relativistic/degenerate Compton scattering, Potekhin (1999) / Cassisi et al. (2007) + Blouin et al. (2020) electron thermal conduction (condtabl.data bicubic spline), low-T/high-T/Type-2/Compton regime blending (kap_eval.f90), and make_differentiable_kap in pure JAX with zero host callbacks.

compton_opacity_jax

compton_opacity_jax(
    rho,
    t,
    lnfree_e,
    d_lnfree_e_dln_rho,
    d_lnfree_e_dln_t,
    eta,
    d_eta_dln_rho,
    d_eta_dln_t,
)

Evaluate Poutanen (2017) relativistic/degenerate Compton opacity.

combine_rad_with_conduction_jax

combine_rad_with_conduction_jax(
    kap_rad,
    dlnkap_rad_dln_rho,
    dlnkap_rad_dln_t,
    kap_cond,
    dlnkap_cond_dln_rho,
    dlnkap_cond_dln_t,
)

Harmonic combination of radiative and conductive opacities in JAX.

electron_conduction_potekhin_jax

electron_conduction_potekhin_jax(
    zbar, log_rho_in, log_t_in
)

Evaluate Potekhin (condtabl.data) electron conduction opacity.

electron_conduction_jax

electron_conduction_jax(
    zbar, log_rho, log_t, *, use_blouin=True
)

Evaluate Potekhin / Blouin electron thermal conduction opacity in JAX.

kap_get_results_jax

kap_get_results_jax(
    z,
    x,
    zbase,
    xc=0.0,
    xn=0.0,
    xo=0.0,
    xne=0.0,
    log_rho=0.0,
    log_t=6.0,
    lnfree_e=0.0,
    d_lnfree_e_dln_rho=0.0,
    d_lnfree_e_dln_t=0.0,
    eta=0.0,
    d_eta_dln_rho=0.0,
    d_eta_dln_t=0.0,
    zbar=1.0,
    *,
    kap_option="gs98",
    kap_co_option="gs98_co",
    kap_low_t_option="lowT_fa05_gs98",
    kap_blend_log_t_upper_bdy=3.88,
    kap_blend_log_t_lower_bdy=3.8,
    cubic_interpolation_in_x=False,
    cubic_interpolation_in_z=False,
    include_electron_conduction=True,
    use_blouin_conductive_opacities=True,
    use_zbase_for_type1=True,
    use_type2_opacities=True,
    kap_type2_full_off_x=0.001,
    kap_type2_full_on_x=1e-06,
    kap_type2_full_off_dz=0.001,
    kap_type2_full_on_dz=0.01,
)

Evaluate Get_kap_Results in native JAX.

make_differentiable_kap

make_differentiable_kap(
    z,
    x,
    zbase,
    xc=0.0,
    xn=0.0,
    xo=0.0,
    xne=0.0,
    lnfree_e=0.0,
    d_lnfree_e_dln_rho=0.0,
    d_lnfree_e_dln_t=0.0,
    eta=0.0,
    d_eta_dln_rho=0.0,
    d_eta_dln_t=0.0,
    zbar=1.0,
    **kwargs,
)

Create a pure @jax.jit / jax.custom_jvp callable.

flexmesa.kap.jax_interp

Pure @jax.jit opacity table interpolators (flexmesa.kap.jax_interp).

Implements 2D PSPLINE bicubic evaluation (do_kap_interpolations, interp_evbicub_prevalidated_db), 1D Steffen (1990) piecewise-monotonic cubic interpolation (interp_pm), Type 1 fixed-metal (kap_eval_fixed.f90), Type 2 C/O-enhanced (kap_eval_co.f90), AESOPUS (kap_aesopus.f90), and kapCN (kapcn.f90) kernels in float64 JAX.

do_kap_interpolations_jax

do_kap_interpolations_jax(
    fin, i, j, x0, xget, x1, y0, yget, y1
)

Evaluate PSPLINE bicubic cell (i, j) and partials.

interp_evbicub_jax

interp_evbicub_jax(xget, yget, x, y, coeffs)

Evaluate interp_evbicub_prevalidated_db at (xget, yget) in JAX.

interp_pm_1d_jax

interp_pm_1d_jax(x_old, y_old, x_new)

Evaluate 1D Steffen (1990) piecewise-monotonic cubic at x_new.

interp_pm_4pt_with_partials_jax

interp_pm_4pt_with_partials_jax(
    x_old, v_old, dr_old, dt_old, x_new
)

Evaluate 4-point Steffen cubic and propagate (dr, dt) tangents.

eval_fixed_metal_jax

eval_fixed_metal_jax(
    z,
    x,
    log_rho,
    log_t,
    *,
    prefix="gs98",
    cubic_x=False,
    cubic_z=False,
)

Evaluate Type 1 fixed-metal or Ferguson/Freedman low-T table in JAX.

flexmesa.kap.jax_co_lowt

Pure @jax.jit evaluators for Type 2 CO, AESOPUS, and kapCN tables.

eval_co_kap_jax

eval_co_kap_jax(
    zbase,
    x,
    dxc,
    dxo,
    log_rho,
    log_t,
    *,
    kap_co_option="gn93_co",
    cubic_x=False,
    cubic_z=False,
)

Evaluate Type 2 C/O-enhanced opacity in JAX.

eval_aesopus_jax

eval_aesopus_jax(zref, x, xc, xn, xo, log_rho, log_t)

Evaluate Marigo & Aringer (2009) AESOPUS_AGSS09 in JAX.

eval_kapcn_jax

eval_kapcn_jax(z, x, fc, fn_val, log_rho, log_t)

Evaluate Lederer & Aringer (2009) kapCN in JAX.

flexmesa.kap.tables_jax

On-demand binary opacity table loader and bicubic spline cache for JAX.

Reads the immutable FMKAP001 binary payload from $FLEXMESA_DATA_DIR/kap_full/kap_tables_full.bin (installed by flexmesa data fetch without invoking any runtime table builder) and fits 2D PSPLINE bicubic spline coefficients [f, f_xx, f_yy, f_xxyy] on demand for native @jax.jit evaluation.

splinck

splinck(x, ztol=0.001)

Check whether 1D grid x is uniformly spaced within ztol.

fit_bicubic_batch

fit_bicubic_batch(log_rs, log_ts, raw_lt_lr, bc=0)

Fit 2D PSPLINE [f, f_xx, f_yy, f_xxyy] on (B, ny, nx) tables.

reset_index_cache

reset_index_cache()

Release FMKAP001 mmap handles and clear parsed index caches.

ensure_indexed

ensure_indexed()

Index and validate byte offsets across FMKAP001 once.

get_kap_blend_bounds_jax

get_kap_blend_bounds_jax(
    kap_option,
    kap_co_option,
    kap_low_t_option,
    *,
    use_type2_opacities,
)

Return (high_t_min, low_t_max, log_t_compton_hi, log_r_compton_lo).

get_fixed_set_jax

get_fixed_set_jax(prefix)

Load and spline-fit a fixed-metal or low-T table set for JAX.

get_potekhin_jax

get_potekhin_jax()

Parse and spline-fit condtabl.data with ZeroFirstDeriv (bc=3).

flexmesa.kap.tables_co_lowt_jax

Type 2 CO, AESOPUS, and kapCN table loaders and spline caches for JAX.

get_co_meta_jax

get_co_meta_jax(prefix)

Load Type 2 CO metadata (zbase, xs, co_table_numbers, etc.).

get_co_z_coeffs_jax

get_co_z_coeffs_jax(prefix, iz)

Fit and cache (nx=5, 60, nlr, nlt, 4) CO splines for (prefix, iz).

get_co_all_z_coeffs_jax

get_co_all_z_coeffs_jax(prefix)

Return (8, 5, 60, 37, 138, 4) CO spline array for prefix.

get_aesopus_meta_jax

get_aesopus_meta_jax()

Return AESOPUS_AGSS09 metadata.

get_aesopus_z_coeffs_jax

get_aesopus_z_coeffs_jax(iz)

Fit and cache (total_slices, nlr, nlt, 4) AESOPUS splines for iz.

get_aesopus_all_z_coeffs_jax

get_aesopus_all_z_coeffs_jax()

Return (13, 1125, 19, 42, 4) AESOPUS spline array across all Z.

get_kapcn_jax

get_kapcn_jax()

Fit and cache all (14, 63, 17, 18, 4) kapCN splines.


Model Atmospheres & Outer Boundary Conditions (flexmesa.atm)

flexmesa.atm evaluates outer photospheric boundary conditions \((\ln P_{\mathrm{surf}}, \ln T_{\mathrm{surf}})\) and their exact \((L, \ln R, \ln M, \ln \kappa)\) partial derivatives using grey \(T(\tau)\) relations (Eddington, solar_Hopf, Krishna_Swamy, Trampedach_solar via get_t_tau_id and eval_t_tau_atm across 'fixed', 'iterated', and 'varying' opacity modes with pextra_factor), Guillot (2010) irradiated planetary atmospheres (eval_irradiated), adaptive Dormand-Prince 5(4) (dopri5) optical-depth integration (eval_t_tau_varying), and pre-validated 2D bicubic spline atmosphere tables (photosphere, tau_100, tau_10, tau_1, tau_1m1, WD_tau_25, DB_WD_tau_25 via get_table_id, eval_table, and off-table 'T_tau' boundary blending in eval_table_atm using get_table_alfa_beta).

flexmesa.atm._core

Surface boundary conditions and model atmosphere evaluators (atm).

AtmEvalOutput dataclass

Surface boundary condition evaluation output (AtmEvalOutput).

Attributes:

Name Type Description
ln_t float

Natural logarithm of surface temperature \(\ln(T / \mathrm{K})\).

dln_t_dl float

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

dln_t_dln_r float

Partial derivative \(\partial \ln T / \partial \ln R\).

dln_t_dln_m float

Partial derivative \(\partial \ln T / \partial \ln M\).

dln_t_dln_kap float

Partial derivative \(\partial \ln T / \partial \ln \kappa\).

ln_p float

Natural logarithm of surface pressure \(\ln(P / \mathrm{dyn\,cm^{-2}})\).

dln_p_dl float

Partial derivative \(\partial \ln P / \partial L\) (\(\mathrm{erg^{-1}\,s}\)).

dln_p_dln_r float

Partial derivative \(\partial \ln P / \partial \ln R\).

dln_p_dln_m float

Partial derivative \(\partial \ln P / \partial \ln M\).

dln_p_dln_kap float

Partial derivative \(\partial \ln P / \partial \ln \kappa\).

kap float

Converged surface opacity \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

AtmIrradiatedOutput dataclass

Irradiated grey atmosphere evaluation output (AtmIrradiatedOutput).

Attributes:

Name Type Description
kap float

Converged thermal opacity \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

tau float

Surface optical depth \(\tau = P_{\mathrm{surf}}\,\kappa / g\).

ln_t float

Natural logarithm of surface temperature \(\ln(T / \mathrm{K})\).

dln_t_dl float

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

dln_t_dln_r float

Partial derivative \(\partial \ln T / \partial \ln R\).

dln_t_dln_m float

Partial derivative \(\partial \ln T / \partial \ln M\).

dln_t_dln_kap float

Partial derivative \(\partial \ln T / \partial \ln \kappa\).

eval_t_tau

eval_t_tau(t_tau_id, tau, teff)

Evaluate \(\ln T(\tau, T_{\mathrm{eff}})\) for a \(T(\tau)\) relation.

Parameters:

Name Type Description Default
t_tau_id int

\(T(\tau)\) relation identifier (1..4).

required
tau float

Optical depth \(\tau\) (dimensionless).

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required

Returns:

Type Description
float

Natural logarithm of temperature \(\ln(T / \mathrm{K})\).

eval_t_tau_dq_dtau

eval_t_tau_dq_dtau(t_tau_id, tau)

Evaluate Hopf-function derivative \(dq/d\tau\) at optical depth \(\tau\).

Parameters:

Name Type Description Default
t_tau_id int

\(T(\tau)\) relation identifier (1..4).

required
tau float

Optical depth \(\tau\) (dimensionless).

required

Returns:

Type Description
float

Derivative \(dq/d\tau\) (dimensionless).

get_t_tau_base

get_t_tau_base(t_tau_id)

Return base optical depth \(\tau_{\mathrm{base}}\) of a \(T(\tau)\) law.

Parameters:

Name Type Description Default
t_tau_id int

\(T(\tau)\) relation identifier (1..4).

required

Returns:

Type Description
float

Base optical depth \(\tau_{\mathrm{base}}\) (dimensionless).

get_t_tau_id

get_t_tau_id(name)

Map an atm_T_tau_relation string to its integer relation identifier.

Parameters:

Name Type Description Default
name str

Upstream \(T(\tau)\) relation name ('Eddington', 'solar_Hopf', 'Krishna_Swamy', or 'Trampedach_solar').

required

Returns:

Type Description
int

Integer \(T(\tau)\) relation identifier (1..4).

get_table_id

get_table_id(name)

Map an atm_table string to its integer table identifier.

Parameters:

Name Type Description Default
name str

Upstream atmosphere table name ('tau_100', 'tau_10', 'tau_1', 'tau_1m1', 'photosphere', 'WD_tau_25', or 'DB_WD_tau_25').

required

Returns:

Type Description
int

Integer atmosphere table identifier (100..106).

eval_e2

eval_e2(x)

Evaluate the second exponential integral \((E_2(x), dE_2/dx)\).

Parameters:

Name Type Description Default
x float

Non-negative optical-depth argument \(x \in [0, 10]\).

required

Returns:

Type Description
tuple[float, float]

Tuple (e2, de2_dx).

eval_paczynski_gradr

eval_paczynski_gradr(
    t, p, rho, tau, kap, luminosity, m, r, cgrav
)

Evaluate the Paczynski (1969) diluted radiative temperature gradient.

Parameters:

Name Type Description Default
t float

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

required
p float

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

required
rho float

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

required
tau float

Optical depth \(\tau\) (dimensionless).

required
kap float

Rosseland mean opacity \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
luminosity float

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

required
m float

Enclosed mass \(M\) (\(\mathrm{g}\)).

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required

Returns:

Type Description
float

Diluted radiative gradient \(\nabla_{\mathrm{rad}}\) (dimensionless).

eval_table

eval_table(
    luminosity,
    r,
    m,
    cgrav,
    table_id,
    z,
    skip_partials,
    teff,
)

Evaluate surface \((\ln T, \ln P)\) from a tabulated model atmosphere.

Parameters:

Name Type Description Default
luminosity float

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

required
r float

Photospheric radius \(R\) (\(\mathrm{cm}\)).

required
m float

Stellar mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
table_id int

Atmosphere table identifier (100..106).

required
z float

Metallicity mass fraction \(Z\).

required
skip_partials bool

If True, skip partial derivative calculation.

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required

Returns:

Type Description
AtmEvalOutput

Populated AtmEvalOutput dataclass.

get_table_alfa_beta

get_table_alfa_beta(
    luminosity, teff, r, m, cgrav, table_id
)

Evaluate blending weights \((\alpha, \beta)\) near table boundaries.

Parameters:

Name Type Description Default
luminosity float

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

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
table_id int

Atmosphere table identifier (100..106).

required

Returns:

Type Description
float

Tuple (alfa, beta) where alfa weights grey \(T(\tau)\) and beta

float

weights the atmosphere table.

get_table_base

get_table_base(table_id)

Return base optical depth \(\tau_{\mathrm{base}}\) of a table.

Parameters:

Name Type Description Default
table_id int

Atmosphere table identifier (100..106).

required

Returns:

Type Description
float

Base optical depth \(\tau_{\mathrm{base}}\) (dimensionless).

eval_t_tau_uniform

eval_t_tau_uniform(
    tau_surf,
    luminosity,
    r,
    m,
    cgrav,
    kap_guess,
    pextra_factor,
    t_tau_id,
    errtol,
    max_iters,
    skip_partials,
    teff,
    chem_id=None,
    xa=None,
    zbase=0.02,
    low_t_option="low_t_fa05_gs98",
)

Evaluate a grey \(T(\tau)\) atmosphere with uniform opacity.

Parameters:

Name Type Description Default
tau_surf float

Surface optical depth \(\tau_{\mathrm{surf}}\).

required
luminosity float

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

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
kap_guess float

Initial opacity guess \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
pextra_factor float

Radiation pressure enhancement factor.

required
t_tau_id int

\(T(\tau)\) relation identifier (1..4).

required
errtol float

Relative convergence tolerance on \(\kappa\).

required
max_iters int

Maximum opacity fixed-point iterations (0 for fixed).

required
skip_partials bool

If True, skip partial derivatives.

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required
chem_id Sequence[int] | None

Optional species catalog IDs ([S]).

None
xa ArrayLike | None

Optional species mass fractions ((S,)).

None
zbase float

Base metallicity \(Z_{\mathrm{base}}\) for kap.

0.02
low_t_option str

Low-temperature opacity table selection.

'low_t_fa05_gs98'

Returns:

Type Description
AtmEvalOutput

Populated AtmEvalOutput dataclass.

eval_t_tau_varying

eval_t_tau_varying(
    tau_surf,
    luminosity,
    r,
    m,
    cgrav,
    t_tau_id,
    errtol,
    max_steps,
    skip_partials,
    teff,
    chem_id,
    xa,
    zbase=0.02,
    low_t_option="low_t_fa05_gs98",
)

Evaluate a \(T(\tau)\) atmosphere integrating depth-varying opacity.

Parameters:

Name Type Description Default
tau_surf float

Surface optical depth \(\tau_{\mathrm{surf}}\).

required
luminosity float

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

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
t_tau_id int

\(T(\tau)\) relation identifier (1..4).

required
errtol float

Relative tolerance for dopri5 integration.

required
max_steps int

Maximum dopri5 steps.

required
skip_partials bool

If True, skip partial derivatives.

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required
chem_id Sequence[int]

Species catalog IDs ([S]).

required
xa ArrayLike

Species mass fractions ((S,)).

required
zbase float

Base metallicity \(Z_{\mathrm{base}}\) for kap.

0.02
low_t_option str

Low-temperature opacity table selection.

'low_t_fa05_gs98'

Returns:

Type Description
AtmEvalOutput

Populated AtmEvalOutput dataclass.

eval_t_tau_atm

eval_t_tau_atm(
    tau_surf,
    luminosity,
    r,
    m,
    cgrav,
    kap_guess,
    pextra_factor,
    t_tau_relation,
    t_tau_opacity,
    errtol,
    max_iters,
    max_steps,
    skip_partials,
    teff,
    chem_id=None,
    xa=None,
    zbase=0.02,
    low_t_option="low_t_fa05_gs98",
)

Dispatch \(T(\tau)\) outer boundary evaluation across opacity modes.

Evaluates 'fixed', 'iterated', or 'varying' opacity treatments with pextra_factor in upstream order (star/private/atm_support.f90).

Parameters:

Name Type Description Default
tau_surf float

Surface optical depth \(\tau_{\mathrm{surf}}\).

required
luminosity float

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

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
kap_guess float

Initial opacity guess \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
pextra_factor float

Radiation pressure enhancement factor (Pextra_factor).

required
t_tau_relation str

Upstream \(T(\tau)\) relation name ('Eddington', 'solar_Hopf', 'Krishna_Swamy', or 'Trampedach_solar').

required
t_tau_opacity str

Upstream opacity mode ('fixed', 'iterated', or 'varying').

required
errtol float

Relative convergence or dopri5 tolerance.

required
max_iters int

Maximum opacity iterations for 'iterated'.

required
max_steps int

Maximum dopri5 integration steps for 'varying'.

required
skip_partials bool

If True, skip partial derivatives.

required
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

required
chem_id Sequence[int] | None

Optional species catalog IDs ([S]).

None
xa ArrayLike | None

Optional species mass fractions ((S,)).

None
zbase float

Base metallicity \(Z_{\mathrm{base}}\) for kap.

0.02
low_t_option str

Low-temperature opacity table selection.

'low_t_fa05_gs98'

Returns:

Type Description
AtmEvalOutput

Populated AtmEvalOutput dataclass.

eval_table_atm

eval_table_atm(
    luminosity,
    r,
    m,
    cgrav,
    atm_table,
    z,
    tau_factor=1.0,
    atm_off_table_option="T_tau",
    t_tau_relation="Eddington",
    t_tau_opacity="fixed",
    kap_guess=0.5,
    pextra_factor=1.0,
    errtol=1e-06,
    max_iters=30,
    max_steps=500,
    skip_partials=False,
    teff=5777.0,
    chem_id=None,
    xa=None,
    zbase=0.02,
    low_t_option="low_t_fa05_gs98",
)

Evaluate a tabulated atmosphere with upstream off-table blending.

Parameters:

Name Type Description Default
luminosity float

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

required
r float

Radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
atm_table str

Upstream table name ('tau_100', 'photosphere', etc.).

required
z float

Metallicity mass fraction \(Z\).

required
tau_factor float

Optical-depth scale factor (must equal 1.0).

1.0
atm_off_table_option str

Off-table backup mode ('T_tau' or '').

'T_tau'
t_tau_relation str

Backup \(T(\tau)\) relation name.

'Eddington'
t_tau_opacity str

Backup \(T(\tau)\) opacity mode.

'fixed'
kap_guess float

Initial opacity guess (\(\mathrm{cm^2\,g^{-1}}\)).

0.5
pextra_factor float

Radiation pressure enhancement factor.

1.0
errtol float

Relative convergence or dopri5 tolerance.

1e-06
max_iters int

Maximum opacity iterations for 'iterated'.

30
max_steps int

Maximum dopri5 steps for 'varying'.

500
skip_partials bool

If True, skip partial derivatives.

False
teff float

Effective temperature \(T_{\mathrm{eff}}\) (\(\mathrm{K}\)).

5777.0
chem_id Sequence[int] | None

Optional species catalog IDs ([S]).

None
xa ArrayLike | None

Optional species mass fractions ((S,)).

None
zbase float

Base metallicity \(Z_{\mathrm{base}}\) for kap.

0.02
low_t_option str

Low-temperature opacity table selection.

'low_t_fa05_gs98'

Returns:

Type Description
tuple[AtmEvalOutput, float]

Tuple (output, tau_base).

eval_irradiated

eval_irradiated(
    luminosity,
    r,
    m,
    cgrav,
    t_eq,
    p_surf,
    kap_guess,
    kap_v,
    gamma,
    errtol,
    max_iters,
    skip_partials,
    chem_id=None,
    xa=None,
    zbase=0.02,
    low_t_option="low_t_fa05_gs98",
)

Evaluate a Guillot & Havel (2011) irradiated grey atmosphere.

Parameters:

Name Type Description Default
luminosity float

Intrinsic luminosity \(L\) (\(\mathrm{erg\,s^{-1}}\)).

required
r float

Planetary/stellar radius \(R\) (\(\mathrm{cm}\)).

required
m float

Mass \(M\) (\(\mathrm{g}\)).

required
cgrav float

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required
t_eq float

Equilibrium irradiation temperature \(T_{\mathrm{eq}}\) (\(\mathrm{K}\)).

required
p_surf float

Surface boundary pressure \(P_{\mathrm{surf}}\) (\(\mathrm{dyn\,cm^{-2}}\)).

required
kap_guess float

Initial thermal opacity guess \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
kap_v float

Visible-band opacity \(\kappa_v\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
gamma float

Optical-to-thermal opacity ratio \(\gamma = \kappa_v / \kappa\) (if <= 0, computed dynamically as kap_v / kap).

required
errtol float

Relative convergence tolerance on \(\kappa\).

required
max_iters int

Maximum opacity fixed-point iterations (0 for fixed).

required
skip_partials bool

If True, skip partial derivatives.

required
chem_id Sequence[int] | None

Optional species catalog IDs ([S]).

None
xa ArrayLike | None

Optional species mass fractions ((S,)).

None
zbase float

Base metallicity \(Z_{\mathrm{base}}\) for kap.

0.02
low_t_option str

Low-temperature opacity table selection.

'low_t_fa05_gs98'

Returns:

Type Description
AtmIrradiatedOutput

Populated AtmIrradiatedOutput dataclass.

flexmesa.atm._jax

Differentiable JAX kernels for surface boundary conditions (atm).

eval_t_tau_jax

eval_t_tau_jax(t_tau_id, tau, teff)

Evaluate \(\ln T(\tau, T_{\mathrm{eff}})\) in pure branchless JAX.

Parameters:

Name Type Description Default
t_tau_id int

\(T(\tau)\) relation identifier (1: Eddington, 2: Solar Hopf, 3: Krishna Swamy, 4: Trampedach solar).

required
tau Array

Optical depth \(\tau\) (scalar or array).

required
teff Array

Effective temperature \(T_{\mathrm{eff}}\) in \(\mathrm{K}\).

required

Returns:

Type Description
Array

Natural logarithm of temperature \(\ln(T / \mathrm{K})\).

eval_paczynski_gradr_jax

eval_paczynski_gradr_jax(
    t, p, rho, tau, kap, luminosity, m, r, cgrav
)

Evaluate Paczynski (1969) diluted \(\nabla_{\mathrm{rad}}\) in JAX.

Parameters:

Name Type Description Default
t Array

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

required
p Array

Pressure \(P\) (\(\mathrm{dyn\,cm^{-2}}\)).

required
rho Array

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

required
tau Array

Optical depth \(\tau\).

required
kap Array

Opacity \(\kappa\) (\(\mathrm{cm^2\,g^{-1}}\)).

required
luminosity Array

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

required
m Array

Mass \(M\) (\(\mathrm{g}\)).

required
r Array

Radius \(R\) (\(\mathrm{cm}\)).

required
cgrav Array

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

required

Returns:

Type Description
Array

Diluted radiative temperature gradient \(\nabla_{\mathrm{rad}}\).

eval_table_jax

eval_table_jax(
    luminosity,
    r,
    m,
    cgrav=constants.STANDARD_CGRAV,
    table_id=_core.ATM_TABLE_PHOTOSPHERE,
    z=0.02,
)

Evaluate differentiable \((\ln T, \ln P)\) from an atmosphere table.

Uses a jax.custom_vjp rule backed by the analytical bicubic spline derivatives \((\partial \ln T / \partial L, \partial \ln T / \partial \ln R, \partial \ln T / \partial \ln M)\) and \((\partial \ln P / \partial L, \partial \ln P / \partial \ln R, \partial \ln P / \partial \ln M)\) computed in flexmesa-atm.

Parameters:

Name Type Description Default
luminosity Array

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

required
r Array

Photospheric radius \(R\) (\(\mathrm{cm}\)).

required
m Array

Stellar mass \(M\) (\(\mathrm{g}\)).

required
cgrav float | Array

Gravitational constant \(G\) (\(\mathrm{cm^3\,g^{-1}\,s^{-2}}\)).

STANDARD_CGRAV
table_id int

Atmosphere table identifier (100..106).

ATM_TABLE_PHOTOSPHERE
z float | Array

Metallicity mass fraction \(Z\).

0.02

Returns:

Type Description
tuple[Array, Array]

Tuple (ln_t, ln_p) as scalar JAX float64 arrays.


Synthetic SEDs & Filter Photometry (flexmesa.colors)

flexmesa.colors synthesizes stellar spectral energy distributions (SEDs) across the 1199-wavelength Kurucz/Castelli (Teff, log_g, [M/H]) grid using a 32-gather 3D cubic Hermite interpolator and integrates bolometric corrections and synthetic absolute magnitudes across Johnson-Cousins \(UBVRIJHK\) filter transmission curves via non-uniform quadratic Simpson quadrature.

flexmesa.colors.photometry

10-column history photometry evaluators for flexmesa.colors.

Ports upstream MESA colors/private/colors_history.f90 and colors/public/colors_lib.f90 into unified Safe Rust (flexmesa._rust) and branchless @jax.jit (float64) evaluators.

eval_colors_jax

eval_colors_jax(
    teff,
    log_g,
    metallicity,
    r,
    d=utils.D_10PC_CM,
    mag_system_id=0,
    method_id=0,
)

Evaluate 10-column colors history vector in @jax.jit float64.

Parameters:

Name Type Description Default
teff Array | float

Effective temperature in K.

required
log_g Array | float

Log10 surface gravity in cm s^-2.

required
metallicity Array | float

Metallicity [M/H] in dex.

required
r Array | float

Photospheric radius in cm.

required
d Array | float

Observer distance in cm.

D_10PC_CM
mag_system_id int

0 for Vega, 1 for AB, 2 for ST.

0
method_id int

0 for Hermite, 1 for Linear, 2 for KNN.

0

Returns:

Type Description
Array

1D array of shape (10,) containing

Array

[Mag_bol, Flux_bol, Interp_rad, B, I, J, M, R, U, V].

eval_colors

eval_colors(
    teff,
    log_g,
    metallicity,
    r,
    d=utils.D_10PC_CM,
    *,
    mag_system="Vega",
    method="Hermite",
    backend="auto",
)

Evaluate the 10-column colors history vector for a stellar model.

Parameters:

Name Type Description Default
teff float | Array

Effective temperature in K.

required
log_g float | Array

Log10 surface gravity in cm s^-2.

required
metallicity float | Array

Metallicity [M/H] in dex.

required
r float | Array

Photospheric radius in cm.

required
d float | Array

Observer distance in cm (default 10 pc).

D_10PC_CM
mag_system str

Zero-point system ("Vega", "AB", or "ST").

'Vega'
method str

SED interpolator ("Hermite", "Linear", or "KNN").

'Hermite'
backend Backend

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

'auto'

Returns:

Type Description
ArrayLike

1D array of shape (10,) containing

ArrayLike

[Mag_bol, Flux_bol, Interp_rad, B, I, J, M, R, U, V].

eval_colors_dual

eval_colors_dual(
    teff,
    log_g,
    metallicity,
    r,
    d=utils.D_10PC_CM,
    *,
    mag_system="Vega",
    backend="auto",
)

Evaluate eval_colors and its (10, 4) Jacobian.

Parameters:

Name Type Description Default
teff float | Array

Effective temperature in K.

required
log_g float | Array

Log10 surface gravity in cm s^-2.

required
metallicity float | Array

Metallicity [M/H] in dex.

required
r float | Array

Photospheric radius in cm.

required
d float | Array

Observer distance in cm.

D_10PC_CM
mag_system str

Zero-point system ("Vega", "AB", or "ST").

'Vega'
backend Backend

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

'auto'

Returns:

Type Description
tuple[ArrayLike, ArrayLike]

Tuple (values, jacobian) with shapes (10,) and (10, 4).

eval_colors_zones

eval_colors_zones(
    teff,
    log_g,
    metallicity,
    r,
    d=utils.D_10PC_CM,
    *,
    mag_system="Vega",
    method="Hermite",
    backend="auto",
    parallel=True,
)

Evaluate 10-column colors output across n_zones stellar models.

Parameters:

Name Type Description Default
teff ArrayLike

1D array of temperatures in K of shape (n_zones,).

required
log_g ArrayLike

1D array of log10(g) in cm s^-2 of shape (n_zones,).

required
metallicity ArrayLike

1D array of [M/H] in dex of shape (n_zones,).

required
r ArrayLike

1D array of radii in cm of shape (n_zones,).

required
d float | Array

Observer distance in cm (default 10 pc).

D_10PC_CM
mag_system str

Zero-point system ("Vega", "AB", or "ST").

'Vega'
method str

SED interpolator ("Hermite", "Linear", or "KNN").

'Hermite'
backend Backend

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

'auto'
parallel bool

Whether to use the persistent rayon thread pool in Rust.

True

Returns:

Type Description
ArrayLike

2D array of shape (n_zones, 10).

flexmesa.colors.sed

3D stellar atmosphere SED interpolators for flexmesa.colors.

Ports upstream MESA colors/private/hermite_interp.f90, linear_interp.f90, and knn_interp.f90 into branchless @jax.jit (float64) and Safe Rust (flexmesa._rust) evaluators over the Kurucz2003all \((T_{\mathrm{eff}}, \log g, [\mathrm{M/H}], \lambda)\) lookup cube.

h00

h00(t)

Evaluate cubic Hermite value basis h00(t) = 2 t^3 - 3 t^2 + 1.

h10

h10(t)

Evaluate cubic Hermite tangent basis h10(t) = t^3 - 2 t^2 + t.

h01

h01(t)

Evaluate cubic Hermite value basis h01(t) = -2 t^3 + 3 t^2.

h11

h11(t)

Evaluate cubic Hermite tangent basis h11(t) = t^3 - t^2.

compute_interp_radius_jax

compute_interp_radius_jax(teff, log_g, metallicity)

Compute normalized Euclidean distance to the nearest Kurucz grid node.

Parameters:

Name Type Description Default
teff Array | float

Effective temperature in K.

required
log_g Array | float

Log10 surface gravity in cm s^-2.

required
metallicity Array | float

Metallicity [M/H] in dex.

required

Returns:

Type Description
Array

Scalar normalized interpolation radius Interp_rad.

eval_sed_hermite_jax

eval_sed_hermite_jax(
    teff, log_g, metallicity, r, d=utils.D_10PC_CM
)

Evaluate 3D cubic Hermite SED interpolation in JAX float64.

Parameters:

Name Type Description Default
teff Array | float

Effective temperature in K.

required
log_g Array | float

Log10 surface gravity in cm s^-2.

required
metallicity Array | float

Metallicity [M/H] in dex.

required
r Array | float

Photospheric radius in cm.

required
d Array | float

Observer distance in cm.

D_10PC_CM

Returns:

Type Description
Array

Diluted 1D SED flux array of shape (1199,) in

Array

erg s^-1 cm^-2 Angstrom^-1.

eval_sed_linear_jax

eval_sed_linear_jax(
    teff, log_g, metallicity, r, d=utils.D_10PC_CM
)

Evaluate 3D log-fallback trilinear SED interpolation in JAX float64.

Matches upstream MESA linear_interp.f90:construct_sed_linear by clamping all 8 cell corners to 1.0e-10 before linear and log blending.

Parameters:

Name Type Description Default
teff Array | float

Effective temperature in K.

required
log_g Array | float

Log10 surface gravity in cm s^-2.

required
metallicity Array | float

Metallicity [M/H] in dex.

required
r Array | float

Photospheric radius in cm.

required
d Array | float

Observer distance in cm.

D_10PC_CM

Returns:

Type Description
Array

Diluted 1D SED flux array of shape (1199,).

eval_sed_knn_jax

eval_sed_knn_jax(
    teff, log_g, metallicity, r, d=utils.D_10PC_CM
)

Evaluate 4-nearest-neighbor inverse-distance SED interpolation in JAX.

Searches the full (76, 11, 8) normalized 3D Kurucz grid to match upstream MESA knn_interp.f90:find_k_nearest_neighbors and interpolate_knn_sed.

Parameters:

Name Type Description Default
teff Array | float

Effective temperature in K.

required
log_g Array | float

Log10 surface gravity in cm s^-2.

required
metallicity Array | float

Metallicity [M/H] in dex.

required
r Array | float

Photospheric radius in cm.

required
d Array | float

Observer distance in cm.

D_10PC_CM

Returns:

Type Description
Array

Diluted 1D SED flux array of shape (1199,).

eval_sed

eval_sed(
    teff,
    log_g,
    metallicity,
    r,
    d=utils.D_10PC_CM,
    *,
    method="Hermite",
    backend="auto",
)

Evaluate the diluted stellar SED (wavelengths, fluxes).

Parameters:

Name Type Description Default
teff float | Array

Effective temperature in K.

required
log_g float | Array

Log10 surface gravity in cm s^-2.

required
metallicity float | Array

Metallicity [M/H] in dex.

required
r float | Array

Photospheric radius in cm.

required
d float | Array

Observer distance in cm (default 10 pc).

D_10PC_CM
method str

SED method ("Hermite", "Linear", or "KNN").

'Hermite'
backend Backend

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

'auto'

Returns:

Type Description
tuple[ArrayLike, ArrayLike]

Tuple (wavelengths, fluxes) of 1D arrays of shape (1199,).

Raises:

Type Description
ValueError

If method is not recognized.

flexmesa.colors.synthetic

Bolometric, synthetic filter, and zero-point photometry for colors.

Ports upstream MESA colors/private/bolometric.f90 and synthetic.f90 into unified Safe Rust (flexmesa._rust) and @jax.jit (float64) evaluators.

flux_to_magnitude

flux_to_magnitude(flux)

Convert integrated flux F > 0 to Pogson magnitude -2.5 log10(F).

Parameters:

Name Type Description Default
flux float | Array

Integrated flux F in erg s^-1 cm^-2.

required

Returns:

Type Description
float | Array

Magnitude -2.5 log10(F), or 99.0 when F <= 0.

clean_sed_fluxes_jax

clean_sed_fluxes_jax(wavelengths, fluxes)

Zero out non-positive interior wavelengths or negative SED fluxes.

Matches the interior sanitization loop 1..n-1 in upstream MESA bolometric.f90 and synthetic.f90.

calculate_bolometric_phot_jax

calculate_bolometric_phot_jax(wavelengths, fluxes)

Integrate bolometric flux and magnitude in JAX float64.

Parameters:

Name Type Description Default
wavelengths Array

1D wavelength grid in Angstrom of shape (n,).

required
fluxes Array

1D flux density in erg s^-1 cm^-2 Angstrom^-1 of shape (n,).

required

Returns:

Type Description
tuple[Array, Array]

Tuple (bol_mag, bol_flux).

calculate_bolometric_phot

calculate_bolometric_phot(
    wavelengths, fluxes, *, backend="auto"
)

Integrate bolometric flux and magnitude over (wavelengths, fluxes).

Parameters:

Name Type Description Default
wavelengths ArrayLike

1D wavelength grid in Angstrom of shape (n,).

required
fluxes ArrayLike

1D flux density in erg s^-1 cm^-2 Angstrom^-1 of shape (n,).

required
backend Backend

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

'auto'

Returns:

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

Tuple (bol_mag, bol_flux).

calculate_synthetic_flux_jax

calculate_synthetic_flux_jax(
    wavelengths, convolved_flux, filter_on_sed_grid
)

Compute photon-counting synthetic filter flux in JAX float64.

Parameters:

Name Type Description Default
wavelengths Array

1D wavelength grid in Angstrom of shape (n,).

required
convolved_flux Array

1D product F_lambda * S_lambda of shape (n,).

required
filter_on_sed_grid Array

1D filter transmission S_lambda of shape (n,).

required

Returns:

Type Description
Array

Photon-counting mean flux

Array

int F S lambda dlambda / int S lambda dlambda.

calculate_synthetic_jax

calculate_synthetic_jax(
    wavelengths,
    fluxes,
    filter_wavelengths,
    filter_trans,
    zero_point_flux,
)

Compute synthetic filter magnitude in JAX float64.

Parameters:

Name Type Description Default
wavelengths Array

1D SED wavelength grid in Angstrom.

required
fluxes Array

1D SED flux density in erg s^-1 cm^-2 Angstrom^-1.

required
filter_wavelengths Array

1D filter wavelength grid in Angstrom.

required
filter_trans Array

1D filter transmission curve.

required
zero_point_flux Array | float

Zero-point flux F_0 in erg s^-1 cm^-2 Angstrom^-1.

required

Returns:

Type Description
Array

Synthetic magnitude -2.5 log10(F_syn / F_0).

calculate_synthetic

calculate_synthetic(
    wavelengths,
    fluxes,
    filter_wavelengths,
    filter_trans,
    zero_point_flux,
    *,
    backend="auto",
)

Compute synthetic filter magnitude from an SED and filter curve.

Parameters:

Name Type Description Default
wavelengths ArrayLike

1D SED wavelength grid in Angstrom.

required
fluxes ArrayLike

1D SED flux density in erg s^-1 cm^-2 Angstrom^-1.

required
filter_wavelengths ArrayLike

1D filter wavelength grid in Angstrom.

required
filter_trans ArrayLike

1D filter transmission curve.

required
zero_point_flux float | Array

Zero-point flux F_0.

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

Synthetic magnitude -2.5 log10(F_syn / F_0).

compute_vega_zero_point

compute_vega_zero_point(
    vega_wave,
    vega_flux,
    filt_wave,
    filt_trans,
    *,
    backend="auto",
)

Compute the Vega photon-counting zero-point flux for a filter curve.

Parameters:

Name Type Description Default
vega_wave ArrayLike

1D Vega wavelength grid in Angstrom.

required
vega_flux ArrayLike

1D Vega flux spectrum in erg s^-1 cm^-2 Angstrom^-1.

required
filt_wave ArrayLike

1D filter wavelength grid in Angstrom.

required
filt_trans ArrayLike

1D filter transmission curve.

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

Vega zero-point flux in erg s^-1 cm^-2 Angstrom^-1.

compute_ab_zero_point

compute_ab_zero_point(
    filt_wave, filt_trans, *, backend="auto"
)

Compute the AB photon-counting zero-point flux (\(f_\nu = 3631\) Jy).

Parameters:

Name Type Description Default
filt_wave ArrayLike

1D filter wavelength grid in Angstrom.

required
filt_trans ArrayLike

1D filter transmission curve.

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

AB zero-point flux in erg s^-1 cm^-2 Angstrom^-1.

compute_st_zero_point

compute_st_zero_point(
    filt_wave, filt_trans, *, backend="auto"
)

Compute the ST photon-counting zero-point flux (\(f_\lambda = 3.63e-9\)).

Parameters:

Name Type Description Default
filt_wave ArrayLike

1D filter wavelength grid in Angstrom.

required
filt_trans ArrayLike

1D filter transmission curve.

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

ST zero-point flux in erg s^-1 cm^-2 Angstrom^-1.

flexmesa.colors.utils

Quadrature, flux dilution, and grid utilities for flexmesa.colors.

Ports upstream MESA colors/private/colors_utils.f90 and colors/private/knn_interp.f90 into unified Safe Rust (flexmesa._rust) and branchless @jax.jit (float64) kernels.

ColorsBuiltinGrid

Bases: NamedTuple

Preloaded Kurucz2003all + Johnson grid arrays in JAX float64.

Attributes:

Name Type Description
teff_grid Array

Effective temperature axis in K of shape (76,).

logg_grid Array

Log10 surface gravity axis in CGS of shape (11,).

meta_grid Array

Metallicity axis [M/H] in dex of shape (8,).

wavelengths Array

Canonical wavelength grid in Angstrom of shape (1199,).

slot_map Array

Flat (76 * 11 * 8,) index map into sed_table.

sed_table Array

Surface flux table of shape (n_slots, 1199) in erg s^-1 cm^-2 Angstrom^-1.

filters_on_sed_grid Array

Resampled Johnson filter curves of shape (7, 1199).

filter_norm_integrals Array

Photon-counting denominators int S_lambda lambda dlambda of shape (7,).

vega_zp Array

Vega zero-point fluxes of shape (7,).

ab_zp Array

AB zero-point fluxes of shape (7,).

st_zp Array

ST zero-point fluxes of shape (7,).

get_builtin_colors_grid cached

get_builtin_colors_grid()

Load the built-in Kurucz2003all + Johnson grid from Rust.

Returns:

Name Type Description
Cached ColorsBuiltinGrid

class:ColorsBuiltinGrid containing jnp.float64 and

ColorsBuiltinGrid

jnp.int64 device arrays.

remove_dat

remove_dat(path)

Strip the file extension starting at the first . character.

Parameters:

Name Type Description Default
path str

Input file path or filter identifier string.

required

Returns:

Type Description
str

Substring prior to the first . character.

dilute_flux_jax

dilute_flux_jax(surface_flux, r, d)

Apply geometric dilution (r / d)^2 in JAX float64.

Parameters:

Name Type Description Default
surface_flux Array

1D surface flux array of shape (n_lambda,) in erg s^-1 cm^-2 Angstrom^-1.

required
r Array | float

Stellar photospheric radius in cm.

required
d Array | float

Observer distance in cm.

required

Returns:

Type Description
Array

Diluted flux array of shape (n_lambda,) in

Array

erg s^-1 cm^-2 Angstrom^-1.

dilute_flux

dilute_flux(
    surface_flux, r, d=D_10PC_CM, *, backend="auto"
)

Apply geometric flux dilution (R / d)^2 to a stellar SED.

Parameters:

Name Type Description Default
surface_flux ArrayLike

1D surface flux array of shape (n_lambda,) in erg s^-1 cm^-2 Angstrom^-1.

required
r float | Array

Stellar radius in cm.

required
d float | Array

Distance in cm (default 3.0857e19 cm = 10 pc).

D_10PC_CM
backend Backend

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

'auto'

Returns:

Type Description
ArrayLike

Diluted flux array of shape (n_lambda,).

trapezoidal_integration_jax

trapezoidal_integration_jax(x, y)

Evaluate composite non-uniform trapezoidal rule in JAX float64.

Parameters:

Name Type Description Default
x Array

1D monotonic grid array of shape (n,).

required
y Array

1D integrand values of shape (n,).

required

Returns:

Type Description
Array

Scalar integral int y(x) dx.

trapezoidal_integration

trapezoidal_integration(x, y, *, backend='auto')

Evaluate composite non-uniform trapezoidal quadrature.

Parameters:

Name Type Description Default
x ArrayLike

1D grid coordinates of shape (n,).

required
y ArrayLike

1D integrand values of shape (n,).

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

Integrated scalar value.

simpson_integration_jax

simpson_integration_jax(x, y)

Evaluate composite non-uniform Simpson quadrature in JAX float64.

Supports batched y of shape (*batch, n) integrated along the last axis against 1D x of shape (n,). Matches upstream MESA colors_utils.f90:simpson_integration, including the trapezoidal tail interval when x.shape[0] is even.

Parameters:

Name Type Description Default
x Array

1D grid coordinates of shape (n,).

required
y Array

Integrand values of shape (*batch, n).

required

Returns:

Type Description
Array

Integrated value of shape (*batch,).

simpson_integration

simpson_integration(x, y, *, backend='auto')

Evaluate composite non-uniform Simpson quadrature.

Parameters:

Name Type Description Default
x ArrayLike

1D grid coordinates of shape (n,).

required
y ArrayLike

1D integrand values of shape (n,).

required
backend Backend

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

'auto'

Returns:

Type Description
float | Array

Integrated scalar value.

interpolate_array_jax

interpolate_array_jax(x_in, y_in, x_out)

Resample 1D curve (x_in, y_in) onto x_out with flat clamping.

Parameters:

Name Type Description Default
x_in Array

1D source coordinates of shape (n_in,).

required
y_in Array

1D source values of shape (n_in,).

required
x_out Array

1D target coordinates of shape (n_out,).

required

Returns:

Type Description
Array

Resampled 1D array of shape (n_out,).

interpolate_array

interpolate_array(x_in, y_in, x_out, *, backend='auto')

Resample 1D curve (x_in, y_in) onto x_out with flat clamping.

Parameters:

Name Type Description Default
x_in ArrayLike

1D source coordinates of shape (n_in,).

required
y_in ArrayLike

1D source values of shape (n_in,).

required
x_out ArrayLike

1D target coordinates of shape (n_out,).

required
backend Backend

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

'auto'

Returns:

Type Description
ArrayLike

Resampled 1D array of shape (n_out,).


Compiled Rust Extension Bridge (flexmesa._rust)

Low-level Safe Rust PyO3 bindings exposed via flexmesa._rust for opacities, atmospheres, and synthetic photometry (_ArrF64 and _ArrI64 denote float64 and int64 NumPy arrays).

kap_py

  • kap_build_full_tables_bin ((kap_dir: str, aesopus_section_path: str, out_path: str) -> None): Assembles and checks an FMKAP001 kap_tables_full.bin file from a MESA kap_data directory and pre-converted aesopus_section.bin.
  • kap_get_aesopus_rust ((zbase: float, x: float, xc: float, xn: float, xo: float, log_rho: float, log_t: float) -> tuple[float, float, float]): Evaluates AESOPUS_AGSS09 low-temperature opacity (kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_co_rust ((zbase: float, x: float, dxc: float, dxo: float, log_rho: float, log_t: float, kap_co_option: str = "gn93_co", cubic_x: bool = False, cubic_z: bool = False) -> tuple[float, float, float]): Evaluates Type 2 C/O-enhanced opacity (log10_kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_compton_opacity_rust ((rho: float, t: float, lnfree_e: float, d_lnfree_e_dln_rho: float, d_lnfree_e_dln_t: float, eta: float, d_eta_dln_rho: float, d_eta_dln_t: float) -> tuple[float, float, float]): Evaluates Poutanen (2017) Compton opacity (kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_elect_cond_opacity_rust ((zbar: float, log_rho: float, log_t: float, use_blouin: bool = True) -> tuple[float, float, float]): Evaluates electron thermal conduction opacity (kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_fixed_metal_rust ((z: float, x: float, log_rho: float, log_t: float, prefix: str = "gs98", cubic_x: bool = False, cubic_z: bool = False) -> tuple[float, float, float]): Evaluates Type 1 fixed-metal opacity (log10_kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_kapcn_rust ((zbase: float, x: float, fc: float, fn_val: float, log_rho: float, log_t: float) -> tuple[float, float, float]): Evaluates kapCN Lederer & Aringer (2009) low-temperature opacity (kap, dlnkap_dlnRho, dlnkap_dlnT).
  • kap_get_results_rust ((z: float, x: float, zbase: float, xc: float, xn: float, xo: float, xne: float, log_rho: float, log_t: float, lnfree_e: float, d_lnfree_e_dln_rho: float, d_lnfree_e_dln_t: float, eta: float, d_eta_dln_rho: float, d_eta_dln_t: float, zbar: float = 1.0, kap_option: str = "gs98", kap_co_option: str = "gs98_co", kap_low_t_option: str = "lowT_fa05_gs98", kap_blend_log_t_upper_bdy: float = 3.88, kap_blend_log_t_lower_bdy: float = 3.80, cubic_interpolation_in_x: bool = False, cubic_interpolation_in_z: bool = False, include_electron_conduction: bool = True, use_blouin_conductive_opacities: bool = True, use_zbase_for_type1: bool = True, use_type2_opacities: bool = True, kap_type2_full_off_x: float = 1.0e-3, kap_type2_full_on_x: float = 1.0e-6, kap_type2_full_off_dz: float = 0.001, kap_type2_full_on_dz: float = 0.01) -> tuple[float, float, float, list[float]]): Evaluates get_kap_results, returning (kap, dlnkap_dlnRho, dlnkap_dlnT, kap_fracs[4]).
  • kap_get_results_zones_rust ((z: float, x: float, zbase: float, xc: float, xn: float, xo: float, xne: float, log_rho_zones: _ArrF64, log_t_zones: _ArrF64, lnfree_e: float, d_lnfree_e_dln_rho: float, d_lnfree_e_dln_t: float, eta: float, d_eta_dln_rho: float, d_eta_dln_t: float, zbar: float = 1.0, kap_option: str = "gs98", kap_co_option: str = "gs98_co", kap_low_t_option: str = "lowT_fa05_gs98", kap_blend_log_t_upper_bdy: float = 3.88, kap_blend_log_t_lower_bdy: float = 3.80, cubic_interpolation_in_x: bool = False, cubic_interpolation_in_z: bool = False, include_electron_conduction: bool = True, use_blouin_conductive_opacities: bool = True, use_zbase_for_type1: bool = True, use_type2_opacities: bool = True, kap_type2_full_off_x: float = 1.0e-3, kap_type2_full_on_x: float = 1.0e-6, kap_type2_full_off_dz: float = 0.001, kap_type2_full_on_dz: float = 0.01, parallel: bool = True) -> _ArrF64): Evaluates get_kap_results across N_zones zones at fixed composition, returning an (N_zones, 7) array.
  • kap_get_rust ((chem_id: npt.NDArray[np.uintp], xa: _ArrF64, log_rho: float, log_t: float, lnfree_e: float, d_lnfree_e_dln_rho: float, d_lnfree_e_dln_t: float, eta: float, d_eta_dln_rho: float, d_eta_dln_t: float, zbase: float = -1.0, kap_option: str = "gs98", kap_co_option: str = "gs98_co", kap_low_t_option: str = "lowT_fa05_gs98", kap_blend_log_t_upper_bdy: float = 3.88, kap_blend_log_t_lower_bdy: float = 3.80, cubic_interpolation_in_x: bool = False, cubic_interpolation_in_z: bool = False, include_electron_conduction: bool = True, use_blouin_conductive_opacities: bool = True, use_zbase_for_type1: bool = True, use_type2_opacities: bool = True, kap_type2_full_off_x: float = 1.0e-3, kap_type2_full_on_x: float = 1.0e-6, kap_type2_full_off_dz: float = 0.001, kap_type2_full_on_dz: float = 0.01) -> tuple[float, float, float, list[float]]): Evaluates kap_get from 1-based isotope IDs chem_id and mass fractions xa.
  • kap_get_zones_rust ((chem_id: npt.NDArray[np.uintp], xa_zones: _ArrF64, log_rho_zones: _ArrF64, log_t_zones: _ArrF64, lnfree_e_zones: _ArrF64, d_lnfree_e_dln_rho_zones: _ArrF64, d_lnfree_e_dln_t_zones: _ArrF64, eta_zones: _ArrF64, d_eta_dln_rho_zones: _ArrF64, d_eta_dln_t_zones: _ArrF64, zbase: float = -1.0, kap_option: str = "gs98", kap_co_option: str = "gs98_co", kap_low_t_option: str = "lowT_fa05_gs98", kap_blend_log_t_upper_bdy: float = 3.88, kap_blend_log_t_lower_bdy: float = 3.80, cubic_interpolation_in_x: bool = False, cubic_interpolation_in_z: bool = False, include_electron_conduction: bool = True, use_blouin_conductive_opacities: bool = True, use_zbase_for_type1: bool = True, use_type2_opacities: bool = True, kap_type2_full_off_x: float = 1.0e-3, kap_type2_full_on_x: float = 1.0e-6, kap_type2_full_off_dz: float = 0.001, kap_type2_full_on_dz: float = 0.01, parallel: bool = True) -> _ArrF64): Evaluates kap_get across N_zones zones in parallel, returning an (N_zones, 7) array [kap, dlnkap_dlnRho, dlnkap_dlnT, frac_lowT, frac_highT, frac_Type2, frac_Compton].

atm_py

  • atm_eval_e2 ((x: float) -> tuple[float, float]): Evaluates the second exponential integral (E_2(x), dE_2/dx).
  • atm_eval_irradiated ((l: float, r: float, m: float, cgrav: float, t_eq: float, p_surf: float, kap_guess: float, kap_v: float, gamma: float, errtol: float, max_iters: int, skip_partials: bool, chem_id: Sequence[int] | None = None, xa: _ArrF64 | None = None, zbase: float = 0.02, low_t_option: str = "low_t_fa05_gs98") -> tuple[float, ...]): Evaluates an irradiated grey atmosphere (eval_irradiated).
  • atm_eval_paczynski_gradr ((t: float, p: float, rho: float, tau: float, kap: float, l: float, m: float, r: float, cgrav: float) -> float): Evaluates the Paczynski (1969) optical-depth-diluted radiative gradient \(\nabla_{\mathrm{rad}}\).
  • atm_eval_t_tau ((t_tau_id: int, tau: float, teff: float) -> float): Evaluates \(\ln T(\tau, T_{\mathrm{eff}})\) for a \(T(\tau)\) relation ID.
  • atm_eval_t_tau_atm ((tau_surf: float, l: float, r: float, m: float, cgrav: float, kap_guess: float, pextra_factor: float, t_tau_relation: str, t_tau_opacity: str, errtol: float, max_iters: int, max_steps: int, skip_partials: bool, teff: float, chem_id: Sequence[int] | None = None, xa: _ArrF64 | None = None, zbase: float = 0.02, low_t_option: str = "low_t_fa05_gs98") -> tuple[float, ...]): Dispatches \(T(\tau)\) atmosphere evaluation across 'fixed', 'iterated', and 'varying' opacity modes with Pextra_factor (eval_t_tau_atm).
  • atm_eval_t_tau_dq_dtau ((t_tau_id: int, tau: float) -> float): Evaluates \(dq/d\tau\) for a \(T(\tau)\) relation ID at optical depth \(\tau\).
  • atm_eval_t_tau_uniform ((tau_surf: float, l: float, r: float, m: float, cgrav: float, kap_guess: float, pextra_factor: float, t_tau_id: int, errtol: float, max_iters: int, skip_partials: bool, teff: float, chem_id: Sequence[int] | None = None, xa: _ArrF64 | None = None, zbase: float = 0.02, low_t_option: str = "low_t_fa05_gs98") -> tuple[float, ...]): Evaluates a grey \(T(\tau)\) atmosphere with uniform opacity (eval_t_tau_uniform).
  • atm_eval_t_tau_varying ((tau_surf: float, l: float, r: float, m: float, cgrav: float, t_tau_id: int, errtol: float, max_steps: int, skip_partials: bool, teff: float, chem_id: Sequence[int], xa: _ArrF64, zbase: float = 0.02, low_t_option: str = "low_t_fa05_gs98") -> tuple[float, ...]): Evaluates a \(T(\tau)\) atmosphere with depth-varying opacity (eval_t_tau_varying).
  • atm_eval_table ((l: float, r: float, m: float, cgrav: float, id: int, z: float, skip_partials: bool, teff: float) -> tuple[float, ...]): Evaluates a tabulated model atmosphere (eval_table).
  • atm_eval_table_atm ((l: float, r: float, m: float, cgrav: float, atm_table: str, z: float, tau_factor: float, atm_off_table_option: str, t_tau_relation: str, t_tau_opacity: str, kap_guess: float, pextra_factor: float, errtol: float, max_iters: int, max_steps: int, skip_partials: bool, teff: float, chem_id: Sequence[int] | None = None, xa: _ArrF64 | None = None, zbase: float = 0.02, low_t_option: str = "low_t_fa05_gs98") -> tuple[tuple[float, ...], float]): Evaluates a tabulated model atmosphere with upstream atm_off_table_option blending (eval_table_atm), returning (eval_tuple, tau_base).
  • atm_eval_table_zones ((l: _ArrF64, r: _ArrF64, m: _ArrF64, cgrav: float, id: int, z: float, skip_partials: bool, teff: _ArrF64, parallel: bool = True) -> _ArrF64): Evaluates eval_table across n_zones surface boundary conditions, returning an (n_zones, 11) array.
  • atm_get_t_tau_base ((t_tau_id: int) -> float): Returns the base optical depth \(\tau_{\mathrm{base}}\) of a \(T(\tau)\) relation ID.
  • atm_get_t_tau_id ((name: str) -> int): Maps an atm_T_tau_relation name ('Eddington', 'solar_Hopf', 'Krishna_Swamy', 'Trampedach_solar') to its integer ID.
  • atm_get_table_alfa_beta ((l: float, teff: float, r: float, m: float, cgrav: float, id: int) -> tuple[float, float]): Evaluates blending weights \((\alpha, \beta)\) between grey and table atmospheres.
  • atm_get_table_base ((id: int) -> float): Returns the base optical depth \(\tau_{\mathrm{base}}\) of an atmosphere table ID.
  • atm_get_table_id ((name: str) -> int): Maps an atm_table name ('tau_100', 'tau_10', 'tau_1', 'tau_1m1', 'photosphere', 'WD_tau_25', 'DB_WD_tau_25') to its integer ID.
  • atm_table_photosphere_zsol_spline (() -> tuple[_ArrF64, _ArrF64, bool, bool, _ArrF64]): Returns (logg_array, teff_array, iling, ilint, pgas_coeffs) for the solar metallicity (log_z == 0.0) slice of ATM_TABLE_PHOTOSPHERE.

colors_py

  • py_colors_builtin_grid (() -> tuple[_ArrF64, _ArrF64, _ArrF64, _ArrF64, _ArrI64, _ArrF64, _ArrF64, _ArrF64, _ArrF64, _ArrF64, _ArrF64]): Returns the built-in Kurucz2003all + Johnson grid arrays for @jax.jit: (teff_grid, logg_grid, meta_grid, wavelengths, slot_map, sed_table, filters_on_sed_grid, filter_norm_integrals, vega_zp, ab_zp, st_zp).
  • py_colors_calculate_bolometric_phot ((wavelengths: _ArrF64, fluxes: _ArrF64) -> tuple[float, float]): Computes (bol_mag, bol_flux) from (wavelengths, fluxes).
  • py_colors_calculate_synthetic ((wavelengths: _ArrF64, fluxes: _ArrF64, filter_wavelengths: _ArrF64, filter_trans: _ArrF64, zero_point_flux: float) -> float): Computes synthetic filter magnitude calculate_synthetic from an SED and filter transmission curve.
  • py_colors_column_names (() -> list[str]): Returns the ordered 10 colors history output column names: ["Mag_bol", "Flux_bol", "Interp_rad", "B", "I", "J", "M", "R", "U", "V"].
  • py_colors_compute_ab_zero_point ((filt_wave: _ArrF64, filt_trans: _ArrF64) -> float): Computes the AB photon-counting zero-point flux (\(f_\nu = 3631\,\)Jy).
  • py_colors_compute_st_zero_point ((filt_wave: _ArrF64, filt_trans: _ArrF64) -> float): Computes the ST photon-counting zero-point flux (\(f_\lambda = 3.63\times 10^{-9}\,\mathrm{erg\,s^{-1}\,cm^{-2}}\,\mathrm{Å}^{-1}\)).
  • py_colors_compute_vega_zero_point ((vega_wave: _ArrF64, vega_flux: _ArrF64, filt_wave: _ArrF64, filt_trans: _ArrF64) -> float): Computes the Vega photon-counting zero-point flux for a filter curve.
  • py_colors_dilute_flux ((surface_flux: _ArrF64, r: float, d: float) -> _ArrF64): Applies geometric flux dilution surface_flux * (r / d)^2.
  • py_colors_eval_colors ((teff: float, log_g: float, metallicity: float, r: float, d: float = 3.0857e19, mag_system: str = "Vega", method: str = "Hermite") -> _ArrF64): Evaluates the 10-column colors output vector [Mag_bol, Flux_bol, Interp_rad, B, I, J, M, R, U, V] at (teff, log_g, metallicity, r, d) (teff in K, log_g in log10(cm s^-2), r and d in cm, mag_system in {"Vega", "AB", "ST"}, method in {"Hermite", "Linear", "KNN"}).
  • py_colors_eval_colors_dual ((teff: float, log_g: float, metallicity: float, r: float, d: float = 3.0857e19, mag_system: str = "Vega") -> tuple[_ArrF64, _ArrF64]): Evaluates (values, jacobian) for eval_colors using DualOrder1<4> seeded on (teff, log_g, metallicity, r) at fixed d, where values has shape (10,) and jacobian has shape (10, 4).
  • py_colors_eval_colors_zones ((teff: _ArrF64, log_g: _ArrF64, metallicity: _ArrF64, r: _ArrF64, d: float = 3.0857e19, mag_system: str = "Vega", method: str = "Hermite", parallel: bool = True) -> _ArrF64): Evaluates the 10-column colors output across n_zones stellar models in parallel on the persistent rayon worker pool, returning an (n_zones, 10) array.
  • py_colors_eval_sed ((teff: float, log_g: float, metallicity: float, r: float, d: float = 3.0857e19, method: str = "Hermite") -> tuple[_ArrF64, _ArrF64]): Evaluates the diluted stellar SED (wavelengths, fluxes) at (teff, log_g, metallicity, r, d) using method ("Hermite", "Linear", or "KNN").
  • py_colors_filter_curve ((idx: int) -> tuple[_ArrF64, _ArrF64, float, float, float]): Returns (wavelengths, transmission, vega_zp, ab_zp, st_zp) for Johnson filter idx (0..7).
  • py_colors_filter_names (() -> list[str]): Returns the ordered 7 Johnson filter names (["B", "I", "J", "M", "R", "U", "V"]).
  • py_colors_interpolate_array ((x_in: _ArrF64, y_in: _ArrF64, x_out: _ArrF64) -> _ArrF64): Resamples 1D curve (x_in, y_in) onto x_out via piecewise-linear interpolation with flat clamping outside [x_in[0], x_in[-1]].
  • py_colors_simpson_integration ((x: _ArrF64, y: _ArrF64) -> float): Evaluates composite non-uniform Simpson quadrature simpson_integration(x, y).
  • py_colors_trapezoidal_integration ((x: _ArrF64, y: _ArrF64) -> float): Evaluates composite trapezoidal quadrature trapezoidal_integration(x, y).