Skip to content

Commit 83a9273

Browse files
committed
add degree of saturation output
1 parent ef40b09 commit 83a9273

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

criteriaModel/criteria1DCase.cpp

+34-6
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ bool Crit1DCase::computeNumericalFluxes(const Crit3DDate &myDate, std::string &e
361361
}
362362

363363

364-
void Crit1DCase::saveWaterContent()
364+
void Crit1DCase::storeWaterContent()
365365
{
366366
prevWaterContent.clear();
367367
prevWaterContent.resize(soilLayers.size());
@@ -537,7 +537,7 @@ bool Crit1DCase::computeDailyModel(Crit3DDate &myDate, std::string &error)
537537

538538
output.dailyIrrigation = 0;
539539
// Water fluxes (first computation)
540-
saveWaterContent();
540+
storeWaterContent();
541541
if (! computeWaterFluxes(myDate, error)) return false;
542542
// Irrigation
543543
double irrigation = checkIrrigationDemand(doy, prec, precTomorrow, output.dailyMaxTranspiration);
@@ -653,11 +653,11 @@ double Crit1DCase::getTotalWaterContent()
653653

654654

655655
/*!
656-
* \brief getWaterContent
656+
* \brief getVolumetricWaterContent
657657
* \param computationDepth = computation soil depth [cm]
658-
* \return volumetric water content at specific depth [-]
658+
* \return volumetric water content (soil moisture) at specific depth [m3 m-3]
659659
*/
660-
double Crit1DCase::getWaterContent(double computationDepth)
660+
double Crit1DCase::getVolumetricWaterContent(double computationDepth)
661661
{
662662
computationDepth /= 100; // [cm] --> [m]
663663

@@ -679,6 +679,34 @@ double Crit1DCase::getWaterContent(double computationDepth)
679679
}
680680

681681

682+
/*!
683+
* \brief getDegreeOfSaturation
684+
* \param computationDepth = computation soil depth [cm]
685+
* \return degree of saturation at specific depth [-]
686+
*/
687+
double Crit1DCase::getDegreeOfSaturation(double computationDepth)
688+
{
689+
computationDepth /= 100; // [cm] --> [m]
690+
if (computationDepth <= 0 || computationDepth > mySoil.totalDepth)
691+
{
692+
return NODATA;
693+
}
694+
695+
double upperDepth, lowerDepth;
696+
for (unsigned int i = 1; i < soilLayers.size(); i++)
697+
{
698+
upperDepth = soilLayers[i].depth - soilLayers[i].thickness * 0.5;
699+
lowerDepth = soilLayers[i].depth + soilLayers[i].thickness * 0.5;
700+
if (computationDepth >= upperDepth && computationDepth <= lowerDepth)
701+
{
702+
return soilLayers[i].waterContent / soilLayers[i].SAT;
703+
}
704+
}
705+
706+
return NODATA;
707+
}
708+
709+
682710
/*!
683711
* \brief getWaterPotential
684712
* \param computationDepth = computation soil depth [cm]
@@ -778,7 +806,7 @@ double Crit1DCase::getWaterDeficitSum(double computationDepth)
778806

779807
/*!
780808
* \brief getWaterCapacity
781-
* \param computationDepth = computation soil depth [cm]
809+
* \param computationDepth = computation soil depth [cm]
782810
* \return sum of available water capacity (FC-WP) from zero to computationDepth (mm)
783811
*/
784812
double Crit1DCase::getWaterCapacitySum(double computationDepth)

criteriaModel/criteria1DCase.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
bool initializeWaterContent(Crit3DDate myDate);
7979
bool computeDailyModel(Crit3DDate &myDate, std::string &error);
8080

81-
double getWaterContent(double computationDepth);
81+
double getVolumetricWaterContent(double computationDepth);
82+
double getDegreeOfSaturation(double computationDepth);
8283
double getWaterPotential(double computationDepth);
8384
double getFractionAW(double computationDepth);
8485
double getSlopeStability(double computationDepth);
@@ -99,7 +100,7 @@
99100
bool computeNumericalFluxes(const Crit3DDate &myDate, std::string &error);
100101
bool computeWaterFluxes(const Crit3DDate &myDate, std::string &error);
101102
double checkIrrigationDemand(int doy, double currentPrec, double nextPrec, double maxTranspiration);
102-
void saveWaterContent();
103+
void storeWaterContent();
103104
void restoreWaterContent();
104105
double getTotalWaterContent();
105106

criteriaModel/criteria1DProject.cpp

+25-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ void Crit1DProject::initialize()
6363
lastSimulationDate = QDate(1800,1,1);
6464

6565
outputString = "";
66+
6667
// specific outputs
6768
waterDeficitDepth.clear();
6869
waterContentDepth.clear();
70+
degreeOfSaturationDepth.clear();
6971
waterPotentialDepth.clear();
7072
availableWaterDepth.clear();
7173
fractionAvailableWaterDepth.clear();
@@ -257,6 +259,12 @@ bool Crit1DProject::readSettings()
257259
projectError = "Wrong water content depth in " + configFileName;
258260
return false;
259261
}
262+
depthList = projectSettings->value("degreeOfSaturation").toStringList();
263+
if (! setVariableDepth(depthList, degreeOfSaturationDepth))
264+
{
265+
projectError = "Wrong degree of saturation depth in " + configFileName;
266+
return false;
267+
}
260268
depthList = projectSettings->value("waterPotential").toStringList();
261269
if (! setVariableDepth(depthList, waterPotentialDepth))
262270
{
@@ -1544,7 +1552,12 @@ bool Crit1DProject::createOutputTable(QString &myError)
15441552
// specific depth variables
15451553
for (unsigned int i = 0; i < waterContentDepth.size(); i++)
15461554
{
1547-
QString fieldName = "SWC_" + QString::number(waterContentDepth[i]);
1555+
QString fieldName = "VWC_" + QString::number(waterContentDepth[i]);
1556+
queryString += ", " + fieldName + " REAL";
1557+
}
1558+
for (unsigned int i = 0; i < degreeOfSaturationDepth.size(); i++)
1559+
{
1560+
QString fieldName = "DEGSAT_" + QString::number(degreeOfSaturationDepth[i]);
15481561
queryString += ", " + fieldName + " REAL";
15491562
}
15501563
for (unsigned int i = 0; i < waterPotentialDepth.size(); i++)
@@ -1604,7 +1617,12 @@ void Crit1DProject::updateOutput(Crit3DDate myDate, bool isFirst)
16041617
// specific depth variables
16051618
for (unsigned int i = 0; i < waterContentDepth.size(); i++)
16061619
{
1607-
QString fieldName = "SWC_" + QString::number(waterContentDepth[i]);
1620+
QString fieldName = "VWC_" + QString::number(waterContentDepth[i]);
1621+
outputString += ", " + fieldName;
1622+
}
1623+
for (unsigned int i = 0; i < degreeOfSaturationDepth.size(); i++)
1624+
{
1625+
QString fieldName = "DEGSAT_" + QString::number(degreeOfSaturationDepth[i]);
16081626
outputString += ", " + fieldName;
16091627
}
16101628
for (unsigned int i = 0; i < waterPotentialDepth.size(); i++)
@@ -1669,7 +1687,11 @@ void Crit1DProject::updateOutput(Crit3DDate myDate, bool isFirst)
16691687
// specific depth variables
16701688
for (unsigned int i = 0; i < waterContentDepth.size(); i++)
16711689
{
1672-
outputString += "," + QString::number(myCase.getWaterContent(waterContentDepth[i]), 'g', 4);
1690+
outputString += "," + QString::number(myCase.getVolumetricWaterContent(waterContentDepth[i]), 'g', 4);
1691+
}
1692+
for (unsigned int i = 0; i < degreeOfSaturationDepth.size(); i++)
1693+
{
1694+
outputString += "," + QString::number(myCase.getDegreeOfSaturation(degreeOfSaturationDepth[i]), 'g', 4);
16731695
}
16741696
for (unsigned int i = 0; i < waterPotentialDepth.size(); i++)
16751697
{

criteriaModel/criteria1DProject.h

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
// specific output
9393
std::vector<int> waterContentDepth;
94+
std::vector<int> degreeOfSaturationDepth;
9495
std::vector<int> waterPotentialDepth;
9596
std::vector<int> waterDeficitDepth;
9697
std::vector<int> awcDepth;

0 commit comments

Comments
 (0)