Skip to content

Commit

Permalink
add crop transpiration
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 24, 2023
1 parent 6844425 commit 26cc6be
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 44 deletions.
Binary file modified DATA/PROJECT/Montue/DATA/crop_Montue.db
Binary file not shown.
81 changes: 70 additions & 11 deletions bin/CRITERIA3D/criteria3DProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void Crit3DProcesses::initialize()
computeMeteo = false;
computeRadiation = false;
computeWater = false;
computeEvaporation = false;
computeCrop = false;
computeSnow = false;
computeSolutes = false;
Expand Down Expand Up @@ -227,6 +228,45 @@ void Crit3DProject::dailyUpdateCrop()
}


/*!
* \brief computeRealET
* assign soil evaporation and crop transpiration for the whole domain
*/
void Crit3DProject::computeRealET()
{
totalEvaporation = 0;
totalTranspiration = 0;

double area = DEM.header->cellSize * DEM.header->cellSize;

for (int row = 0; row < indexMap.at(0).header->nrRows; row++)
{
for (int col = 0; col < indexMap.at(0).header->nrCols; col++)
{
int surfaceIndex = indexMap.at(0).value[row][col];
if (surfaceIndex != indexMap.at(0).header->flag)
{
float lai = laiMap.value[row][col];
if (isEqual(lai, NODATA))
{
lai = 0;
}

// assign real evaporation
double realEvap = assignEvaporation(row, col, lai); // [mm]
double flow = area * (realEvap / 1000.); // [m3 h-1]
totalEvaporation += flow;

// assign real transpiration
double realTransp = assignTranspiration(row, col, lai); // [mm]
flow = area * (realTransp / 1000.); // [m3 h-1]
totalTranspiration += flow;
}
}
}
}


bool Crit3DProject::runModels(QDateTime firstTime, QDateTime lastTime)
{
// initialize meteo
Expand Down Expand Up @@ -947,36 +987,55 @@ bool Crit3DProject::modelHourlyCycle(QDateTime myTime, const QString& hourlyOutp
qApp->processEvents();
}

if (processes.computeCrop)
if (processes.computeSnow)
{
updateDailyTemperatures();

if (! hourlyMeteoMaps->computeET0PMMap(DEM, radiationMaps))
// check conflitti con evaporation
// check snowmelt -> surface H0
if (! computeSnowModel())
{
return false;
}
qApp->processEvents();
}

// initalize sink / source
for (unsigned long i = 0; i < nrNodes; i++)
{
waterSinkSource.at(size_t(i)) = 0.;
}


if (processes.computeEvaporation || processes.computeCrop)
{
if (! hourlyMeteoMaps->computeET0PMMap(DEM, radiationMaps))
return false;

if (isSaveOutputRaster())
{
saveHourlyMeteoOutput(referenceEvapotranspiration, hourlyOutputPath, myTime);
}
}

qApp->processEvents();

// TODO compute evap/transp
if (processes.computeEvaporation && (! processes.computeCrop))
{
computeBareSoilEvaporation();
}

if (processes.computeSnow)
if (processes.computeCrop)
{
if (! computeSnowModel())
return false;
updateDailyTemperatures();

computeRealET();

qApp->processEvents();
}

// soil water balance
if (processes.computeWater)
{
if (! computeWaterSinkSource())
assignPrecipitation();

if (! setSinkSource())
{
logError();
return false;
Expand Down
3 changes: 2 additions & 1 deletion bin/CRITERIA3D/criteria3DProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public:

bool computeMeteo, computeRadiation, computeWater;
bool computeCrop, computeSnow, computeSolutes;
bool computeEvaporation, computeCrop, computeSnow, computeSolutes;
bool computeHeat, computeAdvectiveHeat, computeLatentHeat;

Crit3DProcesses();
Expand Down Expand Up @@ -71,6 +71,7 @@
bool initializeCriteria3DModel();
void initializeCrop();
void dailyUpdateCrop();
void computeRealET();

bool runModels(QDateTime firstTime, QDateTime lastTime);

Expand Down
7 changes: 7 additions & 0 deletions bin/CRITERIA3D/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,11 @@ bool MainWindow::startModels(QDateTime firstTime, QDateTime lastTime)
if (myProject.processes.computeCrop)
{
// TODO: check on crop
if (myProject.landUnitList.size() == 0)
{
myProject.logError("load land units map before.");
return false;
}
}

// Load meteo data
Expand Down Expand Up @@ -2213,6 +2218,7 @@ void MainWindow::on_actionCriteria3D_compute_current_hour_triggered()
myProject.processes.computeMeteo = true;
myProject.processes.computeRadiation = true;
myProject.processes.computeWater = true;
myProject.processes.computeEvaporation = true;
myProject.processes.computeCrop = true;

startModels(currentTime, currentTime);
Expand All @@ -2235,6 +2241,7 @@ void MainWindow::on_actionCriteria3D_run_models_triggered()
myProject.processes.computeMeteo = true;
myProject.processes.computeRadiation = true;
myProject.processes.computeWater = false;
myProject.processes.computeEvaporation = true;
myProject.processes.computeCrop = true;

startModels(firstTime, lastTime);
Expand Down
6 changes: 3 additions & 3 deletions bin/CRITERIA3D/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@
<second>0</second>
<year>1752</year>
<month>10</month>
<day>2</day>
<day>1</day>
</datetime>
</property>
<property name="maximumDate">
Expand Down Expand Up @@ -1848,7 +1848,7 @@
<x>0</x>
<y>0</y>
<width>1280</width>
<height>29</height>
<height>23</height>
</rect>
</property>
<property name="palette">
Expand Down Expand Up @@ -2221,8 +2221,8 @@
<addaction name="menuMeteo_points_2"/>
<addaction name="menuDataSpatialization"/>
<addaction name="menuSolar_radiation_model_2"/>
<addaction name="menuSnow_model"/>
<addaction name="menuCriteria3D"/>
<addaction name="menuSnow_model"/>
<addaction name="menuOutput_points"/>
<addaction name="menuGIS_settings"/>
</widget>
Expand Down
Loading

0 comments on commit 26cc6be

Please sign in to comment.