GCBM
esgymmodule.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_ESGYMMODULE_H_
2 #define MOJA_MODULES_CBM_ESGYMMODULE_H_
3 
4 #include <algorithm>
5 
6 #include "moja/modules/cbm/_modules.cbm_exports.h"
8 
10 
11 namespace moja {
12 namespace modules {
13 namespace cbm {
14 
15  class CBM_API ESGYMModule : public CBMModuleBase {
16  public:
18 
19  virtual ~ESGYMModule() {};
20 
21  void configure(const DynamicObject& config) override;
22  void subscribe(NotificationCenter& notificationCenter) override;
23 
24  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::Model; };
25 
26  void doLocalDomainInit() override;
27  void doTimingInit() override;
28  void doTimingStep() override;
29 
30  private:
31  const flint::IPool* _softwoodMerch;
32  const flint::IPool* _softwoodOther;
33  const flint::IPool* _softwoodFoliage;
34  const flint::IPool* _softwoodCoarseRoots;
35  const flint::IPool* _softwoodFineRoots;
36 
37  const flint::IPool* _hardwoodMerch;
38  const flint::IPool* _hardwoodOther;
39  const flint::IPool* _hardwoodFoliage;
40  const flint::IPool* _hardwoodCoarseRoots;
41  const flint::IPool* _hardwoodFineRoots;
42 
43  const flint::IPool* _aboveGroundVeryFastSoil;
44  const flint::IPool* _aboveGroundFastSoil;
45  const flint::IPool* _belowGroundVeryFastSoil;
46  const flint::IPool* _belowGroundFastSoil;
47  const flint::IPool* _softwoodStemSnag;
48  const flint::IPool* _softwoodBranchSnag;
49  const flint::IPool* _hardwoodStemSnag;
50  const flint::IPool* _hardwoodBranchSnag;
51  const flint::IPool* _mediumSoil;
52  const flint::IPool* _atmosphere;
53 
54  flint::IVariable* _age;
55  flint::IVariable* _turnoverRates;
56  flint::IVariable* _regenDelay;
57  flint::IVariable* _currentLandClass;
58 
59  flint::IVariable* _isForest;
60 
61  flint::IVariable* _cbm_species_id;
62  flint::IVariable* _standSPUID;
63 
64  std::shared_ptr<SoftwoodRootBiomassEquation> SWRootBio;
65  std::shared_ptr<HardwoodRootBiomassEquation> HWRootBio;
66 
68  std::map<moja::Int64, DynamicObject> growth_esgym_species_specific_effects;
69 
71  std::map<moja::Int64, DynamicObject> mortality_esgym_species_specific_effects;
72 
77 
80 
82 
84 
85  DynamicObject topStumpParameters;
86 
87  std::map<int, double> co2Concentrations;
88 
89  void doTurnover(double M) const;
90  void updateBiomassPools();
91  bool shouldRun() const;
92 
93  // biomass and snag turnover rate/parameters
106 
107  // record of the biomass carbon growth increment
108  double swm;
109  double swo;
110  double swf;
111  double hwm;
112  double hwo;
113  double hwf;
114  double swcr;
115  double swfr;
116  double hwcr;
117  double hwfr;
118 
119  // record of the current biomass and snag pool value
134  float ExtractRasterValue(const std::string name);
135  double ComputeComponentGrowth(double predictor, double b0, double b1, double b2);
136  double StandBiomassModifier(double standBio, double standBio_mu, double standBio_sig, double LamBs);
155  double GrowthAndMortality(int age, double B1, double B2, double B3,
156  double B4, double B5, double b1, double b2, double eeq_n,
157  double eeq_mu, double eeq_sig, double dwf_n, double dwf_mu,
158  double dwf_sig)
159  {
160  if (age < 0) {
161  throw std::invalid_argument("age should be greater than or equal to 0");
162  }
163  double dwf = (dwf_n - dwf_mu) / dwf_sig;
164  double eeq = (eeq_n - eeq_mu) / eeq_sig;
165  double Y_n = (B1 + b1 + B3 * dwf + B4 * eeq + B5 * dwf * eeq)
166  * (B2 + b2) * exp(-(B2 + b2)*age)* pow(1 - exp(-(B2 + b2)*age), 2.0);
167  Y_n = std::max(0.0, Y_n);//clamp at 0
168  return Y_n;
169  }
170 
217  double B_dwf, double B_dwf_mu, double B_dwf_sig, double dwf_a,
218  double B_rswd, double B_rswd_mu, double B_rswd_sig, double rswd_a,
219  double B_tmean, double B_tmean_mu, double B_tmean_sig, double tmean_a,
220  double B_vpd, double B_vpd_mu, double B_vpd_sig, double vpd_a,
221  double B_eeq, double B_eeq_mu, double B_eeq_sig, double eeq_a,
222  double B_ws, double B_ws_mu, double B_ws_sig, double ws_a,
223  double B_ndep, double B_ndep_mu, double B_ndep_sig, double ndep,
224  double B_ca, double B_ca_mu, double B_ca_sig, double ca)
225  {
226  double result = (dwf_a - B_dwf_mu) / B_dwf_sig * B_dwf +
227  (rswd_a - B_rswd_mu) / B_rswd_sig * B_rswd +
228  (tmean_a - B_tmean_mu) / B_tmean_sig * B_tmean +
229  (vpd_a - B_vpd_mu) / B_vpd_sig * B_vpd +
230  (eeq_a - B_eeq_mu) / B_eeq_sig * B_eeq +
231  (ws_a - B_ws_mu) / B_ws_sig * B_ws +
232  (ndep - B_ndep_mu) / B_ndep_sig * B_ndep +
233  (ca - B_ca_mu) / B_ca_sig * B_ca;
234  return result;
235  }
236  };
237 
238 }}}
239 #endif
moja::modules::cbm::ESGYMModule::growth_esgym_fixed_effects
DynamicObject growth_esgym_fixed_effects
Definition: esgymmodule.h:67
moja::modules::cbm::ESGYMModule::_hardwoodMerch
const flint::IPool * _hardwoodMerch
Definition: esgymmodule.h:37
moja::modules::cbm::ESGYMModule::standHWFineRootsCarbon
double standHWFineRootsCarbon
Definition: esgymmodule.h:129
moja::modules::cbm::ESGYMModule::swf
double swf
Definition: esgymmodule.h:110
moja::modules::cbm::ESGYMModule::standHardwoodMerch
double standHardwoodMerch
Definition: esgymmodule.h:125
moja::modules::cbm::ESGYMModule::_softwoodMerch
const flint::IPool * _softwoodMerch
Definition: esgymmodule.h:31
moja::modules::cbm::ESGYMModule::_standSPUID
flint::IVariable * _standSPUID
Definition: esgymmodule.h:62
moja::modules::cbm::ESGYMModule::_softwoodFineRoots
const flint::IPool * _softwoodFineRoots
Definition: esgymmodule.h:35
moja::modules::cbm::ESGYMModule::standHWCoarseRootsCarbon
double standHWCoarseRootsCarbon
Definition: esgymmodule.h:128
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::ESGYMModule::hwf
double hwf
Definition: esgymmodule.h:113
moja::modules::cbm::ESGYMModule::topStumpParameters
DynamicObject topStumpParameters
Definition: esgymmodule.h:85
moja::modules::cbm::ESGYMModule::_coarseRootTurnProp
double _coarseRootTurnProp
Definition: esgymmodule.h:103
moja::modules::cbm::ESGYMModule::ESGYMModule
ESGYMModule()
Definition: esgymmodule.h:17
moja::modules::cbm::ESGYMModule::_age
flint::IVariable * _age
Definition: esgymmodule.h:54
moja::modules::cbm::ESGYMModule::moduleType
flint::ModuleTypes moduleType() override
Definition: esgymmodule.h:24
moja::modules::cbm::ESGYMModule::standSoftwoodFoliage
double standSoftwoodFoliage
Definition: esgymmodule.h:122
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::ESGYMModule::SWRootBio
std::shared_ptr< SoftwoodRootBiomassEquation > SWRootBio
Definition: esgymmodule.h:64
moja::modules::cbm::ESGYMModule::softwoodStemSnag
double softwoodStemSnag
Definition: esgymmodule.h:130
moja::modules::cbm::ESGYMModule
Definition: esgymmodule.h:15
moja::modules::cbm::ESGYMModule::_aboveGroundVeryFastSoil
const flint::IPool * _aboveGroundVeryFastSoil
Definition: esgymmodule.h:43
moja::modules::cbm::ESGYMModule::environmentalDescriptiveStatistics
DynamicObject environmentalDescriptiveStatistics
Definition: esgymmodule.h:83
moja::modules::cbm::ESGYMModule::growth_esgym_environmental_effects
DynamicObject growth_esgym_environmental_effects
Definition: esgymmodule.h:73
moja::modules::cbm::ESGYMModule::~ESGYMModule
virtual ~ESGYMModule()
Definition: esgymmodule.h:19
moja::modules::cbm::ESGYMModule::mortality_esgym_fixed_effects
DynamicObject mortality_esgym_fixed_effects
Definition: esgymmodule.h:70
moja::modules::cbm::ESGYMModule::swo
double swo
Definition: esgymmodule.h:109
moja::modules::cbm::ESGYMModule::_coarseRootSplit
double _coarseRootSplit
Definition: esgymmodule.h:102
moja::modules::cbm::ESGYMModule::_softwoodFoliageFallRate
double _softwoodFoliageFallRate
Definition: esgymmodule.h:94
moja::modules::cbm::ESGYMModule::HWRootBio
std::shared_ptr< HardwoodRootBiomassEquation > HWRootBio
Definition: esgymmodule.h:65
moja::modules::cbm::ESGYMModule::_softwoodOther
const flint::IPool * _softwoodOther
Definition: esgymmodule.h:32
moja::modules::cbm::ESGYMModule::softwoodBranchSnag
double softwoodBranchSnag
Definition: esgymmodule.h:131
moja::modules::cbm::ESGYMModule::growth_esgym_species_specific_effects
std::map< moja::Int64, DynamicObject > growth_esgym_species_specific_effects
Definition: esgymmodule.h:68
moja::modules::cbm::ESGYMModule::mortality_esgym_environmental_effects
DynamicObject mortality_esgym_environmental_effects
Definition: esgymmodule.h:74
moja::modules::cbm::ESGYMModule::hwfr
double hwfr
Definition: esgymmodule.h:117
moja::modules::cbm::ESGYMModule::hwcr
double hwcr
Definition: esgymmodule.h:116
moja::modules::cbm::ESGYMModule::standHardwoodOther
double standHardwoodOther
Definition: esgymmodule.h:126
moja::modules::cbm::ESGYMModule::_softwoodFoliage
const flint::IPool * _softwoodFoliage
Definition: esgymmodule.h:33
moja::modules::cbm::ESGYMModule::_hardwoodOther
const flint::IPool * _hardwoodOther
Definition: esgymmodule.h:38
moja::modules::cbm::ESGYMModule::co2Concentrations
std::map< int, double > co2Concentrations
Definition: esgymmodule.h:87
moja::modules::cbm::ESGYMModule::standSoftwoodMerch
double standSoftwoodMerch
Definition: esgymmodule.h:120
moja::modules::cbm::ESGYMModule::_isForest
flint::IVariable * _isForest
Definition: esgymmodule.h:59
moja::modules::cbm::ESGYMModule::swcr
double swcr
Definition: esgymmodule.h:114
moja::modules::cbm::ESGYMModule::standHardwoodFoliage
double standHardwoodFoliage
Definition: esgymmodule.h:127
moja::modules::cbm::ESGYMModule::_mediumSoil
const flint::IPool * _mediumSoil
Definition: esgymmodule.h:51
moja::modules::cbm::ESGYMModule::_fineRootAGSplit
double _fineRootAGSplit
Definition: esgymmodule.h:104
moja::modules::cbm::ESGYMModule::_hardwoodFineRoots
const flint::IPool * _hardwoodFineRoots
Definition: esgymmodule.h:41
moja::modules::cbm::ESGYMModule::foliageAllocationParameters
DynamicObject foliageAllocationParameters
Definition: esgymmodule.h:78
moja::modules::cbm::ESGYMModule::hardwoodStemSnag
double hardwoodStemSnag
Definition: esgymmodule.h:132
moja::modules::cbm::ESGYMModule::standSoftwoodOther
double standSoftwoodOther
Definition: esgymmodule.h:121
moja::modules::cbm::ESGYMModule::hardwoodBranchSnag
double hardwoodBranchSnag
Definition: esgymmodule.h:133
moja::modules::cbm::ESGYMModule::mean_esgym_environmental_effects
DynamicObject mean_esgym_environmental_effects
Definition: esgymmodule.h:75
moja::modules::cbm::ESGYMModule::_softwoodCoarseRoots
const flint::IPool * _softwoodCoarseRoots
Definition: esgymmodule.h:34
moja::modules::cbm::ESGYMModule::swm
double swm
Definition: esgymmodule.h:108
moja::modules::cbm::ESGYMModule::_branchSnagTurnoverRate
double _branchSnagTurnoverRate
Definition: esgymmodule.h:101
moja::modules::cbm::ESGYMModule::_hardwoodBranchTurnOverRate
double _hardwoodBranchTurnOverRate
Definition: esgymmodule.h:98
moja::modules::cbm::ESGYMModule::_fineRootTurnProp
double _fineRootTurnProp
Definition: esgymmodule.h:105
moja::modules::cbm::ESGYMModule::_hardwoodBranchSnag
const flint::IPool * _hardwoodBranchSnag
Definition: esgymmodule.h:50
moja::modules::cbm::ESGYMModule::swfr
double swfr
Definition: esgymmodule.h:115
moja::modules::cbm::ESGYMModule::_turnoverRates
flint::IVariable * _turnoverRates
Definition: esgymmodule.h:55
moja::modules::cbm::ESGYMModule::stddev_esgym_environmental_effects
DynamicObject stddev_esgym_environmental_effects
Definition: esgymmodule.h:76
moja::modules::cbm::ESGYMModule::_cbm_species_id
flint::IVariable * _cbm_species_id
Definition: esgymmodule.h:61
moja::modules::cbm::ESGYMModule::mortality_esgym_species_specific_effects
std::map< moja::Int64, DynamicObject > mortality_esgym_species_specific_effects
Definition: esgymmodule.h:71
moja::modules::cbm::ESGYMModule::branchAllocationParameters
DynamicObject branchAllocationParameters
Definition: esgymmodule.h:79
moja::modules::cbm::ESGYMModule::hwo
double hwo
Definition: esgymmodule.h:112
moja::modules::cbm::ESGYMModule::_belowGroundFastSoil
const flint::IPool * _belowGroundFastSoil
Definition: esgymmodule.h:46
moja::modules::cbm::ESGYMModule::_softwoodBranchTurnOverRate
double _softwoodBranchTurnOverRate
Definition: esgymmodule.h:97
moja::modules::cbm::ESGYMModule::_stemAnnualTurnOverRate
double _stemAnnualTurnOverRate
Definition: esgymmodule.h:96
moja::modules::cbm::ESGYMModule::hwm
double hwm
Definition: esgymmodule.h:111
moja::modules::cbm::ESGYMModule::_stemSnagTurnoverRate
double _stemSnagTurnoverRate
Definition: esgymmodule.h:100
moja::modules::cbm::ESGYMModule::standSWCoarseRootsCarbon
double standSWCoarseRootsCarbon
Definition: esgymmodule.h:123
moja::modules::cbm::ESGYMModule::GrowthAndMortality
double GrowthAndMortality(int age, double B1, double B2, double B3, double B4, double B5, double b1, double b2, double eeq_n, double eeq_mu, double eeq_sig, double dwf_n, double dwf_mu, double dwf_sig)
Definition: esgymmodule.h:155
moja::modules::cbm::ESGYMModule::_belowGroundVeryFastSoil
const flint::IPool * _belowGroundVeryFastSoil
Definition: esgymmodule.h:45
moja::modules::cbm::ESGYMModule::_currentLandClass
flint::IVariable * _currentLandClass
Definition: esgymmodule.h:57
moja::modules::cbm::ESGYMModule::_atmosphere
const flint::IPool * _atmosphere
Definition: esgymmodule.h:52
moja::modules::cbm::ESGYMModule::EnvironmentalModifier
double EnvironmentalModifier(double B_dwf, double B_dwf_mu, double B_dwf_sig, double dwf_a, double B_rswd, double B_rswd_mu, double B_rswd_sig, double rswd_a, double B_tmean, double B_tmean_mu, double B_tmean_sig, double tmean_a, double B_vpd, double B_vpd_mu, double B_vpd_sig, double vpd_a, double B_eeq, double B_eeq_mu, double B_eeq_sig, double eeq_a, double B_ws, double B_ws_mu, double B_ws_sig, double ws_a, double B_ndep, double B_ndep_mu, double B_ndep_sig, double ndep, double B_ca, double B_ca_mu, double B_ca_sig, double ca)
Definition: esgymmodule.h:216
moja::modules::cbm::ESGYMModule::standBiomassModifierParameters
DynamicObject standBiomassModifierParameters
Definition: esgymmodule.h:81
moja::modules::cbm::ESGYMModule::_softwoodStemSnag
const flint::IPool * _softwoodStemSnag
Definition: esgymmodule.h:47
moja::modules::cbm::ESGYMModule::standSWFineRootsCarbon
double standSWFineRootsCarbon
Definition: esgymmodule.h:124
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::ESGYMModule::_hardwoodFoliage
const flint::IPool * _hardwoodFoliage
Definition: esgymmodule.h:39
cbmmodulebase.h
rootbiomassequation.h
moja::modules::cbm::ESGYMModule::_otherToBranchSnagSplit
double _otherToBranchSnagSplit
Definition: esgymmodule.h:99
moja::modules::cbm::ESGYMModule::_hardwoodFoliageFallRate
double _hardwoodFoliageFallRate
Definition: esgymmodule.h:95
moja::modules::cbm::ESGYMModule::_softwoodBranchSnag
const flint::IPool * _softwoodBranchSnag
Definition: esgymmodule.h:48
moja::modules::cbm::ESGYMModule::_aboveGroundFastSoil
const flint::IPool * _aboveGroundFastSoil
Definition: esgymmodule.h:44
moja::modules::cbm::ESGYMModule::_hardwoodStemSnag
const flint::IPool * _hardwoodStemSnag
Definition: esgymmodule.h:49
moja::modules::cbm::ESGYMModule::_hardwoodCoarseRoots
const flint::IPool * _hardwoodCoarseRoots
Definition: esgymmodule.h:40
moja::modules::cbm::ESGYMModule::_regenDelay
flint::IVariable * _regenDelay
Definition: esgymmodule.h:56