Skip to content

Commit

Permalink
Getting Hector set up for H2 emissions (#751)
Browse files Browse the repository at this point in the history
Expose oh lifetime or oh tau to R bindings so it is easy to fetch output, add H2 unit testing, and expose R bindings.
  • Loading branch information
kdorheim authored Oct 15, 2024
1 parent 1ef0b4d commit 1e15620
Show file tree
Hide file tree
Showing 30 changed files with 4,877 additions and 4,743 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export(HFC32_CONSTRAIN)
export(HFC4310_CONSTRAIN)
export(HL_OCEAN_UPTAKE)
export(LAND_TAS)
export(LIFETIME_OH)
export(LIFETIME_SOIL)
export(LIFETIME_STRAT)
export(LL_DEBUG)
Expand Down
13 changes: 13 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @describeIn emissions Emissions hydrogen gas (\code{"Tg H2"})
NULL

#' @describeIn msgtype Message type for retrieving data from a component
#' @keywords internal
GETDATA <- function() {
Expand Down Expand Up @@ -1082,6 +1085,16 @@ EMISSIONS_NMVOC <- function() {
.Call('_hector_EMISSIONS_NMVOC', PACKAGE = 'hector')
}

EMISSIONS_H2 <- function() {
.Call('_hector_EMISSIONS_H2', PACKAGE = 'hector')
}

#' @describeIn oh OH lifetime (\code{"Yr"})
#' @export
LIFETIME_OH <- function() {
.Call('_hector_LIFETIME_OH', PACKAGE = 'hector')
}

#' @describeIn emissions Emissions for organic carbon (\code{"Tg"})
#' @export
EMISSIONS_OC <- function() {
Expand Down
489 changes: 245 additions & 244 deletions data-raw/input_params.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions data-raw/units-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ ch4_vars <- c(PREINDUSTRIAL_CH4(), NATURAL_CH4(), EMISSIONS_CH4(), CH4_CONSTRAIN
LIFETIME_SOIL(), LIFETIME_STRAT())
ch4_uni <- c("ppbv CH4", "Tg CH4", "Tg CH4", "ppbv CH4", "Years", "Years")

oh_vars <- c(EMISSIONS_NOX(), EMISSIONS_CO(), EMISSIONS_NMVOC())
oh_uni <- c("Tg N", "Tg CO", "Tg NMVOC")
oh_vars <- c(EMISSIONS_NOX(), EMISSIONS_CO(), EMISSIONS_NMVOC(), EMISSIONS_H2())
oh_uni <- c("Tg N", "Tg CO", "Tg NMVOC", "Tg H2")

n2o_vars <- c(EMISSIONS_N2O(), N2O_CONSTRAIN(), NAT_EMISSIONS_N2O(), PREINDUSTRIAL_N2O())
n2o_uni <- c("Tg N", "ppbv N2O", "Tg N", "ppbv N2O")
Expand Down
Binary file modified data/inputstable.rda
Binary file not shown.
Binary file modified data/unitstable.rda
Binary file not shown.
2 changes: 2 additions & 0 deletions inst/include/component_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
#define D_COEFFICENT_CH4 "CCH4"
#define D_COEFFICENT_NMVOC "CNMVOC"
#define D_COEFFICENT_CO "CCO"
#define D_EMISSIONS_H2 "H2_emissions"


// o3 component
#define D_PREINDUSTRIAL_O3 "PO3"
Expand Down
1 change: 1 addition & 0 deletions inst/include/oh_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class OHComponent : public IModelComponent {
tseries<unitval> CO_emissions;
tseries<unitval> NOX_emissions;
tseries<unitval> NMVOC_emissions;
tseries<unitval> H2_emissions;
tseries<unitval> TAU_OH;

unitval M0; // initial CH4 concentration
Expand Down
1 change: 1 addition & 0 deletions inst/include/unitval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ enum unit_types {
U_TG_CH4,
U_TG_N,
U_TG_NMVOC,
U_TG_H2,
U_DU_O3,
U_GG_S, // SO2 emissions in Gg-S/yr

Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp119.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
1 change: 1 addition & 0 deletions inst/input/hector_ssp126.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ CH4_emissions=csv:tables/ssp126_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp126_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp126_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp126_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series

TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp245.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp245_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp245_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp245_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp245_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp370.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp370_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp370_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp370_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp370_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp434.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp434_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp434_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp434_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp434_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp460.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp460_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp460_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp460_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp460_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
2 changes: 2 additions & 0 deletions inst/input/hector_ssp534-over.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CH4_emissions=csv:tables/ssp534-over_emiss-constraints_rf.csv ; emissions ti
NOX_emissions=csv:tables/ssp534-over_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp534-over_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp534-over_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series


TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
1 change: 1 addition & 0 deletions inst/input/hector_ssp585.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ CH4_emissions=csv:tables/ssp585_emiss-constraints_rf.csv ; emissions time se
NOX_emissions=csv:tables/ssp585_emiss-constraints_rf.csv ; emissions time series
CO_emissions=csv:tables/ssp585_emiss-constraints_rf.csv ; emissions time series
NMVOC_emissions=csv:tables/ssp585_emiss-constraints_rf.csv ; emissions time series
H2_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series

TOH0=6.6 ; inital OH lifetime (years)
CNOX=0.0042 ; coefficent for NOX
Expand Down
Loading

0 comments on commit 1e15620

Please sign in to comment.