Skip to content

Commit

Permalink
Prefer defined constants over magic numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltryby committed Oct 4, 2024
1 parent 911032e commit 667fa23
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/solver/lid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,22 +1041,22 @@ void validateLidProc(int j)
report_writeErrorMsg(ERR_LID_PARAMS, Msg);
}
else LidProcs[j].surface.alpha =
1.49 * sqrt(LidProcs[j].surface.surfSlope) /
PHI * sqrt(LidProcs[j].surface.surfSlope) /
LidProcs[j].surface.roughness;
}
else
{
//... compute surface overland flow coeff.
if ( LidProcs[j].surface.roughness > 0.0 )
LidProcs[j].surface.alpha = 1.49 / LidProcs[j].surface.roughness *
LidProcs[j].surface.alpha = PHI / LidProcs[j].surface.roughness *
sqrt(LidProcs[j].surface.surfSlope);
else LidProcs[j].surface.alpha = 0.0;
}

//... compute drainage mat layer's flow coeff.
if ( LidProcs[j].drainMat.roughness > 0.0 )
{
LidProcs[j].drainMat.alpha = 1.49 / LidProcs[j].drainMat.roughness *
LidProcs[j].drainMat.alpha = PHI / LidProcs[j].drainMat.roughness *
sqrt(LidProcs[j].surface.surfSlope);
}
else LidProcs[j].drainMat.alpha = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion src/solver/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ void conduit_validate(int j, int k)
// (factor of 0.3 is for circular pipe 95% full)
// NOTE: this factor was used in the past for a modified version of
// Kinematic Wave routing but is now deprecated.
aa = Conduit[k].beta / sqrt(32.2) *
aa = Conduit[k].beta / sqrt(GRAVITY) *
pow(Link[j].xsect.yFull, 0.1666667) * 0.3;
if ( aa >= 1.0 ) Conduit[k].superCritical = TRUE;
else Conduit[k].superCritical = FALSE;
Expand Down
3 changes: 1 addition & 2 deletions src/solver/subcatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
const double MCOEFF = 1.49; // constant in Manning Eq.
const double MEXP = 1.6666667; // exponent in Manning Eq.
const double ODETOL = 0.0001; // acceptable error for ODE solver

Expand Down Expand Up @@ -403,7 +402,7 @@ void subcatch_validate(int j)

if ( area > 0.0 && Subcatch[j].subArea[i].N > 0.0 )
{
Subcatch[j].subArea[i].alpha = MCOEFF * Subcatch[j].width / area *
Subcatch[j].subArea[i].alpha = PHI * Subcatch[j].width / area *
sqrt(Subcatch[j].slope) / Subcatch[j].subArea[i].N;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/solver/transect.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void getGeometry(TTransect *transect, int i, double y)
if ( aSum == 0.0 )
transect->hradTbl[i] = transect->hradTbl[i-1];
else
transect->hradTbl[i] = pow(qSum * Nchannel / 1.49 / aSum, 1.5);
transect->hradTbl[i] = pow(qSum * Nchannel / PHI / aSum, 1.5);
}

//=============================================================================
Expand Down

0 comments on commit 667fa23

Please sign in to comment.