Generic Reaction catalog

PALEOboxes includes a catalog of generic Reactions as a starting point for model construction.

Reservoirs

PALEOboxes.Reservoirs.ReactionReservoirScalarType
ReactionReservoirScalar

A single scalar biogeochemical reservoir with optional paired isotope reservoir, for use in a 0D Domain (eg sedimentary or ocean reservoirs for COPSE (Bergman et al., 2004)).

Creates State and associated Variables, depending on parameter settings:

  • const=false: usual case
    • state_norm=false create state variable R (units mol, with attribute vfunction=VF_StateExplicit) and R_sms (units mol yr-1, with attribute vfunction=VF_Deriv).
    • state_norm=true create state variable R_solve (R normalized by the values of attribute R:norm_value, with attribute vfunction=VF_StateExplicit) and R_solve_sms (units yr-1, with attribute vfunction=VF_Deriv).
  • const=true: a constant value, create R (a Property), and R_sms (a Target)

In addition:

  • a Property R_norm (normalized value) is always created.
  • if parameter field_data <: AbstractIsotopeScalar (eg IsotopeLinear), a Property R_delta is created.

The local name prefix R should then be renamed using variable_links: in the configuration file.

Initialisation

Initial and norm value is set in the variable_attributes: section in the configuration file, using R:initial_value, R:initial_delta, and R:norm_value.

Example configuration in .yaml file

            reservoir_P:  # 0D ocean Phosphorus
                class: ReactionReservoirScalar
                parameters:
                    # field_data: ScalarData        # change to IsotopeLinear to represent an isotope
                    # const: false                  # true to fix to constant value
                variable_links:
                    R*: P                           # rename to represent Phosphorus
                variable_attributes:
                    R:norm_value:           3.1e15  # mol 
                    R:initial_value:        3.1e15  # mol

See also

ReactionReservoir (one value per cell for a spatially resolved Domain eg ocean), ReactionReservoirWellMixed (one value for a whole spatially resolved Domain).

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"
  • const[Bool]=false, default_value=false, description="true to provide a constant value: R is not a state variable, fluxes in R_sms Variable are ignored"
  • state_norm[Bool]=false, default_value=false, description="true to provide solver with normalized values"

Methods and Variables for default Parameters

  • methodfn_do_nothing
    • R_sms (mol yr-1), VT_ReactContributor, VF_Deriv, description="scalar reservoir source-sinks"
  • do_reactionreservoirscalar
    • R_norm (), VT_ReactProperty, description="scalar reservoir normalized"
    • R (mol), VT_ReactDependency, VF_StateExplicit, description="scalar reservoir"
source
PALEOboxes.Reservoirs.ReactionReservoirType
ReactionReservoir, ReactionReservoirTotal

A single (vector) reservoir (state variable) representing a biogeochemical tracer, ie one value per cell in a spatially-resolved Domain (eg ocean).

State Variables can represent either per-cell concentration, or per-cell moles, set by parameter state_conc:

  • state_conc=false (default): create R (mol) and R_sms (mol yr-1) as state variable and source-sink, calculate R_conc (mol m-3)
  • state_conc=true: create R_conc (mol m-3) and R_conc_sms (mol m-3 yr-1) as state variable and source-sink, calculate R (mol), NB: R_sms (mol yr-1) is still available and is added to R_conc_sms.

In addition:

  • if parameter field_data <: AbstractIsotopeScalar (eg IsotopeLinear), a Property R_delta is created.
  • ReactionReservoirTotal or ReactionReservoirConcTotal also calculates the Domain total R_total (units mol), eg to check budgets.

Local name prefix R should then be renamed using variable_links: in the configuration file.

Initialisation

Initial value is set using variable_attributes: in the configuration file, using R:initial_value and R:initial_delta (for 'stateconc=false') or `Rconc:initialvalueandRconc:initialdelta` (for a 'stateconc=true'). (NB: even if initial_value is set on R, it sets concentration in mol m-3.)

Transport is defined by attributes :advect, :vertical_movement (m d-1) set on the concentration variable R_conc. Optical extinction is defined by the :specific_light_extinction (m^2 mol-1) attribute set on the concentration variable R_conc.

Example configuration in .yaml file

            reservoir_P:  # ocean Phosphorus
                class: ReactionReservoirTotal       # include _total (mol)
                parameters:
                    # field_data: ScalarData        # change to IsotopeLinear to represent an isotope                       
                variable_links:
                    R*: P                           # rename to represent Phosphorus
                variable_attributes:
                    R:norm_value:           3e-3    # mol m-3, normalisation value (used by some solvers)
                    R:initial_value:        2e-3    # mol m-3, initial concentration

See also

ReactionReservoirWellMixed (one value for the whole Domain), ReactionReservoirScalar (one value for a reservoir in a 0D Domain eg for COPSE (Bergman et al., 2004)), ReactionReservoirConst (constant time-independent value ie no state variable).

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"
  • total[Bool]=false, default_value=false, description="true to calculate R_total"
  • limit_delta_conc[Float64]=0.0 (mol m-3), default_value=0.0, description="**EXPERIMENTAL** attempt to limit delta for low/-ve concentrations (0.0 to disable)"
  • state_conc[Bool]=false, default_value=false, description="true to define R_conc, R_sms_conc as the state variable pair and calculate R, false to define R, R_sms and calculate R_conc"

Methods and Variables for default Parameters

  • do_reactionreservoir
    • R (mol), VT_ReactDependency, VF_StateExplicit, description="vector reservoir"
    • R_conc (mol m-3), VT_ReactProperty, description="concentration"
    • volume (m3), VT_ReactDependency, description="cell volume (or cell phase volume eg for a sediment with solid and liquid phases)"
  • methodfn_do_nothing
    • R_sms (mol yr-1), VT_ReactContributor, VF_Deriv, description="vector reservoir source-sinks"
source
PALEOboxes.Reservoirs.ReactionReservoirWellMixedType
ReactionReservoirWellMixed

A Scalar Reservoir representing a well-mixed tracer in a vector Domain (eg ocean). Provides a scalar state Variable R and R_sms, and also vector Variables: R_conc (set to uniform concentration), and R_vec_sms Target for accumulating fluxes that is added to the scalar R_sms.

Initialisation

Initial value is set in the variable_attributes: section in the configuration file, using R:initial_value and R:initial_delta. NB: may be initialized either from mean concentration or total (set by parameter initialization_type)

TODO salinity normalisation.

See also

ReactionReservoir (one value per cell), ReactionReservoirScalar (one value for a reservoir in a 0D Domain eg for COPSE (Bergman et al., 2004)).

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"
  • initialization_type[String]="conc", default_value="conc", allowed_values=["conc", "total"], description=":initial_value attribute represents conc (mol m-3) or total (mol)"

Methods and Variables for default Parameters

  • do_reservoir_well_mixed
    • R (mol), VT_ReactDependency, VF_StateExplicit, description="scalar reservoir"
    • R_norm (), VT_ReactProperty, description="scalar reservoir normalized"
    • R_conc (mol m-3), VT_ReactProperty, description="concentration"
    • volume_total (m^3), VT_ReactDependency, description="total volume"
  • do_reservoir_well_mixed_sms
    • R_sms (mol yr-1), VT_ReactContributor, VF_Deriv, description="scalar reservoir source-sinks"
    • R_vec_sms (mol yr-1), VT_ReactTarget, description="vector reservoir source-sinks"
source
PALEOboxes.Reservoirs.ReactionReservoirConstType
ReactionReservoirConst

A single (vector) constant tracer R_conc (constant replacement for a ReactionReservoir).

Local name prefix R should then be renamed using variable_links: in the configuration file.

Initialisation

Set :initial_value, :initial_delta on R_conc (mol m-3) in the variable_attributes: section of the config file.

TODO salinity normalisation.

Example configuration in .yaml file

            reservoir_B:  # Constant value for ocean Boron 
                class: ReactionReservoirConst
                parameters:
                    field_data: IsotopeLinear
                variable_links:
                    R*: B
                variable_attributes:                      
                    R_conc:initial_value:       0.4269239 # contemporary value
                    R_conc:initial_delta:       34.0

See also

ReactionReservoir

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"

Methods and Variables

  • setup_initialvalue_vars_default
    • R_conc (mol m-3), VT_ReactProperty, description="concentration"
source
PALEOboxes.Reservoirs.ReactionReservoirForcedType
ReactionReservoirForced

A single (vector) constant tracer (constant replacement for a ReactionReservoir), with forcing.

Calculates R_conc = R_conc_initial * R_FORCE.

Local name prefix R should then be renamed using variable_links: in the configuration file.

Initialisation

NB: set :initial_value, :initial_delta on R_conc_initial in the variable_attributes: section of the config file.

TODO salinity normalisation.

See also

ReactionReservoirConst, ReactionReservoir

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"

Methods and Variables for default Parameters

  • do_reactionreservoirconstforced
    • R_conc_initial (mol m-3), VT_ReactProperty, description="initial concentration"
    • R_conc (mol m-3), VT_ReactProperty, description="concentration = initial * forcing"
    • R_FORCE (), VT_ReactDependency, description="forcing factor"
source
PALEOboxes.Reservoirs.ReactionConstType
ReactionConst, ReactionScalarConst

Create constant Property Variables with names from parameter constnames.

Initialisation

Constant values set by :initial_value, :initial_delta attributes in the variable_attributes: section of the configuration file.

Example configuration in .yaml file

    atmfloor:
        reactions:                
            floorstubgasmr:  # Provide mixing-ratio boundary condition for a subset of atmospheric variables
                class: ReactionConst
                parameters:
                    constnames: ["O2_mr", "CH4_mr", "CO2_mr", "H2_mr"] #, "H2O_mr"]  
                variable_attributes:        
                    O2_mr:initial_value:  [0.21]  # mol/mol
                    CH4_mr:initial_value:  [0.7443e-6] # [.NaN] # [1.271e-6] # [1.8e-6]  # mol/mol
                    CO2_mr:initial_value:  [300e-6]  # mol/mol
                    H2_mr:initial_value:   [.NaN]  # mol/mol

See also

ReactionReservoirConst, ReactionReservoirScalar. These provide additional variables (eg R_delta) to allow them to function as a drop-in replacement for a non-constant Reservoir.

Parameters

  • constnames[Vector{String}]=["constvar"], default_value=["constvar"], description="vector of names for constant Variables. Isotopes use <name>::CIsotope syntax"

Methods and Variables for default Parameters

  • setup_initialvalue_vars_default
    • constvar (unknown), VT_ReactProperty, description="constant value"
source

Linking to Reservoirs from a Reaction

PALEOboxes.Reservoirs.ReservoirLinksVectorFunction
ReservoirLinksVector(isotope_data::Dict, reservoirlist) -> (res::Vector, sms::Vector, diag::Vector)

Convenience function to create variables required for a Reaction to link to a list of Reservoir variables. res contains VariableReactions <reservoir_name>, sms <reservoir_name>_sms that link to State, State_sms variables. diag contains VariableReactions <reservoir_name>_norm etc that link to additional properties.

Arguments

  • reservoirlist::[(reservoir_name[::Isotope], units, description), ...]: list of Reservoirs
source

Variable Statistics

PALEOboxes.VariableStats.ReactionSumType
ReactionSum, ReactionVectorSum

A sum of variables (eg budget).

  • If Parameter component_to_add == 0, all components of Isotopes are included.
  • If Parameter component_to_add == component_number, a single component only is included.

Parameters

  • vars_to_add[Vector{String}]=["2\myvar", "myothervar", "-1\mythirdvar"], default_value=["2\myvar", "myothervar", "-1\mythirdvar"], description="vector of variable names to add, eg [2*myvar, myothervar, -1*mythirdvar]"
  • vars_prefix[String]="", default_value="", description="optional prefix for vars_to_add"
  • component_to_add[Int64]=0, default_value=0, description="component to add, 0 for all"
  • vectorsum[Bool]=false, default_value=false, description="true to accumulate sum into vector Variable, false to accumulate sum into scalar (adding vector cells if necessary)"

Methods and Variables for default Parameters

  • do_scalarsum
    • sum (unknown), VT_ReactProperty, description="sum of specified variables"
    • [myvar] (unknown), VT_ReactDependency, description=""
    • [myothervar] (unknown), VT_ReactDependency, description=""
    • [mythirdvar] (unknown), VT_ReactDependency, description=""
source
PALEOboxes.VariableStats.ReactionWeightedMeanType
ReactionWeightedMean

Weighted mean (eg by area or volume) of Variable

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"

Methods and Variables

  • do_weighted_mean
    • var (unknown), VT_ReactDependency, description="variable to calculate weighted mean from"
    • measure (unknown), VT_ReactDependency, description="cell area or volume"
    • measure_total (unknown), VT_ReactDependency, description="total Domain area or volume"
    • var_mean (unknown), VT_ReactProperty, description="weighted mean over Domain area or volume"
source
PALEOboxes.VariableStats.ReactionAreaVolumeValInRangeType
ReactionAreaVolumeValInRange

Fraction of Domain area or volume with Variable in a range of values.

Parameters

  • range_min[Float64]=-Inf (mol m-3), default_value=-Inf, description="minimum value to include in frac"
  • range_max[Float64]=Inf (mol m-3), default_value=Inf, description="maximum value to include in frac"

Methods and Variables

  • do_area_volume_in_range
    • rangevar (unknown), VT_ReactDependency, description="variable to check within range"
    • measure (unknown), VT_ReactDependency, description="cell area or volume"
    • measure_total (unknown), VT_ReactDependency, description="total Domain area or volume"
    • frac (), VT_ReactProperty, description="fraction of Domain area or volume in specified range"
source

Fluxes

PALEOboxes.FluxesModule
Fluxes

Create and manage collections of Target and Contrib Variables used to define fluxes within or between Domains.

Conventions for defining biogeochemical fluxes within Domains

  • Particulate organic matter (including CaCO3) with stoichiometry Corg:N:P:Ccarb is usually transferred as: flux_list ["P", "N", "Corg::CIsotope", "Ccarb::CIsotope"] with a prefix indicating the function (eg export_).
  • Solute fluxes are usually transferred as: flux_list ["DIC::CIsotope", "TAlk", "Ca", "P", "O2", "SO4::SIsotope", "H2S::SIsotope", "CH4::CIsotope"] (where these names match the Reservoir names for the solutes), with a prefix indicating the function (usually just flux_ or soluteflux_).

Conventions for defining global fluxes between modules

The model configuration .yaml file should create a Domain for each global flux, containing one or more Fluxes.ReactionFluxTarget. Fluxes are then transferred (copied) by adding a Fluxes.ReactionFluxTransfer to each destination Domain.

Naming conventions for Earth system fluxes:

Domain nametarget prefixflux_list (illustrative, add as needed)
fluxAtoLandflux_["CO2::CIsotope", "O2"]
fluxRtoOceanflux_["DIC::CIsotope", "TAlk", "Ca", "P", "SO4::SIsotope"]
fluxOceanBurialflux_["Corg::CIsotope", "Ccarb::CIsotope", "Porg", "Pauth", "PFe", "P", "GYP::SIsotope", "PYR::SIsotope"]
fluxSedCrusttoAOceanflux_["C::CIsotope", "S::SIsotope", "Redox"]
fluxLandtoSedCrustflux_["Ccarb::CIsotope", "Corg::CIsotope", "GYP::SIsotope", "PYR::SIsotope"]
fluxOceanfloorparticulateflux_["P", "N", "Corg::CIsotope", "Ccarb::CIsotope"]
soluteflux_["DIC::CIsotope", "TAlk", "Ca", "P", "O2", "SO4::SIsotope", "H2S::SIsotope", "CH4::CIsotope"]
fluxAtmtoOceansurfaceflux_["CO2::CIsotope", "CH4::CIsotope", "O2"]
source
PALEOboxes.Fluxes.ReactionFluxTargetType
ReactionFluxTarget

Provides either a target for fluxes from fluxlist in an input Domain or a constant stub, optionally calculates totals.

For each fluxname in fluxlist, creates:

  • if const_stub==false, an input VarTarget pars.target_prefix[]*"flux_"*fluxname (or if const_stub==true, a constant VarProp).
  • if flux_totals is true, a total VarPropScalar target_prefix[]*"flux_total_"*fluxname.

Parameters

  • fluxlist[Vector{String}]=["example"], default_value=["example"], description="available fluxes"
  • target_prefix[String]="flux_", default_value="flux_", description="target names will be "<target_prefix><fluxname>", target total names will be "<target_prefix>total_<fluxname>" (where <fluxname> is an entry in fluxlist)"
  • flux_totals[Bool]=false, default_value=false, description="true to calculate flux totals (as "<target_prefix>flux_total_<fluxname>")"
  • const_stub[Bool]=false, default_value=false, description="true to provide constant flux defined by :initial_value, :initial_delta attributes on input Target Variables "<target_prefix>flux_<fluxname>""

Methods and Variables for default Parameters

  • methodfn_do_nothing
    • flux_example (mol yr-1), VT_ReactTarget, description="flux input"
source
PALEOboxes.Fluxes.ReactionFluxTransferType
ReactionFluxTransfer

Copy fluxes, optionally using transfer matrices to define cell-cell mappings if input and output fluxes are in a different Domain.

There are three common cases:

  • Transfer within a Domain, using transfer_matrix Identity
  • Transfer from a fluxXXX Domain to the Domain hosting the ReactionFluxTransfer, using transfer_matrix to define a mapping if these Domains are of different sizes.
  • Transfer from a fluxXXX Domain to the boundary cells of an interior Domain (eg ocean.oceansurface), where the Domain hosting the ReactionFluxTransfer is the corresponding boundary Domain (eg oceansurface).

Flux names

The list of flux names is generated by finding all names that match the pattern supplied to input_fluxes, so

parameters:
    input_fluxes:  fluxAtmtoOceansurface.flux_$fluxname$
    output_fluxes:  ocean.oceansurface.$fluxname$_sms

will:

  1. Match eg fluxAtmtoOceansurface.flux_CO2, fluxAtmtoOceansurface.flux_O2 and generate names CO2, O2.
  2. Generate variables with Reaction-local names input_CO2, input_O2, and link names configured to link to the input fluxes
  3. Generate variables with Reaction-local names output_CO2, output_O2, and link names configured to link to the output flux names generated by substituting $fluxname$ in output_fluxes.

This handles the common case eg O2 where the names of the input and output fluxes match. However, if they don't match, eg the input flux is called CO2 and the output flux should be applied to DIC, then it is necessary to use variable_links: to change the link name for output_CO2 to DIC.

Parameters

  • input_fluxes[String]="[inputdomain.][inputsubdomain.]flux_$fluxname$", default_value="[inputdomain.][inputsubdomain.]flux_$fluxname$", description="string to match to find input flux Variables. These Variables will local names "input_$fluxname$"."
  • output_fluxes[String]="[outputdomain.][outputsubdomain.]$fluxname$_sms", default_value="[outputdomain.][outputsubdomain.]$fluxname$_sms", description="string to use to generate output flux Variables where $fluxname$ is substituted from input_fluxes. These Variables will local names "output_$fluxname$", and are optional (ie ignored if not linked). Usually the output Domain is the Domain hosting the ReactionFluxTransfer (in general, it must be a Domain of the same size as the Domain hosting the ReactionFluxTransfer)."
  • transfer_multiplier[Float64]=1.0, default_value=1.0, description="scalar multiplier for transfer"
  • transfer_matrix[String]="Identity", default_value="Identity", allowed_values=["Identity", "Distribute", "Custom"], description="matrix defining input Domain (length n) -> output Domain (length m) mapping: 'Identity' copies fluxes directly, requires m == n; 'Distribute' uniformly distributes fluxes from input->output: sums over n and them distributes fraction 1/m evenly to each m; 'Custom' requires transfer matrix to be supplied"
source

Contributing to flux couplers from a Reaction

PALEOboxes.Fluxes.FluxContribFunction
FluxContrib(
    fluxprefix::AbstractString, flux_list;
    [, isotope_data::Dict]
    [, space=PB.CellSpace][, alloptional=true]
) -> vartuple::NamedTuple

Create a NamedTuple of VarContrib from flux_prefix.*flux_list, needed for a Reaction to write to a flux coupler. Entries in flux_list of form fluxname::isotope are parsed to look up isotope type from isotope_data Dict.

For each fluxname in flux_list, the generated VarContrib vartuple.fluxname have link_namestr=$(fluxprefix)$(fluxname)" and localname="$(fluxprefix)$(fluxname) (with any . in fluxprefix substituted to _).

Example:

julia> fluxRtoOcean = PB.Fluxes.FluxContrib("fluxRtoOcean.flux_", ["P", "SO4::SIsotope"], isotope_data=Dict("SIsotope"=>PB.IsotopeLinear), space=PB.ScalarSpace);

julia> fluxRtoOcean.P
PALEOboxes.VariableReaction{PALEOboxes.VT_ReactContributor}
  localname='fluxRtoOcean_flux_P'
  link_name='fluxRtoOcean.flux_P[unlinked]'
  attributes=Dict{Symbol, Any}(:description => "flux P", :space => PALEOboxes.ScalarSpace, :standard_variable => false, :norm_value => 1.0, :data_dims => String[], :long_name => "", :vfunction => PALEOboxes.VF_Undefined, :field_data => PALEOboxes.ScalarData, :initial_delta => 0.0, :units => "mol yr-1"…)

julia> fluxRtoOcean.SO4
PALEOboxes.VariableReaction{PALEOboxes.VT_ReactContributor}
  localname='fluxRtoOcean_flux_SO4'
  link_name='fluxRtoOcean.flux_SO4[unlinked]'
  attributes=Dict{Symbol, Any}(:description => "flux SO4", :space => PALEOboxes.ScalarSpace, :standard_variable => false, :norm_value => 1.0, :data_dims => String[], :long_name => "", :vfunction => PALEOboxes.VF_Undefined, :field_data => PALEOboxes.IsotopeLinear, :initial_delta => 0.0, :units => "mol yr-1"…)
source

Forcings

PALEOboxes.Forcings.ReactionForceInterpType
ReactionForceInterp

Provide a scalar Property F, linearly interpolated from a table of values vs time tforce.

The table of values is set by parameters force_times and force_values.

The input time Variable is tforce, with default linking to the global.tforce Variable.

Use the configuration file to rename the output variable F (and if necessary, the input Variable tforce).

Set extrapolate = "extrapolate" to use extrapolate_before, extrapolate_after to set constant values when 'tforce' is out-of-range of force_times (or alternatively, set extrapolate = "throw" and use guard values for force_times at -1e30, 1e30).

Parameters

  • force_times[Vector{Float64}]=[-1.0e30, 1.0e30] (yr), default_value=[-1.0e30, 1.0e30], description="interpolated forcing times"
  • force_values[Vector{Float64}]=[1.0, 1.0], default_value=[1.0, 1.0], description="interpolated forcing values"
  • extrapolate[String]="throw", default_value="throw", allowed_values=["throw", "constant"], description="behaviour if tforce is out of range"
  • extrapolate_before[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce < first(perturb_times)"
  • extrapolate_after[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce > last(perturb_times)"

Methods and Variables

  • do_forceinterp
    • tforce –> global.tforce (yr), VT_ReactDependency, description="historical time at which to apply forcings, present = 0 yr"
    • F (), VT_ReactProperty, description="interpolated forcing"
source
PALEOboxes.GridForcings.ReactionForceGridType
ReactionForceGrid

Apply time-dependent, periodic forcing from a variable in a netcdf or Matlab file, optionally applying a scaling, a constant linear offset, and a linear offset generated from a scalar model variable.

Reads records tidx_start:tidx_end (assumed to be the last dimension) for data_var from a gridded dataset in netcdf_file or matlab_file, maps grid to linear using the Domain grid (which must match that of data_var).

If tidx_end > tidx_start (ie multiple records), reads a netcdf or Matlab variable named time_var, applies periodicity cycle_time, and uses this to linearly interpolate to model time.

Then applies forcing:

F = scale*`data_var` + constant_offset + scale_offset_var*`scalar_offset_var`

Optionally (if interp_vars is non-empty), interpolate forcing from additional dimensions in the netcdf file, given values supplied by additional Variable dependencies. NB: netcdf dimensions order must be grid_vars x interp_varsxtimevar, where order withininterpvars` also must match netcdf order.

Parameters

  • netcdf_file[String]="", default_value="", description="netcdf file with gridded time-series data"
  • matlab_file[String]="", default_value="", description="matlab file with gridded time-series data"
  • matlab_key[String]="", default_value="", description="Dictionary key in Matlab file to use (empty string to stay at top level Dict)"
  • data_var[String]="", default_value="", description="variable name in data file"
  • time_var[String]="time", default_value="time", description="time variable name in data file (empty to generate evenly spaced times from cycle_time)"
  • time_fac[Float64]=1.0, default_value=1.0, description="multiplier to convert time_var to model time (yr)"
  • tidx_start[Int64]=1, default_value=1, description="first record in data file to use"
  • tidx_end[Int64]=1, default_value=1, description="last record in data file to use (set equal to tidx_start for constant forcing from single record)"
  • use_timeav[Bool]=false, default_value=false, description="true to average records and provide constant forcing at time-averaged value"
  • time_extrap_const[Bool]=false, default_value=false, description="true to extrapolate out-of-range times to first/last value, false to error if time out-of-range"
  • cycle_time[Float64]=0.0 (yr), default_value=0.0, description="time periodicity to apply (0.0 to disable periodic)"
  • interp_vars[Vector{String}]=String[], default_value=String[], description="optional interpolation variables for additional grid dimensions. NB: netcdf dimensions order must be grid_vars x interp_vars x time_var, where order within interp_vars also must match netcdf order"
  • interp_log[Vector{Bool}]=Bool[], default_value=Bool[], description="true to interpolate interp_vars in log space"
  • data_replace_nan[Float64]=NaN, default_value=NaN, description="value to replace NaN in data"
  • scale[Float64]=1.0, default_value=1.0, description="scaling factor to apply"
  • constant_offset[Float64]=0.0, default_value=0.0, description="constant offset to apply"
  • scale_offset_var[Float64]=0.0, default_value=0.0, description="scaling for additional scalar offset from model variable (0.0 to disable)"

Methods and Variables for default Parameters

  • do_force_grid
    • tforce –> global.tforce (yr), VT_ReactDependency, description="historical time at which to apply forcings, present = 0 yr"
    • F (unknown), VT_ReactProperty, description="interpolated forcing"
source
PALEOboxes.FluxPerturb.ReactionFluxPerturbType
ReactionFluxPerturb

Provide a scalar flux F, linearly interpolated from a table of values vs time tforce.

The table of values is set by parameters perturb_times and perturb_totals, and optionally perturb_deltas.

The input time Variable is tforce, with default linking to the global.tforce Variable.

Use the configuration file to rename output variable F (and if necessary, the input Variable tforce).

Set extrapolate = "extrapolate" to use extrapolate_before, extrapolate_after to set constant values when 'tforce' is out-of-range of perturb_times (or alternatively, set extrapolate = "throw" and use guard values for perturb_times at -1e30, 1e30).

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"
  • perturb_times[Vector{Float64}]=[-1.0e30, 1.0e30] (yr), default_value=[-1.0e30, 1.0e30], description="interpolated perturbation times"
  • perturb_totals[Vector{Float64}]=[1.0, 1.0] (mol yr-1), default_value=[1.0, 1.0], description="interpolated perturbation totals"
  • perturb_deltas[Vector{Float64}]=[0.0, 0.0] (per mil), default_value=[0.0, 0.0], description="interpolated perturbation deltas"
  • extrapolate[String]="throw", default_value="throw", allowed_values=["throw", "constant"], description="behaviour if tforce is out of range"
  • extrapolate_before[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce < first(perturb_times)"
  • extrapolate_before_delta[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce < first(perturb_times)"
  • extrapolate_after[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce > last(perturb_times)"
  • extrapolate_after_delta[Float64]=NaN, default_value=NaN, description="value to use if 'extrapolate=constant' and tforce > last(perturb_times)"

Methods and Variables

  • do_flux_perturb
    • tforce –> global.tforce (yr), VT_ReactDependency, description="time at which to apply perturbation"
    • F (mol yr-1), VT_ReactContributor, description="interpolated flux perturbation"
    • FApplied –> %reaction%FApplied (mol yr-1), VT_ReactProperty, description="flux perturbation applied, for diagnostic output"
source
PALEOboxes.FluxPerturb.ReactionRestoreType
ReactionRestore

Adds RestoringFlux in response to discrepancy between Variable WatchLevel and Parameter RequiredLevel

Parameters

  • field_data[DataType]=PALEOboxes.ScalarData, default_value=PALEOboxes.ScalarData, allowed_values=Type[PALEOboxes.ScalarData, PALEOboxes.IsotopeLinear], description="disable / enable isotopes and specify isotope type"
  • RequiredLevel[Float64]=0.0 (mol), default_value=0.0, description="target value of WatchLevel"
  • trestore[Float64]=1.0 (yr), default_value=1.0, description="restoring timescale"
  • RequiredDelta[Float64]=0.0 (per mil), default_value=0.0, description="target value of WatchLevel delta"
  • source_only[Bool]=false, default_value=false, description="false to allow input and output, true to allow input only"

Methods and Variables

  • do_restore
    • WatchLevel (mol), VT_ReactDependency, description="level to observe and restore"
    • RestoringFlux (mol yr-1), VT_ReactContributor, description="restoring flux"
    • RestoringApplied –> %reaction%RestoringApplied (mol yr-1), VT_ReactProperty, description="restoring flux for diagnostic output"
source

Grids

Minimal generic model grids for test purposes.

These just define the Domain size, and don't provide coordinate or metric information (cell volume, area). Models will usually require a Reaction with a Domain-specific implementation (eg for ocean, atmosphere) that defines coordinates and volumes etc and also implements transport (advection, eddy diffusion, etc).

PALEOboxes.GridReactions.ReactionGrid2DNetCDFType
ReactionGrid2DNetCDF

Create a 2D PB.Grids.CartesianLinearGrid from grid information in a NetCDF file.

Parameters

  • grid_type[UnionAll]=PALEOboxes.Grids.CartesianArrayGrid, default_value=PALEOboxes.Grids.CartesianArrayGrid, allowed_values=Type[PALEOboxes.Grids.CartesianArrayGrid, PALEOboxes.Grids.CartesianLinearGrid], description="Cartesian grid type to create"
  • grid_file[String]="", default_value="", description="netcdf file with 2D grid information"
  • coordinate_names[Vector{String}]=["longitude", "latitude"], default_value=["longitude", "latitude"], description="coordinate names to read from netcdf file"
  • equalspacededges[Bool]=false, default_value=false, description="true to calculate cell edges assuming an equal-spaced grid"
  • area_var[String]="", default_value="", description="netcdf variable with cell area (if available)"
  • planet_radius[Float64]=6.371229e6, default_value=6.371229e6, description="radius to calculate cell area from spherical geometry (if area_var = "")"

Methods

  • setup_grid_2DNetCDF
    • Asurf (m^2), VT_ReactProperty, description="horizontal area of surface"
    • Asurf_total (m^2), VT_ReactProperty, description="total horizontal area of surface"
source