diff --git a/data-raw/input_params.csv b/data-raw/input_params.csv index 26bfd6354..7fe44012b 100644 --- a/data-raw/input_params.csv +++ b/data-raw/input_params.csv @@ -67,7 +67,6 @@ so2,SV,n,y,y,"""(csv)""",,volcanic radiative forcing time series CH4,M0,n,n,y,731.41,ppb,"preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb" CH4,Tsoil,n,n,y,160,years,CH4 loss to soil CH4,Tstrat,n,n,y,120,years,CH4 loss to stratosphere -CH4,UC_CH4,n,n,y,2.78,Tg CH4 ppb-1,unit conversion between emissions and concentrations CH4,CH4N,n,n,y,341,,best fit CH4,CH4_emissions,n,y,y,"""(csv)""",,emissions time series CH5,CH4_constrain,n,y,n,"""(csv)""",,CH4 concentration constraint diff --git a/inst/include/ch4_component.hpp b/inst/include/ch4_component.hpp index 589b04b2c..eceff0e84 100644 --- a/inst/include/ch4_component.hpp +++ b/inst/include/ch4_component.hpp @@ -61,7 +61,6 @@ class CH4Component : public IModelComponent { tseries CH4_constrain; // CH4 concentration constraint, ppbv CH4 tseries CH4N; // annual natural emissions, Tg CH4/yr unitval M0; // preindustrial methane, ppbv CH4 - unitval UC_CH4; // conversion factor between emissions and concentration unitval Tsoil; // lifetime of soil sink, yr unitval Tstrat; // lifetime of tropospheric sink, yr diff --git a/inst/include/component_data.hpp b/inst/include/component_data.hpp index de2a9efc4..9a18c99d2 100644 --- a/inst/include/component_data.hpp +++ b/inst/include/component_data.hpp @@ -262,7 +262,6 @@ #define D_EMISSIONS_CH4 "CH4_emissions" #define D_CONSTRAINT_CH4 "CH4_constrain" #define D_NATURAL_CH4 "CH4N" -#define D_CONVERSION_CH4 "UC_CH4" #define D_LIFETIME_SOIL "Tsoil" #define D_LIFETIME_STRAT "Tstrat" diff --git a/inst/include/physical_constants.hpp b/inst/include/physical_constants.hpp new file mode 100644 index 000000000..6a4a194e6 --- /dev/null +++ b/inst/include/physical_constants.hpp @@ -0,0 +1,21 @@ +/* Hector -- A Simple Climate Model + Copyright (C) 2022 Battelle Memorial Institute + + Please see the accompanying file LICENSE.md for additional licensing + information. +*/ +#ifndef PHYSICAL_CONSTANTS_H +#define PHYSICAL_CONSTANTS_H +/* + * physical_constants.hpp + * hector + * + * Created by K. Dorheim on March 2026. + * + */ + +constexpr double ATMOSPHERE_MOL = 1.727e20; // The number of moles in the atmosphere +constexpr double CH4_MOLARMASS = 16.043; // Molar mass of CH4 + + +#endif // PHYSICAL_CONSTANTS_H diff --git a/inst/input/hector_picontrol.ini b/inst/input/hector_picontrol.ini index f43df54d6..53da397d0 100644 --- a/inst/input/hector_picontrol.ini +++ b/inst/input/hector_picontrol.ini @@ -108,7 +108,6 @@ SV[1745]=0.185745674 ; volcanic radiative forcing time series M0=731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/picontrol.csv ; Natural CH4 emissions (Tgrams) constant over simluation CH4_emissions[1745]=0 ; diff --git a/inst/input/hector_ssp119.ini b/inst/input/hector_ssp119.ini index 38124d6c5..cde6ab8d4 100644 --- a/inst/input/hector_ssp119.ini +++ b/inst/input/hector_ssp119.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp119_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp119_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp126.ini b/inst/input/hector_ssp126.ini index 417a3a6d2..0aa692341 100644 --- a/inst/input/hector_ssp126.ini +++ b/inst/input/hector_ssp126.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp126_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp126_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp245.ini b/inst/input/hector_ssp245.ini index 2bd7259af..bf260a91e 100644 --- a/inst/input/hector_ssp245.ini +++ b/inst/input/hector_ssp245.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp245_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp245_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp370.ini b/inst/input/hector_ssp370.ini index 2a0782ba3..792907408 100644 --- a/inst/input/hector_ssp370.ini +++ b/inst/input/hector_ssp370.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp370_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp370_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp434.ini b/inst/input/hector_ssp434.ini index f4fecdf68..096dbabe4 100644 --- a/inst/input/hector_ssp434.ini +++ b/inst/input/hector_ssp434.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp434_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp434_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp460.ini b/inst/input/hector_ssp460.ini index ff0e1ff53..cc29196f8 100644 --- a/inst/input/hector_ssp460.ini +++ b/inst/input/hector_ssp460.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp460_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp460_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp534-over.ini b/inst/input/hector_ssp534-over.ini index a969ad43e..94b49ecbf 100644 --- a/inst/input/hector_ssp534-over.ini +++ b/inst/input/hector_ssp534-over.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp534-over_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp534-over_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/inst/input/hector_ssp585.ini b/inst/input/hector_ssp585.ini index 75a27fc14..86081c90a 100644 --- a/inst/input/hector_ssp585.ini +++ b/inst/input/hector_ssp585.ini @@ -120,7 +120,6 @@ SV=csv:tables/core_inputs.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N=csv:tables/core_inputs.csv ; Natural CH4 emissions (Tgrams) see PR #786 CH4_emissions=csv:tables/ssp585_emiss-constraints_rf.csv ; emissions time series ;CH4_constrain=csv:tables/ssp585_emiss-constraints_rf.csv ; CH4 concentration constraint @@ -180,7 +179,7 @@ RF_misc[1750]=0 ;------------------------------------------------------------------------ [temperature] S=3.0 ; equilibrium climate sensitivity for 2xCO2 degC (A.4.4 of IPCC AR6) -diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details +diff=1.042 ; ocean heat diffusivity, cm2/s calibrated to historical observations see PR 789 for details qco2=3.75 ; 2×CO2 RF (7.3.2 of IPCC AR6) ; Optional global temperature constraint diff --git a/project_files/Xcode/hector.xcodeproj/project.pbxproj b/project_files/Xcode/hector.xcodeproj/project.pbxproj index dfb4d11b3..c64d715c7 100644 --- a/project_files/Xcode/hector.xcodeproj/project.pbxproj +++ b/project_files/Xcode/hector.xcodeproj/project.pbxproj @@ -226,6 +226,8 @@ 27B2C24E261511C8005DE26D /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../src/main.cpp; sourceTree = ""; }; 954D62AD278E005500840656 /* nh3_component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nh3_component.cpp; path = ../../src/nh3_component.cpp; sourceTree = ""; }; 954D62B0278E007500840656 /* nh3_component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = nh3_component.hpp; path = ../../inst/include/nh3_component.hpp; sourceTree = ""; }; + 95C532092F6974470094077B /* physical_constants.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = physical_constants.hpp; sourceTree = ""; }; + 95C5320B2F69C5FF0094077B /* physical_constants.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = physical_constants.hpp; path = "/Users/dorh012/Documents/Hector-WD/hector/inst/include/physical_constants.hpp"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -288,6 +290,8 @@ 27B2C22B26151149005DE26D /* Headers */ = { isa = PBXGroup; children = ( + 95C5320B2F69C5FF0094077B /* physical_constants.hpp */, + 95C532092F6974470094077B /* physical_constants.hpp */, 954D62B0278E007500840656 /* nh3_component.hpp */, 27B2C21C2615112E005DE26D /* avisitor.hpp */, 27B2C2042615112D005DE26D /* bc_component.hpp */, diff --git a/src/ch4_component.cpp b/src/ch4_component.cpp index 8d89bcfa9..15ca61972 100644 --- a/src/ch4_component.cpp +++ b/src/ch4_component.cpp @@ -16,6 +16,7 @@ #include "avisitor.hpp" #include "core.hpp" #include "h_util.hpp" +#include "physical_constants.hpp" #include namespace Hector { @@ -113,9 +114,6 @@ void CH4Component::setData(const string &varName, const message_data &data) { } else if (varName == D_LIFETIME_STRAT) { H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed"); Tstrat = data.getUnitval(U_YRS); - } else if (varName == D_CONVERSION_CH4) { - H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed"); - UC_CH4 = data.getUnitval(U_TG_PPBV); } else if (varName == D_NATURAL_CH4) { H_ASSERT(data.date != Core::undefinedIndex(), "date required"); CH4N.set(data.date, data.getUnitval(U_TG_CH4)); @@ -157,6 +155,13 @@ void CH4Component::run(const double runToDate) { CH4.set(runToDate, CH4_constrain.get(runToDate)); } else { + // Define the conversion factors used by the CH4 componet + constexpr double PG_C_TO_TG_CH4 = (1000.0 * CH4_MOLARMASS / 12.01); + constexpr double TG_TO_MOL = (1 * 1e12 * (1/CH4_MOLARMASS)); // 1 Tg CH4 --> moles of CH4 + constexpr double mol_ratio = TG_TO_MOL / ATMOSPHERE_MOL; // ratio of CH4 moles to total moles in atmosphere + double UC_CH4 = 1/(mol_ratio * 1e9); // convert from decimal ratio to parts per billion + UC_CH4 = std::round(UC_CH4 * 100.0)/100.0; // control the number of digits + // modified from Wigley et al, 2002 // https://doi.org/10.1175/1520-0442(2002)015%3C2690:RFDTRG%3E2.0.CO;2 const double current_ch4em = CH4_emissions.get(runToDate).value(U_TG_CH4); @@ -165,16 +170,14 @@ void CH4Component::run(const double runToDate) { H_LOG(logger, Logger::DEBUG) << "Year " << runToDate << " current_toh = " << current_toh << std::endl; - + // Permafrost thaw produces CH4 emissions -#define PG_C_TO_TG_CH4 (1000.0 * 16.04 / 12.01) const double rh_ch4 = core->sendMessage(M_GETDATA, D_RH_CH4).value(U_PGC_YR) * PG_C_TO_TG_CH4; - // Additional, background CH4 natural emissions const double ch4n = CH4N.get(runToDate).value(U_TG_CH4); const double emisTocon = - (current_ch4em + rh_ch4 + ch4n) / UC_CH4.value(U_TG_PPBV); + (current_ch4em + rh_ch4 + ch4n) / UC_CH4; const double previous_ch4 = CH4.get(oldDate); H_LOG(logger, Logger::DEBUG) diff --git a/tests/testthat/input/luc_pulse.ini b/tests/testthat/input/luc_pulse.ini index 901ef82d0..f111c419f 100644 --- a/tests/testthat/input/luc_pulse.ini +++ b/tests/testthat/input/luc_pulse.ini @@ -100,7 +100,6 @@ SV=csv:luc_pulse_tables.csv ; volcanic radiative forcing time series M0= 731.41 ; 731.41 ppb preindustrial methane IPCC AR6 Table 7.SM.1, the CH4 forcing equations is calibrated to a M0 of 731.41 ppb Tsoil=120 ; lifetime of soil sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 Tstrat=150 ; lifetime of tropospheric sink (years) Myhre et al., 2013, doi: 10.1017/cbo9781107415324.018 -UC_CH4=2.78 ; Tg(CH4)/ppb unit conversion between emissions and concentrations CH4N[1750]=223 ; Natural CH4 emissions (Tgrams) constant over simluation CH4_emissions=csv:luc_pulse_tables.csv ; emissions time series ;CH4_constrain=csv:luc_pulse_tables.csv ; CH4 concentration constraint