Repository navigation
Book the core heat change of a structure update with energy_balance - #1178
Conversation
With core_bc = "energy_balance" the core heat content is core_heatcap * tfac_core_avg * M_core times the temperature of the CMB basic node. A structure update carries the mantle entropy by mass parcel onto the new mesh, so the node temperature changes with the CMB pressure and the core heat content jumps, with no column booking it. The update now books the heat content after the carry minus before it in step_dE_struct_core_J, and the energy_balance call fills step_dE_core_J (the heat content at the end of the call minus at the end of the last kept call) and core_C_eff, so the core ledger E_core_residual_J runs in this mode too and closes with the booked term. No physics changes.
egpbos
left a comment
There was a problem hiding this comment.
🧐 The new module and its registry entries are needed and small; a few parts could be shorter or owned elsewhere: 3 questions, 1 request.
Size: +425/-23, of which 283 lines are tests. No split needed. I did not run the code or a coupled case.
egpbos
left a comment
There was a problem hiding this comment.
💂 3 regressions in 2 files, each with a measured fix (one partly); +425/-23 lines (net +402), 67 % of the added lines in tests.
| Metric | Base | Head | Head with the fixes |
|---|---|---|---|
AragogRunner.run_solver lines (lizard NLOC, limit 50) |
55 | 60 | 53 |
interior_energetics/aragog.py lines (aim 500) |
3844 | 3854 | 3846 |
core_heat_content docstring / body lines |
new | 7 / 6 | 5 / 6 |
No function crosses the complexity limit of 10 (ruff C901); run_solver reaches it (8 to 10). No new unused code (vulture) or duplicated block (symilar). Comment and docstring lines are 34 % of the added source lines (29 of 86), against 36 % in src/proteus at the base.
No fix within the rules: test_a_failed_call_leaves_the_solver_with_the_state_it_started_from grows from 81 to 87 lines and tests/interior_energetics/test_aragog.py from 6118 to 6176 lines, both for new assertions on the runner; tools/_helpfile_scan.py grows from 874 to 875 lines by one registry entry. Not counted: N806 for dE, which the package breaks 2623 times at the base.
Not run: the CVODE test in test_aragog.py (no scikits_odes_sundials here), the JAX runner, and the unit tier outside these two test files.
The structure-update test now checks the energy_balance booking order with and without a stored entropy, the autouse fixture returns its mock, the step_dE_struct_core_J description names only what the column holds, and run_solver uses its core_bc local in place of the repeated config reads.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1178 +/- ##
==========================================
+ Coverage 96.25% 96.32% +0.07%
==========================================
Files 168 169 +1
Lines 28951 29201 +250
Branches 4779 4834 +55
==========================================
+ Hits 27866 28129 +263
+ Misses 771 768 -3
+ Partials 314 304 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
timlichtenberg
left a comment
There was a problem hiding this comment.
Thanks Patrick, this closes the gap in #1113, and the interior output stays unchanged against main. Two things before merge:
After a giant impact the core ledger is not booked and the offset stays. _remelt_aragog sets solver._solution = None (wrapper.py:2260), so end_heat_content returns None at the next structure update and book_core_across_update books nothing.
In a run with one dummy impact of 0.003 M_E at 3 kyr, E_core_residual_J jumps from 8.7e27 to 1.9e29 J at 3100 yr (E_core_residual_frac 0.020 to 0.377) and ends at 0.225, against 0.011 without the impact; step_dE_struct_core_J is 0 on that row. The output reference and the usage page say the update change is booked with energy_balance without exception. Please either book the re-melt step (take the heat content before the solution is dropped), or state in both pages that the ledger is no closure check after an impact.
Please add one test against a real Aragog solver. The new module reads 9 private Aragog attributes on the default core_bc, and the tests only see a stand-in with the same names (test_aragog.py mocks the module for the whole file). A small energy_balance solver from the Aragog test helpers is enough: the core heat content over C equals the basic-node temperature, C dT_node equals the closure term, and an update with an unchanged mesh books exactly 0. Skip it when the EOS tables are missing.
On your question about the CMB node temperature: yes, please open the Aragog issue for a public method. It also takes most of the private reads out of this module, and a follow-up PR is fine for that.
The re-melt drops the Aragog solution, so the structure update after an impact found no heat content to measure from and booked nothing; the core ledger kept the jump. The re-melt now keeps the core heat content at the end of the landing step, and the update after it books the change to its own start state in step_dE_impact_core_J. A smoke test checks the heat content against a real energy_balance solver: the node temperature, the closure term of the Aragog CMB check, and a zero booking on an unchanged mesh. It skips without P-S tables.
|
🤖 Thanks, both points are done in 3c5fa10. Giant impact. The re-melt now keeps the core heat content at the end of the landing step before it drops the solution. The structure update after the impact books the change from there to its own start state in Real Aragog solver. New smoke test Mutants on the lines of this commit: 85 of 85 killed. The Aragog issue for a public node-temperature method follows. |
timlichtenberg
left a comment
There was a problem hiding this comment.
Thanks Patrick, both points are addressed. I reran the impact case at 3c5fa10: the impact row now books the core heat change that was missing before, and the residual stays flat across the impact. The two steps that remain unbooked are the calls where Aragog skips its own CMB closure check, as you say. The smoke test passes with real tables and fails when the capacity factor or the node entropy is changed.
One follow-up, not for this PR: no CI job has the P-S tables, so the smoke test is always skipped there. A follow-up that runs it in CI would make it protect the core balance.
Description
With
core_bc = "energy_balance"the core heat content iscore_heatcap * tfac_core_avg * M_coretimes the temperature of the CMB basic node. A structure update carries the mantle entropy by mass parcel onto the new mesh, so that temperature follows the new CMB pressure and the core heat content jumps, with no column booking it. This PR books it, as proposed in the issue; the physics does not change.step_dE_struct_core_J(newinterior_energetics/aragog_core_balance.py, called fromAragogRunner._apply_structure_update).energy_balancecall now fillsstep_dE_core_J(heat content at the end of the call minus at the end of the last kept call) andcore_C_eff(the capacityC), so the existing core ledgerE_core_residual_J/E_core_residual_fracruns in this mode and closes with the booked term._check_cmb_ledger): bottom cell entropy extrapolated half a basic spacing withdSdr_cmb, on the solver's_cmb_node_phaseevaluator. This reads private solver attributes, as thecore_modulepath already does.docs/Explanations/model.mdanddocs/How-to/usage_core_evolution.mdno longer say the term is 0 in this mode.Closes #1113
Related open PRs on the same files: #1168 (
coupler.py,output.md) and #1149 (interior_energetics/wrapper.py,output.md); expect small conflicts in the generated output reference.Validation of changes
input/all_options.toml(1 M_E, Zalmoxis dynamic structure, Aragogenergy_balance) with the dummy atmosphere and star, no escape, andsolver_method = "radau", to 12 kyr. All 6 structure updates book a positive term (+1.2e28 to +6.3e28 J, 11 to 63 K at C = 1.0017e27 J/K) whileP_cmbrises by 1.1 to 3.1 GPa: the sign follows the pressure change in 6 of 6, and the size is in the range the issue measured. With the term the core ledger moves by at most 3e24 J at an update; without it, it would grow by 1.5e29 J over the run. On the 21 rows without an update,step_dE_core_J / (core_C_eff * dT_cmb_node)is 1.0000, so the node temperature used here is the helpfileT_cmb_node.tests/interior_energetics/test_aragog_core_balance.py): the booked heat equalsC (T_node(P_new) - T_node(P_old))at the carried entropy, with guards against a missingtfac_core_avgand against the bottom cell entropy in place of the node entropy; its sign follows the pressure change; an update that moves nothing books exactly 0; the ledger closes over call, update, call, and misses by exactly the booked heat without it.tests/interior_energetics/test_aragog.pychecks the order in the runner (heat taken before the reset, booked after the entropy hand-over) and that the columns are written only for a returned call.aragog_core_balance.py:63only switches a log line.pip install -e ".[develop]": the unit tier passes except tests that need CVODE (scikits_odes_sundials), atmodeller or a full install (test_install_scripts.py,test_installer.py,test_doctor.py); none of them touch the changed code. ruff,validate_test_structure.shand the fourgenerate_*.py --checkpass.Not checked: the JAX runner (
aragog_jax.py) does not write the new columns; a giant-impact re-melt also moves the CMB node and is not booked, so theenergy_balancecore ledger may show it on impact rows; whether this jump causes the AragogCMBLedgerMissErrorstops (FormingWorlds/aragog#128).Checklist