GCBM
yieldtablegrowthmodule.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_YIELDTABLEGROWTHMODULE_H_
2 #define MOJA_MODULES_CBM_YIELDTABLEGROWTHMODULE_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
6 
14 
15 namespace moja {
16  namespace modules {
17  namespace cbm {
18 
19  class CBM_API YieldTableGrowthModule : public CBMModuleBase {
20  public:
21  YieldTableGrowthModule(std::shared_ptr<StandGrowthCurveFactory> gcFactory, std::shared_ptr<VolumeToBiomassCarbonGrowth> volumeToBioGrowth)
22  : _gcFactory(gcFactory), _volumeToBioGrowth(volumeToBioGrowth) {};
23 
25 
26  void configure(const DynamicObject& config) override;
27  void subscribe(NotificationCenter& notificationCenter) override;
28 
29  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::Model; };
30 
31  void doLocalDomainInit() override;
32  void doTimingInit() override;
33  void doTimingStep() override;
34 
35  void getYieldCurve();
36  std::shared_ptr<StandGrowthCurve> createStandGrowthCurve(
37  Int64 standGrowthCurveID, Int64 spuID) const;
38 
39  private:
40  const flint::IPool* _softwoodMerch = nullptr;
41  const flint::IPool* _softwoodOther = nullptr;
42  const flint::IPool* _softwoodFoliage = nullptr;
43  const flint::IPool* _softwoodCoarseRoots = nullptr;
44  const flint::IPool* _softwoodFineRoots = nullptr;
45 
46  const flint::IPool* _hardwoodMerch = nullptr;
47  const flint::IPool* _hardwoodOther = nullptr;
48  const flint::IPool* _hardwoodFoliage = nullptr;
49  const flint::IPool* _hardwoodCoarseRoots = nullptr;
50  const flint::IPool* _hardwoodFineRoots = nullptr;
51 
52  const flint::IPool* _aboveGroundVeryFastSoil = nullptr;
53  const flint::IPool* _aboveGroundFastSoil = nullptr;
54  const flint::IPool* _belowGroundVeryFastSoil = nullptr;
55  const flint::IPool* _belowGroundFastSoil = nullptr;
56  const flint::IPool* _softwoodStemSnag = nullptr;
57  const flint::IPool* _softwoodBranchSnag = nullptr;
58  const flint::IPool* _hardwoodStemSnag = nullptr;
59  const flint::IPool* _hardwoodBranchSnag = nullptr;
60  const flint::IPool* _mediumSoil = nullptr;
61  const flint::IPool* _atmosphere = nullptr;
62 
63  const flint::IPool* _woodyFoliageDead = nullptr;
64  const flint::IPool* _woodyFineDead = nullptr;
65  const flint::IPool* _woodyCoarseDead = nullptr;
66  const flint::IPool* _woodyRootsDead = nullptr;
67 
68  flint::IVariable* _age = nullptr;
69  flint::IVariable* _gcId = nullptr;
70  flint::IVariable* _spuId = nullptr;
71  flint::IVariable* _turnoverRates = nullptr;
72  flint::IVariable* _regenDelay = nullptr;
73  flint::IVariable* _spinupMossOnly = nullptr;
74  flint::IVariable* _isForest = nullptr;
75  flint::IVariable* _isDecaying = nullptr;
76  flint::IVariable* _growthMultipliers = nullptr;
77  flint::IVariable* _output_removal = nullptr;
78 
79  bool _growthMultipliersEnabled = true;
80  bool _smootherEnabled = true;
81  bool _debuggingEnabled = false;
82  std::string _debuggingOutputPath = ".";
83 
84  Int64 _standGrowthCurveID{ -1 };
85  Int64 _standSPUID{ -1 };
86 
87  std::shared_ptr<VolumeToBiomassCarbonGrowth> _volumeToBioGrowth = nullptr;
88  std::shared_ptr<StandGrowthCurveFactory> _gcFactory = nullptr;
89 
90  void getIncrements();
91  void getTurnoverRates();
92  void initPeatland();
93  void doHalfGrowth() const;
94  void doTurnover() const;
95  void updateBiomassPools();
96  void doMidSeasonGrowth() const;
97  bool shouldRun() const;
98 
99  void switchTurnover() const;
100  void doPeatlandTurnover() const;
101  void switchHalfGrowth() const;
102  void doPeatlandHalfGrowth() const;
103 
104  bool _skipForPeatland{ false };
105  bool _runForForestedPeatland{ false };
106  int _peatlandId{ -1 };
107 
108  // biomass and snag turnover rate/parameters
109  std::unordered_map<std::tuple<Int64, Int64>, std::shared_ptr<TurnoverRates>> _cachedTurnoverRates;
110  std::shared_ptr<TurnoverRates> _currentTurnoverRates;
111 
112  // record of the biomass carbon growth increment
113  double swm = 0;
114  double swo = 0;
115  double swf = 0;
116  double hwm = 0;
117  double hwo = 0;
118  double hwf = 0;
119  double swcr = 0;
120  double swfr = 0;
121  double hwcr = 0;
122  double hwfr = 0;
123 
124  // record of the current biomass and snag pool value
125  double standSoftwoodMerch = 0;
126  double standSoftwoodOther = 0;
127  double standSoftwoodFoliage = 0;
128  double standSWCoarseRootsCarbon = 0;
129  double standSWFineRootsCarbon = 0;
130  double standHardwoodMerch = 0;
131  double standHardwoodOther = 0;
132  double standHardwoodFoliage = 0;
133  double standHWCoarseRootsCarbon = 0;
134  double standHWFineRootsCarbon = 0;
135  double softwoodStemSnag = 0;
136  double softwoodBranchSnag = 0;
137  double hardwoodStemSnag = 0;
138  double hardwoodBranchSnag = 0;
139 
140  void printRemovals(int standAge,
141  double standFoliageRemoval,
142  double standStemSnagRemoval,
143  double standBranchSnagRemoval,
144  double standOtherRemovalToWFD,
145  double standCoarseRootsRemoval,
146  double standFineRootsRemoval,
147  double standOtherRemovalToBranchSnag) const;
148  };
149  }
150  }
151 }
152 #endif
volumetobiomasscarbongrowth.h
foresttypeconfiguration.h
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::YieldTableGrowthModule
Definition: yieldtablegrowthmodule.h:19
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::YieldTableGrowthModule::_currentTurnoverRates
std::shared_ptr< TurnoverRates > _currentTurnoverRates
Definition: yieldtablegrowthmodule.h:110
peatlands.h
moja::modules::cbm::YieldTableGrowthModule::~YieldTableGrowthModule
virtual ~YieldTableGrowthModule()
Definition: yieldtablegrowthmodule.h:24
moja::modules::cbm::YieldTableGrowthModule::_cachedTurnoverRates
std::unordered_map< std::tuple< Int64, Int64 >, std::shared_ptr< TurnoverRates > > _cachedTurnoverRates
Definition: yieldtablegrowthmodule.h:109
standgrowthcurvefactory.h
moja::modules::cbm::YieldTableGrowthModule::moduleType
flint::ModuleTypes moduleType() override
Definition: yieldtablegrowthmodule.h:29
moja::modules::cbm::YieldTableGrowthModule::YieldTableGrowthModule
YieldTableGrowthModule(std::shared_ptr< StandGrowthCurveFactory > gcFactory, std::shared_ptr< VolumeToBiomassCarbonGrowth > volumeToBioGrowth)
Definition: yieldtablegrowthmodule.h:21
standgrowthcurve.h
moja
Definition: ageclasshelper.cpp:10
cbmmodulebase.h
rootbiomassequation.h
turnoverrates.h