Commit 7446afe8 authored by jouke's avatar jouke
Browse files

fix for runMaizeFarquhar with uncorrect label used for getting

sunlitStomatalResistance
parent 15aa6916
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -50,8 +50,8 @@
        </SimulaDirective>
    	
	<SimulaIncludeFile fileName="templates/plantTemplateFullModel.xml"/>
	<SimulaIncludeFile fileName="environments/Rocksprings/Rocksprings-maize.xml"/>
	<!-- SimulaIncludeFile fileName="environments/atmosphereC3C4.xml"/-->
	<!-- SimulaIncludeFile fileName="environments/Rocksprings/Rocksprings-maize.xml"/-->
	<SimulaIncludeFile fileName="environments/WageningseBovenBuurt/WageningseBovenBuurt-maize.xml"/>
	
	<!--  for faster testing purposes -->
    <SimulaDirective path="/environment/dimensions">
+10 −5
Original line number Diff line number Diff line
@@ -58,17 +58,22 @@ NOTE: The GPL.v3 license requires that all derivative work is distributed under
	/************************************************************************/
ETbaseclass::ETbaseclass(SimulaDynamic* const pSV):
DerivativeBase(pSV),
label("notSet"),
interception_(pSD->getSibling("interception","cm/day")),
leafAreaIndex_(pSD->getPath("/plants/meanLeafAreaIndex")),
extinctionCoef_(pSD->getPath("/plants/meanExtinctionCoefficient")),
splitLAI_(nullptr),


splitBySunStatus(0){
	//check if unit given in input file agrees with this function
	std::string name = pSD->getName().substr(0, 6); // name = sunlit or shaded
	if (name == "sunlit") splitBySunStatus = 1;
	if (name == "shaded") splitBySunStatus = 2;
	label = pSD->getName().substr(0, 6); // name = sunlit or shaded
	if (label == "sunlit") {
		splitBySunStatus = 1;
	}else if (label == "shaded") {
		splitBySunStatus = 2;
	}else{
		splitBySunStatus = 0;
		label="";
	}

	if(pSD->getType()=="SimulaVariable"){
		pSD->checkUnit("cm");
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ public:
protected:
	virtual void calculateET(const Time &t, double& ETCROP, double& ETSOIL ) = 0;
	virtual void calculate(const Time &t, double& ET);
	std::string label;
	SimulaBase *interception_;
	SimulaBase *leafAreaIndex_, *extinctionCoef_, *splitLAI_;
	double conv, convS,convSH;
+10 −10
Original line number Diff line number Diff line
@@ -34,13 +34,13 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
		actualVaporPressure_(pSD->getSibling("actualVaporPressure","hPa")),
		saturatedVaporPressure_(pSD->getSibling("saturatedVaporPressure","hPa")),

		stomatalResistance_(splitBySunStatus?pSD->getPath("/plants/" + name + "StomatalResistance", "s/m"):pSD->existingPath("/plants/stomatalResistance", "s/m")),
		stomatalResistance_(splitBySunStatus?pSD->getPath("/plants/" + label + "StomatalResistance", "s/m"):pSD->existingPath("/plants/stomatalResistance", "s/m")),

		aerodynamicResistance_(pSD->getSibling("aerodynamicResistance", "s/m")),
		airDensity_(pSD->existingSibling("airDensity", "kg/m3")),
		faoCropFactor_(pSD->existingPath("/environment/atmosphere/FAO-CropFactor")),

		name(functionName)
		name_(functionName)
{

	//dailyTemperature=ORIGIN->getChild("environment")->getChild("atmosphere")->getChild("averageDailyTemperature","degreesC");
@@ -94,11 +94,11 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
	}


 	if(!stomatalResistance_ && (name == "monteithEQ" || name == "Stanghellini")){
 			msg::error("PenmanMoneith: "+name+" requires /plants/stomatalResistance  to be specified in s/m");
 	if(!stomatalResistance_ && (name_ == "monteithEQ" || name_ == "Stanghellini")){
 			msg::error("PenmanMoneith: "+name_+" requires /plants/stomatalResistance  to be specified in s/m");
 	}

 	if(!faoCropFactor_&& (name=="Grass_reference_evapotranspiration" || name=="Tall_reference_Crop")){
 	if(!faoCropFactor_&& (name_ == "Grass_reference_evapotranspiration" || name_ == "Tall_reference_Crop")){
 		msg::warning("Using FAO reference ET, but no /environment/atmosphere/FAO-CropFactor specified, defaulting to 1.");

 	}
@@ -134,7 +134,7 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
	this->calculateRadiation(t, H_soil, H_crop); //Rn-G in J/m2/day


	if(name=="monteithEQ"){
	if(name_=="monteithEQ"){
		/// PenmanMonteith, ET_0
		///
		/// references listed by SNAPS/SOIL:
@@ -153,7 +153,7 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
		// Using equation 8 on page 208 of
		// Monteith, J.L., Evaporation and Environment, Proc. Symp. Soc. Exp. Biol. 19 (1965), 205-234
		ETSOIL = (delta * H_soil + conversion_day * airDensity * airHeatCapacity * VPD / r_a) / (lambda * (delta + gamma)); // kg/m2/d
	}else if(name=="Grass_reference_evapotranspiration"){
	}else if(name_=="Grass_reference_evapotranspiration"){

		const double u2=std::max(1.0,windSpeed_?	windSpeed_->getDouble(t):2.0);//windspeed in m/s at two meters height
		const double cropFactor=faoCropFactor_?faoCropFactor_->getDouble(t):1.0;
@@ -165,7 +165,7 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
		ETCROP = 0.408e-7 * delta * H_crop + gamma * (900/(temperature+273)) * u2 * VPD/10.0  / (delta + gamma*(1+0.34*u2)); // kg/m2/d
		ETCROP *= cropFactor;
		ETSOIL = ETCROP;
	}else if(name=="Tall_reference_Crop"){
	}else if(name_=="Tall_reference_Crop"){

		const double u2=std::max(1.0,windSpeed_?	windSpeed_->getDouble(t):2.0);//windspeed in m/s at two meters height
		const double cropFactor=faoCropFactor_?faoCropFactor_->getDouble(t):1.0;
@@ -177,7 +177,7 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
		ETCROP = 0.408e-7 * delta * H_crop + gamma * (1600/(temperature+273)) * u2 * VPD/10.0  / (delta + gamma*(1+0.38*u2)); // kg/m2/d
		ETCROP *= cropFactor;
		ETSOIL = ETCROP;
	}else if(name=="Stanghellini"){
	}else if(name_=="Stanghellini"){
	 	const double LAI=leafAreaIndex_->getDouble(t);
		//stanghellini 1987 for greenhouse conditions
		//for greenhouse there is an alternative equation by Stanghellini, ASCE Standards 1998
@@ -298,7 +298,7 @@ PenmanMonteith::PenmanMonteith(SimulaDynamic* const pSV, const std::string &func
 }

 std::string PenmanMonteith::getName() const {
 	return name;
 	return name_;
 }

 DerivativeBase * newInstantiationPenman(
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ protected:
			*netRadiation_, *netRadiationSoil_, *actualVaporPressure_, *saturatedVaporPressure_, *stomatalResistance_;
	SimulaBase *aerodynamicResistance_, *airDensity_;
	SimulaBase *faoCropFactor_;
	const std::string name;
	const std::string name_;