Skip to content

Commit

Permalink
Merge pull request #115 from FormingWorlds/dummy_escape
Browse files Browse the repository at this point in the history
Dummy escape module
  • Loading branch information
nichollsh committed Jul 25, 2024
2 parents 3ac786f + 936e5a0 commit 84cf7ca
Show file tree
Hide file tree
Showing 21 changed files with 445 additions and 192 deletions.
25 changes: 22 additions & 3 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ You can also run PROTEUS inside a Screen session using:

.. code-block:: console
$ tools/RunPROTEUS.sh [cfgfile] [alias] [detach]
$ tools/RunPROTEUS.sh [cfgfile] [alias] [resume] [detach]
Which runs PROTEUS using the config file ``[cfgfile]`` inside a Screen session with the
name ``[alias]``. The ``[detach]`` parameter (y/n) tells the session whether to immediately
name ``[alias]``. The ``[resume]`` parameter (y/n) tells the model whether to resume from
a previous state. The ``[detach]`` parameter (y/n) tells the session whether to immediately
detach or not. This allows multiple instances of the model to be dispatched easily and
safely.

Expand Down Expand Up @@ -239,7 +240,7 @@ configuration, but they must all be passed via the config file.
- Greater than zero.

* - ``shallow_ocean_layer``
- Legaacy method for converging atmospheric and interior upward fluxes.
- Legacy method for converging atmospheric and interior upward fluxes.
- True
- Integer
- 0: Off, 1: On
Expand All @@ -256,6 +257,24 @@ configuration, but they must all be passed via the config file.
- Float
- Greater than or equal to 0. Set to 0 to disable.

* - ``escape_model``
- Escape model to be used.
- False
- Integer
- 0: None, 1: ZEPHYRUS, 2: Dummy

* - ``escape_stop``
- Stop the simulation when the atmosphere mass drops below this fraction of its initial mass.
- False
- Float
- Values between zero and unity (exclusive).

* - ``escape_dummy_rate``
- Bulk escape rate for dummy escape model [kg s-1]
- False
- Float
- Any reasonable positive value.

* - ``prevent_warming``
- Flag to ensure that the net upward energy flux is always positive, which prevents the star from causing net heating inside the planet.
- False
Expand Down
1 change: 0 additions & 1 deletion examples/dummy_atmosphere/init_coupler.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e2 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand Down
1 change: 0 additions & 1 deletion examples/earth_demo/init_coupler.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e4 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand Down
6 changes: 5 additions & 1 deletion input/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e4 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand All @@ -75,6 +74,11 @@ steady_dprel = 1.0e-9 # Percentage change in melt fraction over
emit_stop = 1 # Enable this break condition
F_crit = 0.2 # Critical flux, below which the model will terminate

# Atmospheric escape
escape_model = 0 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 0.0 # Bulk escape rate for dummy escape model [kg s-1]

# Method for solving for T(p) profile
atmosphere_model = 0 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_solve_energy = 0 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
Expand Down
40 changes: 22 additions & 18 deletions input/dummy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,42 @@ stellar_heating = 1
plot_iterfreq = 1 # Plotting frequency, 0: wait until completion | n: every n iterations
plot_format = png # Plotting image file format
sspec_dt_update = 1e9 # Time intervals at which to re-calculate the stellar spectrum
sinst_dt_update = 1e2 # Time intervals at which to re-calculate the instellation
sinst_dt_update = 1e1 # Time intervals at which to re-calculate the instellation
dt_maximum = 3e7 # Maximum time-step
dt_minimum = 1e2 # Minimum time-step
dt_method = 1 # Time-stepping method, 0: proportional | 1: adaptive | 2: maximum
dt_propconst = 52.0 # Proportionality constant for dt_method=0
dt_atol = 0.02 # Step size atol
dt_rtol = 0.07 # Step size rtol
dt_atol = 0.02 # Step size atol
dt_rtol = 0.10 # Step size rtol
dt_initial = 1e2 # Inital step size

# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled

# Break at solidification?
solid_stop = 1
solid_stop = 0
phi_crit = 0.005 # melt fraction

# Break at steady state?
steady_stop = 1
steady_stop = 0
steady_flux = 0.8 # Maximum absolute value of F_atm allowed for convergence
steady_dprel = 1.0e-9 # Percentage change in melt fraction over time (dp/p)/dt*100

# Break at small flux?
emit_stop = 1 # Enable this break condition
emit_stop = 0 # Enable this break condition
F_crit = 0.2 # Model will terminate when |F_atm| < F_crit

# Atmospheric escape
escape_model = 2 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 2e7 # Bulk escape rate for dummy escape model [kg s-1]

# Method for solving for T(p) profile
atmosphere_model = 2 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_model = 2 # Atmosphere model to be used, 0: JANUS | 1: AGNI | 2: Dummy
atmosphere_solve_energy = 0 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
atmosphere_surf_state = 1 # Atmosphere bottom edge boundary condition, 0: free | 1: fixed at T_surf | 2: conductive skin

Expand Down Expand Up @@ -115,10 +119,10 @@ mixing_length = 2
solver_tolerance = 1.0e-10

# Maximum absolute surface temperature change [K]
tsurf_poststep_change = 20.0
tsurf_poststep_change = 30.0

# Maximum fractional surface temperature change [fraction]
tsurf_poststep_change_frac = 0.01
tsurf_poststep_change_frac = 0.02

# Fractional core radius
planet_coresize = 0.55
Expand All @@ -131,13 +135,13 @@ ic_dsdr = -4.698e-06
F_atm = 1e6

# Oxygen fugacity offset relative to the IW buffer (log10 units)
fO2_shift_IW = 4
fO2_shift_IW = 2

# Enable solving for initial partial pressures (0: off | 1: on)
solvevol_use_params = 0
solvevol_use_params = 1

# Parameters used to solve for initial partial pressures (when solvepp_use_params = 1)
T_magma = 1900 # Surface temperature initial guess [K]
T_magma = 3000 # Surface temperature initial guess [K]
Phi_global = 1.0 # Mantle melt fraction initial guess
CH_ratio = 1.0 # C/H ratio
hydrogen_earth_oceans = 6.0 # Hydrogen inventory in units of equivalent Earth oceans
Expand All @@ -147,7 +151,7 @@ sulfur_ppmw = 200.0 # Sulfur inventory in ppmw relative to m
# Prescribed injected partial pressures [bar]
# Summed with solvepp results when solvepp_enabled = 1
H2O_included = 1
H2O_initial_bar = 30.0
H2O_initial_bar = 0.0

CO2_included = 1
CO2_initial_bar = 0.0
Expand All @@ -158,15 +162,15 @@ N2_initial_bar = 0.0
S2_included = 1
S2_initial_bar = 0.0

SO2_included = 0
SO2_included = 1
SO2_initial_bar = 0.0

H2_included = 0
H2_included = 1
H2_initial_bar = 0.0

CH4_included = 0
CH4_included = 1
CH4_initial_bar = 0.0

CO_included = 0
CO_included = 1
CO_initial_bar = 0.0

6 changes: 5 additions & 1 deletion input/janus_mixed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e4 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand All @@ -75,6 +74,11 @@ steady_dprel = 1.0e-9 # Percentage change in melt fraction ov
emit_stop = 1 # Enable this break condition
F_crit = 0.2 # Model will terminate when |F_atm| < F_crit

# Atmospheric escape
escape_model = 0 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 0.0 # Bulk escape rate for dummy escape model [kg s-1]

# Method for solving for T(p) profile
atmosphere_model = 0 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_solve_energy = 0 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
Expand Down
6 changes: 5 additions & 1 deletion input/jgr_grid.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 8e2 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand All @@ -75,6 +74,11 @@ steady_dprel = 1.0e-9 # Percentage change in melt fraction ov
emit_stop = 1 # Enable this break condition
F_crit = 0.2 # Model will terminate when |F_atm| < F_crit

# Atmospheric escape
escape_model = 0 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 0.0 # Bulk escape rate for dummy escape model [kg s-1]

# Method for solving for T(p) profile
atmosphere_model = 0 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_solve_energy = 0 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
Expand Down
7 changes: 6 additions & 1 deletion input/rce_mixed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e4 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand All @@ -75,6 +74,12 @@ steady_dprel = 1.0e-9 # Percentage change in melt fraction ov
emit_stop = 1 # Enable this break condition
F_crit = 0.2 # Model will terminate when |F_atm| < F_crit

# Atmospheric escape
escape_model = 0 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 0.0 # Bulk escape rate for dummy escape model [kg s-1]


# Method for solving for T(p) profile
atmosphere_model = 1 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_solve_energy = 1 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
Expand Down
6 changes: 5 additions & 1 deletion input/rce_steam.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dt_initial = 1e4 # Inital step size
# Flux convergence scheme and tolerances for surface equilibration
shallow_ocean_layer = 0 # 0: off | 1: on
F_atm_bc = 0 # Boundary condition choice for F_atm, 0: TOA | 1: Surface
RF_crit = 0.01 # depth fraction
skin_d = 0.01 # m
skin_k = 2.0 # W m-1 K-1
prevent_warming = 1 # Require that the planet only cool down over time, 0: disabled | 1: enabled
Expand All @@ -75,6 +74,11 @@ steady_dprel = 1.0e-9 # Percentage change in melt fraction ov
emit_stop = 1 # Enable this break condition
F_crit = 0.2 # Model will terminate when |F_atm| < F_crit

# Atmospheric escape
escape_model = 0 # Escape model to be used, 0: None | 1: ZEPHYRUS | 2: Dummy
escape_stop = 3e-4 # Terminate when atm mass drops below this fraction of its initial mass
escape_dummy_rate = 0.0 # Bulk escape rate for dummy escape model [kg s-1]

# Method for solving for T(p) profile
atmosphere_model = 1 # Atmosphere model to be used, 0: JANUS | 1: AGNI
atmosphere_solve_energy = 1 # Enable time-stepped atmosphere solution, 0: disabled | 1: enabled
Expand Down
77 changes: 77 additions & 0 deletions plot/cpl_elements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3

from utils.modules_ext import *
from utils.plot import *

log = logging.getLogger("PROTEUS")

def plot_elements( output_dir, plot_format="pdf", t0=100.0):

log.info("Plot elements")

hf_all = pd.read_csv(output_dir+"/runtime_helpfile.csv", sep=r"\s+")

time = np.array(hf_all["Time"] )
if len(time) < 3:
log.warning("Cannot make plot with less than 3 samples")
return

# make plot
lw = 1.2
al = 0.5
scale = 1.1
fig,ax = plt.subplots(1,1, figsize=(7*scale,4*scale))


total = np.zeros(len(time))
for e in element_list:
y = hf_all[e+"_kg_total"]
l = ax.plot(time, y, lw=lw, ls='solid', label="Total "+e)[0]

total += y

# c = l.get_color()
# ax.plot(time, hf_all[e+"_kg_liquid"], lw=lw, color=c, alpha=al, ls='dashed') # in magma ocean
# ax.plot(time, hf_all[e+"_kg_atm"], lw=lw, color=c, alpha=al, ls='dotted') # in atmosphere

ax.plot(time, total, lw=lw, ls='solid', label='Total', c='k')
ax.plot(time, hf_all["M_atm"], lw=lw, ls='dotted', label='Atmos.', c='k')

# decorate
ax.set_ylabel("Inventory [kg]")
ax.set_yscale("log")
ax.set_xlabel("Time [yr]")
ax.set_xscale("log")
ax.set_xlim(left=t0, right=np.amax(time))
ax.grid(alpha=0.2)
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

plt.close()
plt.ioff()

fpath = os.path.join(output_dir, "plot_elements.%s"%plot_format)
fig.savefig(fpath, dpi=200, bbox_inches='tight')

#====================================================================
def main():

if len(sys.argv) == 2:
cfg = sys.argv[1]
else:
cfg = 'init_coupler.cfg'

# Read in COUPLER input file
log.info("Read cfg file")
from utils.coupler import ReadInitFile, SetDirectories
COUPLER_options, time_dict = ReadInitFile( cfg )

# Set directories dictionary
dirs = SetDirectories(COUPLER_options)

plot_elements( output_dir=dirs["output"], plot_format=COUPLER_options["plot_format"] )

#====================================================================

if __name__ == "__main__":

main()
4 changes: 2 additions & 2 deletions plot/cpl_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ def plot_global( output_dir , COUPLER_options, logt=True, tmin=1e1):
max_temp = np.amax(hf_all["T_surf"])
ax_cl.plot(hf_all["Time"], hf_all["T_surf"], ls="dashed", lw=lw, alpha=al, color=dict_colors["int"])
ax_cl.plot(hf_all["Time"], hf_all["T_surf"], ls="-", lw=lw, alpha=al, color=dict_colors["atm"])
ax_cl.set_ylim(min(1000.0,min_temp) , max(3500.0,max_temp))
ax_cl.set_ylim(min(1000.0,min_temp-25) , max(3500.0,max_temp+25))


# PLOT ax_bl
ax_bl.axhline( y=COUPLER_options["planet_coresize"], ls='dashed', lw=lw*1.5, alpha=al, color=dict_colors["qmagenta_dark"], label=r'C-M boundary' )
ax_bl.plot( hf_all["Time"], 1.0-hf_all["RF_depth"], color=dict_colors["int"], ls="solid", lw=lw, alpha=al, label=r'Rheol. front')
ax_bl.plot( hf_all["Time"], hf_all["Phi_global"], color=dict_colors["atm"], linestyle=':', lw=lw, alpha=al, label=r'Melt fraction')
ax_bl.legend(loc='center left', **leg_kwargs)
ax_bl.set_ylim(0.0,1.0)
ax_bl.set_ylim(0.0,1.01)


# PLOT ax_tr
Expand Down
Loading

0 comments on commit 84cf7ca

Please sign in to comment.