GCBM
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ESGYMSpinupSequencer Class Reference

#include <esgymspinupsequencer.h>

Inherits SequencerModuleBase.

Collaboration diagram for ESGYMSpinupSequencer:
Collaboration graph

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 &notificationCenter, flint::ILandUnitController &luc, int maximumSteps, bool incrementStep)
 
void fireHistoricalLastDisturbanceEvent (NotificationCenter &notificationCenter, 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
 

Constructor & Destructor Documentation

◆ ESGYMSpinupSequencer()

◆ ~ESGYMSpinupSequencer()

virtual ~ESGYMSpinupSequencer ( )
virtual

Member Function Documentation

◆ configure() [1/2]

void configure ( const DynamicObject &  config)
override

◆ configure() [2/2]

void configure ( flint::ITiming &  timing)
override

Set the value of startDate and endDate from parameter timing

◆ fetchDistTypeCodes()

void fetchDistTypeCodes ( )
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.

Returns
void

◆ fireHistoricalLastDisturbanceEvent()

void fireHistoricalLastDisturbanceEvent ( NotificationCenter &  notificationCenter,
flint::ILandUnitController &  luc,
std::string  disturbanceName 
)
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

Parameters
notificationCenterNotificationCenter&
lucflint::ILandUnitController&
disturbanceNamestring
Returns
void

◆ fireSpinupSequenceEvent()

void fireSpinupSequenceEvent ( NotificationCenter &  notificationCenter,
flint::ILandUnitController &  luc,
int  maximumSteps,
bool  incrementStep 
)
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

Parameters
notificationCenterNotificationCenter&
lucflint::ILandUnitController&
maximumStepsint
incrementStepbool
Returns
void

◆ getSpinupParameters()

bool getSpinupParameters ( flint::ILandUnitDataWrapper &  landUnitData)
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

Parameters
landUnitflint::ILandUnitDataWrapper&
Returns
bool

◆ isSlowPoolStable()

bool isSlowPoolStable ( double  lastSlowPoolValue,
double  currentSlowPoolValue 
)
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

Parameters
lastSlowPoolValuedouble
currentSlowPoolValuedouble
Returns
bool

◆ Run()

bool Run ( NotificationCenter &  _notificationCenter,
flint::ILandUnitController &  luc 
)
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

Parameters
notificationCenterflint::NotificationCenter&
lucflint::ILandUnitController&
Returns
bool

Member Data Documentation

◆ _aboveGroundSlowSoil

const flint::IPool* _aboveGroundSlowSoil
private

◆ _age

flint::IVariable* _age
private

◆ _ageReturnInterval

int _ageReturnInterval
private

Age interval to fire a historic disturbance, 125 years

◆ _belowGroundSlowSoil

const flint::IPool* _belowGroundSlowSoil
private

◆ _delay

flint::IVariable* _delay
private

◆ _distTypeCodes

std::unordered_map<std::string, int> _distTypeCodes
private

◆ _historicDistType

std::string _historicDistType
private

Historic disturbance type happened at each age interval


◆ _lastPassDistType

std::string _lastPassDistType
private

Last disturance type happened when the slow pool is stable and minimum rotations are done


◆ _maxRotationValue

int _maxRotationValue
private

Maximum rotations to do the spinup, 30, each rotation is 125 years

◆ _miniumRotation

int _miniumRotation
private

Minimum rotation to do the spinup, 3

◆ _rampStartDate

Poco::Nullable<DateTime> _rampStartDate
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, ...

◆ _spinupGrowthCurveID

int _spinupGrowthCurveID
private

Spinup growth curve ID


◆ _standAge

int _standAge
private

Stand age to grow after the last disturbance


◆ _standDelay

int _standDelay
private

Years to delay, during delay period, only turnover and decay processes


◆ delay

const std::string delay = "delay"

◆ endDate

DateTime endDate
private

◆ historicDistType

const std::string historicDistType = "historic_disturbance_type"

◆ inventoryDelay

const std::string inventoryDelay = "inventory_delay"

◆ lastDistType

const std::string lastDistType = "last_pass_disturbance_type"

◆ maxRotation

const std::string maxRotation = "max_rotations"

◆ returnInverval

const std::string returnInverval = "return_interval"

◆ startDate

DateTime startDate
private

The documentation for this class was generated from the following files: