proteus.outgas.wrapper¶
The outgassing step of each iteration: the target budgets, the desiccated, crystallised and normal paths, and the oxygen budget check.
For how this part works, see Outgassing, rock vapour and volatile trapping.
wrapper
¶
calc_target_elemental_inventories(dirs, config, hf_row)
¶
Calculate total amount of volatile elements in the planet.
This function pre-populates hf_row['O_kg_total'] from the user's O_mode/
O_budget settings (unless O_mode == 'ic_chemistry', in which case the
first outgas call sets it). The atmosphere+dissolved O thus enters
the M_ele aggregation and the Zalmoxis dry-mass subtraction, closing
the bookkeeping asymmetry that can let M_atm exceed M_planet.
Source code in src/proteus/outgas/wrapper.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
check_desiccation(config, hf_row)
¶
Check if the planet has desiccated. This is done by checking if all volatile masses are below a threshold AND verifying that the loss is consistent with cumulative escape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Configuration object |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if desiccation occurred, False otherwise |
Notes
The escape-balance gate guards against the failure mode where an
upstream AGNI or outgas failure wipes the atmosphere as a side
effect (e.g. NaN volume mixing ratios that get zeroed downstream),
causing all *_kg_total to collapse below mass_thresh in a single
iteration without esc_kg_cumulative having moved. The CHILI sweep
R7/R21 cascades fired this exact pattern: AGNI failed, the
atmosphere was wiped, and the old check_desiccation reported success
instead of letting the deadlock detector catch the upstream failure.
The gate compares (M_vol_initial - current M_ele) against
1.5 * esc_kg_cumulative + 1e3 kg. The 1.5x slack absorbs rounding
and threshold-truncation noise; the 1e3 kg floor prevents the gate
from firing on pathologically tiny inventories. If the gate is
inactive (no baseline tracked yet, e.g. resuming an old CSV without
M_vol_initial), the function falls back to the old threshold-only
behaviour. The current total skips a non-finite element, as run_desiccated
does, and mass an earlier desiccation removed, M_desiccated, is left out
of the loss the gate compares, so a desiccated row passes again on resume.
Scope of "desiccated": the threshold loop below considers the volatile
elements (vol_element_list: H, O, C, N, S) together with the noble gases,
so a planet with a noble-gas dominated atmosphere is not desiccated.
Source code in src/proteus/outgas/wrapper.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
check_ic_oxygen_budget(config, hf_row, threshold_frac=0.5)
¶
Verify the user-supplied IC oxygen budget against CALLIOPE's chemistry.
After the first run_outgassing call at IC, CALLIOPE (or
atmodeller) has written hf_row['O_kg_total'] from the fO2-
buffered equilibrium. We compare that against the user-supplied
O_budget that calc_target_elemental_inventories stashed earlier
in hf_row['O_kg_user_ic']. A large divergence usually means
either:
- The user under-specified O_budget so the planet cannot actually support the equilibrium atmosphere CALLIOPE wants. The implied mantle FeO reservoir is being over-drawn.
- The user over-specified O_budget so M_planet now carries phantom oxygen mass that has no physical home (not in the atmosphere, not in the mantle FeO that PALEOS density accounts for).
Both cases are best caught loudly at IC rather than silently corrupting the trajectory.
Skipped when:
- planet.fO2_source != "user_constant". When
fO2_source = 'from_O_budget' the user O budget is the
authoritative input that drives the chemistry,
so any "divergence" between it and the derived O inventory is
zero by construction. The check is meaningful only when fO2 is
the input and O is the output.
- O_kg_user_ic is the sentinel (-1.0), which marks
O_mode == 'ic_chemistry' (the user opted into chemistry-
derived O so any discrepancy is, by definition, accepted).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Configuration object. Reads |
required |
hf_row
|
dict
|
Helpfile row after the first outgas call at IC. |
required |
threshold_frac
|
float
|
Maximum allowed relative divergence between user O_budget and CALLIOPE's IC equilibrium value. Default 0.5 (50 percent). |
0.5
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If divergence exceeds |
Source code in src/proteus/outgas/wrapper.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
condensed_mass_withheld(config, hf_row, *, initial)
¶
Start the chemistry from no condensed mass, keeping held condensates out of it.
Every backend starts from empty {e}_kg_condensed and {X}_cd_kg
columns; only atmodeller with condensates enabled fills them, so they stay 0
otherwise. With outgas.prevent_desaturation on, the condensed mass so far
is also taken out of each element total for the solve, so the chemistry cannot
re-vapourise it, and on exit it is added back to the totals, to
{e}_kg_condensed and to each condensate's {X}_cd_kg, on top of what the
solve newly condensed. The reservoirs then only grow. The exit runs also when
the solve raises, so the row then holds the held mass, no more and no less.
{X}_cd_activity stays the solver's value: it is the saturation of the
inventory left in the solve, not of the held layer, so it can be below 1 while
a layer is held.
In the init stage (initial) nothing is held back: each init iteration
resets the element totals to the delivered budget and solves the same starting
state again, so condensate from an earlier trial solve is not kept.
Source code in src/proteus/outgas/wrapper.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
desiccated_after_trapping(config, hf_row, desiccated, step)
¶
Whether a desiccated planet is still desiccated after this step's trapping.
A remelting step returns buried mass to the melt, where :func:run_desiccated
keeps it while trapping is on. Once the mass the melt holds brings an element
above mass_thresh the planet holds volatiles again, and the flag clears so
that escape and outgassing take that mass from there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Configuration object |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only |
required |
desiccated
|
bool
|
Whether the planet was desiccated before this step |
required |
step
|
TrappingStep or None
|
What this step's trapping did, as returned by |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the planet is desiccated now. |
Source code in src/proteus/outgas/wrapper.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
outgassing_derives_o_kg_total(config)
¶
Whether each outgassing call derives O_kg_total from the melt fO2.
CALLIOPE and atmodeller derive the O budget from the fixed fO2 under
planet.fO2_source = 'user_constant'; O_mode = 'ic_chemistry'
requires that source at config load. The dummy outgassing derives an empty
O_kg_total only in the init stage and otherwise keeps it as given, and
from_O_budget takes the O budget as input.
Source code in src/proteus/outgas/wrapper.py
460 461 462 463 464 465 466 467 468 469 470 471 472 | |
run_crystallized(config, hf_row, dt)
¶
Handle a crystallized mantle: volatile exchange frozen, but escape still erodes the atmosphere.
After the mantle solidifies (Phi_global < phi_crit), volatiles can no longer exchange between mantle and atmosphere: dissolved volatiles are trapped in the solid and outgassing no longer replenishes the atmosphere.
Escape, however, continues. run_escape runs earlier in the main loop
with atmosphere_only=True in this regime, so it debits each element
total (*_kg_total) by its share of the escaping mass, its atmospheric
mass over the sum of the element masses in the atmosphere. The atmospheric
reservoirs are scaled here by the fraction of that same sum that remains,
so each element's atmosphere loses exactly what escape took from its total
and the per-element totals and reservoirs stay consistent. M_atm, the
sum of the species masses, can differ from the element sum where the
chemistry's molar masses do (by 1.8e-5 with CALLIOPE); scaling it by
(M_atm - esc) / M_atm instead would leave that fraction of every step's
loss in the atmosphere. The scaling is uniform, so partial-pressure ratios,
VMRs and the mean molecular weight are unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Configuration object. Used to confirm the escape model is unfractionated. |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only. |
required |
dt
|
float
|
Length of the current step [yr], used to size the escaped mass. |
required |
Source code in src/proteus/outgas/wrapper.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | |
run_desiccated(dirs, config, hf_row, first_iter)
¶
Handle desiccation of the planet. This substitutes for run_outgassing when the planet
has lost its entire volatile inventory. The atmosphere and the melt are emptied,
noble gases included; the solid mantle keeps its share, which becomes each
species and element total. With solid-phase trapping on, the melt is kept as
well: a remelt returns buried mass to it, and emptying it every step would make
what the planet keeps depend on how many steps the remelt takes. The mass
removed is booked in M_desiccated and the Zalmoxis target.
The kept share is the sum of the kept columns limited to [0, total before the
call], each column scaled alike; a non-finite column keeps nothing and is
logged. The kept columns, kg and mol, are set to their share. No total rises,
so the mass removed is not negative and a row that passed
check_desiccation passes it again. A non-finite total stays as it is, with
its mol total set to NaN. A non-finite M_desiccated reads as 0, as in the
check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirs
|
dict
|
Dictionary of directory paths |
required |
config
|
Config
|
Configuration object |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only |
required |
first_iter
|
bool
|
Whether the run is in its init stage. |
required |
Source code in src/proteus/outgas/wrapper.py
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
run_outgassing(dirs, config, hf_row, *, initial)
¶
Run outgassing model to get new volatile surface pressures
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirs
|
dict
|
Dictionary of directory paths |
required |
config
|
Config
|
Configuration object |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only |
required |
initial
|
bool
|
Whether this is an init-stage iteration, where the dummy outgassing derives an empty O budget from the outgassed species. |
required |
Source code in src/proteus/outgas/wrapper.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
run_outgassing_and_vapourisation(dirs, config, hf_row, first_iter)
¶
Runs volatile outgassing and rock vapourisation together and combines the results.
Two step process: - outgassing calculated from solubility+thermochemical equilibrium - vapourisation of refractory species from the surface.
Vapourisation re-equilibrates the combined gas, allowing for computation of melt outgassing and dissolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirs
|
dict
|
Dictionary of directory paths |
required |
config
|
Config
|
Configuration object |
required |
hf_row
|
dict
|
Dictionary of helpfile variables, at this iteration only |
required |
first_iter
|
bool
|
Whether the run is in its init stage; the dummy outgassing derives an empty O budget only then. |
required |
Source code in src/proteus/outgas/wrapper.py
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | |