Tolerance & Discrepancy Ledger¶
FlexMESA enforces a strict numerical governance policy (notes/SCOPE.md, DECISIONS #9, #17, #20, #22, #23): test tolerances are governed prospectively against unauthorized widening (with pre-audit tolerance broadenings documented in the repository audit under #142), and only Safe Rust "strict" mode is judged against MESA release 26.4.1 (Zenodo record 19722306; #141, #165). Safe Rust "fast" mode (std f64 intrinsics with mul_add) and the derived JAX layer (#166) are validated against Rust "strict" mode and are never treated as upstream MESA oracles (wider claim and benchmark updates on this page are tracked in #142 and #178).
1. Three-Level Numerics Policy (#165) & Test-Suite Tolerance Classes¶
1.1 Three Fidelity Levels for Canonical Rust "strict" Mode¶
| Level | Requirement | Enforcement Gate |
|---|---|---|
| Level 1 | "strict" mode is bit-identical across machines (x86_64 and aarch64) and thread counts (1 vs. 4 threads) |
Enforced per PR in CI (strict-determinism and strict-cross-machine-gate jobs running scripts/check_strict_determinism.py) |
| Level 2 | "strict" kernels are bit-identical to MESA 26.4.1 wherever operations and evaluation order match |
Tested against exact 16-digit hexadecimal MESA 26.4.1 outputs (474,062 math vectors across 47 sections in mesa_26_4_1_vectors.rs, extended module by module under #141 and Phase C) |
| Level 3 | Full evolutionary trajectories match stored real MESA 26.4.1 histories |
Enforced via benchmarks/history_harness/case_manifest.toml tolerances (DECISIONS #20, #143), tracking first_diverging_step toward zero |
1.2 Automated Test-Suite Tolerance Classes (pytest & cargo test)¶
| Check Class | Target Operators & Modules | Relative Bound | Comparison Target |
|---|---|---|---|
| Module Reference & Autodiff Checks | Physical constants (constants), elementary intrinsics (math), dual/hyperdual numbers (auto_diff), 1D/2D spline evaluation (interp_1d, interp_2d), dense/banded/block-tridiagonal solves (mtx), composition moments (chem), thermal neutrinos (neu), REACLIB/weak/screening rates (rates), grey 'fixed'/'iterated', irradiated, and knot-aligned tabulated model atmospheres (atm), reaction network RHS & Jacobians (net), Roche-lobe geometry (binary), and acoustic integrals (astero) |
\(\le 10^{-14}\) to \(10^{-10}\) (module test_output & 26.4.1 oracle rows; 0 ULP on neu 300,000/300,000 and atm 'fixed'/'iterated'/t_tau_rel)\(\le 10^{-10}\) (1st-order AD vs. jax.jacfwd) |
Upstream Fortran MESA <pkg>/test/test_output files (#141), benchmarks/fortran_mesa/*_oracles/, and forward/reverse AD identities |
Iterative Solvers & Derived-JAX Validation (#166) |
Brent/Newton root finders (num), Dormand-Prince dopri5 depth-varying \(T(\tau)\) atmospheres (atm 'varying', atm/private/atm_t_tau_varying.f90:182-279 & num/private/mod_dopri5.f), Rosenbrock stiff 1-zone burners (net), (P_gas, T) EOS inversions (eos_pt_get), implicit Kuhfuss TDC (set_tdc), and 3rd-order Skye free-energy heat capacities (\(c_V \propto \partial^2 F/\partial T^2\) and \(\partial c_V/\partial\ln T \propto \partial^3 F/\partial T^3\)) |
\(\le 10^{-10}\) to \(10^{-8}\) (converged roots, dopri5 \(\ln P_{\mathrm{surf}} \le 5 \times 10^{-12}\), & 2nd derivatives)\(\le 10^{-7}\) ( atm 'varying' finite-difference \(\partial\ln P_{\mathrm{surf}}/\partial(L, \ln R, \ln M)\))\(\le 3 \times 10^{-6}\) (3rd-order Skye JAX vs. Rust strict across crlibm RZ vs. XLA RN/FMA) |
Implicit Function Theorem identities (\(\partial y^*/\partial\theta = -(\partial Q/\partial y)^{-1}(\partial Q/\partial\theta)\)), MESA 26.4.1 dopri5 oracles, and JAX validated against Rust strict |
End-to-End Trajectory Harness (#143, DECISIONS #20) |
Uncapped star (90), binary (8), and astero (8) test_suite evolutions in "strict" mode |
Final 0.0005–0.002, track 0.002–0.005 (case_manifest.toml) |
Stored real Fortran MESA 26.4.1 LOGS/history.data and binary_history.data (#141, #143) |
2. Documented Upstream Fortran MESA Discrepancies¶
During line-by-line inspection and baseline testing against upstream Fortran MESA (release 26.4.1), several upstream bugs and implicit single-precision truncations were identified. Below is the ledger explaining how each arises in Fortran MESA and how FlexMESA handles it (note that pre-audit RSP2 departures in §2.9 are scheduled to revert to upstream 26.4.1 behaviour under #178).
2.1 Implicit 32-Bit REAL (f32) Hermite Basis Variables in interp_2d/private/bicub_db.f¶
- Upstream Location:
interp_2d/private/bicub_db.f, subroutinefvbicub_db(and downstream callers such asionization/private/ion_tables_eval.f90:eval_charge_of_Fe56_in_He4andatm/private/table_atm.f90:405inget_table_values). - Root Cause: The legacy Fortran 77 routine
fvbicub_dbomitsimplicit none. While its arguments and spline coefficient arrays are declaredreal(dp)(f64), its local Hermite basis variables (xp,yp,cx,cy,hx2,hy2,z36th = 1.0/36.0) are undeclared and therefore default to 32-bit single-precisionREAL(f32, \(\epsilon_{\mathrm{mach}} \approx 1.19 \times 10^{-7}\)). - Measured Effect: When evaluating 2D bicubic splines in
interp_2d,ion_fe56, andatmtables, Safe Rust and Python/JAX agree with each other in strict IEEE-754f64to \(\le 3.7 \times 10^{-14}\) (andatmtable queries on exact \((\log g, T_{\mathrm{eff}})\) grid knots such asWD_tau_25andDB_WD_tau_25inmesa_26_4_1_atm_oracles.tsvagree with MESA26.4.1to \(\le 5 \times 10^{-14}\)), whereas off-knot queries (photosphereandtau_*inatm/test/test_output/module_hex, up to7.86 \times 10^6ULP) exhibit a \(4.83 \times 10^{-9}\) to \(7.20 \times 10^{-9}\) single-precision truncation floor in the 9th significant digit. FlexMESABehaviour (Subject to#161/#169Upstream Review):FlexMESAevaluates all Hermite basis polynomials (w0,w1,w2) and grid spacings in full 64-bit IEEE-754f64(1.0_f64 / 36.0_f64). Whether"strict"mode should match MESA26.4.1fvbicub_dbvs. retaining this difference as a deferred upstream-bug review is tracked under #169 and #161.
2.2 Missing Density Factor \(\rho\) in HELM Mixed Density-Composition Derivatives (dpepdda, dpepddz)¶
- Upstream Location:
eos/private/helm_electron_positron.dek, lines 566 to 567. - Root Cause: The Timmes & Swesty (2000)
HELMroutine tabulates electron-positron pressure \(P_{\mathrm{ele}}(\text{din}, T)\) as a function of electron-nucleon density \(\text{din} = Y_e \rho\) (where \(Y_e = \bar{Z}/\bar{A}\)). Withdindd\(= \partial\text{din}/\partial\rho = Y_e\),dindda\(= \partial\text{din}/\partial\bar{A} = -\rho Y_e / \bar{A}\),ww\(= \partial P_{\mathrm{ele}}/\partial\text{din}\), andzz\(= \partial^2 P_{\mathrm{ele}}/\partial\text{din}^2\), differentiating \(\partial P_{\mathrm{ele}}/\partial\rho = \text{ww}(\text{din}, T)\,Y_e(\bar{A}, \bar{Z})\) with respect to \(\bar{A}\) by the product and chain rules yields:
because \((\partial\text{din}/\partial\bar{A})\,Y_e = \text{dindda}\cdot Y_e\) and \(\partial Y_e/\partial\bar{A} = \text{dindda}/\rho\), or equivalently when dindda is defined with \(\rho\) factored out, the first term requires \(\text{din} = Y_e\rho\) rather than \(\text{dindd} = Y_e\). Upstream Fortran MESA lines 566 to 567 instead write:
which replaces din (\(= Y_e\rho\)) with dindd (\(= Y_e\)), omitting a factor of \(\rho\) whenever \(\text{zz} = \partial^2 P_{\mathrm{ele}}/\partial\text{din}^2 \neq 0\) (degenerate regimes).
- FlexMESA Resolution: Both Safe Rust and JAX analytical HELM evaluators preserve upstream MESA's helm_electron_positron.dek:566-567 formula in the returned d_dlnd / composition slots. Safe Rust "strict" mode matches compiled MESA 26.4.1 (benchmarks/fortran_mesa/eos_oracles/mesa_26_4_1_eos_oracles.tsv) across all 17 HELM test states (1,360 values and partial derivatives) to unfloored relative error \(< 10^{-12}\) (zero_atol = 1e-14 on near-zero cancelled stencil slots; crates/flexmesa-eos/tests/ and tests/test_eos_wave3a2.py), while tests/test_eos_wave3a2.py checks unfloored jax.jacfwd consistency across unaffected channels and at \(\rho = 1\,\mathrm{g\,cm^{-3}}\) where \(\text{din} = \text{dindd}\) (with derived JAX HELM 3rd-order Hermite derivatives agreeing with MESA 26.4.1 within 3e-6 to 5e-5 across crlibm vs. XLA evaluation).
2.3 Factored Horner Derivative vs. Standard Autodiff in Biquintic HELM Basis Functions¶
- Upstream Location:
eos/private/helm_electron_positron.dek(psi0,dpsi0,ddpsi0). - Root Cause: The biquintic Hermite basis function \(w_0(z) = 1 - z^2(3 - 2z)\) has the algebraically factored derivative \(w_0'(z) = 6z(z - 1)\). Differentiating the unfactored expression \(1 - z^2(3 - 2z)\) directly via standard automatic differentiation evaluates \(-2z(3 - 2z) + 2z^2\), which differs by 1 to 2 ULPs (\(\sim 2.2 \times 10^{-16}\)). Because
HELMdivides grid-coordinate derivatives by \(\Delta\rho^2\) during second-derivative reconstruction, a 1-ULP difference in \(w_0'(z)\) is amplified by \(O(\Delta\rho^{-2}) \sim 10^{10}\) at low density (\(\rho \sim 10^{-6}\,\mathrm{g\,cm^{-3}}\)). FlexMESAResolution:src/flexmesa/eos/_helm_jax_poly.pyattaches recursive@jax.custom_jvprules (quintic_w0_coord,cubic_w0_coord) that force JAX forward-mode AD to evaluate the factored Horner derivative polynomials matching Safe Rust"strict"mode (< 10^{-11}agreement between JAX and Safe Rust across the 26HELMchannels).
2.4 Near-Center Pressure Scale-Height Cap in star/private/hydro_vars.f90¶
- Upstream Location:
star/private/hydro_vars.f90(alt_scale_height). - Root Cause: Near the stellar center (\(r \to 0\)), the standard hydrostatic pressure scale height \(H_P = P / (\rho g)\) diverges as \(g = G m / r^2 \to 0\). Upstream MESA caps the scale height via:
Inside the innermost radiative core zones where \(\sqrt{P/(G\rho^2)} < P/(\rho g)\), \(H_P\) depends only on \((P, \rho)\) and is mathematically independent of radius \(r\), so \(\partial H_P / \partial\ln r = 0\) identically.
- FlexMESA Resolution: crates/flexmesa-star/src/hydro_vars.rs and src/flexmesa/star/jax_kernels.py implement the alt_scale_height cap, and radial Jacobian tests (tests/test_star_wave4_1.py) check \(\partial H_P/\partial\ln r \neq 0\) on interior shells outside the central fallback sphere.
2.5 Profile-Norm Scaling Across Zero Crossings in w5_riemann_rsp2¶
- Location:
src/flexmesa/bench/kernels_wave5.pyandtests/test_wave5_bench.py. - Root Cause: The composite per-zone digest observable for
w5_riemann_rsp2sums positive turbulent energy \((w / 10^5)\) and negative turbulent dissipation \((\dot{\epsilon}_t / 10^8)\), crossing zero near \(s_k \approx 0.435\). At zone \(k = 55\) (\(N_{\mathrm{zones}} = 128\)), \(|v_{55}| / \max_j |v_j| = 1.2 \times 10^{-4}\), magnifying a single-ULP CPU vs. XLA FMA difference by \(10^4\) when divided pointwise by \(|v_k|\). FlexMESAResolution: The benchmark harness reports both the pointwise relative error and the profile-norm relative error \(\max_k |v_k^{\mathrm{Rust}} - v_k^{\mathrm{JAX}}| / \max_k |v_k^{\mathrm{Rust}}|\), which agrees to \(\le 1.45 \times 10^{-15}\) across all grid resolutions.
2.6 Thin-Zone Energy Scaling (set_energy_eqn_scal), Chemical Rate Floor (min_chem_eqn_scale), & Photospheric Table Boundary Anchoring (star/test_suite)¶
- Upstream Locations:
star/private/star_utils.f90:3678-3697(subroutineset_energy_eqn_scal),star/private/hydro_chem_eqns.f90:130(subroutinedo1_chem_eqns), andstar/private/hydro_vars.f90:779-1030(subroutineget_surf_PT). - Root Cause: Three scaling sensitivities govern Henyey residual conditioning on realistic multi-thousand-zone stellar grids:
- In thin outer envelope zones (\(\Delta q_k \sim 10^{-13}\), \(\Delta m_k \sim 10^{21}\,\mathrm{g}\) on a \(4\,M_\odot\) ZAMS grid), a single IEEE-754
f64ULP in \(L_k - L_{k+1}\) (\(L \cdot 2^{-53} \sim 10^{20}\,\mathrm{erg\,s^{-1}}\)) divided by \(\Delta m_k\) and scaled naively by \(\Delta t / e_{\mathrm{start},k}\) produces a residual quantization floor of \(\sim 3.5 \times 10^{-4}\), exceedinggold_tol_max_residual3 = 1e-4even when Newton corrections reach \(10^{-12}\). Upstreamset_energy_eqn_scalcaps the dimensionless prefactor at \((e_{\mathrm{start},k}\Delta m_k / E_{\mathrm{int,start}})\,\mathrm{dedt\_eqn\_r\_scale}\) (dedt_eqn_r_scale = 1d8), cancelling \(\Delta m_k\) in zones holding less than \(10^{-8}\) of total internal energy while leaving thicker interior zones (\(\Delta q_k \ge 10^{-8}\)) unchanged; onmake_wave4_zams_model(8), surface zone \(k = 0\) has \(\Delta q_0 \approx 10^{-10} < 10^{-8}\) and is likewise capped byset_energy_eqn_scal. - Upstream
do1_chem_eqns(hydro_chem_eqns.f90:130) scales abundance rate residuals by \(\max(\mathrm{min\_chem\_eqn\_scale}, \mathrm{x\_scale}_{j,k}/\Delta t)\) withmin_chem_eqn_scale = 1.0\(\mathrm{s^{-1}}\) so slow hydrostatic nuclear drift does not inflate dimensionless residual norms when \(\Delta t \gg 1\,\mathrm{s}\), whilesizeBstill enforces scaled abundance corrections againstxa_scale = 1e-5. - Evaluating analytical grey opacity partial derivatives (\(\partial\ln\kappa/\partial\ln\rho < -1\)) at cool TP-AGB photospheres relaxed against tabulated low-\(T\) molecular atmospheres (
atm_option = 'table') reverses the sign of the surface pressure residual derivative \(1 + (P_{\mathrm{surf}}/P_0)(\partial\ln\kappa/\partial\ln\rho)\). FlexMESAResolution:crates/flexmesa-star/src/hydro_energy.rsandsrc/flexmesa/star/jax_kernels.pyimplement upstreamset_energy_eqn_scal(dedt_eqn_r_scale = 1e8),crates/flexmesa-star/src/hydro_eqns.rsimplementsmin_chem_eqn_scale = 1.0\(\mathrm{s^{-1}}\) indo1_chem_eqns, andcrates/flexmesa-star/src/hydro_vars.rsanchors photospheric table boundaries consistently acrossstar/test_suite.
2.7 Hardcoded 1d-8 Newton Stopping Tolerance in eos/private/eospt_eval.f90¶
- Upstream Locations:
eos/private/eospt_eval.f90(lines 180 to 191, subroutineGet_PT_Results_using_DT) andnum/private/mod_root.f90(line 102, subroutinedo_safe_root_with_guess). - Root Cause: Upstream Fortran MESA's \((P_{\mathrm{gas}}, T) \to \rho\) wrapper
Get_PT_Results_using_DThardcodesother_tol = 1d-8,logRho_tol = 1d-8, andmax_iter = 20when callingdo_eosDT_get_Rho, wheredo_safe_root_with_guessterminates Newton-Brent iteration as soon as \(|y(x_i)| < \max(\epsilon_y, |\mathrm{d}y/\mathrm{d}x|\,\epsilon_x)\) for \(x = \log_{10}\rho\) and \(y(x) = \ln P_{\mathrm{gas}}(x) - \ln P_{\mathrm{gas,target}}\). TighteninglogRho_tolbeyond1d-8shifts the converged density by \(\sim 5 \times 10^{-11}\,\mathrm{dex}\) and shifts theatm/test/test_outputreference value (4.3649748642304882e-3on irradiated \(T(\tau)\) opacity at MESA release26.4.1). On the fullZ = 1.0FreeEOStable (mesa-FreeEOS_100z00x_COat \(\rho = 100\,\mathrm{g\,cm^{-3}}, T = 10^7\,\mathrm{K}\)), Newton step \(i = 2\) reaches \(|y(x_2)| = 3.31 \times 10^{-10} < |\mathrm{d}\ln P_{\mathrm{gas}}/\mathrm{d}\log_{10}\rho|\times 10^{-8} \approx 2.30 \times 10^{-8}\) and returns \(|\log_{10}\rho - 2.0| = 6.25 \times 10^{-11} < 10^{-10}\), corresponding to \(|\rho - \rho_{\mathrm{true}}|/\rho_{\mathrm{true}} = \ln(10)\,|\Delta\log_{10}\rho| = 1.44 \times 10^{-10}\). FlexMESAResolution: Bothcrates/flexmesa-eos/src/eos_pt.rsandsrc/flexmesa/eos/_inverse_solver.pypreserve upstream Fortran MESA's1d-8Newton stopping rule, matching all40test1_eosPTscalars ineos/test/test_outputto unfloored relative error \(< 10^{-12}\) in Safe Rust"strict"mode (\(< 10^{-11}\) in JAX;tests/test_eos_wave3b1.py) and matching compiled MESA26.4.1eosPT_get,eosPT_get_T,eosDT_get_T, andeosDT_get_Rhooracle rows inmesa_26_4_1_eos_oracles.tsv(\(< 10^{-12}\) to \(< 10^{-8}\);wave3a3_skye_inverse_tests.rs,wave3b1_golden_tests.rs, andtests/test_eos_wave3a3.py). Three remaining pre-existing EOS component and control-wiring differences against MESA26.4.1(PCeos/private/pc_eos.f90:1895use_EXCOR7_table = .true.bicubic spline vs. analyticalEXCOR7,Skye/Skye+HELMHermite 3rd-derivative operation order, and Pythoneos.eos_dt_get_tlogT_tol/other_tolkwargs) are registered bijectively inbenchmarks/history_harness/known_gaps.tomlunder #161 (eos/defaults/eos.defaults:163include_radiation = .true.inCMSandeos/defaults/eos.defaults:225-228real(4)bounds inGet_Skye_alfa_simpleare aligned in #149).
2.8 Zeroed Secant Step D = F2*(T4_0 - T4_0)/(F2 - F1) in RSP STAH Anchor-Temperature Root Finder¶
- Upstream Location:
star/private/rsp_build.f90(lines 675 to 676 and line 772, insidestahandget_T_estimate). - Root Cause: During static envelope integration (
create_RSP_model), upstream Fortran MESA'sstahsubroutine solves for the anchor shell mass \(\Delta m_N\) where the zone-\(N\) temperature equals \(T_{\mathrm{anchor}} = 1.1 \times 10^4\,\mathrm{K}\) to relative toleranceTH0_tol = 1d-8. Two upstream properties interact in this loop: - Line 772 writes
D = F2 * (T4_0 - T4_0) / (F2 - F1)(subtractingT4_0from itself rather thanT4_0 - T4_prev), which evaluates identically to0.0d0so the outerstahiteration reduces to pure bisection on[dmN_small, dmN_large]after initial sign bracketing. - Each shell temperature step invokes
get_T_estimatewith loose root-finding tolerancesepsx = 1d-5, epsy = 1d-5(rsp_build.f90:675-676). On low-metallicityGs98opacity tables (Z = 0.0014), discrete switching of the internalbrent_safe_zeroiteration count introduces \(\sim 2 \times 10^{-5}\) quantization jumps in \(T_N(\Delta m_N)\) that exceedTH0_tol = 1d-8even when the bisection interval width has converged to machine precision. FlexMESANote:crates/flexmesa-star/src/rsp_stah.rspreserves upstream Fortran MESA'sepsx = 1e-5, epsy = 1e-5inner step and bisection update (tested against all 7 MESA release26.4.1rsp_*_26_4_1.modmodels inrsp_build_lina_test.rs; removal of non-upstream departures is tracked under #178).
2.9 Dimensional \(w^4\) Turbulent Pressure, Cp vs. T Flux-Limiter Typo, and Dropped \(\partial D_r / \partial w\) in RSP2¶
- Upstream Locations:
star/private/star_utils.f90(star_utils.f90:3334,star_utils.f90:3341-3342, andstar_utils.f90:3346, insidecalc_Ptrb_ad_tw) andstar/private/hydro_rsp2.f90(hydro_rsp2.f90:311insidedo1_turbulent_energy_eqn,hydro_rsp2.f90:567insidecompute_PII_face, andhydro_rsp2.f90:912andhydro_rsp2.f90:922insidecompute_Dr). - Root Cause: Four distinct coding defects appear in the experimental
RSP2turbulent-convection solver in upstream Fortran MESA release26.4.1(tracked for restoration to upstream behaviour under #178): calc_Ptrb_ad_tw(star/private/star_utils.f90:3341-3342) definesPtrb_div_etrb = s% RSP2_alfap * x_ALFAP * etrb * rho(which already equals \(P_{\mathrm{trb}} = \frac{2}{3}\alpha_p \rho w^2\) because \(e_{\mathrm{trb}} = w^2\)) and then multiplies byetrba second time (Ptrb = Ptrb_div_etrb * etrb = (2/3) * RSP2_alfap * rho * w^4), yielding a dimensionally invalid \(\mathrm{g\,cm^{-3}\,(cm\,s^{-1})^4}\) pressure whilePtrb_starton line 3346 omitsx_ALFAP = 2/3and line 3334 checksRSP_nz_div_IBOTOMrather thanRSP2_nz_div_IBOTOM.compute_PII_face(star/private/hydro_rsp2.f90:567) writesT_face = alfa*Cp_00 + beta*Cp_m1instead ofalfa*T_00 + beta*T_m1inside theuse_TDC_enthalpy_flux_limiterbranch, substituting specific heat \(C_P\) for temperature \(T\) in the dimensionless flux-limiter argument \(X = (C_{P,\mathrm{face}} T_{\mathrm{face}} / h_{\mathrm{face}})(x_{\alpha_s}\alpha Y_{\mathrm{face}} / \sqrt{2/3})\).compute_Dr(star/private/hydro_rsp2.f90:912andstar/private/hydro_rsp2.f90:922) constructs the automatic-differentiation variablew_00 = wrap_w_00(s, k)on line 912 yet multiplies by the scalarget_etrb(s, k)(pow2(s% w(k))) on line 922, dropping \(\partial D_r / \partial w_k\) from the analytical Henyey Jacobian ofdo1_turbulent_energy_eqn.do1_turbulent_energy_eqn(star/private/hydro_rsp2.f90:311) scales the non-turbulent cell residualw_00 / s% csound(k)by the un-wrapped trial sound speed rather than start-of-stepcsound_start(k), omitting \((\ln\rho_k, \ln T_k)\) partial derivatives whenever trial \(w_k \neq 0\).- Pre-Audit Departure (Scheduled for Upstream Restoration under
#178):crates/flexmesa-star/src/rsp2_ad.rs,crates/flexmesa-star/src/mesh.rs, andcrates/flexmesa-star/src/hydro_state.rscurrently evaluate \(P_{\mathrm{trb}} = \frac{2}{3}\alpha_p \rho w^2\) and \(P_{\mathrm{trb,start}} = \frac{2}{3}\alpha_p \rho_{\mathrm{start}} w_{\mathrm{start}}^2\) gated byRSP2_nz_div_IBOTOM, interpolate face temperaturet_face = t_00 * alfa + t_m1 * betainuse_tdc_enthalpy_flux_limiter, retainw_00 * w_00incompute_Dr, and scale non-turbulent damping bycsound_start(crates/flexmesa-star/tests/rsp2_test.rs). PerDECISIONS #17, these departures are scheduled to revert to exact MESA26.4.1behaviour under #178.
2.10 MLT Cubic Cancellation Near Marginal Convection (mlt.f90)¶
- Upstream Location:
turb/private/mlt.f90(Cardano/Cox convective efficiency polynomial). - Root Cause: When a stellar face approaches marginal convective neutrality (\(0 < \delta = a_0 B^3 = a_0 A^2 (\nabla_{\mathrm{rad}} - \nabla_L) \ll 1\)), evaluating the Cardano cubic root \(\Gamma(B)\) directly in IEEE-754
f64suffers subtractive cancellation between nearly equal cube roots, producing positive-ULP spikes (\(\Gamma \sim +10^{-16} \gg B \implies \zeta \to 1\)) and discontinuous jumps in \(\partial\nabla_T / \partial\ln T\) when \(0 < \delta \lesssim 10^{-12}\), whereas a dimensional floor on \(\nabla_{\mathrm{rad}} - \nabla_L\) would misclassify deep high-\(A\) convective cores (\(A \sim 10^8\), \(\delta \gg 1\) even at \(\nabla_{\mathrm{rad}} - \nabla_L \sim 10^{-13}\)). FlexMESABehaviour:crates/flexmesa-turb/src/mlt.rsevaluates the closed-form root as upstream does (turb/private/mlt.f90:132-151). A 3-term small-\(\delta\) series that an earlier version used for \(0 < \delta \le 10^{-6}\) was removed as a departure from upstream and is recorded as a deferred enhancement in #322.
2.11 Mass-Change Heating, Mass-Adjustment Clamping, and Stop-Condition Deferred Upstream Bugs (eps_mdot.f90 / adjust_mass.f90 / do_one_utils.f90 / history.f90)¶
- Upstream
MESABehavior: Upstreamadjust_massevaluates \(\delta e_{\mathrm{tot}}\) across small wind and accretion steps using 128-bit quadruple-precision (real(qp)) total-energy arrays so changes in gravitational potential \(\Delta(-G m_{\mathrm{grav}}/r)\) do not suffer catastrophic cancellation against \(-G M / r\). Additionally, MESA26.4.1contains three audited bugs tracked under #169: star/private/adjust_mass.f90:239-265(#263): when clamping a crossing step againstmin_star_mass_for_lossormax_star_mass_for_gain, upstream updatesnew_mstar,delta_m, andmstar_dotwithout updatingnew_xmstar, leavings% xmstarands% mstar = s% xmstar + s% M_centerat the unclamped mass on the crossing step.star/private/do_one_utils.f90:738-745and:790-796(#264): upstream aborts viamesa_errorwhenpeak_burn_vconv_div_cs > 0.75 * peak_burn_vconv_div_cs_limitbefore the clean>= limitstop check can be reached.star/private/do_one_utils.f90:635andstar/private/history.f90:1956-1957(#265): upstream computesv_surf_div_v_khasv_surf / (R_phot_Rsun / kh_timescale_yr)in mixed units (\(\mathrm{cm\,s^{-1}\cdot yr / R_\odot}\)).FlexMESANote (#159):crates/flexmesa-star/src/eps_mdot.rs(calculate_eps_mdot_with_change, given pre-stepPrevMassStatearrays) computes \(\Delta r_k = \frac{3}{4\pi} \Delta V_k / (r_{\mathrm{new},k}^2 + r_{\mathrm{new},k} r_{\mathrm{old},k} + r_{\mathrm{old},k}^2)\) and \(\Delta\phi_k = -G (r_{\mathrm{old},k} \Delta m_{\mathrm{grav},k} - m_{\mathrm{grav},\mathrm{old},k} \Delta r_k) / (r_{\mathrm{old},k} r_{\mathrm{new},k})\) inf64(includingv_flagkinetic energy andmass_correctionineval_cell_specific_total_energyandcompute_leak_fracatk = nz - 1), andcrates/flexmesa-star/src/adjust_mass.rs,termination.rs, andmesa_history.rsreproduce#263,#264, and#265verbatim pending the post-v0.1.0#169upstream-bug review.
2.12 Swapped (d_alfa_dlogT, d_alfa_dlogRho) Arguments in HELM-to-Ideal Blend (eosdt_eval.f90:728,749-750)¶
- Upstream Location:
eos/private/eosdt_eval.f90, line 728 (call get_helm_alfa) and lines 749 to 750 (subroutine get_helm_alfa). - Root Cause: In MESA
26.4.1,subroutine get_helm_alfa(rq, logRho, logT, Z, alfa, d_alfa_dlogT, d_alfa_dlogRho)declaresd_alfa_dlogTbefored_alfa_dlogRho(eosdt_eval.f90:749-750), whereas the call site ineval_eosDT_helm_and_idealinvokescall get_helm_alfa(rq, logRho, logT, Z, alfa, d_alfa_dlogRho, d_alfa_dlogT, ierr)(eosdt_eval.f90:728), swapping the density and temperature blend-weight partial derivatives across the narrow outerHELM-to-ideal-gas edge ramp (\(\log_{10}\rho \in [10.8, 10.9]\) and \(\log_{10} T \in [2.9, 3.1]\) when \(e^-e^+\) pairs are excluded). FlexMESABehaviour (#176, Deferred Post-Baseline Review in#169): PerDECISIONS #17and#36, bothcrates/flexmesa-eos/src/blend_dt.rs(eval_lvl6) andsrc/flexmesa/eos/_blend_dt_jax.py(_lvl6) reproduce MESA26.4.1's swapped(d_alfa_dlogRho, d_alfa_dlogT)call-site argument order without option flags, matching compiled MESA26.4.1eosdt_helm_ideal_hi_rho_blendandeosdt_helm_ideal_lo_t_noep_blendoracle rows inmesa_26_4_1_eos_oracles.tsv(< 10^{-13}in Safe Rust"strict"mode). Whether to fix the swapped derivatives after the26.4.1baseline is tracked in #169 and #176.
3. Script-Generated Trajectory & Numerics Reports (#142, #143, #165, #174)¶
Earlier hand-typed E2E-1 through E2E-5 tables on this page claimed 107 / 107 cases verified at 0 ULP from step-capped runs and have been removed following the repository audit (notes/audit/README.md, #142, DECISIONS #17). Under current governance:
- End-to-End
test_suiteStatus (106MESA26.4.1Cases): Reported exclusively by the script-generated table innotes/audit/case_table.md(flexmesa harness table, #143) and the generated port dashboard (#174). Fastvs.StrictNumerics Differences (#165): Reported by the script-generated table innotes/audit/fast_vs_strict.md(scripts/generate_fast_vs_strict_report.py), covering all47math vector sections (474,062inputs) and a shortstar/1.3M_ms_high_Zevolution.
Programmatic Tolerance Comparison Example¶
import numpy as np
from flexmesa.testing import golden
# Compare two 64-bit thermodynamic arrays against a relative tolerance bound
ref = np.array([1.43822426e02, 5.68883671e03], dtype=np.float64)
val = ref * (1.0 + 2.0e-15)
golden.assert_values_match(float(val[0]), float(ref[0]), rtol=1.0e-12)
max_rel = float(np.max(np.abs(val - ref) / np.abs(ref)))
print(f"Relative tolerance check passed: max_rel_err = {max_rel:.3e}")