Repository navigation
Check IIP level equations relative to their total rate - #3828
Conversation
The level solve accepted a population when every residual of the normalized rate equations was below an absolute 1e-10. That limit depends on the unit of time and on how fast each level is populated, and sits at the precision the root finder reaches, so accepted states could fail final closure at 1.0-2.3e-10. Each residual is now divided by the gross rate of its equation, the sum of the magnitudes of the rates into and out of the level, and closes at LEVEL_RESIDUAL_LIMIT = 1e-10 of it. A metamorphic test checks that the relative residual does not depend on the rate unit. The terminal level residual, re-evaluated at the charge-solved electron density, is removed. It was a diagnostic only, and rebuilt the bound-bound rates on every evaluation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
*beep* *bop* Hi, human. I'm the @tardis-bot and I noticed that your email is not associated with an ORCID ID in our database. Please add your email and ORCID ID to the If you don't have an ORCID ID yet, you can create one for free at orcid.org. ORCID IDs help ensure you get proper credit for your scientific contributions. The format should be: Runs: ORCID check · comment publisher |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3828 +/- ##
==========================================
+ Coverage 71.35% 71.36% +0.01%
==========================================
Files 207 207
Lines 15983 15997 +14
==========================================
+ Hits 11404 11417 +13
- Misses 4579 4580 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| npt.assert_allclose(perturbed_q_ratio, 0.125) | ||
|
|
||
|
|
||
| def test_relative_level_residual_does_not_depend_on_rate_unit() -> None: |
There was a problem hiding this comment.
I couldn't really make sense of what this was trying to test. Codex review found some issues and explained them better than just my general confusion:
-
This test bypasses the production normalization helper. Line 285 computes residual / total_rate inside the test. Breaking calculate_relative_level_residual would leave this test passing.
-
This test never exercises acceptance. Reverting the solver to its old absolute-residual stopping criterion would also leave this test passing. That criterion is the central behavior this PR changes.
-
This test does not establish that the denominator is correct. Omitting recombination from total_rate, for example, still produces a denominator that scales linearly with every rate. Both assertions would pass.
|
There is a merge conflict to be fixed |
📝 Description
Type: 🪲
bugfixThe level solve accepted a population when every residual of the normalized rate equations was below an absolute 1e-10. That limit depends on the unit of time and on how fast each level is populated, and sits at the precision the root finder reaches, so accepted states could fail final closure at 1.0-2.3e-10. Each residual is now divided by the total rate of its equation (the sum of the magnitudes of the rates into and out of the level) and closes at the fraction LEVEL_RESIDUAL_LIMIT = 1e-10. A test checks that the relative residual does not depend on the rate unit.
The terminal level residual, re-evaluated at the charge-solved electron density, is removed. It was a diagnostic only, and rebuilt the bound-bound rates on every evaluation.
📌 Resources
Examples, notebooks, and links to useful references.
🚦 Testing
How did you test these changes?
☑️ Checklist
build_docslabel