Skip to content

Commit

Permalink
Updated peatland module to have an option to load initial value for p…
Browse files Browse the repository at this point in the history
…eat pool (acrotelm_o, catotelm_a) from database in spinupnext procedure.
  • Loading branch information
gazhang committed May 9, 2024
1 parent 9091baa commit bedc920
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 228 deletions.
262 changes: 133 additions & 129 deletions Source/moja.modules.cbm/include/moja/modules/cbm/peatlandspinupnext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,135 +11,139 @@
#include "moja/modules/cbm/peatlands.h"

namespace moja {
namespace modules {
namespace cbm {

/*
After regular spinup procedure, this class is called to quicly build up the peat DOM pools.
This class is implemented based on R-code
*/
class CBM_API PeatlandSpinupNext : public CBMModuleBase {
public:
PeatlandSpinupNext() : CBMModuleBase() { }
virtual ~PeatlandSpinupNext() = default;

void configure(const DynamicObject& config) override;
void subscribe(NotificationCenter& notificationCenter) override;

void doLocalDomainInit() override;
//void doTimingInit() override;
void doPrePostDisturbanceEvent() override;

private:
const flint::IPool* _softwoodMerch;
const flint::IPool* _softwoodOther;
const flint::IPool* _softwoodFoliage;
const flint::IPool* _softwoodCoarseRoots;
const flint::IPool* _softwoodFineRoots;
const flint::IPool* _softwoodStemSnag;
const flint::IPool* _softwoodBranchSnag;

const flint::IPool* _hardwoodMerch;
const flint::IPool* _hardwoodOther;
const flint::IPool* _hardwoodFoliage;
const flint::IPool* _hardwoodCoarseRoots;
const flint::IPool* _hardwoodFineRoots;
const flint::IPool* _hardwoodStemSnag;
const flint::IPool* _hardwoodBranchSnag;

const flint::IPool* _softwoodStem;
const flint::IPool* _hardwoodStem;

const flint::IPool* _woodyFoliageLive;
const flint::IPool* _woodyStemsBranchesLive;
const flint::IPool* _woodyRootsLive;
const flint::IPool* _sedgeFoliageLive;
const flint::IPool* _sedgeRootsLive;
const flint::IPool* _featherMossLive;
const flint::IPool* _sphagnumMossLive;

const flint::IPool* _woodyFoliageDead;
const flint::IPool* _woodyFineDead;
const flint::IPool* _woodyCoarseDead;
const flint::IPool* _woodyRootsDead;
const flint::IPool* _sedgeFoliageDead;
const flint::IPool* _sedgeRootsDead;
const flint::IPool* _feathermossDead;
const flint::IPool* _acrotelm_o;
const flint::IPool* _catotelm_a;
const flint::IPool* _acrotelm_a;
const flint::IPool* _catotelm_o;

const flint::IPool* _atmosphere;

const flint::IVariable* _turnoverRates;

double _softwoodFoliageFallRate{ 0 };
double _hardwoodFoliageFallRate{ 0 };
double _stemAnnualTurnOverRate{ 0 };
double _stemSnagTurnoverRate{ 0 };
double _softwoodBranchTurnOverRate{ 0 };
double _hardwoodBranchTurnOverRate{ 0 };
double _coarseRootTurnProp{ 0 };
double _fineRootTurnProp{ 0 };
double _otherToBranchSnagSplit{ 0 };
double _branchSnagTurnoverRate{ 0 };


int smallTreeOn{ 0 };
double smallTreeFoliageRemoval{ 0 };
double smallTreeFineRootRemoval{ 0 };
double smallTreeCoarseRootRemoval{ 0 };
double smallTreeOtherRemovalToWFD{ 0 };
double smallTreeBranchSnagRemoval{ 0 };
double smallTreeStemSnagRemoval{ 0 };

int largeTreeOn{ 0 };
double largeTreeFoliageRemoval{ 0 };
double largeTreeFineRootRemoval{ 0 };
double largeTreeCoarseRootRemoval{ 0 };
double largeTreeOtherRemovalToWFD{ 0 };
double largeTreeBranchSnagRemoval{ 0 };
double largeTreeStemSnagRemoval{ 0 };

double meanAnnualTemperature{ 0 };
double f_r{ 1 };
double f_fr{ 1 };

// decay parameters associated to this peatland unit
std::shared_ptr<PeatlandDecayParameters> decayParas;

// turnover parameters associated to this peatland unit
std::shared_ptr<PeatlandTurnoverParameters> turnoverParas;

// the growth parameters associated to this peatland unit
std::shared_ptr<PeatlandGrowthParameters> growthParas;

// the peatland fire parameter
std::shared_ptr<PeatlandFireParameters> fireParas;

void getTreeTurnoverRate(Peatlands peatlandId);

void getAndUpdateParameter();

void getNonOpenPeatlandRemovals(Peatlands peatlandId);

void populatePeatlandDeadPoolsV1();

void populatePeatlandDeadPoolsV2();

void populatePeatlandDeadPoolsV3();

void getCurrentDeadPoolValues();

void resetSlowPools();

inline double modifyQ10(double baseQ10Para) {
return (pow(baseQ10Para, 0.1 * (meanAnnualTemperature - 10)));
};
};

}}} // namespace moja::modules::cbm
namespace modules {
namespace cbm {

/*
After regular spinup procedure, this class is called to quicly build up the peat DOM pools.
This class is implemented based on R-code
*/
class CBM_API PeatlandSpinupNext : public CBMModuleBase {
public:
PeatlandSpinupNext() : CBMModuleBase() { }
virtual ~PeatlandSpinupNext() = default;

void configure(const DynamicObject& config) override;
void subscribe(NotificationCenter& notificationCenter) override;

void doLocalDomainInit() override;
//void doTimingInit() override;
void doPrePostDisturbanceEvent() override;

private:
const flint::IPool* _softwoodMerch;
const flint::IPool* _softwoodOther;
const flint::IPool* _softwoodFoliage;
const flint::IPool* _softwoodCoarseRoots;
const flint::IPool* _softwoodFineRoots;
const flint::IPool* _softwoodStemSnag;
const flint::IPool* _softwoodBranchSnag;

const flint::IPool* _hardwoodMerch;
const flint::IPool* _hardwoodOther;
const flint::IPool* _hardwoodFoliage;
const flint::IPool* _hardwoodCoarseRoots;
const flint::IPool* _hardwoodFineRoots;
const flint::IPool* _hardwoodStemSnag;
const flint::IPool* _hardwoodBranchSnag;

const flint::IPool* _softwoodStem;
const flint::IPool* _hardwoodStem;

const flint::IPool* _woodyFoliageLive;
const flint::IPool* _woodyStemsBranchesLive;
const flint::IPool* _woodyRootsLive;
const flint::IPool* _sedgeFoliageLive;
const flint::IPool* _sedgeRootsLive;
const flint::IPool* _featherMossLive;
const flint::IPool* _sphagnumMossLive;

const flint::IPool* _woodyFoliageDead;
const flint::IPool* _woodyFineDead;
const flint::IPool* _woodyCoarseDead;
const flint::IPool* _woodyRootsDead;
const flint::IPool* _sedgeFoliageDead;
const flint::IPool* _sedgeRootsDead;
const flint::IPool* _feathermossDead;
const flint::IPool* _acrotelm_o;
const flint::IPool* _catotelm_a;
const flint::IPool* _acrotelm_a;
const flint::IPool* _catotelm_o;

const flint::IPool* _atmosphere;

const flint::IVariable* _turnoverRates;

double _softwoodFoliageFallRate{ 0 };
double _hardwoodFoliageFallRate{ 0 };
double _stemAnnualTurnOverRate{ 0 };
double _stemSnagTurnoverRate{ 0 };
double _softwoodBranchTurnOverRate{ 0 };
double _hardwoodBranchTurnOverRate{ 0 };
double _coarseRootTurnProp{ 0 };
double _fineRootTurnProp{ 0 };
double _otherToBranchSnagSplit{ 0 };
double _branchSnagTurnoverRate{ 0 };


int smallTreeOn{ 0 };
double smallTreeFoliageRemoval{ 0 };
double smallTreeFineRootRemoval{ 0 };
double smallTreeCoarseRootRemoval{ 0 };
double smallTreeOtherRemovalToWFD{ 0 };
double smallTreeBranchSnagRemoval{ 0 };
double smallTreeStemSnagRemoval{ 0 };

int largeTreeOn{ 0 };
double largeTreeFoliageRemoval{ 0 };
double largeTreeFineRootRemoval{ 0 };
double largeTreeCoarseRootRemoval{ 0 };
double largeTreeOtherRemovalToWFD{ 0 };
double largeTreeBranchSnagRemoval{ 0 };
double largeTreeStemSnagRemoval{ 0 };

double meanAnnualTemperature{ 0 };
double f_r{ 1 };
double f_fr{ 1 };

// decay parameters associated to this peatland unit
std::shared_ptr<PeatlandDecayParameters> decayParas;

// turnover parameters associated to this peatland unit
std::shared_ptr<PeatlandTurnoverParameters> turnoverParas;

// the growth parameters associated to this peatland unit
std::shared_ptr<PeatlandGrowthParameters> growthParas;

// the peatland fire parameter
std::shared_ptr<PeatlandFireParameters> fireParas;

void getTreeTurnoverRate(Peatlands peatlandId);

void getAndUpdateParameter();

void getNonOpenPeatlandRemovals(Peatlands peatlandId);

//void populatePeatlandDeadPoolsV1();

//void populatePeatlandDeadPoolsV2();

void populatePeatlandDeadPoolsV3();

void getCurrentDeadPoolValues();

void resetSlowPools();

void loadPeatlandInitialPoolValues(const DynamicObject& data);

inline double modifyQ10(double baseQ10Para) {
return (pow(baseQ10Para, 0.1 * (meanAnnualTemperature - 10)));
};
};

}
}
} // namespace moja::modules::cbm

#endif // MOJA_MODULES_CBM_PLDECAY_H_

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace moja {
void doWaterTableFlux();

bool _isInitialPoolLoaded{ false };
void loadPeatlandInitialPoolValues(const DynamicObject& data);
};
}
}
Expand Down
33 changes: 33 additions & 0 deletions Source/moja.modules.cbm/src/cbmspinupsequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,39 @@ namespace moja {
_smallTreeAge->reset_value();
_age->reset_value();

// in case of loading initial peat pool value, just simulate to grow/turnover/decay firstly
// and then fire the spinup next event to load and replace the peat pool value
auto loadPeatInitialPool = _landUnitData->getVariable("load_peatpool_initials")->value();
if (loadPeatInitialPool) {
int startYear = timing->startDate().year(); // Simulation start year.
int minimumPeatlandWoodyAge = fireReturnIntervalValue; // Set the default regrow year.

if (lastFireYearValue < 0) { // No last fire year record.
minimumPeatlandWoodyAge = fireReturnIntervalValue;
}
else if (startYear - lastFireYearValue < 0) { // Fire occurred after simulation.
minimumPeatlandWoodyAge = startYear - lastFireYearValue + fireReturnIntervalValue;
}
else { // Fire occurred before simulation.
minimumPeatlandWoodyAge = startYear - lastFireYearValue;
}

// Regrow to minimum peatland woody age.
if (peatlandFireRegrowValue) {
if (_standAge > 0) {
//for forest peatland, just regrow to initial stand age
minimumPeatlandWoodyAge = _standAge;
}
fireSpinupSequenceEvent(notificationCenter, luc, minimumPeatlandWoodyAge, false);
}

//if loading initial pool value is preferred, skip rest spinup procedure
//post a special pre-disturbance signal to trigger peatland spinup next call
//to load initial peat pool value (acrotelm_o, catotelm_a)
notificationCenter.postNotification(moja::signals::PrePostDisturbanceEvent);
return;
}

// in production/removal mode, only run one rotation,
// and use live biomass value at minimum spinup time steps(200)
peatlandMaxRotationValue = 1;
Expand Down
Loading

0 comments on commit bedc920

Please sign in to comment.