Skip to content

1D Stellar Structure & Evolution (flexmesa.star)

Frozen & Unverified JAX Star Helpers (#166)

The JAX star modules (jax_kernels, jax_winds_mix, jax_evolve, jax_diffusion_rot, jax_hydro_pulse, jax_rsp) are frozen and unverified (JAX_ENGINE_STATUS = "frozen-unverified-until-#143") until the canonical Safe Rust engine passes the upstream MESA 26.4.1 history harness (#143). No JAX stellar evolution step exists (StarModel wraps the Rust solver), and these helpers must not be modified before #143 passes.

The flexmesa.star subpackage implements the 1D Lagrangian stellar structure and evolution engine, bridging the Safe Rust core (crates/flexmesa-star) with frozen (float64) JAX structure, wind, mixing, hydrodynamic, and pulsation formula kernels. It provides:

  • Model Initialization & I/O: Zero-Age Main Sequence (StarModel.from_zams), the MESA 26.4.1 pre-main-sequence builder (StarModel.from_pre_ms, build_pre_ms_model), upstream ASCII .mod readers/writers (from_mod_file, from_mod_str, write_mod_file, to_mod_str), generated little-endian serde binary .photo checkpoints (FMPHOTO2 v30 via to_photo_bytes, try_write_photo_bytes, from_photo_bytes, load_photo_bytes, verify_photo_restart, saving primary/start/old arrays plus controls, job, rsp, energy-accounting scalars, and cumulative solver counters while skipping ephemeral MicrophysicsCache hit/miss counters so restarts remain bit-exact against uninterrupted runs; FlexMESA .photo bytes remain internal and are not binary-compatible with Fortran MESA photos/), and MESA 26.4.1 LOGS/history.data, LOGS/profileN.data (StarModel.to_profile_str), and LOGS/profiles.index column evaluators (including phase_of_evolution and upstream energy-conservation columns), incremental writers (StarLogsWriter, IncrementalHistoryWriter, run_inlist_stage_with_logs, run_test_suite_case_with_logs), and lossless ASCII readers (read_mesa_log_file, read_profiles_index_file), with HistoryRow.log_lh reporting hydrogen-burning luminosity (pp + cno) separately from helium, metal, and net nuclear burning (#159, #163). &controls and &star_job defaults match MESA 26.4.1 (#149, #151, #152, #155, #156, #159, #161, #299), using upstream scalar sentinels (1e36, 11.0, 12.0, 99.0, 3e7, 0.99, 0.0, -1, -111), explicit set_* / set_initial_* rotation booleans, and explicit &kap::zbase (-1 default without silent cross-namelist copying).
  • Coupled Henyey Solver & Time Evolution: Staggered 1D cell/face grids, 24-slot 3-cell stencil automatic differentiation (StarAdOrder1), coupled block-tridiagonal Newton-Raphson relaxation (solve_henyey, step_struct_burn_mix, evolve) porting MESA 26.4.1's do_solver_work, adjust_correction, Bdomain, scale_correction_norm, retry-dependent max_tries schedule, solver_itermin, high-\(T\) correction tolerance relaxation, check_after_converge, and sizequ/sizeB norms (#152, #177, #251, #252, #260), structured StarError::{StepFailure, Terminated} diagnostics (StepFailureInfo carrying zone, equation, paired variable, value, norms, and retry cause, with zero-retry fast-fail on InvalidInput/IoError/Terminated), in-place PrimaryStateBuffer rollback (restore_mesh_on_retry), 2-slot bit-exact MicrophysicsCache reuse (micro_cache_hits, micro_cache_misses), retry-proof solver/redo counters (total_num_solver_calls, num_redos, num_retries), optional JSONL step telemetry (FLEXMESA_STEP_TRACE / FLEXMESA_STEP_TRACE_FILE), MESA 26.4.1 end-of-step total-energy conservation accounting (eval_total_energy_integrals with Quad PE/KE, rotational, TDC, RSP2, and RSP terms, plus Phase 1 and Phase 2 update_step_energy_conservation for both dedt and eps_grav; #151), MESA 26.4.1 adaptive mesh planning, burning/composition gradient multipliers, conservative energy/momentum/angular-momentum remapping, and split_merge_amr (do_adjust_mesh, do_mesh_plan, set_mesh_function_data, get_gval_info, remap_onto_dq, remesh_split_merge, do_prune_mesh_surface; #153), MESA 26.4.1 3-region do_adjust_mass_step (compute_delta_m, get_xa_for_accretion, set_omega_adjust_mass, adjust_j_lost, smooth_outer_xa, and eps_mdot mass-change heating; #159), select_mdot_action rotational-wind redo/retry control (#139, #152), MESA 26.4.1 do_check_limits with when_to_stop_{rtol,atol} target-hitting redos (redo_limit), set_phase_of_evolution across all 13 stop_at_phase_* phases, exact time_sec max_age / graded num_adjusted_dt_steps_before_max_age approach (#159), sub-cell CoreMasses and PowerCategories reporting, and Söderlind-Wang H211 PI timestep control (timestep_controller, eval_h211_timestep_jax) with full timestep.f90 soft/hard limiters and min_timestep_limit / max_number_retries / redo_limit termination (#151, #152, #177, #253).
  • Advanced Stellar Physics (partial/unverified against MESA 26.4.1; #154, #157-#158): 16-set exponential and step convective overshooting (overshoot.rs) with 'none' short-circuiting, 3-cell log-\(H_P\) boundary interpolation, cospi mass ramp, and unsmoothed_brunt_B cutoff, verbatim predictive mixing (predictive_mix.rs) and convective premixing (conv_premix.rs), threshold-gated binomial brunt_B and gradL_composition_term smoothing (#155), Reimers/Blocker/Vink/Björklund/Nugis-Lamers/Dutch/'other' stellar winds (do_set_mdot, do_set_mdot_with_extras), super-Eddington wind (eval_super_eddington_wind with 0.5 * vesc2 and start-of-step prev_Ledd), single-star RLO wind (eval_rlo_wind), central-temperature/envelope/timestep wind gates, and surface-averaged v_div_v_crit rotational enhancement shared with flexmesa-binary (#159), Burgers multi-fluid atomic diffusion (do_element_diffusion_step, do_solve_diffusion, get_matrix_coeffs, paquette_coefficients, supporting Paquette et al. 1986 splines, Stanton & Murillo 2016, Caplan, Bauer, & Freeman 2022 OCP blending, Thoul/Hu and CGS Burgers solvers, backward-Euler BE_solve and block-tridiagonal Rosenbrock solve_with_isolve, and eps_diffusion / eps_WD_sedimentation heating; partly ported from MESA 26.4.1 in #156 with routine-level evidence in notes/audit/routine_table.md, while op_mono radiative levitation fails loudly pending C10), white-dwarf crystallization phase separation (do_phase_separation_step with Blouin et al. 2021a,b 'CO' and 'ONe' shifts, EOS phase > 0.9 front, constant-Pgas Skye updates, mix_outward, and eps_phase_separation; partly ported from MESA 26.4.1 in #156; routine-level evidence in notes/audit/routine_table.md), shellular Roche rotation, angular momentum mixing (solve_omega_mix), Spruit-Tayler magnetic dynamos (#158), coupled 3-cell StarAdOrder1 spherical HLLC Riemann u_flag hydrodynamics (riemann_ad) and Duffell (2016) Rayleigh-Taylor alpha_rti shock mixing (hydro_rti), RSP2 radial pulsation equations (#153), and GYRE/FGONG/OSC structure exporters (to_gyre_str, to_fgong_str, to_osc_str, plus flexmesa_star::pulse_fgong::get_fgong_data with 'T_tau' build_atm support for flexmesa-adipls).
  • Inlist & test_suite Runners: Recursive Fortran inlist bundle parsing (parse_inlist_bundle; full &controls/&star_job wiring tracked in #147), rn stage extraction (parse_rn_stages), internal linear oscillation stub and RSP LINA/envelope builders (eval_linear_oscillation_modes, eval_target_mode_frequency_and_growth, and eval_astero_scaling_dnu_numax_uhz pending GYRE/ADIPLS in #170/#171, eval_rsp_lina_modes, build_rsp_envelope_model), and the star/test_suite runner (run_test_suite_case, accepting optional caller-supplied test-side extras callbacks while canonical MESA 26.4.1 trajectory comparison lives in flexmesa.testing.history_compare).

For governing equations and numerical architecture, see 1D Stellar Structure, Henyey & Hydrodynamics and Convection, Diffusion, Rotation & Dynamos.


Quick Usage Example

import flexmesa.star as star

# Load a 1.0 Msun, Z = 0.02 Zero-Age Main Sequence model
model = star.StarModel.from_zams(initial_mass=1.0, initial_z=0.02)
model.eval_hydro_vars()
print(f"nz={model.nz}, Teff={model.teff:.1f} K, log10(T_c)={model.ln_t[-1] / 2.302585093:.4f}")

Package Overview (flexmesa.star)

flexmesa.star

1D stellar structure, ZAMS/pre-MS initialization, .mod/.photo I/O, zone/face microphysics, coupled Henyey solver, convective mixing/overshooting, stellar winds, adaptive remeshing, H211 timestep control, and the evolution driver (flexmesa.star).

Note

The JAX star helper kernels (jax_kernels, jax_winds_mix, jax_evolve, jax_diffusion_rot, jax_hydro_pulse, jax_rsp; JAX_ENGINE_STATUS == "frozen-unverified-until-#143") are frozen and unverified under #166 (DECISIONS #17) until the canonical Rust engine passes the #143 upstream MESA 26.4.1 history harness. No JAX stellar evolution step exists (StarModel wraps the Rust solver).


Stellar Model Driver (flexmesa.star.model)

flexmesa.star.model

Python and JAX hybrid stellar structure model (StarModel).

Wraps flexmesa._rust.RustStarModel (Tier A/B Safe Rust engine) and exposes both zero-copy NumPy arrays and pure @jax.jit staggered-grid, face-gradient, Henyey residual, diffusive mixing, and stellar wind kernels.

StarModel

Bases: StarModelArrays

1D Lagrangian stellar structure and evolution model (Star_Info).

Provides a unified Python/JAX interface backed by RustStarModel (flexmesa-star) for ZAMS interpolation, \(n=1.5\) pre-MS polytrope construction, ASCII .mod and binary .photo I/O, parallelized zone/face microphysics evaluation, convective boundary overshooting, operator-split and coupled structure-burn-mix solves, and stellar winds.

__init__

__init__(rust_model)

Initialize a StarModel from a RustStarModel instance.

copy

copy()

Return an independent copy of the full model state.

Unlike set_primary_state, the copy also carries the start-of-step, solver and mixing state (for example the TDC mlt_vc that a step starts from), so a step taken on each copy starts from the same state.

from_zams classmethod

from_zams(
    initial_mass=1.0,
    initial_z=0.02,
    initial_y=-1.0,
    eval_hydro=True,
)

Load a Zero-Age Main Sequence (ZAMS) model (get_zams_model).

from_pre_ms classmethod

from_pre_ms(
    initial_mass=1.0,
    initial_z=0.02,
    initial_y=-1.0,
    t_c=300000.0,
    d_log10_p=0.0,
    eval_hydro=True,
)

Construct an \(n = 1.5\) pre-main-sequence polytrope model.

from_mod_str classmethod

from_mod_str(text, eval_hydro=False, search_dir=None)

Parse an upstream MESA ASCII .mod string into a StarModel.

Parameters:

Name Type Description Default
text str

Contents of the .mod file.

required
eval_hydro bool

Evaluate hydro variables after loading.

False
search_dir str | Path | None

Directory searched first for the model's network file (for example a test case's own .net), before the built-in network bundle.

None

Returns:

Type Description
StarModel

The loaded StarModel.

from_mod_file classmethod

from_mod_file(path, eval_hydro=False)

Read an ASCII .mod file from disk into a StarModel.

The model's network is looked up first in the file's own directory, then in the built-in network bundle.

from_photo_bytes classmethod

from_photo_bytes(data, eval_hydro=False)

Restore a StarModel from binary .photo restart bytes.

to_mod_str

to_mod_str()

Serialize the model to an ASCII .mod string.

write_mod_file

write_mod_file(path)

Write the model to an ASCII .mod file on disk.

to_photo_bytes

to_photo_bytes()

Serialize the model to binary .photo checkpoint bytes.

eval_hydro_vars

eval_hydro_vars(skip_net=False, skip_net_jacobian=False)

Evaluate zone and face microphysics (set_hydro_vars).

set_phot_info

set_phot_info()

Set and return teff (K) from the photosphere (set_phot_info).

eval_hydro_vars does not set teff: upstream sets it in set_phot_info (star/private/star_utils.f90:1094-1125), called from do_report (star/private/report.f90:327).

set_primary_state

set_primary_state(lnd, ln_t, ln_r, lum, dq, xa)

Replace primary state arrays and synchronize staggered geometry.

save_start_values

save_start_values()

Snapshot current state arrays as start-of-step *_start values.

record_start_of_step_energy_integrals

record_start_of_step_energy_integrals()

Record the start-of-step energy integrals for a standalone solve.

The step driver records them after set_mdot (star/private/evolve.f90:427-453); call this after :meth:save_start_values and before :meth:eval_equations or :meth:solve_henyey outside the step driver.

save_old_values

save_old_values()

Snapshot current state arrays as previous-step *_old values.

set_evolve_controls

set_evolve_controls(
    mesh_delta_coeff=1.0, varcontrol_target=0.001
)

Set mesh_delta_coeff and varcontrol_target on controls.

eval_equations

eval_equations(include_chem=False)

Evaluate 1D Henyey residuals and block-tridiagonal Jacobian.

solve_henyey

solve_henyey(include_chem=False, use_bcyclic=True)

Execute a damped Newton-Raphson Henyey step for the current dt.

update_mixing

update_mixing(
    dt,
    overshoot_f=0.0,
    overshoot_f0=0.004,
    scheme="exponential",
)

Clean mixing glitches, locate boundaries, and apply overshooting.

Parameters:

Name Type Description Default
dt float

Timestep in seconds (s).

required
overshoot_f float

Overshoot decay scale f in units of H_P.

0.0
overshoot_f0 float

Anchor step distance f_0 into CZ in units of H_P.

0.004
scheme str

"exponential" or "step".

'exponential'

Returns:

Type Description
int

Number of detected convective boundaries (num_conv_boundaries).

eval_dxdt_mix

eval_dxdt_mix()

Evaluate mass-conserving species diffusion rate (nz, species).

solve_diffusion

solve_diffusion(dt)

Solve implicit backward-Euler species diffusion over dt (s).

run_omega_mix

run_omega_mix(dt, omega, nu_omega, n_substeps=4)

Solve substepped rotational angular momentum diffusion.

step_struct_burn_mix

step_struct_burn_mix(
    dt,
    op_split_burn=False,
    use_bcyclic=True,
    overshoot_f=0.0,
    overshoot_f0=0.004,
)

Execute a do_struct_burn_mix step (coupled or operator-split).

apply_wind_and_adjust_mass

apply_wind_and_adjust_mass(scheme='Dutch', eta=1.0, dt=0.0)

Evaluate wind mass-loss rate and optionally adjust 3-region mass.

adjust_mesh

adjust_mesh()

Run adaptive remeshing (do_adjust_mesh) -> (splits, merges).

pick_next_timestep

pick_next_timestep(
    max_timestep_factor=1.2, min_timestep_factor=0.5
)

Compute (dt_next, varcontrol, dt_limit_ratio) via H211 filter.

evolve_step

evolve_step(
    do_remesh=False, op_split_burn=False, use_bcyclic=True
)

Execute a single evolutionary step (star_evolve_step).

evolve

evolve(
    max_steps,
    do_remesh=False,
    op_split_burn=False,
    use_bcyclic=True,
    max_age=None,
)

Evolve the model for up to max_steps steps (star_evolve).

history_row

history_row()

Extract the current HistoryRow summary (history.data).

to_history_line

to_history_line()

Format the current state as a fixed-width history.data line.

to_profile_str

to_profile_str()

Format the current radial structure as a profile.data table.

eval_mesh_gval_jax

eval_mesh_gval_jax(mesh_delta_coeff=1.0)

Evaluate dimensionless mesh spacing variation g_k via JAX.

to_jax_state

to_jax_state()

Export primary structure variables as an immutable JaxStarState.

eval_face_mlt_jax

eval_face_mlt_jax()

Evaluate face temperature gradients, MLT, and Brunt N^2 via JAX.

eval_hydro_residuals_jax

eval_hydro_residuals_jax()

Evaluate the 4-equation hydrostatic residual array (nz, 4).

eval_winds_jax

eval_winds_jax(eta=1.0)

Evaluate differentiable wind mass-loss rates via JAX.

do_element_diffusion

do_element_diffusion(dt, scheme='stanton_murillo')

Run multi-species Burgers element diffusion over dt (s).

set_rotation_mixing_info

set_rotation_mixing_info()

Run MESA's set_rotation_mixing_info on the current model.

Returns:

Type Description
_ArrF64

(nz, 9) face values `(D_DSI, D_SH, D_SSI, D_ES, D_GSF, D_ST,

_ArrF64

nu_ST, B_phi, B_r): diffusivities incm^2 s^-1`, dynamo fields

_ArrF64

in Gauss. All zero when omega is zero everywhere.

Raises:

Type Description
ValueError

On the explicit-error paths of the Rust routine.

do_conv_premix

do_conv_premix(max_iters=10, avoid_fuel_increase=True)

Run iterative convective premixing (do_conv_premix).

add_predictive_mixing

add_predictive_mixing(
    ingested_mass_limit_coeff=0.1, superad_thresh=0.005
)

Apply predictive mixing at convective boundaries.

do_phase_separation

do_phase_separation(
    dt, gamma_crystallization=175.0, is_one_mixture=False
)

Execute white-dwarf crystallization phase separation over dt.

eval_riemann_profile

eval_riemann_profile(
    u_cell=None,
    u_old_cell=None,
    p_surf_bc=0.0,
    parallel=True,
)

Evaluate HLLC Riemann face states (nz, 7) and residuals (nz,).

build_pulse_points

build_pulse_points(
    add_center_point=True,
    add_double_points=False,
    grad_mu_threshold=1e99,
)

Build the (n_pts, 26) pulsation structure matrix.

to_gyre_str

to_gyre_str(
    add_center_point=True,
    keep_surface_point=False,
    add_atmosphere=False,
)

Export the model as GYRE text (star_export_pulse_data).

Parameters:

Name Type Description Default
add_center_point bool

Add a point at the centre.

True
keep_surface_point bool

Keep the outermost face.

False
add_atmosphere bool

Attach an atmosphere (not ported; raises).

False

Returns:

Type Description
str

The file text, as MESA 26.4.1's pulse_gyre.f90 writes it.

Raises:

Type Description
ValueError

Where upstream stops, or for a path not ported.

to_fgong_str

to_fgong_str(
    add_center_point=True,
    keep_surface_point=False,
    add_atmosphere=False,
)

Export the model as FGONG text (star_export_pulse_data).

Parameters:

Name Type Description Default
add_center_point bool

Add a point at the centre.

True
keep_surface_point bool

Keep the outermost face.

False
add_atmosphere bool

Attach an atmosphere (not ported; raises).

False

Returns:

Type Description
str

The file text, as MESA 26.4.1's pulse_fgong.f90 writes it.

Raises:

Type Description
ValueError

Where upstream stops, or for a path not ported.

to_osc_str

to_osc_str(
    add_center_point=True,
    keep_surface_point=False,
    add_atmosphere=False,
)

Export the model as OSC text (star_export_pulse_data).

Parameters:

Name Type Description Default
add_center_point bool

Add a point at the centre.

True
keep_surface_point bool

Keep the outermost face.

False
add_atmosphere bool

Attach an atmosphere (not ported; raises).

False

Returns:

Type Description
str

The file text, as MESA 26.4.1's pulse_osc.f90 writes it.

Raises:

Type Description
ValueError

Where upstream stops, or for a path not ported.

to_gsm_bytes

to_gsm_bytes(add_center_point=True)

Export the model in GYRE GSM v110 format (pulse_gsm.f90).

to_saio_str

to_saio_str(add_center_point=True)

Export the model in SAIO ASCII format (pulse_saio.f90).

to_cafein_str

to_cafein_str(add_center_point=True)

Export the model in CAFEIN ASCII format (pulse_cafein.f90).

to_gr1d_str

to_gr1d_str(add_center_point=True)

Export the model in GR1D ASCII format (pulse_gr1d.f90).

to_pulse_str

to_pulse_str(fmt, add_center_point=True)

Export the model in pulsation format fmt (pulse.f90).

to_stella_pair

to_stella_pair()

Export the model as a STELLA (hyd, abn) pair (stella_io).

verify_photo_restart

verify_photo_restart(n_steps=1)

Verify bit-identical .photo restart parity over n_steps steps.

yrs_for_init_timestep

yrs_for_init_timestep(m_msun)

Compute the initial ZAMS timestep in years (yrs_for_init_timestep).

interp_q

interp_q(dq1, v1, dq2)

Interpolate profile v1 from Lagrangian grid dq1 onto dq2.


Structure Reports & State Containers (flexmesa.star._arrays)

flexmesa.star._arrays

Zero-copy NumPy array property mixin (StarModelArrays) and result types.

JaxStarState dataclass

Immutable JAX PyTree snapshot of a 1D stellar structure model.

Attributes:

Name Type Description
lnd Array

Cell natural log density of shape (nz,) (ln(g cm^-3)).

ln_t Array

Cell natural log temperature of shape (nz,) (ln(K)).

ln_r Array

Face natural log radius of shape (nz,) (ln(cm)).

lum Array

Face luminosity of shape (nz,) (erg s^-1).

dq Array

Cell relative mass fractions of shape (nz,).

xa Array

Cell species mass fractions of shape (nz, species).

mstar float

Total stellar mass in grams (g).

HenyeySystemResult dataclass

Assembled 1D Henyey residual vector and block-tridiagonal Jacobian.

Attributes:

Name Type Description
equ _ArrF64

Residual array of shape (nz, nvar).

lblk _ArrF64

Sub-diagonal Jacobian blocks of shape (nz, nvar, nvar).

dblk _ArrF64

Diagonal Jacobian blocks of shape (nz, nvar, nvar).

ublk _ArrF64

Super-diagonal Jacobian blocks of shape (nz, nvar, nvar).

x_scale _ArrF64

Variable scaling array of shape (nz, nvar).

HenyeySolverReport dataclass

Convergence report returned by StarModel.solve_henyey.

Attributes:

Name Type Description
converged bool

Whether convergence tolerances were satisfied.

iterations int

Number of Newton-Raphson iterations executed.

residual_norm float

Mean absolute residual sum(|equ|) / (nz * nvar).

max_residual float

Maximum absolute residual max(|equ|).

correction_norm float

Mean absolute scaled correction.

max_correction float

Maximum absolute scaled correction.

EvolveStepReport dataclass

Diagnostic summary returned by StarModel.evolve_step.

Attributes:

Name Type Description
model_number int

Evolutionary step counter after completion.

star_age float

Stellar age in years (yr).

dt float

Timestep taken in seconds (s).

dt_next float

Proposed next timestep in seconds (s).

iterations int

Number of Henyey Newton-Raphson iterations.

retries int

Number of step retries (dt halvings).

num_splits int

Number of zone splits during remeshing.

num_merges int

Number of zone merges during remeshing.

varcontrol float

Measured normalized structural variation.

converged bool

Whether the step converged.

HistoryRow dataclass

Scalar evolutionary summary corresponding to a history.data line.

StarModelArrays

Mixin exposing scalar and 1D/2D NumPy array properties on StarModel.

nz property

nz

Number of Lagrangian zones (nz).

species property

species

Number of active nuclear species (species).

model_number property

model_number

Current evolutionary step number.

star_age property

star_age

Stellar age in years (yr).

dt property writable

dt

Current timestep in seconds (s).

dt_next property

dt_next

Proposed next timestep in seconds (s).

dt_old property

dt_old

Previous step timestep in seconds (s).

mstar property

mstar

Total stellar mass in grams (g).

teff property

teff

Surface effective temperature in Kelvin (K).

r_center property

r_center

Inner core radius in centimeters (cm).

l_center property

l_center

Inner core luminosity in erg s^-1.

m_center property

m_center

Inner core mass in grams (g).

v_center property

v_center

Inner core boundary velocity in cm s^-1.

total_num_solver_iterations property

total_num_solver_iterations

Cumulative Henyey Newton iterations across the run.

total_num_solver_calls property

total_num_solver_calls

Cumulative Henyey solver invocations across the run.

num_retries property

num_retries

Cumulative step retries preserved across rollbacks.

num_redos property

num_redos

Cumulative wind/implicit-step redos preserved across rollbacks.

micro_cache_hits property

micro_cache_hits

Cumulative microphysics cache hits in set_hydro_vars.

micro_cache_misses property

micro_cache_misses

Cumulative microphysics cache misses in set_hydro_vars.

ln_peos_surf property

ln_peos_surf

Surface natural log total pressure from atmosphere BC.

ln_t_surf property

ln_t_surf

Surface natural log temperature from atmosphere BC.

iso_names property

iso_names

Active isotope names in zone order (len = species).

chem_id property

chem_id

Active 1-based chem_id indices (len = species).

lnd property

lnd

Cell natural log density of shape (nz,) (ln(g cm^-3)).

lnd_start property

lnd_start

Start-of-step cell natural log density of shape (nz,).

ln_t property

ln_t

Cell natural log temperature of shape (nz,) (ln(K)).

ln_r property

ln_r

Face natural log radius of shape (nz,) (ln(cm)).

ln_r_start property

ln_r_start

Start-of-step face natural log radius of shape (nz,) (ln(cm)).

lum property

lum

Face luminosity of shape (nz,) (erg s^-1).

dq property

dq

Cell relative mass fraction of shape (nz,).

q property

q

Face enclosed mass fraction of shape (nz,).

xq property

xq

Face exterior mass fraction 1 - q of shape (nz,).

m property

m

Face enclosed mass of shape (nz,) (g).

dm property

dm

Cell mass of shape (nz,) (g).

dm_bar property

dm_bar

Face control-volume mass of shape (nz,) (g).

r property

r

Face radius of shape (nz,) (cm).

rmid property

rmid

Cell volumetric mid-radius of shape (nz,) (cm).

grav property

grav

Face gravitational acceleration of shape (nz,) (cm s^-2).

xa property

xa

Cell species mass fractions of shape (nz, species).

xh_mass property

xh_mass

Cell hydrogen mass fraction X of shape (nz,).

yhe_mass property

yhe_mass

Cell helium mass fraction Y of shape (nz,).

rho property

rho

Cell mass density of shape (nz,) (g cm^-3).

t property

t

Cell temperature of shape (nz,) (K).

pgas property

pgas

Cell gas pressure of shape (nz,) (dyn cm^-2).

prad property

prad

Cell radiation pressure of shape (nz,) (dyn cm^-2).

peos property

peos

Cell total pressure of shape (nz,) (dyn cm^-2).

peos_start property

peos_start

Start-of-step cell total pressure of shape (nz,) (dyn cm^-2).

ln_peos property

ln_peos

Cell natural log total pressure of shape (nz,).

energy property

energy

Cell specific internal energy of shape (nz,) (erg g^-1).

energy_start property

energy_start

Start-of-step cell specific internal energy of shape (nz,).

entropy property

entropy

Cell specific entropy of shape (nz,) (erg g^-1 K^-1).

grada property

grada

Cell adiabatic temperature gradient of shape (nz,).

cp property

cp

Cell specific heat C_P of shape (nz,) (erg g^-1 K^-1).

cv property

cv

Cell specific heat C_V of shape (nz,) (erg g^-1 K^-1).

chi_rho property

chi_rho

Cell chi_rho = (d ln P / d ln rho)_T of shape (nz,).

chi_t property

chi_t

Cell chi_T = (d ln P / d ln T)_rho of shape (nz,).

gamma1 property

gamma1

Cell adiabatic exponent Gamma_1 of shape (nz,).

eta property

eta

Cell electron degeneracy parameter of shape (nz,).

mu property

mu

Cell mean molecular weight of shape (nz,).

csound property

csound

Cell adiabatic sound speed of shape (nz,) (cm s^-1).

opacity property

opacity

Cell Rosseland mean opacity of shape (nz,) (cm^2 g^-1).

tau property

tau

Face optical depth of shape (nz,).

non_nuc_neu property

non_nuc_neu

Cell thermal neutrino energy loss rate (erg g^-1 s^-1).

non_nuc_neu_start property

non_nuc_neu_start

Start-of-step cell thermal neutrino loss rate (erg g^-1 s^-1).

eps_nuc property

eps_nuc

Cell nuclear energy generation rate of shape (nz,).

eps_grav property

eps_grav

Cell gravitational energy rate of shape (nz,) (erg g^-1 s^-1).

eps_mdot property

eps_mdot

Cell mass-change heating rate of shape (nz,) (erg g^-1 s^-1).

dxdt_nuc property

dxdt_nuc

Cell nuclear abundance rates of shape (nz, species) (s^-1).

gradt property

gradt

Face actual temperature gradient grad_T of shape (nz,).

gradr property

gradr

Face radiative temperature gradient grad_rad of shape (nz,).

gradl property

gradl

Face Ledoux temperature gradient grad_L of shape (nz,).

scale_height property

scale_height

Face pressure scale height H_P of shape (nz,) (cm).

mlt_vc property

mlt_vc

Face convective velocity of shape (nz,) (cm s^-1).

mlt_d property

mlt_d

Face MLT diffusion coefficient of shape (nz,) (cm^2 s^-1).

mlt_cdc property

mlt_cdc

Face convective conductivity of shape (nz,).

d_mix property

d_mix

Face diffusion coefficient D_mix of shape (nz,) (cm^2 s^-1).

conv_vel property

conv_vel

Face convective velocity after overshooting of shape (nz,).

sig property

sig

Face Lagrangian coupling sig of shape (nz,) (g s^-1).

omega property

omega

Face rotational angular velocity of shape (nz,) (rad s^-1).

j_rot property

j_rot

Face specific angular momentum of shape (nz,) (cm^2 s^-1).

brunt_b property

brunt_b

Face composition gradient term B of shape (nz,).

brunt_n2 property

brunt_n2

Face Brunt-Väisälä frequency N^2 of shape (nz,) (s^-2).

mixing_type property

mixing_type

Face integer mixing classification codes of shape (nz,).


Differentiable Structure & Henyey Kernels (flexmesa.star.jax_kernels)

flexmesa.star.jax_kernels

Differentiable JAX (float64) staggered-grid and face-microphysics kernels.

Provides pure branchless @jax.jit kernels for staggered cell/face geometry, mass-weighted face interpolation (get_face_weights), optical depth integration (get_tau), Brunt-Väisälä composition and buoyancy frequency (do_brunt_B, do_brunt_N2), and Cox & Giuli (1968) Mixing-Length Theory (set_mlt_vars) across all nz stellar zones.

compute_staggered_grid_jax

compute_staggered_grid_jax(
    dq,
    ln_r,
    mstar,
    m_center=0.0,
    r_center=0.0,
    cgrav=_G_CGS,
)

Compute staggered Lagrangian grid quantities across nz zones.

Parameters:

Name Type Description Default
dq Array

Cell relative mass fractions of shape (nz,) (dimensionless).

required
ln_r Array

Face natural log radius of shape (nz,) (ln(cm)).

required
mstar float | Array

Total stellar mass in grams (g).

required
m_center float | Array

Inner core mass in grams (g).

0.0
r_center float | Array

Inner core radius in centimeters (cm).

0.0
cgrav float | Array

Gravitational constant in cm^3 g^-1 s^-2.

_G_CGS

Returns:

Type Description
dict[str, Array]

Dictionary with keys `("dq", "q", "xq", "dm", "dm_bar", "m", "r",

dict[str, Array]

"rmid", "grav"), each of shape(nz,)`.

face_weights_jax

face_weights_jax(dq)

Compute mass-weighted face interpolation coefficients (alfa, beta).

At face k > 0, f_face[k] = alfa[k] * f[k] + beta[k] * f[k - 1], with alfa[k] = dq[k - 1] / (dq[k - 1] + dq[k]) and beta[k] = 1 - alfa[k]. At surface face k = 0, alfa[0] = 1.0, beta[0] = 0.0.

Parameters:

Name Type Description Default
dq Array

Cell relative mass fractions of shape (nz,) (dimensionless).

required

Returns:

Type Description
tuple[Array, Array]

Tuple (alfa, beta) of shape (nz,).

interp_cell_to_face_jax

interp_cell_to_face_jax(dq, cell_val)

Interpolate a cell-centered array of shape (nz,) to faces (nz,).

Parameters:

Name Type Description Default
dq Array

Cell relative mass fractions of shape (nz,).

required
cell_val Array

Cell-centered quantity of shape (nz,).

required

Returns:

Type Description
Array

Face-centered array of shape (nz,).

eval_optical_depth_jax

eval_optical_depth_jax(
    dm, rmid, opacity, tau_surf=2.0 / 3.0
)

Integrate optical depth tau inward from the surface across nz zones.

Parameters:

Name Type Description Default
dm Array

Cell masses of shape (nz,) (g).

required
rmid Array

Cell mid-radii of shape (nz,) (cm).

required
opacity Array

Cell Rosseland mean opacities of shape (nz,) (cm^2 g^-1).

required
tau_surf float | Array

Surface optical depth tau[0] (dimensionless).

2.0 / 3.0

Returns:

Type Description
Array

Face optical depth tau of shape (nz,).

eval_face_mlt_and_brunt_jax

eval_face_mlt_and_brunt_jax(
    dq,
    ln_r,
    lum,
    m_grav,
    rho,
    t,
    peos,
    ln_peos,
    grada,
    cp,
    chi_rho,
    chi_t,
    mu,
    opacity,
    tau_0=2.0 / 3.0,
    mixing_length_alpha=2.0,
    use_ledoux_criterion=False,
    cgrav=_G_CGS,
    brunt_b=None,
)

Evaluate face temperature gradients, Cox MLT, and Brunt-Väisälä N^2.

Parameters:

Name Type Description Default
dq Array

Cell relative mass fractions of shape (nz,).

required
ln_r Array

Face natural log radius of shape (nz,) (ln(cm)).

required
lum Array

Face luminosity of shape (nz,) (erg s^-1).

required
m_grav Array

Face enclosed gravitational mass of shape (nz,) (g).

required
rho Array

Cell density of shape (nz,) (g cm^-3).

required
t Array

Cell temperature of shape (nz,) (K).

required
peos Array

Cell total pressure of shape (nz,) (dyn cm^-2).

required
ln_peos Array

Cell natural log pressure of shape (nz,).

required
grada Array

Cell adiabatic temperature gradient of shape (nz,).

required
cp Array

Cell specific heat at constant pressure of shape (nz,).

required
chi_rho Array

Cell dlnP/dlnRho at constant T of shape (nz,).

required
chi_t Array

Cell dlnP/dlnT at constant Rho of shape (nz,).

required
mu Array

Cell mean molecular weight of shape (nz,).

required
opacity Array

Cell opacity of shape (nz,) (cm^2 g^-1).

required
tau_0 float | Array

Surface optical depth tau[0].

2.0 / 3.0
mixing_length_alpha float

Mixing-length parameter alpha_MLT.

2.0
use_ledoux_criterion bool

Whether to include brunt_B in gradL.

False
cgrav float | Array

Gravitational constant (cm^3 g^-1 s^-2).

_G_CGS
brunt_b Array | None

Optional precomputed Brunt composition term of shape (nz,).

None

Returns:

Type Description
dict[str, Array]

Dictionary containing `("scale_height", "gradr", "gradl", "gradt",

dict[str, Array]

"mlt_vc", "mlt_d", "mlt_cdc", "brunt_b", "brunt_n2")of shape(nz,)`.

eval_hydro_residuals_jax

eval_hydro_residuals_jax(
    dq,
    dm,
    dm_bar,
    m_grav,
    lnd,
    ln_t,
    ln_r,
    lum,
    lnd_start,
    ln_peos,
    ln_e,
    energy_start,
    gradt,
    eps_nuc,
    non_nuc_neu,
    eps_mdot,
    ln_peos_surf,
    ln_t_surf,
    dt,
    r_center=0.0,
    l_center=0.0,
    cgrav=_G_CGS,
    non_nuc_neu_start=None,
    dedt_eqn_r_scale=100000000.0,
    use_momentum_outer_bc=False,
    ln_r_start=None,
    m_center=0.0,
    v_center=0.0,
    peos_start=None,
)

Evaluate the 4-equation hydrostatic Henyey residual array (nz, 4).

Computes the dimensionless residual slots (i_equ_l, i_dv_dt, i_dlnd_dt, i_dlne_dt) across all nz zones in pure differentiable JAX (float64), matching eval_henyey_equations in flexmesa-star.

Parameters:

Name Type Description Default
dq Array

Cell relative mass fractions of shape (nz,).

required
dm Array

Cell masses of shape (nz,) (g).

required
dm_bar Array

Face control-volume masses of shape (nz,) (g).

required
m_grav Array

Face enclosed gravitational masses of shape (nz,) (g).

required
lnd Array

Cell natural log densities of shape (nz,) (ln(g cm^-3)).

required
ln_t Array

Cell natural log temperatures of shape (nz,) (ln(K)).

required
ln_r Array

Face natural log radii of shape (nz,) (ln(cm)).

required
lum Array

Face luminosities of shape (nz,) (erg s^-1).

required
lnd_start Array

Start-of-step cell lnd of shape (nz,).

required
ln_peos Array

Cell natural log total pressure of shape (nz,).

required
ln_e Array

Cell natural log specific internal energy of shape (nz,).

required
energy_start Array

Start-of-step specific internal energy of shape (nz,).

required
gradt Array

Face actual temperature gradient of shape (nz,).

required
eps_nuc Array

Cell nuclear energy generation rate of shape (nz,).

required
non_nuc_neu Array

Cell thermal neutrino loss rate of shape (nz,).

required
eps_mdot Array

Cell mass-adjustment energy rate of shape (nz,).

required
ln_peos_surf float | Array

Surface natural log pressure from atmosphere BC.

required
ln_t_surf float | Array

Surface natural log temperature from atmosphere BC.

required
dt float | Array

Timestep in seconds (s).

required
r_center float | Array

Inner core radius in centimeters (cm).

0.0
l_center float | Array

Inner core luminosity in erg s^-1.

0.0
cgrav float | Array

Gravitational constant (cm^3 g^-1 s^-2).

_G_CGS
non_nuc_neu_start Array | None

Optional start-of-step cell thermal neutrino loss rate of shape (nz,) (erg g^-1 s^-1) for trapezoidal time-centering 0.5 * (non_nuc_neu_start + non_nuc_neu).

None
dedt_eqn_r_scale float | Array

Energy equation relative cell-fraction scale cap (1.0e8 default; <= 0 disables cell-fraction capping).

100000000.0
use_momentum_outer_bc bool | Array

When True, zeroes the half-cell hydrostatic surface pressure offset dp_0 (hydro_eqns.f90:479).

False
ln_r_start Array | None

Optional start-of-step face ln(r) of shape (nz,) for spherical face mechanical work and gravitational potential rates.

None
m_center float | Array

Inner core mass in grams (g).

0.0
v_center float | Array

Inner core boundary velocity in cm s^-1.

0.0
peos_start Array | None

Optional start-of-step cell pressure of shape (nz,) (dyn cm^-2).

None

Returns:

Type Description
Array

Dimensionless residual matrix equ of shape (nz, 4).

solve_henyey_linear_jax

solve_henyey_linear_jax(
    lblk, dblk, ublk, equ, solver_mode="pcr"
)

Solve the scaled Henyey linear system J dx_scaled = -equ.

Parameters:

Name Type Description Default
lblk Array

Sub-diagonal blocks of shape (nz, nvar, nvar).

required
dblk Array

Diagonal blocks of shape (nz, nvar, nvar).

required
ublk Array

Super-diagonal blocks of shape (nz, nvar, nvar).

required
equ Array

Residual vector of shape (nz, nvar).

required
solver_mode str

"pcr" for native JAX Parallel Cyclic Reduction or "rust_ffi" for the jax.custom_vjp Safe Rust bcyclic FFI.

'pcr'

Returns:

Type Description
Array

Scaled Newton step dx_scaled of shape (nz, nvar).

Raises:

Type Description
ValueError

If solver_mode is not "pcr" or "rust_ffi".


Winds & Convective Mixing Kernels (flexmesa.star.jax_winds_mix)

flexmesa.star.jax_winds_mix

Differentiable JAX kernels for stellar winds, Lagrangian mixing coupling (sig), and conservative species diffusion (flexmesa.star, Wave 4.3).

eval_convection_sigmas_jax

eval_convection_sigmas_jax(
    r,
    rho,
    dq,
    d_mix,
    xmstar,
    dt,
    mix_factor=1.0,
    sig_term_limit=10000000000.0,
)

Compute Lagrangian face mixing coupling factors sig ((nz,)).

Parameters:

Name Type Description Default
r Array

Face radii of shape (nz,) (cm).

required
rho Array

Cell densities of shape (nz,) (g cm^-3).

required
dq Array

Cell relative mass fractions of shape (nz,).

required
d_mix Array

Face diffusion coefficients of shape (nz,) (cm^2 s^-1).

required
xmstar float

Enveloped mass M_* - M_center in grams (g).

required
dt float

Timestep in seconds (s).

required
mix_factor float

Global diffusivity multiplier (1.0 default).

1.0
sig_term_limit float

Stability limiter factor (1e10 default).

10000000000.0

Returns:

Type Description
Array

Face coupling factors sig of shape (nz,) (g s^-1, sig[0] = 0).

eval_dxdt_mix_jax

eval_dxdt_mix_jax(xa, sig, dm)

Evaluate explicit mass-conserving diffusive species mixing rates.

Parameters:

Name Type Description Default
xa Array

Cell species mass fractions of shape (nz, species).

required
sig Array

Face Lagrangian coupling factors of shape (nz,) (g s^-1).

required
dm Array

Cell masses of shape (nz,) (g).

required

Returns:

Type Description
Array

Diffusive rates (dX/dt)_mix of shape (nz, species) (s^-1).

eval_winds_jax

eval_winds_jax(
    l_surf,
    m_surf,
    t_surf,
    x_surf=0.7,
    y_surf=0.28,
    z_surf=0.02,
    eta=1.0,
)

Evaluate differentiable wind mass-loss rates (M_sun yr^-1, g s^-1).

Parameters:

Name Type Description Default
l_surf float | Array

Surface luminosity in erg s^-1, scalar or shape (*batch,).

required
m_surf float | Array

Stellar mass in grams (g), scalar or shape (*batch,).

required
t_surf float | Array

Effective temperature in Kelvin (K), scalar or shape (*batch,).

required
x_surf float | Array

Surface hydrogen mass fraction X, scalar or shape (*batch,).

0.7
y_surf float | Array

Surface helium mass fraction Y, scalar or shape (*batch,).

0.28
z_surf float | Array

Surface metal mass fraction Z, scalar or shape (*batch,).

0.02
eta float

Wind scaling multiplier (1.0 default).

1.0

Returns:

Type Description
dict[str, Array]

Dictionary of arrays with shape (*batch,) (matching broadcast

dict[str, Array]

inputs) containing w_reimers, w_blocker, w_vink, w_bjorklund,

dict[str, Array]

w_nieuwenhuijzen, w_de_jager, w_van_loon, w_dutch in

dict[str, Array]

M_sun yr^-1 and mdot_dutch in g s^-1.


Mesh & Timestep Control Kernels (flexmesa.star.jax_evolve)

flexmesa.star.jax_evolve

Differentiable JAX kernels for adaptive mesh spacing variation (g_k), structural variation (varcontrol), and the Söderlind & Wang (2006) H211PI digital timestep filter (flexmesa.star, Wave 4.4).

eval_mesh_gval_jax

eval_mesh_gval_jax(
    ln_peos,
    ln_t,
    mesh_delta_coeff=1.0,
    p_function_weight=40.0,
    t_function1_weight=110.0,
)

Compute dimensionless mesh variation indicator g_k ((nz,)).

Parameters:

Name Type Description Default
ln_peos Array

Cell logarithmic pressures of shape (nz,).

required
ln_t Array

Cell logarithmic temperatures of shape (nz,).

required
mesh_delta_coeff float

Global mesh spacing factor (1.0 default).

1.0
p_function_weight float

Pressure spacing weight (40.0 default).

40.0
t_function1_weight float

Temperature spacing weight (110.0 default).

110.0

Returns:

Type Description
Array

Dimensionless mesh variation array gval of shape (nz,).

eval_varcontrol_jax

eval_varcontrol_jax(
    lnd,
    ln_t,
    ln_r,
    lum,
    lnd_old,
    ln_t_old,
    ln_r_old,
    lum_old,
)

Evaluate normalized structural variation varcontrol (timestep.f90).

Parameters:

Name Type Description Default
lnd Array

Current cell log-densities of shape (nz,).

required
ln_t Array

Current cell log-temperatures of shape (nz,).

required
ln_r Array

Current face log-radii of shape (nz,).

required
lum Array

Current face luminosities of shape (nz,) (erg s^-1).

required
lnd_old Array

Previous step cell log-densities of shape (nz,).

required
ln_t_old Array

Previous step cell log-temperatures of shape (nz,).

required
ln_r_old Array

Previous step face log-radii of shape (nz,).

required
lum_old Array

Previous step face luminosities of shape (nz,) (erg s^-1).

required

Returns:

Type Description
Array

Scalar JAX array holding varcontrol.

eval_h211_timestep_jax

eval_h211_timestep_jax(
    dt,
    dt_old,
    dt_limit_ratio,
    dt_limit_ratio_old=1.0,
    max_timestep_factor=1.2,
    min_timestep_factor=0.5,
)

Evaluate Söderlind & Wang (2006) H211PI next timestep dt_next (s).

Parameters:

Name Type Description Default
dt float | Array

Current timestep in seconds (s).

required
dt_old float | Array

Previous timestep in seconds (s).

required
dt_limit_ratio float | Array

Current step variation ratio w_n.

required
dt_limit_ratio_old float | Array

Previous step variation ratio w_{n-1}.

1.0
max_timestep_factor float

Upper multiplier cap (1.2 default).

1.2
min_timestep_factor float

Lower multiplier floor (0.5 default).

0.5

Returns:

Type Description
Array

Proposed next timestep dt_next in seconds (s).


Diffusion, Phase Separation & Rotation Kernels (flexmesa.star.jax_diffusion_rot)

flexmesa.star.jax_diffusion_rot

Differentiable JAX kernels for Wave 5.1 stellar diffusion, shellular rotation, Spruit-Tayler magnetic dynamo, and crystallization phase separation.

eval_rotation_fp_ft_jax

eval_rotation_fp_ft_jax(
    w_div_w_crit, fp_min=0.75, ft_min=0.95
)

Evaluates Fabry et al. (2022) / Paxton et al. (2019) Roche rotational distortion polynomials (f_P, f_T, i_rot / r^2).

Parameters:

Name Type Description Default
w_div_w_crit Array

Dimensionless angular velocity Omega / Omega_crit, shape (*batch,) (dimensionless).

required
fp_min float

Floor on f_P (dimensionless).

0.75
ft_min float

Floor on f_T (dimensionless).

0.95

Returns:

Type Description
tuple[Array, Array, Array]

Tuple (f_P, f_T, i_rot_over_r2) of shape (*batch,).

eval_omega_crit_jax

eval_omega_crit_jax(
    cgrav, m_grav, r_polar, lum, opacity, max_gamma_edd=0.99
)

Evaluates the critical Roche angular velocity Omega_crit (rad/s).

Parameters:

Name Type Description Default
cgrav Array

Local gravitational constant (cm^3 g^-1 s^-2).

required
m_grav Array

Enclosed gravitational mass (g).

required
r_polar Array

Polar/spherical radius (cm).

required
lum Array

Radiative luminosity (erg/s).

required
opacity Array

Rosseland mean opacity (cm^2/g).

required
max_gamma_edd float

Cap on Eddington factor Gamma_Edd.

0.99

Returns:

Type Description
Array

Critical angular velocity Omega_crit in rad/s.

eval_rotational_mixing_zone_jax

eval_rotational_mixing_zone_jax(
    r,
    hp,
    grav,
    rho,
    t,
    cp,
    opacity,
    chi_t,
    chi_rho,
    grada,
    gradt,
    brunt_n2_t,
    brunt_n2_mu,
    omega,
    dln_omega_dln_r,
    abar,
    zbar,
)

Evaluates the five hydrodynamic rotational instabilities (DSI, SH, SSI, ES, GSF) and Spruit-Tayler (2002) magnetic dynamo in JAX.

Parameters:

Name Type Description Default
r Array

Shell radius (cm).

required
hp Array

Pressure scale height (cm).

required
grav Array

Effective gravity (cm/s^2).

required
rho Array

Mass density (g/cm^3).

required
t Array

Temperature (K).

required
cp Array

Isobaric specific heat (erg g^-1 K^-1).

required
opacity Array

Rosseland mean opacity (cm^2/g).

required
chi_t Array

(d ln P / d ln T)_rho (dimensionless).

required
chi_rho Array

(d ln P / d ln rho)_T (dimensionless).

required
grada Array

Adiabatic temperature gradient (dimensionless).

required
gradt Array

Actual temperature gradient (dimensionless).

required
brunt_n2_t Array

Thermal Brunt-Vaisala component N_T^2 (s^-2).

required
brunt_n2_mu Array

Composition Brunt-Vaisala component N_mu^2 (s^-2).

required
omega Array

Angular velocity Omega (rad/s).

required
dln_omega_dln_r Array

Dimensionless shear d ln Omega / d ln r.

required
abar Array

Mean atomic mass number A_bar.

required
zbar Array

Mean ionic charge Z_bar.

required

Returns:

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

Tuple (d_dsi, d_sh, d_ssi, d_es, d_gsf, d_st, nu_st, b_phi, b_r).

eval_caplan_ocp_dstar_jax

eval_caplan_ocp_dstar_jax(gamma_i, kappa)

Evaluates the Caplan, Bauer & Freeman (2022) strong-coupling OCP dimensionless self-diffusion coefficient D*(Gamma, kappa).

Parameters:

Name Type Description Default
gamma_i Array

Coulomb coupling parameter Gamma_i (dimensionless).

required
kappa Array

Screening parameter a_i / lambda_TF (dimensionless).

required

Returns:

Type Description
Array

Dimensionless self-diffusion coefficient D*.

eval_burgers_velocities_jax

eval_burgers_velocities_jax(
    a, z, x_mass, rho, t, dlnt_dr, g_grav
)

Solves the full-rank (2m + 2) x (2m + 2) Thoul, Bahcall & Loeb (1994) multi-species Burgers system in JAX with Stanton & Murillo (2016) Yukawa collision integrals.

Parameters:

Name Type Description Default
a Array

Atomic mass numbers A_i, shape (nc,).

required
z Array

Ionic charges Z_i, shape (nc,).

required
x_mass Array

Species mass fractions X_i, shape (nc,).

required
rho Array

Mass density (g/cm^3).

required
t Array

Temperature (K).

required
dlnt_dr Array

Temperature gradient d ln T / dr (cm^-1).

required
g_grav Array

Gravitational acceleration (cm/s^2).

required

Returns:

Type Description
Array

Tuple (v_gt, d_self, ee_force) where v_gt and d_self have

Array

shape (nc,).

eval_phase_separation_shift_jax

eval_phase_separation_shift_jax(
    x_heavy, is_one_mixture=False
)

Evaluates the Blouin et al. (2020, 2021) 5th-order polynomial solid-liquid distillation shift Delta x_heavy in JAX.

Parameters:

Name Type Description Default
x_heavy Array

Mass fraction of the heavier ion species (O16 or Ne20).

required
is_one_mixture bool

False for C/O mixture, True for O/Ne mixture.

False

Returns:

Type Description
Array

Solid-minus-liquid mass-fraction enrichment Delta x_heavy.


HLLC Hydrodynamics & Pulsation Kernels (flexmesa.star.jax_hydro_pulse)

flexmesa.star.jax_hydro_pulse

Branchless @jax.jit kernels for Wave 5.2: HLLC Riemann hydrodynamics, Dziembowski pulsation variables, STELLA Sobolev optical depths, and GYRE / ADIPLS BVP wrappers (hydro_riemann.f90, hydro_momentum.f90, pulse_utils.f90, and parse_swd_vel_feii.f90).

RSP2 time-dependent turbulent convection kernels are defined in flexmesa.star.jax_rsp and re-exported here for backwards compatibility.

eval_hllc_face_jax

eval_hllc_face_jax(
    p_l,
    rho_l,
    cs_l,
    u_l,
    dm_l,
    p_r,
    rho_r,
    cs_r,
    u_r,
    dm_r,
    r_face,
    m_grav_face,
    cgrav_face,
)

Evaluate the well-balanced Lagrangian HLLC Riemann state at interior faces (do1_Riemann_Types in star/private/hydro_riemann.f90).

Parameters:

Name Type Description Default
p_l, rho_l, cs_l, u_l, dm_l

Left (inner) cell pressure (dyn cm^-2), density (g cm^-3), sound speed (cm s^-1), velocity (cm s^-1), and mass (g), shape (*batch,).

required
p_r, rho_r, cs_r, u_r, dm_r

Right (outer) cell state, shape (*batch,).

required
r_face, m_grav_face, cgrav_face

Face radius (cm), gravitational mass (g), and effective gravitational constant (cm^3 g^-1 s^-2).

required

Returns:

Type Description
_Arr7

7-tuple (p_l_star, p_r_star, s_l, s_r, u_face, p_face, ke_flux) of

_Arr7

shape (*batch,).

eval_hllc_surface_face_jax

eval_hllc_surface_face_jax(
    p_surf_cell,
    rho_surf,
    cs_surf,
    u_surf,
    dm_surf,
    r_surf,
    m_surf,
    cgrav_surf,
    p_bc,
)

Evaluate the surface (\(k = 0\)) HLLC Riemann boundary state (setup_for_surf_Riemann in star/private/hydro_riemann.f90).

Parameters:

Name Type Description Default
p_surf_cell, rho_surf, cs_surf, u_surf, dm_surf

Outermost cell pressure (dyn cm^-2), density (g cm^-3), sound speed (cm s^-1), velocity (cm s^-1), and mass (g).

required
r_surf, m_surf, cgrav_surf

Surface radius (cm), mass (g), and gravitational constant (cm^3 g^-1 s^-2).

required
p_bc Array

Exterior surface boundary pressure (dyn cm^-2).

required

Returns:

Type Description
_Arr7

7-tuple (p_l_star, p_r_star, s_l, s_r, u_face, p_face, ke_flux) of

_Arr7

shape (*batch,).

eval_riemann_momentum_residual_jax

eval_riemann_momentum_residual_jax(
    u_k,
    u_old_k,
    dt,
    dm_k,
    r_outer,
    r_inner,
    p_face_outer,
    p_face_inner,
    p_cell_k,
    g_cell_k,
)

Evaluate the spherical Lagrangian HLLC momentum residual (do1_momentum_eqn in star/private/hydro_momentum.f90).

Parameters:

Name Type Description Default
u_k, u_old_k

Current and old cell velocities (cm s^-1).

required
dt Array

Timestep (s).

required
dm_k Array

Cell mass (g).

required
r_outer, r_inner

Outer and inner face radii (cm).

required
p_face_outer, p_face_inner

Outer and inner HLLC contact pressures (dyn cm^-2).

required
p_cell_k Array

Cell total pressure (dyn cm^-2).

required
g_cell_k Array

Cell gravitational acceleration (cm s^-2).

required

Returns:

Type Description
Array

Momentum equation residual (cm s^-2) of shape (*batch,).

eval_dziembowski_variables_jax

eval_dziembowski_variables_jax(
    r, m, p, rho, gamma1, n2, cgrav, r_tot, m_tot
)

Evaluate the 5 dimensionless Dziembowski pulsation variables \((V, V_g, A_*, U, c_1)\) across a stellar profile (pulse_utils.f90).

Parameters:

Name Type Description Default
r, m, p, rho, gamma1, n2, cgrav

Zone radius (cm), enclosed mass (g), pressure (dyn cm^-2), density (g cm^-3), adiabatic exponent \(\Gamma_1\), squared Brunt-Väisälä frequency (s^-2), and gravitational constant (cm^3 g^-1 s^-2).

required
r_tot, m_tot

Total stellar radius \(R\) (cm) and mass \(M\) (g).

required

Returns:

Type Description
_Arr5

5-tuple (v_dziem, v_g, a_star, u_dziem, c_1) of shape (*batch,).

eval_sobolev_feii_5169_tau_jax

eval_sobolev_feii_5169_tau_jax(rho, x_fe, eta, t_exp_s)

Evaluate the STELLA homologous Sobolev optical depth \(\tau_{\mathrm{Sob}}\) for Fe II 5169 (parse_swd_vel_feii.f90).

Parameters:

Name Type Description Default
rho Array

Zone mass density (g cm^-3) of shape (*batch,).

required
x_fe Array

Iron mass fraction (dimensionless) of shape (*batch,).

required
eta Array

Population fraction \(\eta(\rho, T)\) of shape (*batch,).

required
t_exp_s float | Array

Time since shock breakout (s).

required

Returns:

Type Description
Array

Sobolev optical depth \(\tau_{\mathrm{Sob}}\) of shape (*batch,).

solve_gyre_mesa_modes

solve_gyre_mesa_modes(
    mesa_str,
    l_deg,
    omega_min,
    omega_max,
    n_scan=200,
    nonadiabatic=True,
)

Solve the 4th/6th-order GYRE BVP on a GYRE MESA model string.

Parameters:

Name Type Description Default
mesa_str str

GYRE v101/v120 structure table text.

required
l_deg int

Spherical harmonic degree \(\ell\).

required
omega_min, omega_max

Dimensionless frequency scan bounds.

required
n_scan int

Number of scan intervals.

200
nonadiabatic bool

Whether to include radiative cooling perturbations.

True

Returns:

Type Description
list[tuple[int, int, int, int, float, float, float, float, float]]

List of eigenmode tuples `(l, n_p, n_g, n_pg, omega_re, omega_im,

list[tuple[int, int, int, int, float, float, float, float, float]]

freq_uhz, inertia, eta_growth)`.

solve_adipls_fgong_modes

solve_adipls_fgong_modes(
    fgong_str, l_deg, freq_min_uhz, freq_max_uhz, n_scan=500
)

Solve the 4th/6th-order ADIPLS BVP on an FGONG model string.

Parameters:

Name Type Description Default
fgong_str str

FGONG structure file text.

required
l_deg int

Spherical harmonic degree \(\ell\).

required
freq_min_uhz, freq_max_uhz

Frequency scan bounds (uHz).

required
n_scan int

Number of scan intervals.

500

Returns:

Type Description
list[tuple[int, int, int, int, float, float, float, float]]

List of eigenmode tuples `(l, n_p, n_g, n_pg, sigma2, freq_uhz,

list[tuple[int, int, int, int, float, float, float, float]]

inertia, delta_nu_share)`.

run_stella_from_hyd_abn

run_stella_from_hyd_abn(
    hyd_str, abn_str, eta_str, times_days
)

Run the STELLA bolometric light-curve and Fe II 5169 solver.

Parameters:

Name Type Description Default
hyd_str str

.hyd hydrodynamic profile table text.

required
abn_str str

.abn abundance table text.

required
eta_str str

Fe II 5169 \(\eta(\rho, T)\) lookup table text.

required
times_days list[float]

Post-breakout epochs (days).

required

Returns:

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

2-tuple (lbol_curve, feii_velocities).


RSP & RSP2 Turbulent Pulsation Kernels (flexmesa.star.jax_rsp)

flexmesa.star.jax_rsp

Branchless @jax.jit (float64) kernels for RSP and RSP2 radial stellar pulsation and time-dependent turbulent convection (hydro_rsp2.f90 and rsp/eval_equations.inc, resolving Issue #5).

rsp2_flux_limiter_jax

rsp2_flux_limiter_jax(x)

Evaluate the quintic \(C^2\) smootherstep enthalpy flux limiter (flux_limiter_function in star/private/hydro_rsp2.f90:610-642).

Parameters:

Name Type Description Default
x Array

Dimensionless convective-to-enthalpy flux ratio \(X = G/F\) of shape (*batch,).

required

Returns:

Type Description
_Arr2

2-tuple (fl, dfl_dx) of shape (*batch,) giving the limited ratio

_Arr2

\(\mathrm{FL}(X)\) and analytical derivative \(\mathrm{dFL}/\mathrm{d}X\).

compute_rsp2_uq_face_jax

compute_rsp2_uq_face_jax(
    chi_outer, chi_inner, r_face, dm_bar
)

Evaluate face eddy-viscous acceleration \(U_{q,\mathrm{face},k}\) (compute_Uq_face in star/private/hydro_rsp2.f90:785-817).

Parameters:

Name Type Description Default
chi_outer Array

Outer cell eddy viscosity \(\mathrm{X}_{k-1}\) (erg), shape (*batch,).

required
chi_inner Array

Inner cell eddy viscosity \(\mathrm{X}_k\) (erg), shape (*batch,).

required
r_face Array

Face radius \(r_k\) (cm), shape (*batch,).

required
dm_bar Array

Face mass spacing \(\overline{\Delta m}_k\) (g), shape (*batch,).

required

Returns:

Type Description
Array

Eddy-viscous acceleration $4\pi(\mathrm{X}_{k-1}-\mathrm{X}_k) /

Array

(r_k \overline{\Delta m}_k)$ (cm s^-2) of shape (*batch,).

eval_rsp2_zone_jax

eval_rsp2_zone_jax(
    w,
    t,
    rho,
    p,
    cp,
    grad_ad,
    delta,
    kappa,
    hp_cell,
    grad_t,
    r_outer,
    r_inner,
    u_outer,
    u_inner,
    dm,
    dlnd_dt,
    alfa=1.5,
    alfap=1.0,
    alfas=1.0,
    alfad=1.0,
    alfam=0.25,
    gammar=1.0,
    min_w2_for_turbulence=0.0,
    w_min_for_damping=0.0,
)

Evaluate cell-centered RSP2 turbulent pressure, eddy viscosity, viscous heating, and turbulent energy terms (hydro_rsp2.f90:717-934).

Parameters:

Name Type Description Default
w Array

Specific turbulent velocity \(\sqrt{e_t}\) (cm s^-1), shape (*batch,).

required
t, rho, p, cp, grad_ad, delta, kappa

Cell thermodynamic state and opacity (K, g cm^-3, dyn cm^-2, erg g^-1 K^-1, dimensionless, dimensionless, cm^2 g^-1), shape (*batch,).

required
hp_cell, grad_t

Cell pressure scale height (cm) and temperature gradient, shape (*batch,).

required
r_outer, r_inner, u_outer, u_inner

Bounding radii (cm) and velocities (cm s^-1), shape (*batch,).

required
dm Array

Cell mass (g), shape (*batch,).

required
dlnd_dt Array

Logarithmic density rate \(\mathrm{d}\ln\rho/\mathrm{d}t\) (s^-1), shape (*batch,).

required
alfa, alfap, alfas, alfad, alfam, gammar

Kuhfuss (1986) RSP2 mixing-length and convective/viscous/radiative multipliers.

required
min_w2_for_turbulence, w_min_for_damping

Minimum \(w^2\) (cm^2 s^-2) and \(w\) (cm s^-1) thresholds for eddy viscosity and damping.

required

Returns:

Type Description
_Arr7

7-tuple `(p_turb, chi_turb, eq_visc, source_s, sink_d, sink_dr,

_Arr7

de_t_dt)of shape(*batch,)`.

eval_rsp2_face_jax

eval_rsp2_face_jax(
    r_face,
    m_grav_face,
    cgrav_face,
    p_face,
    rho_face,
    t_face,
    cp_face,
    grad_ad_face,
    kappa_face,
    w_inner,
    w_outer,
    t4_inner,
    t4_outer,
    lnp_inner,
    lnp_outer,
    chi_face,
    du_over_r_face,
    dm_bar,
    alfa=1.5,
    alfac=1.0,
    alfat=0.01,
)

Evaluate face-centered RSP2 scale height, superadiabaticity, convective transport factor \(\Pi_k\), and radiative/convective/turbulent luminosities (hydro_rsp2.f90:230-285, 436-608, 1015-1172).

Parameters:

Name Type Description Default
r_face, m_grav_face, cgrav_face

Face radius (cm), gravitational mass (g), and effective gravitational constant (cm^3 g^-1 s^-2).

required
p_face, rho_face, t_face, cp_face, grad_ad_face, kappa_face

Interpolated face thermodynamic state and opacity.

required
w_inner, w_outer

Adjacent cell turbulent velocities (cm s^-1).

required
t4_inner, t4_outer

Adjacent cell \(T^4\) (K^4).

required
lnp_inner, lnp_outer

Adjacent cell \(\ln P\).

required
chi_face, du_over_r_face

Unused compatibility arguments retained for call-signature stability.

required
dm_bar Array

Face mass spacing \(\overline{\Delta m}_k\) (g).

required
alfa, alfac, alfat

RSP2 mixing-length, convective flux, and turbulent kinetic flux multipliers.

required

Returns:

Type Description
_Arr6

6-tuple (hp_face, y_face, pi_face, l_r, l_c, l_t) of shape

_Arr6

(*batch,).

solve_stationary_rsp2_w_jax

solve_stationary_rsp2_w_jax(
    t,
    rho,
    p,
    cp,
    grad_ad,
    delta,
    kappa,
    hp_cell,
    grad_t,
    alfa=1.5,
    alfas=1.0,
    alfad=1.0,
    gammar=1.0,
)

Solve the stationary local RSP2 turbulent balance \(S(w) - D(w) - D_r(w) = 0\) for \(w\) (hydro_rsp2.f90:1195-1253).

Parameters:

Name Type Description Default
t, rho, p, cp, grad_ad, delta, kappa

Cell thermodynamic state and opacity ((*batch,)).

required
hp_cell, grad_t

Cell pressure scale height (cm) and temperature gradient ((*batch,)).

required
alfa, alfas, alfad, gammar

RSP2 model multipliers.

required

Returns:

Type Description
Array

Equilibrium turbulent velocity \(w\) (cm s^-1) of shape (*batch,).

eval_rsp2_turbulent_eqn_residual_jax

eval_rsp2_turbulent_eqn_residual_jax(
    w,
    w_start,
    rho,
    rho_start,
    p_turb,
    lt_outer,
    lt_inner,
    coupl,
    eq_visc,
    dm,
    dt,
    cp,
    t,
)

Evaluate the dimensionless RSP2 turbulent-energy Henyey residual (do1_turbulent_energy_eqn in star/private/hydro_rsp2.f90:312-417).

Parameters:

Name Type Description Default
w, w_start

End-of-step and start-of-step turbulent velocities (cm s^-1), shape (*batch,).

required
rho, rho_start

End-of-step and start-of-step cell densities (g cm^-3), shape (*batch,).

required
p_turb Array

Cell turbulent pressure \(P_{\mathrm{trb},k}\) (dyn cm^-2), shape (*batch,).

required
lt_outer, lt_inner

Outer and inner face turbulent luminosities (erg s^-1), shape (*batch,).

required
coupl Array

Net convective coupling \(S_k - D_k - D_{r,k}\) (erg g^-1 s^-1), shape (*batch,).

required
eq_visc Array

Eddy-viscous heating \(E_{q,\mathrm{cell},k}\) (erg g^-1 s^-1), shape (*batch,).

required
dm, dt

Cell mass (g) and timestep (s), shape (*batch,).

required
cp, t

Specific heat \(C_P\) (erg g^-1 K^-1) and temperature (K), shape (*batch,).

required

Returns:

Type Description
Array

Dimensionless turbulent-energy equation residual of shape (*batch,).

eval_rsp_hyd_fluxes_jax

eval_rsp_hyd_fluxes_jax(
    r_face,
    t_outer,
    t_inner,
    kap_outer,
    kap_inner,
    rho_face,
    t_face,
    pii_face,
    w_outer,
    w_inner,
    hp_face,
    dm_bar,
    du_compr,
    cs_cell,
    rho_cell,
    alfa=1.5,
    alfac=1.0,
    alfat=0.01,
    cq=4.0,
    zsh=0.1,
)

Evaluate Stellingwerf radiative luminosity \(L_r\), Kuhfuss convective luminosity \(L_c\), turbulent kinetic luminosity \(L_t\), and artificial viscosity pressure \(Q_{\mathrm{visc}}\) (rsp/eval_equations.inc).

Parameters:

Name Type Description Default
r_face Array

Face radius (cm), shape (*batch,).

required
t_outer, t_inner

Outer (k-1) and inner (k) cell temperatures (K), shape (*batch,).

required
kap_outer, kap_inner

Outer and inner cell opacities (cm^2 g^-1), shape (*batch,).

required
rho_face, t_face, pii_face, hp_face

Face density (g cm^-3), temperature (K), convective factor \(\Pi_k\) (erg g^-1 K^-1), and pressure scale height (cm), shape (*batch,).

required
w_outer, w_inner

Outer and inner cell turbulent velocities (cm s^-1), shape (*batch,).

required
dm_bar Array

Face mass spacing (g), shape (*batch,).

required
du_compr, cs_cell, rho_cell

Cell velocity difference \(u_{\mathrm{in}} - u_{\mathrm{out}}\) (cm s^-1), sound speed (cm s^-1), and cell density (g cm^-3), shape (*batch,).

required
alfa, alfac, alfat, cq, zsh

Mixing-length, convective, turbulent diffusion, and artificial viscosity parameters.

required

Returns:

Type Description
_Arr4

4-tuple (l_r, l_c, l_t, q_visc) of shape (*batch,) (erg s^-1,

_Arr4

erg s^-1, erg s^-1, dyn cm^-2).


Inlist Bundle & test_suite Runner (flexmesa.star.e2e)

flexmesa.star.e2e

End-to-end MESA inlist parser, ./rn stage extractor, multi-stage test_suite case execution driver, and linear/envelope pulsation helpers (flexmesa.star.e2e).

copy_cleaned_case

copy_cleaned_case(src_dir, dst_dir, suite='star')

Copy an upstream MESA test case directory while stripping unsupported and unused namelist keys for strict cleaned-copy verification.

parse_inlist_bundle

parse_inlist_bundle(
    inlist_path, allow_unsupported_controls=False
)

Parse a MESA inlist file and recursively resolve read_extra_*_inlist.

Parameters:

Name Type Description Default
inlist_path str | Path

Path to the entry inlist file.

required
allow_unsupported_controls bool

When True, bypass strict failure on unread, unused, or unimplemented upstream MESA controls.

False

Returns:

Type Description
dict[str, Any]

Dictionary of resolved &star_job and &controls settings.

parse_rn_stages

parse_rn_stages(case_dir, skip_optional=True)

Parse an upstream MESA ./rn bash script into execution stages.

Parameters:

Name Type Description Default
case_dir str | Path

Path to the test_suite case directory.

required
skip_optional bool

Whether MESA_SKIP_OPTIONAL branches are active.

True

Returns:

Type Description
list[tuple[str, str, str]]

List of (stage_kind, arg1, arg2) stage tuples.

run_test_suite_case

run_test_suite_case(
    case_dir,
    skip_optional=True,
    max_steps_per_stage=None,
    verify_restart=False,
    allow_unsupported_controls=False,
    extras=None,
)

Execute a multi-stage upstream MESA test_suite case directory.

Parameters:

Name Type Description Default
case_dir str | Path

Path to the test_suite case directory.

required
skip_optional bool

Whether MESA_SKIP_OPTIONAL branches are active.

True
max_steps_per_stage int | None

Optional cap on evolutionary steps per stage.

None
verify_restart bool

Whether to verify internal .photo round-trip consistency.

False
allow_unsupported_controls bool

When True, bypass strict failure on unread, unused, or unimplemented upstream MESA controls.

False
extras Any

Optional Python run_star_extras object with hook methods.

None

Returns:

Type Description
dict[str, Any]

Structured dictionary containing per-stage reports, step counts,

dict[str, Any]

Newton iterations, final physical state, and wall-clock runtime.

eval_linear_oscillation_modes

eval_linear_oscillation_modes(model, l_deg, n_orders)

Evaluate linearized adiabatic and non-adiabatic oscillation eigenmodes.

Parameters:

Name Type Description Default
model StarModel

Active StarModel instance.

required
l_deg int

Spherical harmonic degree l >= 0.

required
n_orders list[int]

Radial order indices n_pg (> 0 for acoustic p-modes, < 0 for gravity g-modes).

required

Returns:

Type Description
list[dict[str, Any]]

List of dictionaries with keys `("l", "n_pg", "freq_hz", "freq_uhz",

list[dict[str, Any]]

"period_days", "growth_rate_s", "growth_timescale_days", "inertia")`.

eval_target_mode_frequency_and_growth

eval_target_mode_frequency_and_growth(model)

Evaluate the target oscillation mode specified by x_integer_ctrl(3..4) and x_ctrl(1..2) on model.

Parameters:

Name Type Description Default
model StarModel

Active StarModel instance.

required

Returns:

Type Description
tuple[dict[str, Any], bool]

Tuple (mode_dict, matched_target).

eval_astero_scaling_dnu_numax_uhz

eval_astero_scaling_dnu_numax_uhz(model)

Evaluate global asteroseismic scaling parameters \((\Delta\nu, \nu_{\max})\) in \(\mu\mathrm{Hz}\) on model.

Parameters:

Name Type Description Default
model StarModel

Active StarModel instance.

required

Returns:

Type Description
tuple[float, float]

Tuple (delta_nu_uhz, nu_max_uhz) in uHz.

eval_rsp_lina_modes

eval_rsp_lina_modes(
    m_msun,
    l_lsun,
    teff_k,
    x_h=0.73,
    z_metal=0.007,
    n_modes=3,
)

Evaluate linear non-adiabatic (LINA) radial pulsation periods and growth rates for an RSP envelope.

Parameters:

Name Type Description Default
m_msun float

Total stellar mass in \(M_\odot\).

required
l_lsun float

Surface luminosity in \(L_\odot\).

required
teff_k float

Effective temperature in K.

required
x_h float

Hydrogen mass fraction \(X\).

0.73
z_metal float

Metal mass fraction \(Z\).

0.007
n_modes int

Number of radial modes to compute (1..=15).

3

Returns:

Type Description
list[dict[str, Any]]

List of dictionaries with keys `("mode_index", "period_days",

list[dict[str, Any]]

"growth_rate")`.

build_rsp_envelope_model

build_rsp_envelope_model(
    m_msun=4.165,
    l_lsun=1438.8,
    teff_k=6050.0,
    x_h=0.73,
    z_metal=0.007,
)

Build a static radial stellar pulsation (RSP) envelope StarModel (create_RSP_model = .true.).

Parameters:

Name Type Description Default
m_msun float

Envelope total stellar mass in \(M_\odot\).

4.165
l_lsun float

Envelope surface luminosity in \(L_\odot\).

1438.8
teff_k float

Envelope effective temperature in K.

6050.0
x_h float

Hydrogen mass fraction \(X\).

0.73
z_metal float

Metal mass fraction \(Z\).

0.007

Returns:

Type Description
StarModel

Initialized StarModel with RSP_flag = True.


Compiled Rust Extension Bridge (flexmesa._rust)

Low-level Safe Rust PyO3 bindings exposed via flexmesa._rust for 1D stellar structure, evolution, extras hooks, pulsation exports, and test-suite drivers (_ArrF64 denotes a float64 NumPy ndarray).

star_py, star_lib_py, and extras_py

  • RustStarModel (class RustStarModel; static constructors from_zams, from_pre_ms, from_mod_str, from_photo_bytes; core methods to_mod_str, to_photo_bytes, eval_hydro_vars, set_evolve_controls, save_start_values, save_old_values, record_start_of_step_energy_integrals, eval_equations, solve_henyey, update_mixing, eval_dxdt_mix, solve_diffusion, run_omega_mix, step_struct_burn_mix, apply_wind_and_adjust_mass, adjust_mesh, pick_next_timestep, evolve_step, evolve, history_tuple, to_history_line, to_profile_str, copy, set_primary_state): Python wrapper around flexmesa_star::StarModel exposing primary state, zone/face profiles, controls, and solver telemetry.
  • star_interp_q ((dq1: _ArrF64, v1: _ArrF64, dq2: _ArrF64) -> _ArrF64): Interpolates profile v1 from Lagrangian grid dq1 onto dq2 (interp_q).
  • star_yrs_for_init_timestep ((m_msun: float) -> float): Computes the initial ZAMS timestep in years (yrs_for_init_timestep).
  • StarLibModel (class StarLibModel; static constructor new_for_build; properties nz, species, model_number; methods get, set, get_scalar, set_scalar, xa, get_atm_options, set_atm_options, normalize_dqs, set_qs, set_m_and_dm, set_dm_bar, change_to_xa_for_accretion, basic_composition_info, get_atm_pt, get_surf_pt, solve_eos_given_pgas_t, solve_eos_given_pgas_t_auto, do_eos_for_cell, do_kap_for_cell, set_mlt_vars, d_gradt_dlnt00, pack_xh, write_model): Model handle exposing the star_lib subset for custom build hooks (#453).
  • atm_teff ((l: float, r: float) -> float): Evaluates black-body effective temperature in \(\mathrm{K}\) for \(L\) in \(\mathrm{erg\,s^{-1}}\) and \(R\) in \(\mathrm{cm}\) (atm_Teff in atm/public/atm_lib.f90).
  • crmath_log ((x: float) -> float): Evaluates correctly rounded natural logarithm (log in math_lib).
  • PyRspBuildContext (class PyRspBuildContext; attributes case_dir, output_dir, work_dir, rsp_mass, rsp_x, rsp_z, rsp_alfam, rsp_alfap, rsp_alfat, rsp_gammar, x_ctrl, x_integer_ctrl, x_logical_ctrl, x_character_ctrl; method eval_lina): Context passed into Python other_rsp_build_model hooks for static RSP envelope and LINA instability scans (#148).
  • star_apply_extras_updates ((model: RustStarModel, updates: dict[str, Any]) -> None): Applies a MESA star extras update dictionary onto a RustStarModel in place (#148, #231), raising ValueError on unrecognized keys or invalid values.
  • star_extras_snapshot ((model: RustStarModel, case_dir: str = "", include_history: bool = True) -> dict[str, Any]): Builds the MESA star_info extras snapshot dictionary for a RustStarModel without running a full trace (#148, #231).
  • star_solve_gyre_mesa_modes_full ((gyre_content: str, l: int = 0, omega_min: float = 0.5, omega_max: float = 12.0, n_freq: int = 400) -> list[tuple[int, int, int, int, float, list[float], list[float]]]): Solves adiabatic GYRE MESA modes and returns (l, n_p, n_g, n_pg, freq_uhz, x_grid, xi_r) per eigenmode.

star_e2e_py

  • binary_run_test_suite_case ((case_dir: str, max_steps_cap: int | None = None, allow_unsupported_controls: bool = False, extras: Any = None) -> dict[str, Any]): Runs a coupled binary/test_suite/<case> directory and returns a report dictionary.
  • star_build_rsp_envelope_model ((m_msun: float, l_lsun: float, teff_k: float, x_h: float = 0.73, z_metal: float = 0.007) -> Any): Builds a static RSP envelope RustStarModel with \((M/M_\odot, L/L_\odot, T_{\mathrm{eff}}, X, Z)\).
  • star_copy_cleaned_case ((src_dir: str, dst_dir: str, suite: str = "star") -> None): Copies a star, binary, or astero case directory from src_dir to dst_dir while stripping unsupported or unused namelist keys.
  • star_eval_astero_scaling_dnu_numax_uhz ((model: Any) -> tuple[float, float]): Evaluates global asteroseismic scaling parameters \((\Delta\nu, \nu_{\max})\) in \(\mu\mathrm{Hz}\) on model.
  • star_eval_linear_oscillation_modes ((model: Any, l: int = 1, n_orders: list[int] = ...) -> list[dict[str, Any]]): Evaluates adiabatic/non-adiabatic linear oscillation modes at degree l across radial orders n_orders on model.
  • star_eval_rsp_lina_modes ((m_msun: float, l_lsun: float, teff_k: float, x_h: float = 0.73, z_metal: float = 0.007, n_modes: int = 3) -> list[dict[str, Any]]): Evaluates linear non-adiabatic (LINA) radial pulsation periods (\(\mathrm{d}\)) and growth rates for an RSP envelope with \((M/M_\odot, L/L_\odot, T_{\mathrm{eff}}, X, Z)\).
  • star_eval_target_mode_frequency_and_growth ((model: Any) -> tuple[dict[str, Any], bool]): Evaluates the target oscillation mode requested by x_integer_ctrl(3..4) and x_ctrl(1..2) on model, returning (mode_dict, matched_target).
  • star_parse_inlist_bundle ((inlist_path: str, allow_unsupported_controls: bool = False) -> dict[str, Any]): Parses a MESA inlist file (recursively resolving read_extra_*_inlist includes) and returns a summary dictionary of parsed controls.
  • star_parse_rn_stages ((case_dir: str, skip_optional: bool = True) -> list[tuple[str, str, str]]): Parses an upstream MESA ./rn script in case_dir into (stage_kind, arg1, arg2) tuples.
  • star_run_astero_test_suite_case ((case_dir: str, skip_optional: bool = True, max_steps_per_stage: int | None = None, verify_restart: bool = True, allow_unsupported_controls: bool = False, extras: Any = None) -> dict[str, Any]): Runs an astero/test_suite/<case> directory and returns a report dictionary.
  • star_run_test_suite_case ((case_dir: str, skip_optional: bool = True, max_steps_per_stage: int | None = None, verify_restart: bool = False, allow_unsupported_controls: bool = False, extras: Any = None) -> dict[str, Any]): Runs a multi-stage upstream MESA test_suite case directory and returns a structured telemetry dictionary.
  • star_verify_photo_restart ((model: Any, n_steps: int = 1) -> tuple[int, int]): Runs a .photo restart bit-identity check on model over n_steps.

star_wave5_py

  • star_add_predictive_mixing ((model: RustStarModel, ingested_mass_limit_coeff: float = 0.1, superad_thresh: float = 0.005) -> int): Applies predictive mixing at convective boundaries on model.
  • star_do_conv_premix ((model: RustStarModel, max_iters: int = 10, avoid_fuel_increase: bool = True) -> int): Runs iterative convective premixing on model and returns the number of cells absorbed across convective boundaries.
  • star_do_element_diffusion ((model: RustStarModel, dt: float, scheme: str = "stanton_murillo") -> tuple[_ArrF64, _ArrF64]): Runs multi-species element diffusion across all zones of model over dt seconds, returning (v_gt_2d, eps_wd_sed_1d).
  • star_do_phase_separation ((model: RustStarModel, dt: float, gamma_crystallization: float = 175.0, is_one_mixture: bool = False) -> _ArrF64): Executes white-dwarf crystallization phase separation on model and returns the gravothermal heating rate array \(\epsilon_{\mathrm{phase\_sep},k}\).
  • star_eval_burgers_velocities ((a: _ArrF64, z: _ArrF64, x_mass: _ArrF64, rho: float, t: float, dlnt_dr: float, g_grav: float, g_rad: _ArrF64 | None = None, scheme: str = "stanton_murillo") -> tuple[_ArrF64, _ArrF64, float]): Solves the single-zone multi-species Burgers resistance equations and returns (v_gt, d_self, ee_force).
  • star_eval_caplan_ocp_dstar ((gamma_i: float, kappa: float) -> float): Evaluates the Caplan, Bauer & Freeman (2022) strong-coupling OCP dimensionless self-diffusion coefficient \(D^*(\Gamma, \kappa)\).
  • star_eval_omega_crit ((cgrav: float, m_grav: float, r_polar: float, lum: float, opacity: float, max_gamma_edd: float = 0.99) -> float): Evaluates local critical Roche angular velocity \(\Omega_{\mathrm{crit}}\) (\(\mathrm{rad\,s^{-1}}\)).
  • star_eval_phase_separation_shift ((x_heavy: float, is_one_mixture: bool = False) -> float): Evaluates the Blouin et al. (2020, 2021) solid-liquid distillation shift \(\Delta x_{\mathrm{heavy}}\).
  • star_eval_radiative_levitation_accel ((kappa_species: float, lum_face: float, r_face: float) -> float): Evaluates radiative levitation acceleration \(g_{\mathrm{rad},i}\) (\(\mathrm{cm\,s^{-2}}\)).
  • star_eval_rotation_fp_ft ((w_div_w_crit: float, fp_min: float = 0.75, ft_min: float = 0.95) -> tuple[float, float, float]): Evaluates Fabry et al. (2022) / Paxton et al. (2019) Roche rotational distortion polynomials \((f_P, f_T, i_{\mathrm{rot}}/r^2)\).
  • star_eval_rotational_mixing_zone ((r: float, hp: float, grav: float, rho: float, t: float, cp: float, opacity: float, chi_t: float, chi_rho: float, grada: float, gradt: float, brunt_n2_t: float, brunt_n2_mu: float, omega: float, dln_omega_dln_r: float, abar: float, zbar: float, d_visc: float = 0.0) -> tuple[float, float, float, float, float, float, float, float, float]): Evaluates all five rotational instabilities and the Spruit-Tayler dynamo at a single spherical shell face, returning (d_dsi, d_sh, d_ssi, d_es, d_gsf, d_st, nu_st, b_phi, b_r).
  • star_eval_wd_sedimentation_heating ((a: _ArrF64, z: _ArrF64, x_mass: _ArrF64, v_gt: _ArrF64, abar: float, zbar: float, g_grav: float) -> float): Evaluates white-dwarf gravitational sedimentation heating rate \(\epsilon_{\mathrm{WD,sed}}\) (\(\mathrm{erg\,g^{-1}\,s^{-1}}\)).
  • star_set_rotation_mixing_info ((model: RustStarModel) -> _ArrF64): Runs set_rotation_mixing_info (star/private/rotation_mix_info.f90) on model, returning a (nz, 9) array (D_DSI, D_SH, D_SSI, D_ES, D_GSF, D_ST, nu_ST, dynamo_B_phi, dynamo_B_r) with diffusivities in \(\mathrm{cm^2\,s^{-1}}\) and magnetic fields in \(\mathrm{G}\), raising ValueError on explicit-error paths (#503).

star_wave5_2_py

  • star_build_pulse_points ((model: RustStarModel, add_center_point: bool = True, add_double_points: bool = False, grad_mu_threshold: float = 1.0e99) -> _ArrF64): Builds the center-to-surface pulsation structure array (n_pts, 26) containing physical variables and Dziembowski variables \((V, V_g, A_*, U, c_1)\).
  • star_eval_center_parabolic ((r_inner: float, r_outer: float, v_inner: float, v_outer: float) -> float): Parabolically extrapolates \(v(r)\) to \(r = 0\) (pulse_utils).
  • star_eval_hllc_face ((p_l: float, rho_l: float, cs_l: float, u_l: float, dm_l: float, p_r: float, rho_r: float, cs_r: float, u_r: float, dm_r: float, r_face: float, m_grav_face: float, cgrav_face: float) -> tuple[float, float, float, float, float, float, float]): Evaluates the well-balanced Lagrangian HLLC Riemann state at an interior cell interface (hydro_riemann).
  • star_eval_hllc_surface_face ((p_surf_cell: float, rho_surf: float, cs_surf: float, u_surf: float, dm_surf: float, r_surf: float, m_surf: float, cgrav_surf: float, p_bc: float) -> tuple[float, float, float, float, float, float, float]): Evaluates the surface (\(k = 0\)) HLLC Riemann state (hydro_riemann).
  • star_eval_riemann_momentum_residual ((u_k: float, u_old_k: float, dt: float, dm_k: float, r_outer: float, r_inner: float, p_face_outer: float, p_face_inner: float, p_cell_k: float, g_cell_k: float) -> float): Evaluates the spherical Lagrangian HLLC momentum residual for cell \(k\) (hydro_momentum).
  • star_eval_riemann_profile ((model: RustStarModel, u_cell: _ArrF64, u_old_cell: _ArrF64, p_surf_bc: float = 0.0, parallel: bool = True) -> tuple[_ArrF64, _ArrF64]): Evaluates full-profile HLLC Riemann face states (nz, 7) and cell momentum residuals (nz,) across all zones of model.
  • star_eval_rsp2_face ((r_face: float, m_grav_face: float, cgrav_face: float, p_face: float, rho_face: float, t_face: float, cp_face: float, grad_ad_face: float, kappa_face: float, w_inner: float, w_outer: float, t4_inner: float, t4_outer: float, lnp_inner: float, lnp_outer: float, chi_face: float, du_over_r_face: float, dm_bar: float, alfa: float = 1.5, alfac: float = 1.0, alfat: float = 0.01) -> tuple[float, float, float, float, float, float]): Evaluates face-centered RSP2 scale height, superadiabaticity, viscous stress, and radiative/convective/turbulent luminosities (hydro_rsp2).
  • star_eval_rsp2_zone ((w: float, t: float, rho: float, p: float, cp: float, grad_ad: float, delta: float, kappa: float, hp_cell: float, grad_t: float, r_outer: float, r_inner: float, u_outer: float, u_inner: float, dm: float, dlnd_dt: float = 0.0, alfa: float = 1.5, alfap: float = 1.0, alfas: float = 1.0, alfac: float = 1.0, alfad: float = 1.0, alfam: float = 0.25, alfat: float = 0.01, gammar: float = 1.0, min_w2_for_turbulence: float = 0.0, w_min_for_damping: float = 0.0) -> tuple[float, float, float, float, float, float, float]): Evaluates a cell's RSP2 turbulent pressure, eddy viscosity, viscous heating, buoyant source, dissipation sink, radiative cooling sink, and net turbulent energy rate (hydro_rsp2).
  • star_solve_stationary_rsp2_w ((t: float, rho: float, p: float, cp: float, grad_ad: float, delta: float, kappa: float, hp_cell: float, grad_t: float, alfa: float = 1.5, alfas: float = 1.0, alfad: float = 1.0, gammar: float = 1.0) -> float): Solves stationary local RSP2 turbulent balance for \(w\) (rsp2_solve).
  • star_export_cafein ((model: RustStarModel, add_center_point: bool = True) -> str): Exports model in CAFEIN ASCII format (pulse_cafein).
  • star_export_fgong ((model: RustStarModel, add_center_point: bool = True, keep_surface_point: bool = False, add_atmosphere: bool = False) -> str): Exports model as FGONG text (star_export_pulse_data in star/private/pulse.f90).
  • star_export_gr1d ((model: RustStarModel, _add_center_point: bool = True) -> str): Exports model in GR1D ASCII format (pulse_gr1d).
  • star_export_gsm ((model: RustStarModel, add_center_point: bool = True) -> bytes): Exports model in GYRE GSM v110 format (pulse_gsm).
  • star_export_gyre ((model: RustStarModel, add_center_point: bool = True, keep_surface_point: bool = False, add_atmosphere: bool = False) -> str): Exports model as GYRE text (star_export_pulse_data in star/private/pulse.f90).
  • star_export_osc ((model: RustStarModel, add_center_point: bool = True, keep_surface_point: bool = False, add_atmosphere: bool = False) -> str): Exports model as OSC text (star_export_pulse_data in star/private/pulse.f90).
  • star_export_pulse_by_format ((model: RustStarModel, format: str, add_center_point: bool = True) -> str): Exports model in any pulsation format ("gyre", "fgong", "osc", "gsm", "saio", "cafein", "gr1d").
  • star_export_saio ((model: RustStarModel, add_center_point: bool = True) -> str): Exports model in SAIO ASCII format (pulse_saio).
  • star_export_stella_pair ((model: RustStarModel) -> tuple[str, str]): Exports model as a STELLA (hyd_str, abn_str) pair (stella_io).
  • star_run_stella_from_hyd_abn ((hyd_str: str, abn_str: str, eta_str: str, times_days: list[float]) -> tuple[list[tuple[float, float]], list[tuple[float, float, float, float]]]): Runs STELLA radiation-hydrodynamics light-curve and Sobolev Fe II 5169 line-velocity evaluation on .hyd, .abn, and FeII_5169_eta.dat strings.
  • star_solve_adipls_fgong_modes ((fgong_str: str, l: int, freq_min_uhz: float, freq_max_uhz: float, n_scan: int = 500) -> list[tuple[int, int, int, int, float, float, float, float]]): Solves the 4th-order ADIPLS BVP on an FGONG model string.
  • star_solve_gyre_mesa_modes ((mesa_str: str, l: int, omega_min: float, omega_max: float, n_scan: int = 200, _nonadiabatic: bool = True) -> list[tuple[int, int, int, int, float, float, float, float, float]]): Solves the 4th-order BVP on a GYRE MESA-format model string.

Frozen JAX Engine Status (flexmesa.star.JAX_ENGINE_STATUS)

  • JAX_ENGINE_STATUS (str, "frozen-unverified-until-#143"): Marks the derived JAX star engine twins as frozen and not an upstream parity oracle until the canonical Rust engine passes the upstream-history harness (#143, #166).