GCBM
cbmdecaymodule.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMDECAYMODULE_H_
2 #define MOJA_MODULES_CBM_CBMDECAYMODULE_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 
8 namespace moja {
9 namespace modules {
10 namespace cbm {
11 
13  std::string pool;
14  double baseDecayRate;
15  double maxDecayRate;
16  double q10;
17  double tRef;
18  double pAtm;
19 
21 
22  PoolDecayParameters(const DynamicObject& data) {
23  pool = data["pool"].convert<std::string>();
24  baseDecayRate = data["organic_matter_decay_rate"];
25  q10 = data["q10"];
26  tRef = data["reference_temp"];
27  maxDecayRate = data["max_decay_rate_soft"];
28  pAtm = data["prop_to_atmosphere"];
29  }
30 
31  double getDecayRate(double mat) {
32  return std::min(
33  baseDecayRate * std::exp((mat - tRef) * std::log(q10) * 0.1),
34  maxDecayRate);
35  }
36  };
37 
38  class CBM_API CBMDecayModule : public CBMModuleBase {
39  public:
41  virtual ~CBMDecayModule() = default;
42 
43  void configure(const DynamicObject& config) override;
44  void subscribe(NotificationCenter& notificationCenter) override;
45 
46  void doLocalDomainInit() override;
47  void doTimingInit() override;
48  void doTimingStep() override;
49 
50  private:
51  void getTransfer(std::shared_ptr<flint::IOperation> operation,
52  double meanAnnualTemperature,
53  const std::string& domPool,
54  const flint::IPool* poolSrc,
55  const flint::IPool* poolDest);
56 
57  void getTransfer(std::shared_ptr<flint::IOperation> operation,
58  double meanAnnualTemperature,
59  const std::string& domPool,
60  const flint::IPool* pool);
61 
62  bool shouldRun();
63  void initPeatland();
64 
65  const flint::IPool* _aboveGroundVeryFastSoil;
66  const flint::IPool* _belowGroundVeryFastSoil;
67  const flint::IPool* _aboveGroundFastSoil;
68  const flint::IPool* _belowGroundFastSoil;
69  const flint::IPool* _mediumSoil;
70  const flint::IPool* _aboveGroundSlowSoil;
71  const flint::IPool* _belowGroundSlowSoil;
72  const flint::IPool* _softwoodStemSnag;
73  const flint::IPool* _softwoodBranchSnag;
74  const flint::IPool* _hardwoodStemSnag;
75  const flint::IPool* _hardwoodBranchSnag;
76  const flint::IPool* _atmosphere;
77 
78  flint::IVariable* _spinupMossOnly;
79  flint::IVariable* _isDecaying;
80 
82  bool _extraDecayRemovals { false };
83  bool _skipForPeatland { false };
84 
85  std::map<std::string, PoolDecayParameters> _decayParameters;
86  std::map<std::string, std::map<std::string, double>> _decayRemovals;
87  };
88 
89 }}} // namespace moja::modules::cbm
90 
91 #endif // MOJA_MODULES_CBM_CBMDECAYMODULE_H_
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::CBMDecayModule::_atmosphere
const flint::IPool * _atmosphere
Definition: cbmdecaymodule.h:76
moja::modules::cbm::CBMDecayModule::_belowGroundFastSoil
const flint::IPool * _belowGroundFastSoil
Definition: cbmdecaymodule.h:68
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::PoolDecayParameters::pAtm
double pAtm
Definition: cbmdecaymodule.h:18
moja::modules::cbm::CBMDecayModule::_belowGroundVeryFastSoil
const flint::IPool * _belowGroundVeryFastSoil
Definition: cbmdecaymodule.h:66
moja::modules::cbm::CBMDecayModule::_aboveGroundSlowSoil
const flint::IPool * _aboveGroundSlowSoil
Definition: cbmdecaymodule.h:70
moja::modules::cbm::PoolDecayParameters::maxDecayRate
double maxDecayRate
Definition: cbmdecaymodule.h:15
peatlands.h
moja::modules::cbm::CBMDecayModule::_aboveGroundFastSoil
const flint::IPool * _aboveGroundFastSoil
Definition: cbmdecaymodule.h:67
moja::modules::cbm::CBMDecayModule::CBMDecayModule
CBMDecayModule()
Definition: cbmdecaymodule.h:40
moja::modules::cbm::PoolDecayParameters::q10
double q10
Definition: cbmdecaymodule.h:16
moja::modules::cbm::CBMDecayModule::_decayParameters
std::map< std::string, PoolDecayParameters > _decayParameters
Definition: cbmdecaymodule.h:85
moja::modules::cbm::CBMDecayModule::_aboveGroundVeryFastSoil
const flint::IPool * _aboveGroundVeryFastSoil
Definition: cbmdecaymodule.h:65
moja::modules::cbm::CBMDecayModule::_softwoodStemSnag
const flint::IPool * _softwoodStemSnag
Definition: cbmdecaymodule.h:72
moja::modules::cbm::PoolDecayParameters::PoolDecayParameters
PoolDecayParameters(const DynamicObject &data)
Definition: cbmdecaymodule.h:22
moja::modules::cbm::CBMDecayModule::_spinupMossOnly
flint::IVariable * _spinupMossOnly
Definition: cbmdecaymodule.h:78
moja::modules::cbm::PoolDecayParameters
Definition: cbmdecaymodule.h:12
moja::modules::cbm::PoolDecayParameters::tRef
double tRef
Definition: cbmdecaymodule.h:17
moja::modules::cbm::CBMDecayModule
Definition: cbmdecaymodule.h:38
moja::modules::cbm::CBMDecayModule::_softwoodBranchSnag
const flint::IPool * _softwoodBranchSnag
Definition: cbmdecaymodule.h:73
moja::modules::cbm::PoolDecayParameters::pool
std::string pool
Definition: cbmdecaymodule.h:13
moja::modules::cbm::PoolDecayParameters::PoolDecayParameters
PoolDecayParameters()
Definition: cbmdecaymodule.h:20
moja::modules::cbm::CBMDecayModule::_slowMixingRate
double _slowMixingRate
Definition: cbmdecaymodule.h:81
moja::modules::cbm::CBMDecayModule::_hardwoodStemSnag
const flint::IPool * _hardwoodStemSnag
Definition: cbmdecaymodule.h:74
moja::modules::cbm::PoolDecayParameters::baseDecayRate
double baseDecayRate
Definition: cbmdecaymodule.h:14
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::CBMDecayModule::_decayRemovals
std::map< std::string, std::map< std::string, double > > _decayRemovals
Definition: cbmdecaymodule.h:86
moja::modules::cbm::PoolDecayParameters::getDecayRate
double getDecayRate(double mat)
Definition: cbmdecaymodule.h:31
cbmmodulebase.h
moja::modules::cbm::CBMDecayModule::_hardwoodBranchSnag
const flint::IPool * _hardwoodBranchSnag
Definition: cbmdecaymodule.h:75
moja::modules::cbm::CBMDecayModule::_belowGroundSlowSoil
const flint::IPool * _belowGroundSlowSoil
Definition: cbmdecaymodule.h:71
moja::modules::cbm::CBMDecayModule::_mediumSoil
const flint::IPool * _mediumSoil
Definition: cbmdecaymodule.h:69
moja::modules::cbm::CBMDecayModule::_isDecaying
flint::IVariable * _isDecaying
Definition: cbmdecaymodule.h:79