Skip to content

Commit

Permalink
Merge pull request #292 from FormingWorlds/hn/hppm
Browse files Browse the repository at this point in the history
Allow setting Hydrogen inventory relative to mantle mass
  • Loading branch information
nichollsh authored Nov 26, 2024
2 parents a194012 + 92aa7c1 commit 5a273dd
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 19 deletions.
9 changes: 5 additions & 4 deletions input/aragog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
H_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mass of melt
CH_ratio = 1.0 # C/H mass ratio in mantle/atmosphere system
H_oceans = 0.0 # Hydrogen inventory in units of equivalent Earth oceans
H_ppmw = 109.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mantle mass

# Set initial volatile inventory by partial pressures in atmosphere
[delivery.volatiles]
Expand Down
9 changes: 5 additions & 4 deletions input/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
H_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mass of melt
CH_ratio = 1.0 # C/H mass ratio in mantle/atmosphere system
H_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mantle mass

# Set initial volatile inventory by partial pressures in atmosphere
[delivery.volatiles]
Expand Down
3 changes: 2 additions & 1 deletion input/hd63433d.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
CH_ratio = 1.0 # C/H mass ratio in mantle/atmosphere system
H_oceans = 8.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.01 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 235.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down
3 changes: 2 additions & 1 deletion input/k218b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 0.1 # C/H ratio in mantle/atmosphere system
CH_ratio = 0.1 # C/H mass ratio in mantle/atmosphere system
H_oceans = 60.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.01 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 235.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down
3 changes: 2 additions & 1 deletion input/l9859d.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
CH_ratio = 1.0 # C/H mass ratio in mantle/atmosphere system
H_oceans = 8.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.01 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 235.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down
3 changes: 2 additions & 1 deletion input/trappist1c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"

# Set initial volatile inventory by planetary element abundances
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
CH_ratio = 1.0 # C/H mass ratio in mantle/atmosphere system
H_oceans = 8.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.01 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 235.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down
13 changes: 8 additions & 5 deletions src/proteus/config/_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ class Elements:
Attributes
----------
CH_ratio: float
Volatile C/H nass ratio in combined mantle+atmosphere system.
Volatile C/H mass ratio in combined mantle+atmosphere system.
H_oceans: float
Bulk hydrogen inventory in units of equivalent Earth oceans.
Absolute hydrogen inventory, units of equivalent Earth oceans.
H_ppmw: float
Relative hydrogen inventory, ppmw relative to mantle mass.
N_ppmw: float
Bulk nitrogen inventory in ppmw relative to mantle mass.
Relative nitrogen inventory, ppmw relative to mantle mass.
S_ppmw: float
Bulk sulfur inventory in ppmw relative to mantle mass.
Absolute sulfur inventory, ppmw relative to mantle mass.
"""
CH_ratio: float = field(validator=gt(0))
H_oceans: float = field(validator=gt(0))
H_oceans: float = field(validator=ge(0))
H_ppmw: float = field(validator=ge(0))
N_ppmw: float = field(validator=ge(0))
S_ppmw: float = field(validator=ge(0))

Expand Down
27 changes: 26 additions & 1 deletion src/proteus/outgas/calliope.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
if TYPE_CHECKING:
from proteus.config import Config

from calliope.constants import molar_mass, ocean_moles
from calliope.solve import (
equilibrium_atmosphere,
get_target_from_params,
Expand Down Expand Up @@ -35,8 +36,27 @@ def construct_options(dirs:dict, config:Config, hf_row:dict):
solvevol_inp["T_magma"] = hf_row["T_magma"]
solvevol_inp['fO2_shift_IW'] = config.outgas.fO2_shift_IW

# Sum hydrogen absolute and relative amounts...

# absolute part
# internally, calliope will convert this to mass in kg as:
# H_kg = H_oceans * number_ocean_moles * molar_mass['H2']
H_abs = float(config.delivery.elements.H_oceans)

# relative part
# H_kg = H_rel * 1e-6 * M_mantle
# then converted to units of earth oceans, and summed with absolute part
H_rel = config.delivery.elements.H_ppmw * 1e-6 * hf_row["M_mantle"]
H_rel /= ocean_moles * molar_mass['H2']

# avoid floating point errors here
if H_abs < 1e-10:
H_abs = 0.0
if H_rel < 1e-10:
H_rel < 0.0

# Elemental inventory
solvevol_inp['hydrogen_earth_oceans'] = config.delivery.elements.H_oceans
solvevol_inp['hydrogen_earth_oceans'] = H_abs + H_rel
solvevol_inp['CH_ratio'] = config.delivery.elements.CH_ratio
solvevol_inp['nitrogen_ppmw'] = config.delivery.elements.N_ppmw
solvevol_inp['sulfur_ppmw'] = config.delivery.elements.S_ppmw
Expand All @@ -59,6 +79,11 @@ def calc_target_masses(dirs:dict, config:Config, hf_row:dict):
# make solvevol options
solvevol_inp = construct_options(dirs, config, hf_row)

# warn
if (config.delivery.elements.H_ppmw > 1e-10) \
and (config.delivery.elements.H_oceans > 1e-10):
log.warning("Hydrogen inventory set by summing `H_ppmw` and `H_oceans`")

# calculate target mass of atoms (except O, which is derived from fO2)
if config.delivery.initial == 'elements':
solvevol_target = get_target_from_params(solvevol_inp)
Expand Down
1 change: 0 additions & 1 deletion src/proteus/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
R_core_earth = 3485000.0 # m
M_core_earth = 1.94E24 # kg
mol = 6.02214076e+23 # mol definition
ocean_moles = 7.68894973907177e+22 # moles of H2 (or H2O) in one present-day Earth ocean

# Earth heat flux, globally averaged [W m-2]
# https://se.copernicus.org/articles/1/5/2010/
Expand Down
1 change: 1 addition & 0 deletions tests/integration/dummy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
H_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down
1 change: 1 addition & 0 deletions tests/integration/physical.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"
[delivery.elements]
CH_ratio = 1.0 # C/H ratio in mantle/atmosphere system
H_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans, by mass
H_ppmw = 0.0 # Hydrogen inventory in ppmw relative to mantle mass
N_ppmw = 2.0 # Nitrogen inventory in ppmw relative to mantle mass, by mass
S_ppmw = 200.0 # Sulfur inventory in ppmw relative to mass of melt

Expand Down

0 comments on commit 5a273dd

Please sign in to comment.