GCBM
esgymspinupsequencer.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_ESGYMSPINUPSEQUENCER_H_
2 #define MOJA_MODULES_CBM_ESGYMSPINUPSEQUENCER_H_
3 
4 #include <unordered_map>
5 
6 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 #include "moja/datetime.h"
8 #include "moja/flint/itiming.h"
9 #include "moja/flint/sequencermodulebase.h"
10 #include "moja/notificationcenter.h"
11 #include "moja/pocojsonutils.h"
12 
13 namespace moja {
14 namespace modules {
15 namespace cbm {
16 
17  class CBM_API ESGYMSpinupSequencer : public flint::SequencerModuleBase {
18  public:
19  ESGYMSpinupSequencer() : _standAge(0) {};
20  virtual ~ESGYMSpinupSequencer() {};
21 
22  const std::string returnInverval = "return_interval";
23  const std::string maxRotation = "max_rotations";
24  const std::string historicDistType = "historic_disturbance_type";
25  const std::string lastDistType = "last_pass_disturbance_type";
26  const std::string delay = "delay";
27  const std::string inventoryDelay = "inventory_delay";
28 
29  void configure(const DynamicObject& config) override {
30  if (config.contains("ramp_start_date")) {
31  _rampStartDate = moja::parseSimpleDate(
32  config["ramp_start_date"].extract<std::string>());
33  }
34  };
35 
39  void configure(flint::ITiming& timing) override {
40  startDate = timing.startDate();
41  endDate = timing.endDate();
42  };
43 
44  bool Run(NotificationCenter& _notificationCenter, flint::ILandUnitController& luc) override;
45 
46  private:
47  DateTime startDate;
48  DateTime endDate;
49 
50  const flint::IPool* _aboveGroundSlowSoil;
51  const flint::IPool* _belowGroundSlowSoil;
52  flint::IVariable* _age;
53  flint::IVariable* _delay;
54 
55  /* Get spinup parameters for this land unit */
56  bool getSpinupParameters(flint::ILandUnitDataWrapper& landUnitData);
57 
58  /* Check if the slow pool is stable */
59  bool isSlowPoolStable(double lastSlowPoolValue, double currentSlowPoolValue);
60 
61  /* Fire timing events */
62  void fireSpinupSequenceEvent(NotificationCenter& notificationCenter,
63  flint::ILandUnitController& luc,
64  int maximumSteps,
65  bool incrementStep);
66 
67  /* Fire historical and last disturbance */
68  void fireHistoricalLastDisturbanceEvent(NotificationCenter& notificationCenter,
69  flint::ILandUnitController& luc,
70  std::string disturbanceName);
71 
72  void fetchDistTypeCodes();
73 
77  int _maxRotationValue; // maximum rotations to do the spinup, 30, each rotation is 125 years
78 
82  int _miniumRotation; // minimum rotation to do the spinup, 3
83 
87  int _ageReturnInterval; // age interval to fire a historic disturbance, 125 years
88 
92  int _standAge; // stand age to grow after the last disturbance
93 
97  int _standDelay; // years to delay, during delay period, only turnover and decay processes
98 
102  int _spinupGrowthCurveID; // spinup growth curve ID
103 
107  std::string _historicDistType; // historic disturbance type happened at each age interval
108 
112  std::string _lastPassDistType; // last disturance type happened when the slow pool is stable and minimum rotations are done
113 
121  Poco::Nullable<DateTime> _rampStartDate;
122 
123  std::unordered_map<std::string, int> _distTypeCodes;
124  };
125 }}}
126 #endif
moja::modules::cbm::ESGYMSpinupSequencer::_distTypeCodes
std::unordered_map< std::string, int > _distTypeCodes
Definition: esgymspinupsequencer.h:123
moja::modules::cbm::ESGYMSpinupSequencer::_lastPassDistType
std::string _lastPassDistType
Last disturance type happened when the slow pool is stable and minimum rotations are done
Definition: esgymspinupsequencer.h:112
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::ESGYMSpinupSequencer::_standDelay
int _standDelay
Years to delay, during delay period, only turnover and decay processes
Definition: esgymspinupsequencer.h:97
moja::modules::cbm::ESGYMSpinupSequencer::_standAge
int _standAge
Stand age to grow after the last disturbance
Definition: esgymspinupsequencer.h:92
moja::modules::cbm::ESGYMSpinupSequencer::_age
flint::IVariable * _age
Definition: esgymspinupsequencer.h:52
moja::modules::cbm::ESGYMSpinupSequencer::_belowGroundSlowSoil
const flint::IPool * _belowGroundSlowSoil
Definition: esgymspinupsequencer.h:51
moja::modules::cbm::ESGYMSpinupSequencer::endDate
DateTime endDate
Definition: esgymspinupsequencer.h:48
moja::modules::cbm::ESGYMSpinupSequencer::_maxRotationValue
int _maxRotationValue
Maximum rotations to do the spinup, 30, each rotation is 125 years
Definition: esgymspinupsequencer.h:77
moja::modules::cbm::ESGYMSpinupSequencer::_rampStartDate
Poco::Nullable< DateTime > _rampStartDate
Last disturance type happened when the slow pool is stable and minimum rotations are done Optional ra...
Definition: esgymspinupsequencer.h:121
moja::modules::cbm::ESGYMSpinupSequencer::_aboveGroundSlowSoil
const flint::IPool * _aboveGroundSlowSoil
Definition: esgymspinupsequencer.h:50
moja::modules::cbm::ESGYMSpinupSequencer::ESGYMSpinupSequencer
ESGYMSpinupSequencer()
Definition: esgymspinupsequencer.h:19
moja::modules::cbm::ESGYMSpinupSequencer::startDate
DateTime startDate
Definition: esgymspinupsequencer.h:47
moja::modules::cbm::ESGYMSpinupSequencer::_delay
flint::IVariable * _delay
Definition: esgymspinupsequencer.h:53
moja::modules::cbm::ESGYMSpinupSequencer::configure
void configure(flint::ITiming &timing) override
Set the value of startDate and endDate from parameter timing
Definition: esgymspinupsequencer.h:39
moja::modules::cbm::ESGYMSpinupSequencer::~ESGYMSpinupSequencer
virtual ~ESGYMSpinupSequencer()
Definition: esgymspinupsequencer.h:20
moja::modules::cbm::ESGYMSpinupSequencer::_ageReturnInterval
int _ageReturnInterval
Age interval to fire a historic disturbance, 125 years
Definition: esgymspinupsequencer.h:87
moja::modules::cbm::ESGYMSpinupSequencer::configure
void configure(const DynamicObject &config) override
Definition: esgymspinupsequencer.h:29
moja::modules::cbm::ESGYMSpinupSequencer
Definition: esgymspinupsequencer.h:17
moja::modules::cbm::ESGYMSpinupSequencer::_spinupGrowthCurveID
int _spinupGrowthCurveID
Spinup growth curve ID
Definition: esgymspinupsequencer.h:102
moja::modules::cbm::ESGYMSpinupSequencer::_miniumRotation
int _miniumRotation
Minimum rotation to do the spinup, 3
Definition: esgymspinupsequencer.h:82
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::ESGYMSpinupSequencer::_historicDistType
std::string _historicDistType
Historic disturbance type happened at each age interval
Definition: esgymspinupsequencer.h:107