Loading OpenSimRoot/src/modules/PlantNutrients/OptimalNutrientContent.cpp +43 −11 Original line number Diff line number Diff line Loading @@ -42,13 +42,26 @@ DerivativeBase * newInstantiationUseRootClassAndNutrientSpecificTable(SimulaDyna bool OptimalNutrientContent::issueMessage(true); OptimalNutrientContent::OptimalNutrientContent(SimulaDynamic* pSD) : TotalBaseLabeled(pSD) { TotalBaseLabeled(pSD), current(nullptr), dw(nullptr), rca(nullptr), paramConc(nullptr) { std::string l(pSD->getName().substr(11, 7)); if (l[0] == 'O') l[0] = 'o'; if (l[0] == 'M') l[0] = 'm'; current = pSD->getSibling(l + "NutrientConcentration"); current = pSD->existingSibling(l + "NutrientConcentration"); if(!current){ //use parameter section to get target concentrations //plant type and root type std::string plantType; PLANTTYPE(plantType,pSD); //get the root type std::string rootType; pSD->getParent(4)->getChild("rootType")->get(rootType); SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); paramConc=param->getChild(pSD->getParent()->getName())->getChild(l + "NutrientConcentration"); } //dryweight dw = pSD->getParent(2)->getChild("rootSegmentDryWeight"); Loading Loading @@ -92,15 +105,23 @@ void OptimalNutrientContent::calculate(const Time &t, double &result) { l[0] = 'o'; if (l[0] == 'M') l[0] = 'm'; SimulaBase *next = getNext(t)->getSibling(l + "NutrientConcentration"); SimulaBase *next = getNext(t); //get optimal concentrations at these datapoints double concD0(0); double concD0(0), concD1(0); if(current){ current->get(t, concD0); double concD1(concD0); next=next->getSibling(l + "NutrientConcentration"); if(next!=current && next->evaluateTime(t)){ next->get(t, concD1); } }else{ const double t0=pSD->getStartTime(); const double t1=next->getStartTime(); paramConc->get(t-t0,concD0); paramConc->get(t-t1,concD1); } //get dryweight double d; Loading @@ -124,6 +145,7 @@ void OptimalNutrientContent::calculate(const Time &t, double &result) { scale_ = result; } bool OptimalNutrientContent::postIntegrationCorrection(SimulaVariable::Table & data) { //only for old input files that expect integration, rather than a simply algabreic solution. bool r(false); //iterators SimulaVariable::Table::iterator eit(data.end()); Loading @@ -148,7 +170,7 @@ DerivativeBase * newInstantiationOptimalNutrientContent(SimulaDynamic* const pSD } ShootOptimalNutrientContent::ShootOptimalNutrientContent(SimulaDynamic* pSD) : DerivativeBase(pSD) { //leafs or stem DerivativeBase(pSD), conc(nullptr), dw(nullptr), refTime(0) { //leafs or stem std::string s(pSD->getName()); std::size_t n(s.size() - 22); std::string sp(s.substr(0, n)); Loading @@ -156,12 +178,22 @@ ShootOptimalNutrientContent::ShootOptimalNutrientContent(SimulaDynamic* pSD) : //dryweight dw = pSD->getParent(2)->getChild(sp + "DryWeight", "g"); //concentration conc = pSD->getSibling(som + "NutrientConcentration", pSD->getUnit() / "g"); conc = pSD->existingSibling(som + "NutrientConcentration", pSD->getUnit() / "g"); if(!conc){ refTime=pSD->getStartTime(); //use parameter section to get target concentrations //plant type and root type std::string plantType; PLANTTYPE(plantType,pSD); //get the root type SimulaBase *param=GETSHOOTPARAMETERS(plantType); conc = param->getChild(pSD->getParent()->getName())->getChild(som + "NutrientConcentration", pSD->getUnit() / "g"); } } void ShootOptimalNutrientContent::calculate(const Time &t, double &result) { dw->get(t, result); double c; conc->get(t, c); conc->get(t-refTime, c); result *= c; } std::string ShootOptimalNutrientContent::getName() const { Loading OpenSimRoot/src/modules/PlantNutrients/OptimalNutrientContent.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: std::string getName() const; protected: void calculate(const Time &t, double &var); SimulaBase *current, *dw, *rca; SimulaBase *current, *dw, *rca, *paramConc; static bool issueMessage; double scale_; }; Loading @@ -50,6 +50,7 @@ public: protected: void calculate(const Time &t, double &var); SimulaBase *conc, *dw; Time refTime; }; class ActualNutrientContent: public TotalBaseLabeled { public: Loading Loading
OpenSimRoot/src/modules/PlantNutrients/OptimalNutrientContent.cpp +43 −11 Original line number Diff line number Diff line Loading @@ -42,13 +42,26 @@ DerivativeBase * newInstantiationUseRootClassAndNutrientSpecificTable(SimulaDyna bool OptimalNutrientContent::issueMessage(true); OptimalNutrientContent::OptimalNutrientContent(SimulaDynamic* pSD) : TotalBaseLabeled(pSD) { TotalBaseLabeled(pSD), current(nullptr), dw(nullptr), rca(nullptr), paramConc(nullptr) { std::string l(pSD->getName().substr(11, 7)); if (l[0] == 'O') l[0] = 'o'; if (l[0] == 'M') l[0] = 'm'; current = pSD->getSibling(l + "NutrientConcentration"); current = pSD->existingSibling(l + "NutrientConcentration"); if(!current){ //use parameter section to get target concentrations //plant type and root type std::string plantType; PLANTTYPE(plantType,pSD); //get the root type std::string rootType; pSD->getParent(4)->getChild("rootType")->get(rootType); SimulaBase *param=GETROOTPARAMETERS(plantType,rootType); paramConc=param->getChild(pSD->getParent()->getName())->getChild(l + "NutrientConcentration"); } //dryweight dw = pSD->getParent(2)->getChild("rootSegmentDryWeight"); Loading Loading @@ -92,15 +105,23 @@ void OptimalNutrientContent::calculate(const Time &t, double &result) { l[0] = 'o'; if (l[0] == 'M') l[0] = 'm'; SimulaBase *next = getNext(t)->getSibling(l + "NutrientConcentration"); SimulaBase *next = getNext(t); //get optimal concentrations at these datapoints double concD0(0); double concD0(0), concD1(0); if(current){ current->get(t, concD0); double concD1(concD0); next=next->getSibling(l + "NutrientConcentration"); if(next!=current && next->evaluateTime(t)){ next->get(t, concD1); } }else{ const double t0=pSD->getStartTime(); const double t1=next->getStartTime(); paramConc->get(t-t0,concD0); paramConc->get(t-t1,concD1); } //get dryweight double d; Loading @@ -124,6 +145,7 @@ void OptimalNutrientContent::calculate(const Time &t, double &result) { scale_ = result; } bool OptimalNutrientContent::postIntegrationCorrection(SimulaVariable::Table & data) { //only for old input files that expect integration, rather than a simply algabreic solution. bool r(false); //iterators SimulaVariable::Table::iterator eit(data.end()); Loading @@ -148,7 +170,7 @@ DerivativeBase * newInstantiationOptimalNutrientContent(SimulaDynamic* const pSD } ShootOptimalNutrientContent::ShootOptimalNutrientContent(SimulaDynamic* pSD) : DerivativeBase(pSD) { //leafs or stem DerivativeBase(pSD), conc(nullptr), dw(nullptr), refTime(0) { //leafs or stem std::string s(pSD->getName()); std::size_t n(s.size() - 22); std::string sp(s.substr(0, n)); Loading @@ -156,12 +178,22 @@ ShootOptimalNutrientContent::ShootOptimalNutrientContent(SimulaDynamic* pSD) : //dryweight dw = pSD->getParent(2)->getChild(sp + "DryWeight", "g"); //concentration conc = pSD->getSibling(som + "NutrientConcentration", pSD->getUnit() / "g"); conc = pSD->existingSibling(som + "NutrientConcentration", pSD->getUnit() / "g"); if(!conc){ refTime=pSD->getStartTime(); //use parameter section to get target concentrations //plant type and root type std::string plantType; PLANTTYPE(plantType,pSD); //get the root type SimulaBase *param=GETSHOOTPARAMETERS(plantType); conc = param->getChild(pSD->getParent()->getName())->getChild(som + "NutrientConcentration", pSD->getUnit() / "g"); } } void ShootOptimalNutrientContent::calculate(const Time &t, double &result) { dw->get(t, result); double c; conc->get(t, c); conc->get(t-refTime, c); result *= c; } std::string ShootOptimalNutrientContent::getName() const { Loading
OpenSimRoot/src/modules/PlantNutrients/OptimalNutrientContent.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: std::string getName() const; protected: void calculate(const Time &t, double &var); SimulaBase *current, *dw, *rca; SimulaBase *current, *dw, *rca, *paramConc; static bool issueMessage; double scale_; }; Loading @@ -50,6 +50,7 @@ public: protected: void calculate(const Time &t, double &var); SimulaBase *conc, *dw; Time refTime; }; class ActualNutrientContent: public TotalBaseLabeled { public: Loading