Loading OpenSimRoot/src/modules/CarbonModule/CarbonSinks.cpp +28 −12 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ NOTE: The GPL.v3 license requires that all derivative work is distributed under //returns potential growth of the root in g/day CARBON //this is the old function that only does longitudinal growth and works for the whole root //replace with the node one and use for the whole root the total function if you want to do secondary growth RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD) RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD),refTime(0.) { //warning message since radial growth is not implemented yet msg::warning("RootPotentialCarbonSinkForGrowth: Assuming no secondary growth for roots, use other module if you do want secondary growth"); Loading @@ -48,17 +48,24 @@ RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic //plantType std::string plantType; plantTop->getChild("plantType")->get(plantType); //pointer to object that gives root type specific density densitySimulator=pSD->existingSibling("rootSegmentSpecificWeightCortex"); if(!densitySimulator){ refTime=pSD->getStartTime(); //get the root type std::string rootType; pSD->getSibling("rootType")->get(rootType); //pointer to object that gives root type specific density densitySimulator=ORIGIN->getChild("rootTypeParameters")->getChild(plantType)->getChild(rootType)->getChild("density","g/cm3"); SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); densitySimulator=param->getOneOfThesePaths("specificWeight","density"); } //carbon conversion factor. CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%");} CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%"); } void RootPotentialCarbonSinkForGrowth::calculate(const Time &t,double &carbon){ //get density in g/cm3 double density; densitySimulator->get(density); densitySimulator->get(t-refTime, density); //get current longitudinal growth rate in cm/day double li(0); lgSimulator->getRate(t,li); Loading Loading @@ -96,12 +103,13 @@ DerivativeBase * newInstantiationRootPotentialCarbonSinkForGrowth(SimulaDynamic* } //this one does both secondary and longitudinal growth. RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD), RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD): TotalBase(pSD), growth(nullptr), surfaceArea(nullptr), density(nullptr), diameter(nullptr), CinDryWeight(nullptr) CinDryWeight(nullptr), refTime(0) { //root diameter simulator growth=pSD->existingSibling("rootPotentialLongitudinalGrowth","cm"); Loading @@ -128,7 +136,13 @@ RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(Simul pSD->getParent(2)->getChild("rootType")->get(rootType); } //pointer to object that gives root type specific density density=GETROOTPARAMETERS(plantType,rootType)->getChild("density","g/cm3"); density=pSD->existingSibling("rootSegmentSpecificWeightCortex"); if(!density){ refTime=pSD->getStartTime(); //get the root type SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); density=param->getOneOfThesePaths("specificWeight","density"); } //carbon conversion factor. CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%"); } Loading @@ -137,7 +151,7 @@ void RootNodePotentialCarbonSinkForGrowth::calculate(const Time &t,double &c){ double cdw; CinDryWeight->get(t,cdw); //get density in g/cm3 density->get(c); density->get(t-refTime,c); c*=cdw; //get volume increase, either in diameter or in length double g(0); Loading Loading @@ -185,7 +199,9 @@ LeafPotentialCarbonSinkForGrowth::LeafPotentialCarbonSinkForGrowth(SimulaDynamic pSD->checkUnit("g"); //growth simulator gSimulator=pSD->existingSibling("stressAdjustedPotentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->getSibling("potentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->existingSibling("potentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->existingSibling("leafArea","cm2"); // if(!gSimulator) msg::error("LeafPotentialCarbonSinkForGrowth: needing one of stressAdjustedPotentialLeafArea, potentialLeafArea, or leafArea"); //pointer to plant SimulaBase * plantTop(pSD); PLANTTOP(plantTop) Loading OpenSimRoot/src/modules/CarbonModule/CarbonSinks.hpp +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ NOTE: The GPL.v3 license requires that all derivative work is distributed under #define CARBONSINKS_HPP_ #include "../../engine/BaseClasses.hpp" #include "../GenericModules/Totals.hpp" class RootPotentialCarbonSinkForGrowth:public DerivativeBase{ public: Loading @@ -30,15 +31,17 @@ public: protected: void calculate(const Time &t,double &var); SimulaBase *lgSimulator, *rdSimulator, *densitySimulator, *CinDryWeight; Time refTime; }; class RootNodePotentialCarbonSinkForGrowth:public DerivativeBase{ class RootNodePotentialCarbonSinkForGrowth:public TotalBase{ public: RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD); std::string getName()const; protected: void calculate(const Time &t,double &var); SimulaBase *growth, *surfaceArea, *density, *diameter, *CinDryWeight; Time refTime; }; class LeafPotentialCarbonSinkForGrowth:public DerivativeBase{ Loading Loading
OpenSimRoot/src/modules/CarbonModule/CarbonSinks.cpp +28 −12 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ NOTE: The GPL.v3 license requires that all derivative work is distributed under //returns potential growth of the root in g/day CARBON //this is the old function that only does longitudinal growth and works for the whole root //replace with the node one and use for the whole root the total function if you want to do secondary growth RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD) RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD),refTime(0.) { //warning message since radial growth is not implemented yet msg::warning("RootPotentialCarbonSinkForGrowth: Assuming no secondary growth for roots, use other module if you do want secondary growth"); Loading @@ -48,17 +48,24 @@ RootPotentialCarbonSinkForGrowth::RootPotentialCarbonSinkForGrowth(SimulaDynamic //plantType std::string plantType; plantTop->getChild("plantType")->get(plantType); //pointer to object that gives root type specific density densitySimulator=pSD->existingSibling("rootSegmentSpecificWeightCortex"); if(!densitySimulator){ refTime=pSD->getStartTime(); //get the root type std::string rootType; pSD->getSibling("rootType")->get(rootType); //pointer to object that gives root type specific density densitySimulator=ORIGIN->getChild("rootTypeParameters")->getChild(plantType)->getChild(rootType)->getChild("density","g/cm3"); SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); densitySimulator=param->getOneOfThesePaths("specificWeight","density"); } //carbon conversion factor. CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%");} CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%"); } void RootPotentialCarbonSinkForGrowth::calculate(const Time &t,double &carbon){ //get density in g/cm3 double density; densitySimulator->get(density); densitySimulator->get(t-refTime, density); //get current longitudinal growth rate in cm/day double li(0); lgSimulator->getRate(t,li); Loading Loading @@ -96,12 +103,13 @@ DerivativeBase * newInstantiationRootPotentialCarbonSinkForGrowth(SimulaDynamic* } //this one does both secondary and longitudinal growth. RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD):DerivativeBase(pSD), RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD): TotalBase(pSD), growth(nullptr), surfaceArea(nullptr), density(nullptr), diameter(nullptr), CinDryWeight(nullptr) CinDryWeight(nullptr), refTime(0) { //root diameter simulator growth=pSD->existingSibling("rootPotentialLongitudinalGrowth","cm"); Loading @@ -128,7 +136,13 @@ RootNodePotentialCarbonSinkForGrowth::RootNodePotentialCarbonSinkForGrowth(Simul pSD->getParent(2)->getChild("rootType")->get(rootType); } //pointer to object that gives root type specific density density=GETROOTPARAMETERS(plantType,rootType)->getChild("density","g/cm3"); density=pSD->existingSibling("rootSegmentSpecificWeightCortex"); if(!density){ refTime=pSD->getStartTime(); //get the root type SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); density=param->getOneOfThesePaths("specificWeight","density"); } //carbon conversion factor. CinDryWeight=plantTop->getChild("carbonToDryWeightRatio","100%"); } Loading @@ -137,7 +151,7 @@ void RootNodePotentialCarbonSinkForGrowth::calculate(const Time &t,double &c){ double cdw; CinDryWeight->get(t,cdw); //get density in g/cm3 density->get(c); density->get(t-refTime,c); c*=cdw; //get volume increase, either in diameter or in length double g(0); Loading Loading @@ -185,7 +199,9 @@ LeafPotentialCarbonSinkForGrowth::LeafPotentialCarbonSinkForGrowth(SimulaDynamic pSD->checkUnit("g"); //growth simulator gSimulator=pSD->existingSibling("stressAdjustedPotentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->getSibling("potentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->existingSibling("potentialLeafArea","cm2"); if(!gSimulator) gSimulator=pSD->existingSibling("leafArea","cm2"); // if(!gSimulator) msg::error("LeafPotentialCarbonSinkForGrowth: needing one of stressAdjustedPotentialLeafArea, potentialLeafArea, or leafArea"); //pointer to plant SimulaBase * plantTop(pSD); PLANTTOP(plantTop) Loading
OpenSimRoot/src/modules/CarbonModule/CarbonSinks.hpp +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ NOTE: The GPL.v3 license requires that all derivative work is distributed under #define CARBONSINKS_HPP_ #include "../../engine/BaseClasses.hpp" #include "../GenericModules/Totals.hpp" class RootPotentialCarbonSinkForGrowth:public DerivativeBase{ public: Loading @@ -30,15 +31,17 @@ public: protected: void calculate(const Time &t,double &var); SimulaBase *lgSimulator, *rdSimulator, *densitySimulator, *CinDryWeight; Time refTime; }; class RootNodePotentialCarbonSinkForGrowth:public DerivativeBase{ class RootNodePotentialCarbonSinkForGrowth:public TotalBase{ public: RootNodePotentialCarbonSinkForGrowth(SimulaDynamic* pSD); std::string getName()const; protected: void calculate(const Time &t,double &var); SimulaBase *growth, *surfaceArea, *density, *diameter, *CinDryWeight; Time refTime; }; class LeafPotentialCarbonSinkForGrowth:public DerivativeBase{ Loading