Skip to content

Commit

Permalink
Update to PALEOboxes 0.17, add PARS and METHODS to docstrings (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdaines authored Apr 28, 2022
1 parent 776f477 commit 0d139c0
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PALEOcopse"
uuid = "4a6ed817-0e58-48c6-8452-9e9afc8cb508"
authors = ["sd336 "]
version = "0.2.0"
version = "0.2.1"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand All @@ -19,7 +19,7 @@ Documenter = "0.27"
Infiltrator = "1.0"
Interpolations = "0.13"
MAT = "0.10"
PALEOboxes = "0.16"
PALEOboxes = "0.17"
PALEOmodel = "0.14"
Plots = "1.0"
Roots = "1.0, 2.0"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ PALEOcopse = "4a6ed817-0e58-48c6-8452-9e9afc8cb508"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
PALEOboxes = "804b410e-d900-4b2a-9ecd-f5a06d4c1fd4"
8 changes: 7 additions & 1 deletion src/COPSE/CIsotopes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
module CIsotopes

import PALEOboxes as PB

using PALEOboxes.DocStrings
"""
ReactionCIsotopes
Carbon isotope fractionation from Bergman (2004) COPSE biogeochemical model.
Calculates global mean isotope fractionation for marine carbonate burial and land and ocean organic carbon burial
from global mean `TEMP`, `pCO2PAL` and `pO2PAL`.
# Parameters
$(PARS)
# Methods and Variables for default Parameters
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionCIsotopes{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down
15 changes: 14 additions & 1 deletion src/COPSE/MapAtmOceanReservoirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module MapAtmOceanReservoirs

import PALEOboxes as PB
using PALEOboxes.DocStrings

"""
ReactionAtmOcean_O
Expand All @@ -14,6 +15,12 @@ file to present-day atmospheric value).
Also calculates additional quantities `pO2atm` (partial pressure in bar), and `pO2PAL` (equal to `O_norm`), which should usually
be relinked to the `atm` Domain in the config file. Assumes ocean oxygen is a neglible fraction of the total.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionAtmOcean_O <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -92,6 +99,12 @@ The calculation of `phi` atm-ocean fraction is set by Parameter `f_atfrac`:
hence `[CO3--]` carbonate ion concentration is approximately constant.
If Parameter `delta_atm_ocean == true`, also calculates atmosphere CO2 and ocean DIC isotopic fractionation.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionAtmOcean_A{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand All @@ -111,7 +124,7 @@ end

function PB.register_methods!(rj::ReactionAtmOcean_A)

_, CIsotopeType = PB.split_nameisotope("::CIsotope", rj.external_parameters)
_, CIsotopeType = PB.split_nameisotope("::CIsotope", rj.external_parameters; default=PB.ScalarData)

vars = [
PB.VarStateExplicitScalar("A", "mol", "atm-ocean inorganic carbon (CO2 + DIC)",
Expand Down
8 changes: 8 additions & 0 deletions src/COPSE/ModelBergman2004.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPSE (Bergman, 2004) Phanerozoic biogeochemical model.
module ModelBergman2004

import PALEOboxes as PB
using PALEOboxes.DocStrings

import PALEOcopse

"""
Expand All @@ -14,6 +16,12 @@ import PALEOcopse
Monolithic COPSE Bergman(2004) model, providing all biogeochemistry as a single Reaction in a single `global` Domain.
Requires reservoirs, forcings, and global temperature (ReactionGlobalTemperatureCK1992) to form a complete model.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionModelBergman2004{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down
26 changes: 25 additions & 1 deletion src/Forcings/COPSEForcings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ import XLSX # Excel file access
import DataFrames

import PALEOboxes as PB
using PALEOboxes.DocStrings

import PALEOcopse


"""
ReactionForce_CK_Solar
`SOLAR` forcing (incident solar flux at Earth, W m^-2)
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionForce_CK_Solar <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -57,6 +65,9 @@ Provides:
Bergman etal (2004)
Interpolates and optionally applies naive extrapolation of forcings into (constant) Precambrian and future
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionForce_UDWEbergman2004 <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -100,7 +111,7 @@ function PB.register_methods!(rj::ReactionForce_UDWEbergman2004)

vars = [
PB.VarDepScalar("tforce", "yr", "historical time at which to apply forcings, present = 0 yr"),
PB.VarPropScalar("UPLIFT", "", "tectonic uplift normalized to present"),
PB.VarPropScalar("UPLIFT", "", "tectonic uplift normalized to present. GEOCARB II (Berner 1994) based on Sr isotopes."),
PB.VarPropScalar("DEGASS", "", "metamorphic and volcanic degassing normalized to present"),
PB.VarPropScalar("EVO", "", "land plant evolution and colonisation"),
PB.VarPropScalar("W", "", "biological enhancement of weathering"),
Expand Down Expand Up @@ -135,6 +146,9 @@ end
ReactionForce_Bbergman2004
`Bforcing` forcing, calcerous plankton evolution (COPSE 2004)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionForce_Bbergman2004 <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -175,6 +189,9 @@ end
`CPland_relative` forcing.
CP land burial ratio doubles in permo-carboniferous (COPSE)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionForce_CPlandrelbergman2004 <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -220,6 +237,13 @@ Generic forcing interpolated from values in spreadsheet. Spreadsheet should cont
with a single header row, and time in Ma as the first column.
Interpolates and optionally applies naive extrapolation of forcings into (constant) Precambrian and future
# Parameters
$(PARS)
# Methods and Variables TODO
- `tforce` (yr) historical time at which to apply forcing
- `<forcename>` name from Parameter `forcename`
"""
Base.@kwdef mutable struct ReactionForce_spreadsheet{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down
10 changes: 9 additions & 1 deletion src/Forcings/LipForcing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import XLSX # Excel file access
import Roots

import PALEOboxes as PB
using PALEOboxes.DocStrings

import PALEOcopse

import Infiltrator # Julia debugger
Expand Down Expand Up @@ -223,6 +225,12 @@ flood basalt area.
If Parameter `co2releasefield` != `NoCO2`, a CO2 pulse (duration 2e5yr, magnitude from spreadsheet, -5 per mil) is output as
`LIP_CO2` and added to Variable `flux_C` -> `fluxSedCrusttoAOcean.flux_C`.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionForce_LIPs{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -254,7 +262,7 @@ function PB.register_methods!(rj::ReactionForce_LIPs)

rj.LIP_data = read_lips_xlsx(lipfile)

_, CIsotopeType = PB.split_nameisotope("::CIsotope", rj.external_parameters)
_, CIsotopeType = PB.split_nameisotope("::CIsotope", rj.external_parameters; default=PB.ScalarData)
@info " CIsotopeType=$(CIsotopeType) from CIsotope in external_parameters"

vars = [
Expand Down
35 changes: 31 additions & 4 deletions src/biogeochem/Strontium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,24 @@ A Sr model configuration should contain the following Reservoirs and Reactions:
module Strontium

import PALEOboxes as PB
using PALEOboxes.DocStrings

import Infiltrator # Julia debugger

const SrIsotopeDefault = PB.IsotopeLinear

"""
ReactionSrMantleCrust
Calculate strontium isotope composition of mantle, old (granite), and new (basalt) igneous rocks as a function of time,
given present day isotopic composition and an initial uniform value at the formation of the Earth.
Assumes all subsequent evolution was due to Rb decay with different Rb/Sr ratios (ie no exchange between these mantle and rock reserovirs).
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionSrMantleCrust{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -98,6 +107,12 @@ end
ReactionSrSed
Calculate contribution to rate of change of a sedimentary `Sr_sed` reservoir due to metamorphic loss, and Rb decay.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionSrSed{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand All @@ -116,7 +131,7 @@ Base.@kwdef mutable struct ReactionSrSed{P} <: PB.AbstractReaction
end

function PB.register_methods!(rj::ReactionSrSed)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters; default=SrIsotopeDefault)

vars = [
PB.VarDepScalar("global.tforce", "yr", "historical time at which to apply forcings, present = 0 yr"),
Expand All @@ -141,7 +156,7 @@ end
function PB.check_configuration(rj::ReactionSrSed, model::PB.Model)
configok = true

_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters; default=SrIsotopeDefault)

if !(SrIsotopeType in (PB.ScalarData, PB.IsotopeLinear))
@warn "ReactionSrSed.check_configuration unsupported IsotopeType $SrIsotopeType"
Expand Down Expand Up @@ -193,6 +208,12 @@ end
ReactionSrLand
Calculate Sr weathering flux from land surface, given relative (normalized) basalt, granite, carbonate weathering rates and Sr isotopic composition.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionSrLand{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand All @@ -213,7 +234,7 @@ end


function PB.register_methods!(rj::ReactionSrLand)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters; default=SrIsotopeDefault)

vars = [
PB.VarDepScalar("basw_relative", "", "Basalt weathering normalized to present"),
Expand Down Expand Up @@ -284,6 +305,12 @@ end
Calculate evolution of an ocean`Sr` reservoir due to ocean burial (assumed proportional to carbonate burial),
seafloor weathering, and hydrothermal (mantle) input fluxes.
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionSrOceanfloor{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand All @@ -305,7 +332,7 @@ end


function PB.register_methods!(rj::ReactionSrOceanfloor)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters)
_, SrIsotopeType = PB.split_nameisotope("::SrIsotope", rj.external_parameters; default=SrIsotopeDefault)

vars = [
PB.VarDepScalar("global.DEGASS", "", "normalized DEGASS forcing"),
Expand Down
13 changes: 13 additions & 0 deletions src/global/Temperature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Temperature


import PALEOboxes as PB
using PALEOboxes.DocStrings

"""
ReactionGlobalTemperatureCK1992
Expand All @@ -12,6 +13,12 @@ Provides a `TEMP` state variable, with either an error term for a DAE solver (if
or a restoring term for an ODE solver (if `temp_DAE = false`).
Valid range: 1e-8 < pCO2atm < 1e-2 (bar), 273.15 < TEMP < 283.15 (K)
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionGlobalTemperatureCK1992{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down Expand Up @@ -151,6 +158,12 @@ end
ReactionGlobalTemperatureBerner
Global temperature calculation from pCO2, with implicit change in solar luminosity (calculated from forcing time tforce).
# Parameters
$(PARS)
# Methods and Variables
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionGlobalTemperatureBerner{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down
7 changes: 7 additions & 0 deletions src/landsurface/LandArea.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module LandArea

import PALEOboxes as PB
using PALEOboxes.DocStrings

"""
ReactionLandArea
Calculate land areas and lithology.
Provides `GRAN_AREA` and `BA_AREA`.
# Parameters
$(PARS)
# Methods and Variables for default Parameters
$(METHODS_DO)
"""
Base.@kwdef mutable struct ReactionLandArea{P} <: PB.AbstractReaction
base::PB.ReactionBase
Expand Down
Loading

2 comments on commit 0d139c0

@sjdaines
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/59332

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 0d139c0d722f46c7c6aa66103e825e5797481ed8
git push origin v0.2.1

Please sign in to comment.