Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data-raw/input_params.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion inst/include/ch4_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class CH4Component : public IModelComponent {
tseries<unitval> CH4_constrain; // CH4 concentration constraint, ppbv CH4
tseries<unitval> 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

Expand Down
1 change: 0 additions & 1 deletion inst/include/component_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
21 changes: 21 additions & 0 deletions inst/include/physical_constants.hpp
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion inst/input/hector_picontrol.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp119.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp126.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp245.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp370.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp434.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp460.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp534-over.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions inst/input/hector_ssp585.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions project_files/Xcode/hector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@
27B2C24E261511C8005DE26D /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../src/main.cpp; sourceTree = "<group>"; };
954D62AD278E005500840656 /* nh3_component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nh3_component.cpp; path = ../../src/nh3_component.cpp; sourceTree = "<group>"; };
954D62B0278E007500840656 /* nh3_component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = nh3_component.hpp; path = ../../inst/include/nh3_component.hpp; sourceTree = "<group>"; };
95C532092F6974470094077B /* physical_constants.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = physical_constants.hpp; sourceTree = "<group>"; };
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 = "<absolute>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -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 */,
Expand Down
17 changes: 10 additions & 7 deletions src/ch4_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "avisitor.hpp"
#include "core.hpp"
#include "h_util.hpp"
#include "physical_constants.hpp"
#include <math.h>

namespace Hector {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/input/luc_pulse.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down