Repository navigation
Treat the oxygen budget as derived under from_mantle_redox - #1190
Merged
Merged
Conversation
Under planet.fO2_source = 'from_mantle_redox' CALLIOPE and atmodeller fix the fO2 at the offset of the melt redox state and derive O_kg_total from it, as they do under user_constant. The truth table of outgassing_derives_o_kg_total now reads every source from the config validator, and a property test checks the rule for any value of the module and the source. Both fail until the rule counts from_mantle_redox.
The Zalmoxis core stays at core_frac of the planet without its kept volatiles when the outgassing derives the oxygen. The test now runs for CALLIOPE and atmodeller under user_constant and under from_mantle_redox. Under from_mantle_redox it fails until the derived oxygen leaves the kept mass: the core then falls by 0.325 of the oxygen inventory.
With the fO2 fixed by the melt redox state the next outgassing call replaces O_kg_total with the derived budget, so impactor oxygen credited to it leaves the mass ledger. The impact test now runs under from_mantle_redox for CALLIOPE and atmodeller and checks M_accreted_rock against the impact mass. Both cases fail until the oxygen goes into the rock: on the base the rock is short by the delivered oxygen.
Under from_mantle_redox the fixed fO2 is the offset of the melt redox state, fO2_shift_IW_mantle, and outgas.fO2_shift_IW is not read. The test checks that the oxygen rise warns under that source and that the message names the offset of the last row instead of the config value; under user_constant it keeps the config value. It fails until the check runs for from_mantle_redox and words the source.
Under planet.fO2_source = 'from_mantle_redox', CALLIOPE and atmodeller fix the fO2 at the offset of the melt redox state and, as under user_constant, derive O_kg_total from it on every call. outgassing_derives_o_kg_total now says so. With it, the Zalmoxis structure leaves the derived oxygen out of the kept mass, an impact puts the delivered oxygen into the rock (not into the budget, which the next outgassing call replaces), and the oxygen rise check runs. The docstring no longer claims that O_mode = 'ic_chemistry' needs user_constant; the config refuses it only with from_O_budget. The oxygen warning names the fixed fO2 of each source: outgas.fO2_shift_IW under user_constant, and fO2_shift_IW_mantle of the last row under from_mantle_redox. apply_impact refuses a split whose rock, delivered and lost volatiles do not add up to the impact mass, and one that credits delivered oxygen to a budget the outgassing derives. Both raise before anything moves.
…e_redox The redox page now says that the outgassing derives O_kg_total from the fixed fO2 under from_mantle_redox, so the Zalmoxis structure counts that oxygen as mantle mass and impact oxygen goes into the rock. It also states where the atmodeller IW buffer differs from the CALLIOPE one at 1 bar: equal from 1000 to 8148 K, 0.18 log units lower at 700 K, and about 42 log units lower above 8148 K. The Deng et al. (2023) citation gets its footnote.
A short Earth run under from_mantle_redox with one dummy impact of 0.01 Earth masses and 1000 ppmw oxygen checks that the accreted rock equals the impact mass, that the impactor oxygen is in the rock, and that the derived O_kg_total moves by less than 1 % of the delivered oxygen across the impact. The test writes the validation plot of the ledger and runs in the aragog-accretion nightly shard on Linux.
The case explains the oxygen ledger of one impact under from_mantle_redox, its tolerances, the plot and the test command. The Kegerreis and Roche citations on the page use footnotes, with the definitions of the accretion reference page.
Under from_mantle_redox the outgassing derives O_kg_total as under user_constant, so the per-element closure with trapping or a seal must not hold oxygen to its reservoirs. The impact split check takes its tolerance from the clamped rock and the impact mass instead of the planet mass.
The impactor oxygen docstring and the generated config reference, the outgassing and interior reference pages, the fO2 warning module and two comments now name from_mantle_redox next to user_constant where the outgassing derives O_kg_total.
…test O_kg_total changes by -2.96e16 kg at the impact also when the impactor oxygen goes into the volatile budget, so that clause passed on either booking. M_volatile_change takes the whole 5.972e19 kg there and none of it when the oxygen is rock. The two assertions that followed from the first are gone, and the nightly comment names the Linux-only test.
The validation case states what the volatile booking of the impactor oxygen does to M_accreted_rock and M_volatile_change, names CALLIOPE and its limit, and links from a new redox section on where the oxygen budget comes from. The atmodeller buffer gap above 8148 K is given at 8149 and 10000 K. The wrapper page cites Biersteker & Schlichting (2021) and the published Roche et al. (2026) with footnotes in the standard form, links the Zenodo data record, and names both jobs of the wrapper.
…ct mass An event record may give a merged mass up to 1e-6 short of target plus impactor, so a small impactor can have a negative impact mass; its rock clamps to 0 and the split must still close. The trapping rule reads the source once.
The model page and the atmodeller constraint comment state the buffered oxygen of the melt redox source next to user_constant.
The atmloss_law docstring cites Roche et al. (2026), Kegerreis et al. (2020) and Biersteker & Schlichting (2021) with footnotes, and the reference page carries the published Roche et al. record.
…dox tracker The redox page names the outgassing modules for which the oxygen budget is derived, moves the atmodeller buffer limits into their own subsection and lists giant impacts among the limits of the iron tracker. The impactor oxygen case moves its measured numbers into the reference answer, and the page title says what it checks.
The delivered and lost volatiles and the oxygen put into the rock must add up to the impactor content within 1e-12 of it. The check no longer depends on the impact mass, so an impact mass near zero and a clamped rock are checked like any other impact.
…ning conditions Impact melting returns tracked solid iron to the melt like any rise of the melt fraction; only the iron of the impactor stays out of the reservoirs. The model page lists the 3 conditions of the oxygen rise warning, and the wrapper page restores the case layout sentence, cites Roche et al. (2026) in one form and states the numbers of the wrong booking under the tested quantities.
Each element of the impactor content must equal its delivered and lost parts, plus the rock oxygen for O, within 1e-12 of it, and no part may be negative or NaN. A transfer of mass between elements or a negative part offset elsewhere no longer closes.
Under from_mantle_redox the outgassing offset comes from the melt redox state, which planet.interior_chem.ferric_fraction_initial seeds; outgas.fO2_shift_IW has no effect there.
…gets The slow ledger test asserts that the oxygen total of the impact row is the sum of its atmosphere, melt and solid parts, and that a row precedes the impact. The equal-to-target case uses round ppmw values that exceed the zero impact mass.
Under from_mantle_redox the offset follows the melt redox state, so it is not fixed. The config description, the docstrings and the oxygen warning name the fO2 that each outgassing call holds.
The melt redox page, the generated planet reference and the validation index give each paper its footnote with the DOI and SciX link from Crossref and ADS; the preprint links to arXiv. The validation index row of the redox case gets its plot cell.
…dry mantle With dry_mantle the structure target leaves out all derived oxygen while the core base keeps it, since it is not a kept volatile; with a wet mantle only its atmospheric part leaves the target.
Both bookings conserve mass; the rule moves core_frac of the impactor oxygen into the core and keeps it out of the desiccation baseline, so the case names those effects and the model rule as its reference.
The fault matrix of the split test now takes 1e-9 of the impact mass from the delivered hydrogen as well, for a positive and a clamped rock, so the separate clamped deficit test goes; the deficit test with the fO2_source parametrization and an atmosphere loss stays.
The core share of impactor oxygen holds with the Zalmoxis structure, the atmodeller buffer threshold is 8148 K on every page, the fcc-hcp boundary names its temperature, and the impact page reads in shorter sentences.
…dget The dummy outgassing builds its O reservoirs from the O of its species and keeps a user O budget as given, so the per-element closure must skip O there while it still stops a leak in another element.
The dummy O reservoirs are the stoichiometric O of its species and are not tied to O_kg_total, so the closure skips O for the dummy module as it does where the chemistry derives the total. The accretion and structure rule stays as it is.
…the fO2 offsets of the impactor oxygen
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1190 +/- ##
==========================================
+ Coverage 96.13% 96.32% +0.19%
==========================================
Files 174 174
Lines 29759 29778 +19
Branches 4909 4913 +4
==========================================
+ Hits 28608 28683 +75
+ Misses 773 756 -17
+ Partials 378 339 -39
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With
planet.fO2_source = "from_mantle_redox", CALLIOPE and atmodeller hold the fO2 at the offset of the melt redox state and deriveO_kg_totalon every call, as they do under"user_constant". The flag that says so,outgassing_derives_o_kg_total, was true only for"user_constant". Three parts of the code read that flag, and each treated the derived oxygen under"from_mantle_redox"as an input budget:O_kg_total. The accreted rock was short by that oxygen, andM_volatile_changeheld it.dry_mantle = truetook the derived oxygen out of the mass that sets the core.The flag is now true for both sources with CALLIOPE or atmodeller. What changes for a run with
"from_mantle_redox":M_volatile_changetakes none of it.core_fractimes the derived oxygen (first table below)."user_constant".fO2_shift_IW_mantle. The error of the oxygen budget check at the start, which already ran under this source, namesplanet.interior_chem.ferric_fraction_initialas the setting to change.For every source,
apply_impactnow checks the split of the impactor volatiles per element before any mass moves: delivered plus lost, plus for oxygen the part put into the rock, must equal the impactor content within 1e-12 of it, and no part can be negative. A split that does not close stops the run with aRuntimeError.One more change affects the dummy outgassing: the per-element closure now leaves its oxygen out under every source, because the dummy module builds its oxygen reservoirs from H2O, CO2 and SO2 and keeps
O_kg_totalas given. On main this was so only under"user_constant". With the dummy outgassing,"from_mantle_redox", Aragog,trap_mode = "front"and an oxygen budget of 1e21 kg (O_mode = "kg"), main stops at the closure (O_kg_total1.000e21 kg against reservoirs of 1.342e21 kg); this branch completes the run with the same 2 values in the helpfile.Runs with
"user_constant"or"from_O_budget"and CALLIOPE do not change in the 3 pairs listed below. No config key changes. No issue is tagged.Questions for the review:
O_kg_totalmeant as a quantity that the outgassing derives under"from_mantle_redox", as under"user_constant", so that Zalmoxis must not keep that oxygen in the dry-mantle mass and accretion must move delivered oxygen into rock?"from_mantle_redox"is the IW buffer at max(T_magma,outgas.T_floor) plusfO2_shift_IW_mantle. Is that the intent at temperatures where atmodeller has its own buffer limits (below 1000 K and above 8148 K)? This PR only documents the limits (docs/Explanations/redox.md).core_fracof it, as it does under"user_constant". Is that intended, or must impactor oxygen stay in the mantle? I have no literature check for this rule.Validation of changes
Before and after, my runs on macOS arm64 with
PYTHONPATH=<tree>/src: maina7e063eeagainst this branch ata72d1b33, 1 Earth mass, CALLIOPE 26.11.8, Aragog 26.11.24, Zalmoxis 26.11.22 withdry_mantle = true,core_frac = 0.325andlowt_extension = false, H 0.5 oceans, C 2.73e20 kg. The 3 module versions are the lowest thatpyproject.tomlof the tip allows. Each number is from the 2runtime_helpfile.csvfiles by script.Run without impacts (
"from_mantle_redox", 13 rows to 2692 yr): 138 of 1073 numeric columns differ.M_core(kg), all rowsM_mantle(kg), all rowsR_int(m), all rowsP_surf(bar), last rowT_magma(K), last rowThe core mass change is 3.158e20 kg, which is 0.32500 times the
O_kg_totalof the first row (9.7165e20 kg). Over 6 runs of this config withlowt_extension = trueat8f66582d, whoseplanet.delta_T_superdiffers by steps of 1e-12 of its value, the last-row spread is 0 forM_core,M_mantleandR_int, 4.2e-9 forP_surfand 1.3e-7 forT_magma.F_cmbspreads by 1.7e-2 there, more than its change of +3.3e-3 in this pair, so it is not in the table.Run with 1 impact of 0.01 Earth masses with 1000 ppmw oxygen at 1000 yr and no atmosphere loss (the config of
tests/integration/test_slow_accretion_oxygen_ledger.py, 14 rows). The impactor oxygen is 5.972e19 kg.M_accreted_rock(kg)M_volatile_change(kg)O_kg_total(kg)The same check as a validation case on
docs/Validation/accretion/wrapper.md, from that slow test:Runs that must not change, 13 rows each to 2692 yr, same comparison script: with
"user_constant", 0 of 1073 numeric columns differ between main and this branch; with"from_O_budget"(O budget 9.7e20 kg), 0 of 1073. The impact run above with"user_constant"(14 rows): 0 of 1073, withM_accreted_rock5.972000e22 kg andM_volatile_change0 on both trees. The columnruntime(wall time) is left out of the count.pytest -q -p no:randomly -m "not slow"on the 6 changed fast test files with the branch source ata72d1b33, in both file orders: 485 passed.coverage run -m pyteston the same files: 23 changed statements insrc, 0 missed (git diff -U0 a7e063ee a72d1b33 -- srcagainst the missed lines of the coverage report).043177b4, 25 of 25 jobs pass: https://github.com/FormingWorlds/PROTEUS/actions/runs/47505771308. The tip adds 2 merges of main:git diff --name-only 043177b4 a72d1b33lists 9 files, those of Raise the VULCAN floor to 26.12.2 #1187 and Pass the chemical eddy diffusivity to the numpy path of Aragog #1188.DID NOT RAISE). Its tolerance at 1e-3: 14 more (DID NOT RAISE). Its test for a negative part off: 8 more (7DID NOT RAISE, 1AssertionError)."from_mantle_redox"taken out of the flag: 14 more. The dummy term taken out of the closure rule: 5 more (3AssertionError, 2 closureRuntimeError).Not checked: a run to full solidification (the pairs above end at 2692 yr with a molten mantle); a run in which the front traps volatiles under
"from_mantle_redox"(withtrap_mode = "front"the 13-row pair completes on both trees, with the same 138 columns that differ, and traps nothing); atmodeller in a full run (the unit tests cover its flag; the runs use CALLIOPE); an impact with atmosphere loss in a full run (unit tests only); an impact under"from_O_budget"in a full run.Late-time differences are not resolved. In 4 run pairs to about 8.4e5 yr (main
1571eb41against 2 earlier commits of this branch,"from_mantle_redox", no impacts), the lastT_magmaof the branch differs from main by +6.7, +6.4, +2.5 and -17.6 %. The 4 main runs, whoseplanet.delta_T_superdiffers by 1e-12 of its value, spread by 6.8 % in the same quantity.M_corediffers by +1.6274e-4 in all 4 pairs.Size, from
git diff --numstat a7e063ee..a72d1b33andgit ls-tree -lat both commits:Checklist