-
-
Notifications
You must be signed in to change notification settings - Fork 493
Description
Is your feature request related to a problem? Please describe.
The RadiativeRatesSolver class in tardis/plasma/equilibrium/rates/radiative_rates.py has no direct unit tests. A fixture radiative_rate_solver already exists in tardis/plasma/equilibrium/tests/conftest.py but no test file ever calls .solve() on it. Errors in this solver (wrong transition direction, missing spontaneous emission term A_ul, wrong output index structure) would silently corrupt all ion and level populations without any focused test catching them.
Describe the solution you'd like
Create a new test file tardis/plasma/equilibrium/tests/test_radiative_rates.py with focused unit tests for the class. Tests should cover:
- Valid construction with a correct Einstein coefficients DataFrame
AssertionErrorraised when columnsA_ul,B_ul,B_lu, ornuare missingAssertionErrorraised when index names are wrongAssertionErrorraised whenlevel_number_lower >= level_number_uppersolve()output DataFrame has the correct 6-level MultiIndexr_lu = B_lu × J_nuverified numericallyr_ul = B_ul × J_nu + A_ulwith spontaneous emission term present- Full
solve()output pinned against regression HDF5 data - Zero radiation field intensity (
W=0) givesr_lu=0andr_ul = A_ul
Regression data path should be modified locally so no PR to the regression data repository is needed.
Describe alternatives you've considered
- Relying only on indirect full plasma regression tests — rejected because a failure anywhere in the plasma chain masks whether
RadiativeRatesSolveris the cause. - Only testing construction validation — rejected because the most critical logic is inside
solve()and must be verified against known physical values.
Additional context
The existing fixture in conftest.py (lines 64–66) already builds a RadiativeRatesSolver from Si Chianti atomic data — the test file just needs to use it. Bonus tests to mention in the PR: pass both DilutePlanckianRadiationField and PlanckianRadiationField as inputs to solve(), assert all output rates are non-negative, and verify that both up and down transitions appear for every spectral line.