Skip to content

Commit

Permalink
fix root depth
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Dec 2, 2023
1 parent cb1160b commit a3e5921
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions agrolib/crop/root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,16 @@ namespace root
// this function computes the roots rate of development
double getRootLengthDD(const Crit3DRoot &myRoot, double currentDD, double emergenceDD)
{
double currentRootLength = NODATA;
double maxRootLength = myRoot.actualRootDepthMax - myRoot.rootDepthMin;
// in order to avoid numerical divergences when calculating density through cardioid and gamma function
if (currentDD <= 1)
return 0.;

if (currentDD <= 0) return 0.;
if (currentDD > myRoot.degreeDaysRootGrowth) return maxRootLength;
// growth phase ended
double maxRootLength = myRoot.actualRootDepthMax - myRoot.rootDepthMin;
if (currentDD > myRoot.degreeDaysRootGrowth)
return maxRootLength;

double currentRootLength = NODATA;
if (myRoot.growth == LINEAR)
{
currentRootLength = maxRootLength * (currentDD / myRoot.degreeDaysRootGrowth);
Expand Down

0 comments on commit a3e5921

Please sign in to comment.