Skip to content

Commit

Permalink
Merge commit '44c73eebc827d202154a6c15d64bd22dc2ab0780'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Feb 3, 2025
2 parents 32645e8 + 44c73ee commit eaa76e4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
66 changes: 31 additions & 35 deletions agrolib/hydrall/hydrall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,23 @@ double getCO2(Crit3DDate myDate, double myTemperature, double myElevation)
}
*/
atmCO2 += 3*cos(2*PI*getDoyFromDate(myDate)/365.0); // to consider the seasonal effects
return atmCO2*getPressureFromElevation(myTemperature, myElevation)/1000000 ; // [Pa] in +- ppm/10
}
//return atmCO2*getPressureFromElevation(myTemperature, myElevation)/1000000 ; // [Pa] in +- ppm/10 formula changed from the original Hydrall

return atmCO2 * pressureFromAltitude(myElevation)/1000000;
}
/*
double getPressureFromElevation(double myTemperature, double myElevation)
{
return SEA_LEVEL_PRESSURE * exp((- GRAVITY * M_AIR * myElevation) / (R_GAS * myTemperature));
}

double getLAI()
*/
double Crit3D_Hydrall::getLAI()
{
// TODO
return 4;
}

double photosynthesisAndTranspiration()
double Crit3D_Hydrall::photosynthesisAndTranspiration()
{
TweatherDerivedVariable weatherDerivedVariable;

Expand All @@ -95,38 +97,10 @@ double photosynthesisAndTranspiration()

void Crit3D_Hydrall::initialize()
{
//initializeLeaf(sunlit);
//initializeLeaf(shaded);
//weatherVariable.initialize();
myChlorophyllContent = NODATA;
elevation = NODATA;
}

void initializeLeaf(TbigLeaf myLeaf)
{
myLeaf.leafAreaIndex = NODATA;
myLeaf.leafTemperature = NODATA;
myLeaf.absorbedPAR = NODATA;
myLeaf.aerodynamicConductanceCO2Exchange = NODATA;
myLeaf.aerodynamicConductanceHeatExchange = NODATA;
myLeaf.totalConductanceHeatExchange = NODATA;
myLeaf.minimalStomatalConductance = NODATA;
myLeaf.assimilation = NODATA;
myLeaf.isothermalNetRadiation = NODATA;
myLeaf.darkRespiration = NODATA;
myLeaf.maximalCarboxylationRate = NODATA;
myLeaf.maximalElectronTrasportRate = NODATA;
myLeaf.carbonMichaelisMentenConstant = NODATA;
myLeaf.oxygenMichaelisMentenConstant = NODATA;
myLeaf.compensationPoint = NODATA;
myLeaf.convexityFactorNonRectangularHyperbola = NODATA;
myLeaf.quantumYieldPS2 = NODATA;
myLeaf.assimilation = NODATA;
myLeaf.transpiration = NODATA;
myLeaf.stomatalConductance = NODATA;

}

void Crit3D_Hydrall::setHourlyVariables(double temp, double irradiance , double prec , double relativeHumidity , double windSpeed, double directIrradiance, double diffuseIrradiance, double cloudIndex)
{
setWeatherVariables(temp, irradiance, prec, relativeHumidity, windSpeed, directIrradiance, diffuseIrradiance, cloudIndex);
Expand Down Expand Up @@ -176,7 +150,7 @@ void Crit3D_Hydrall::setPlantVariables(double chlorophyllContent)
void Crit3D_Hydrall::radiationAbsorption(double mySunElevation, double leafAreaIndex)
{
// taken from Hydrall Model, Magnani UNIBO
double sineSolarElevation;

// TODO chiedere a Magnani questi parametri
static double leafAbsorbanceNIR= 0.2;
static double hemisphericalIsotropyParameter = 0. ; // in order to change the hemispherical isotropy from -0.4 to 0.6 Wang & Leuning 1998
Expand Down Expand Up @@ -205,7 +179,7 @@ void Crit3D_Hydrall::radiationAbsorption(double mySunElevation, double leafAreaI
//Include effects of leaf clumping (see Goudriaan & van Laar 1994, p 110)
directLightK *= clumpingParameter ;//direct light
diffuseLightK *= clumpingParameter ;//diffuse light
if (0.001 < sineSolarElevation)
if (sineSolarElevation > 0.001)
{
//Leaf area index of sunlit (1) and shaded (2) big-leaf
sunlit.leafAreaIndex = UPSCALINGFUNC(directLightK,leafAreaIndex);
Expand Down Expand Up @@ -286,3 +260,25 @@ void Crit3D_Hydrall::radiationAbsorption(double mySunElevation, double leafAreaI
shaded.absorbedPAR *= 4.57E-6 ;
}

void Crit3D_Hydrall::leafTemperature()
{
if (sineSolarElevation > 0.001)
{
double sunlitGlobalRadiation,shadedGlobalRadiation;

//shadedIrradiance = myDiffuseIrradiance * shaded.leafAreaIndex / statePlant.stateGrowth.leafAreaIndex;
shadedGlobalRadiation = weatherVariable.derived.myDiffuseIrradiance * simulationStepInSeconds ;
shaded.leafTemperature = weatherVariable.myInstantTemp + 1.67*1.0e-6 * shadedGlobalRadiation - 0.25 * weatherVariable.vaporPressureDeficit / psychro(pressureFromAltitude(elevation),weatherVariable.myInstantTemp); // by Stanghellini 1987 phd thesis

// sunlitIrradiance = myDiffuseIrradiance * sunlit.leafAreaIndex/ statePlant.stateGrowth.leafAreaIndex;
//sunlitIrradiance = myDirectIrradiance * sunlit.leafAreaIndex/ statePlant.stateGrowth.leafAreaIndex;
sunlitGlobalRadiation = weatherVariable.myInstantTemp * simulationStepInSeconds ;
sunlit.leafTemperature = weatherVariable.myInstantTemp + 1.67*1.0e-6 * sunlitGlobalRadiation - 0.25 * weatherVariable.vaporPressureDeficit / psychro(pressureFromAltitude(elevation),weatherVariable.myInstantTemp) ; // by Stanghellini 1987 phd thesis
}
else
{
sunlit.leafTemperature = shaded.leafTemperature = weatherVariable.myInstantTemp;
}
sunlit.leafTemperature += ZEROCELSIUS;
shaded.leafTemperature += ZEROCELSIUS;
}
18 changes: 10 additions & 8 deletions agrolib/hydrall/hydrall.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
double irradiance;
double relativeHumidity;
double windSpeed;
double atmosphericPressure;
//double atmosphericPressure;
//double meanDailyTemperature;
double vaporPressureDeficit;

Expand Down Expand Up @@ -95,27 +95,29 @@
// ~Crit3D_Hydrall();

void initialize();
void initializeLeaf(TbigLeaf myLeaf);
//gis::Crit3DRasterGrid* stateMaps;

TbigLeaf sunlit,shaded;
TweatherVariable weatherVariable;
double myChlorophyllContent;
double sineSolarElevation;
double elevation;
int simulationStepInSeconds;

void radiationAbsorption(double mySunElevation, double leafAreaIndex);
void setHourlyVariables(double temp, double irradiance , double prec , double relativeHumidity , double windSpeed, double directIrradiance, double diffuseIrradiance, double cloudIndex);
bool setWeatherVariables(double temp, double irradiance , double prec , double relativeHumidity , double windSpeed, double directIrradiance, double diffuseIrradiance, double cloudIndex);
void setDerivedWeatherVariables(double directIrradiance, double diffuseIrradiance, double cloudIndex);
void setPlantVariables(double chlorophyllContent);
bool computeHydrallPoint(Crit3DDate myDate, double myTemperature, double myElevation, int secondPerStep);
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation);
double getPressureFromElevation(double myTemperature, double myElevation);
double getLAI();
double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp);
double photosynthesisAndTranspiration();
void leafTemperature();

};

bool computeHydrallPoint(Crit3DDate myDate, double myTemperature, double myElevation, int secondPerStep);
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation);
double getPressureFromElevation(double myTemperature, double myElevation);
double getLAI();
double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp);
double photosynthesisAndTranspiration();

#endif // HYDRALL_H

0 comments on commit eaa76e4

Please sign in to comment.