GCBM
|
#include <esgymspinupsequencer.h>
Inherits SequencerModuleBase.
Public Member Functions | |
ESGYMSpinupSequencer () | |
virtual | ~ESGYMSpinupSequencer () |
void | configure (const DynamicObject &config) override |
void | configure (flint::ITiming &timing) override |
Set the value of startDate and endDate from parameter timing More... | |
bool | Run (NotificationCenter &_notificationCenter, flint::ILandUnitController &luc) override |
Public Attributes | |
const std::string | returnInverval = "return_interval" |
const std::string | maxRotation = "max_rotations" |
const std::string | historicDistType = "historic_disturbance_type" |
const std::string | lastDistType = "last_pass_disturbance_type" |
const std::string | delay = "delay" |
const std::string | inventoryDelay = "inventory_delay" |
Private Member Functions | |
bool | getSpinupParameters (flint::ILandUnitDataWrapper &landUnitData) |
bool | isSlowPoolStable (double lastSlowPoolValue, double currentSlowPoolValue) |
void | fireSpinupSequenceEvent (NotificationCenter ¬ificationCenter, flint::ILandUnitController &luc, int maximumSteps, bool incrementStep) |
void | fireHistoricalLastDisturbanceEvent (NotificationCenter ¬ificationCenter, flint::ILandUnitController &luc, std::string disturbanceName) |
void | fetchDistTypeCodes () |
Private Attributes | |
DateTime | startDate |
DateTime | endDate |
const flint::IPool * | _aboveGroundSlowSoil |
const flint::IPool * | _belowGroundSlowSoil |
flint::IVariable * | _age |
flint::IVariable * | _delay |
int | _maxRotationValue |
Maximum rotations to do the spinup, 30, each rotation is 125 years More... | |
int | _miniumRotation |
Minimum rotation to do the spinup, 3 More... | |
int | _ageReturnInterval |
Age interval to fire a historic disturbance, 125 years More... | |
int | _standAge |
Stand age to grow after the last disturbance More... | |
int | _standDelay |
Years to delay, during delay period, only turnover and decay processes More... | |
int | _spinupGrowthCurveID |
Spinup growth curve ID More... | |
std::string | _historicDistType |
Historic disturbance type happened at each age interval More... | |
std::string | _lastPassDistType |
Last disturance type happened when the slow pool is stable and minimum rotations are done More... | |
Poco::Nullable< DateTime > | _rampStartDate |
Last disturance type happened when the slow pool is stable and minimum rotations are done Optional ramp to use at the end of the spinup period; used when, for example, spinup uses a value of 10 for a variable, and the rest of the simulation uses a value of 20, and the values need to blend smoothly together, so the user prepares a 10-value ramp which is used for the last 10 timesteps of the spinup period: 10, 11, 12, 13, ... More... | |
std::unordered_map< std::string, int > | _distTypeCodes |
|
virtual |
|
override |
|
override |
Set the value of startDate and endDate from parameter timing
|
private |
Get disturbance type and disturbance type codes
If _landUnitData has the variable "disturbance_type_codes", for each code in variable "disturbance_type_codes", populate ESGYMSpinupSequencer._distTypeCodes mapping the "disturbance_type" to the "disturbance_type_code" value.
|
private |
Fire historical and last disturbance
Post the moja::signals::DisturbanceEvent notification with argument data, and also post a generic follow-up notification after the subscriber receives the original signal
data is a DynamicVar with key "disturbance", value as parameter disturbanceName, key "disturbance_type_code", which takes the value of parameter disturbanceName in ESGYMSpinupSequencer._distTypeCodes if count of parameter disturbanceName in ESGYMSpinupSequencer._distTypeCodes > 0 else takes value -1 , key "transfers", a vector of CBMDistEventTransfer to keep the event pool transfers
notificationCenter | NotificationCenter& |
luc | flint::ILandUnitController& |
disturbanceName | string |
|
private |
Fire timing events
For each time step in the range 0 to paraemter maximumSteps, get the timing object from _landUnitData, invoke setStep() on timing, set the current timestep to the previous timestep + 1,
setStartStepDate() on timing, increment the current timestep start date by 1 year,
setEndStepDate() on timing, increment the current timestep end date by 1 year,
setCurStartDate() on timing, increment the current fractional timestep start date by 1 year,
setCurEndDate() on timing, increment the current fractional timestep end date by 1 year,
Post notifications moja::signals::TimingStep, moja::signals::TimingPreEndStep and also post a generic follow-up notification after the subscriber receives the original signal
Post notification moja::signals::TimingEndStep and moja::signals::TimingPostStep
notificationCenter | NotificationCenter& |
luc | flint::ILandUnitController& |
maximumSteps | int |
incrementStep | bool |
|
private |
Get spinup parameters for this land unit
If value of variable "spinup_parameters" in parameter landUnitData is false, return false
Extract DynamicObject from variable "spinup_parameters" in parameter landUnitData and store it in a variable spinupParams
Assign values of ESGYMSpinupSequencer::returnInverval, ESGYMSpinupSequencer::maxRotation, ESGYMSpinupSequencer::historicDistType, ESGYMSpinupSequencer::lastDistType in spinupParams to ESGYMSpinupSequencer._ageReturnInterval, ESGYMSpinupSequencer._maxRotationValue, ESGYMSpinupSequencer._historicDistType and ESGYMSpinupSequencer._lastPassDistType
If ESGYMSpinupSequencer::inventoryDelay exists in spinupParams, assign it to ESGYMSpinupSequencer._standDelay, else assign ESGYMSpinupSequencer::delay
Assign ESGYMSpinupSequencer._miniumRotation, ESGYMSpinupSequencer._age,ESGYMSpinupSequencer._standAge, ESGYMSpinupSequencer._delay values of variables "minimum_rotation", "age", "initial_age", "delay" in parameter landUnitData, ESGYMSpinupSequencer._aboveGroundSlowSoil, ESGYMSpinupSequencer._belowGroundSlowSoil values of pools "AboveGroundSlowSoil", "BelowGroundSlowSoil" in parameter landUnitData
Set the value of ESGYMSpinupSequencer._delay to ESGYMSpinupSequencer._standDelay
Return true
landUnit | flint::ILandUnitDataWrapper& |
|
private |
Check if the slow pool is stable
Return true if the ratio of parameter currentSlowPoolValue / parameter lastSlowPoolValue > 0.999 and < 1.001, where lastSlowPoolValue != 0, else return false
lastSlowPoolValue | double |
currentSlowPoolValue | double |
|
override |
If ESGYMSpinupSequencer._distTypeCodes is empty and _landUnitData has a variable "disturbance_type_codes", invoke ESGYMSpinupSequencer.fetchDistTypeCodes()
If getSpinupParameters() on _landUnitData returns false, return false
Set the stepping period of the simulation to TimeStepping::Annual
If _rampStartDate is true, set the simulation start date to _rampStartDate, set the simulation end date to luc.timing().startDate(), set the current timestep start date, current timestamp end date, current fractional timestep start date and current fractional timestep end date to the start date of the simulation, result of the startDate() on _landUnitData->timing()
Post notifications moja::signals::TimingInit and moja::signals::TimingPostInit
Create a variable currentRotation with value 0, till the time currentRotation is less than ESGYMSpinupSequencer._maxRotationValue, fire spinup pass, each pass is up to the stand age return interval, get the slow pool values at the end of the current age interval as the sum of values _aboveGroundSlowSoil and _belowGroundSlowSoil and assign it to variable currentSlowPoolValue, the slow pool value at the end of the previous iteration is stored in variable lastSlowPoolValue
If the result of ESGYMSpinupSequencer.isSlowPoolStable() with arguments lastSlowPoolValue and currentSlowPoolValue is true, and variable currentRotation > _miniumRotation, break from the loop, as slow pool is stable, and the minimum rotations are done
Whenever the max rotations are reached, stop even if the slow pool is not stable
CBM spinup is not done, notify to simulate the historic disturbance.
Perform the optional ramp-up from spinup to regular simulation values
Determine the number of years the final stages of the simulation need to run without advancing the timestep into the ramp-up period; i.e. all spinup timeseries variables are aligned to the end of spinup for each pixel.
Fire up the spinup sequencer to grow the stand to the original stand age, set value of _age to 0
If there is stand delay, ESGYMSpinupSequencer._standDelay > 0 , due to deforestation disturbance, fire up the stand delay to do turnover and decay only
notificationCenter | flint::NotificationCenter& |
luc | flint::ILandUnitController& |
|
private |
|
private |
|
private |
Age interval to fire a historic disturbance, 125 years
|
private |
|
private |
|
private |
|
private |
Historic disturbance type happened at each age interval
|
private |
Last disturance type happened when the slow pool is stable and minimum rotations are done
|
private |
Maximum rotations to do the spinup, 30, each rotation is 125 years
|
private |
Minimum rotation to do the spinup, 3
|
private |
Last disturance type happened when the slow pool is stable and minimum rotations are done Optional ramp to use at the end of the spinup period; used when, for example, spinup uses a value of 10 for a variable, and the rest of the simulation uses a value of 20, and the values need to blend smoothly together, so the user prepares a 10-value ramp which is used for the last 10 timesteps of the spinup period: 10, 11, 12, 13, ...
|
private |
Spinup growth curve ID
|
private |
Stand age to grow after the last disturbance
|
private |
Years to delay, during delay period, only turnover and decay processes
const std::string delay = "delay" |
|
private |
const std::string historicDistType = "historic_disturbance_type" |
const std::string inventoryDelay = "inventory_delay" |
const std::string lastDistType = "last_pass_disturbance_type" |
const std::string maxRotation = "max_rotations" |
const std::string returnInverval = "return_interval" |
|
private |