Commit 067a11c0 authored by jouke's avatar jouke
Browse files

minor code update, making sure shoot allocation can not be more than 1.

parent ca14d972
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -135,6 +135,11 @@ std::string RelativeCarbonAllocation2LeafsFromInputFile::getName()const{
	return "relativeCarbonAllocation2LeafsFromInputFile";
}
DerivativeBase * newInstantiationCarbonRelativeAllocation2LeafsFromInputFile(SimulaDynamic* const pSD){
	// using deprecated naming, in future warn about this? But it is no big deal.
   return new RelativeCarbonAllocation2LeafsFromInputFile(pSD);
}
DerivativeBase * newInstantiationCarbonRelativeAllocation2Leafs(SimulaDynamic* const pSD){
	// renamed this, as the code is actually supporting sink strength allocation
   return new RelativeCarbonAllocation2LeafsFromInputFile(pSD);
}

@@ -208,6 +213,7 @@ void RelativeCarbonAllocation2ShootPotentialGrowth::calculate(const Time &t,doub
		if (c > 0) {
			//scaling factor
			scale = p / c;
			if(scale>1) scale = 1;
		} else {
			scale = 0;
		}
@@ -514,7 +520,9 @@ void CarbonAllocation2Roots::calculate(const Time &t,double &scale){
	c2rootsSimulator->get(t,a);
	scale*=a;
	if(scale<0){
		if (scale<-1e-4) msg::warning("CarbonAllocation2Roots: allocation < 0");
		if (scale<-1e-4){
			msg::warning("CarbonAllocation2Roots: allocation < 0, relative allocation is "+std::to_string(a)+" carbon Available for growth is "+std::to_string(scale/a));
		}
		scale=0;
	}
}
@@ -784,6 +792,7 @@ public:
   		///@todo work on leafs/stems/reproductive tissu - but this partitioning should take place at root level.
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2ShootFromInputFile"] = newInstantiationCarbonRelativeAllocation2ShootFromInputFile;
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2LeafsFromInputFile"] = newInstantiationCarbonRelativeAllocation2LeafsFromInputFile;
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2Leafs"] = newInstantiationCarbonRelativeAllocation2Leafs;
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2RootsPotentialGrowth"] = newInstantiationCarbonRelativeAllocation2RootsPotentialGrowth;
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2ShootPotentialGrowth"] = newInstantiationCarbonRelativeAllocation2ShootPotentialGrowth;
   		BaseClassesMap::getDerivativeBaseClasses()["relativeCarbonAllocation2ShootSwitch"] = newInstantiationCarbonRelativeAllocation2ShootSwitch;