Skip to content

Commit

Permalink
Added saturated hydraulic conductivity as parameter to swrcp
Browse files Browse the repository at this point in the history
- updated `SWRC_PDF_Cosby1984_for_Campbell1974()` now also estimates `K_sat`
- updated `SWRC_check_parameters_for_Campbell1974()` now also checks `K_sat`
- updated `SWRC_check_parameters_for_vanGenuchten1980()` now also checks `K_sat`
  • Loading branch information
dschlaep committed Jun 10, 2022
1 parent 8be1d98 commit 5653f7f
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 21 deletions.
130 changes: 127 additions & 3 deletions SW_Site.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void SWRC_PDF_estimate_parameters(
@brief Estimate Campbell's 1974 SWRC parameters
using Cosby et al. 1984 multivariate PDF
Estimation of three SWRC parameter values `swrcp`
Estimation of four SWRC parameter values `swrcp`
based on sand, clay, and (silt).
Parameters are explained in `SWRC_check_parameters_for_Campbell1974()`.
Expand All @@ -486,14 +486,20 @@ void SWRC_PDF_Cosby1984_for_Campbell1974(
double sand, double clay
) {
/* Table 4 */
/* Original equations formulated with percent sand (%) and clay (%),
here re-formulated for fraction of sand and clay */

/* swrcp[0] = psi_saturated: originally formulated as function of silt
here re-formulated as function of clay */
swrcp[0] = powe(10.0, -1.58 * sand - 0.63 * clay + 2.17);
/* swrcp[1] = theta_saturated: originally with units [100 * cm / cm]
here re-formulated with units [cm / cm] */
swrcp[1] = -0.142 * sand - 0.037 * clay + 0.505;
/* swrcp[2] = b */
swrcp[2] = -0.3 * sand + 15.7 * clay + 3.10;
/* swrcp[3] = K_saturated: originally with units [inches / day]
here re-formulated with units [cm / day] */
swrcp[3] = 2.54 * 24. * powe(10.0, 1.26 * sand - 6.4 * clay - 0.60);
}


Expand Down Expand Up @@ -740,11 +746,12 @@ Bool SWRC_check_parameters(unsigned int swrc_type, double *swrcp) {
See `SWRC_SWCtoSWP_Campbell1974()` and `SWRC_SWPtoSWC_Campbell1974()`
for implementation of Campbell's 1974 SWRC (\cite Campbell1974).
Campbell's 1974 SWRC uses three parameters:
Campbell's 1974 SWRC uses four parameters:
- `swrcp[0]` (`psisMatric`): air-entry suction [cm]
- `swrcp[1]` (previously named `thetasMatric`):
saturated volumetric water content for the matric component [cm/cm]
- `swrcp[2]` (`bMatric`): slope of the linear log-log retention curve [-]
- `swrcp[3]` (`K_sat`): saturated hydraulic conductivity `[cm / day]`
@param[in] *swrcp Vector of SWRC parameters
Expand Down Expand Up @@ -786,6 +793,17 @@ Bool SWRC_check_parameters_for_Campbell1974(double *swrcp) {
);
}

if (LE(swrcp[3], 0.0)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_Campbell1974(): invalid value of "
"K_sat = %f (must be > 0)\n",
swrcp[3]
);
}

return res;
}

Expand All @@ -795,13 +813,14 @@ Bool SWRC_check_parameters_for_Campbell1974(double *swrcp) {
See `SWRC_SWCtoSWP_vanGenuchten1980()` and `SWRC_SWPtoSWC_vanGenuchten1980()`
for implementation of van Genuchten's 1980 SWRC (\cite vanGenuchten1980).
van Genuchten's 1980 SWRC uses four parameters:
van Genuchten's 1980 SWRC uses five parameters:
- `swrcp[0]` (`theta_r`): residual volumetric water content
of the matric component [cm/cm]
- `swrcp[1]` (`theta_s`): saturated volumetric water content
of the matric component [cm/cm]
- `swrcp[2]` (`alpha`): related to the inverse of air entry suction [cm-1]
- `swrcp[3]` (`n`): measure of the pore-size distribution [-]
- `swrcp[4]` (`K_sat`): saturated hydraulic conductivity `[cm / day]`
@param[in] *swrcp Vector of SWRC parameters
Expand Down Expand Up @@ -867,6 +886,111 @@ Bool SWRC_check_parameters_for_vanGenuchten1980(double *swrcp) {
);
}

if (LE(swrcp[4], 0.0)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"K_sat = %f (must be > 0)\n",
swrcp[4]
);
}

return res;
}


/**
@brief Check FXW SWRC parameters
See `SWRC_SWCtoSWP_FXW()` and `SWRC_SWPtoSWC_FXW()`
for implementation of FXW's SWRC
(\cite fredlund1994CGJa, \cite wang2018wrr, \rudiyanto2020JoH).
FXW SWRC uses four parameters:
- `swrcp[0]` (`theta_r`): residual volumetric water content
of the matric component [cm/cm]
- `swrcp[1]` (`theta_s`): saturated volumetric water content
of the matric component [cm/cm]
- `swrcp[2]` (`alpha`): related to the inverse of air entry suction [cm-1]
- `swrcp[3]` (`n`): measure of the pore-size distribution [-]
@param[in] *swrcp Vector of SWRC parameters
@return A logical value indicating if parameters passed the checks.
*/
Bool SWRC_check_parameters_for_FXW(double *swrcp) {
Bool res = swTRUE;

if (LE(swrcp[0], 0.0) || GT(swrcp[0], 1.)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"theta(residual, matric, [cm/cm]) = %f (must within 0-1)\n",
swrcp[0]
);
}

if (LE(swrcp[1], 0.0) || GT(swrcp[1], 1.)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"theta(saturated, matric, [cm/cm]) = %f (must within 0-1)\n",
swrcp[1]
);
}

if (LE(swrcp[1], swrcp[0])) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid values for "
"theta(residual, matric, [cm/cm]) = %f and "
"theta(saturated, matric, [cm/cm]) = %f "
"(must be theta_r < theta_s)\n",
swrcp[0], swrcp[1]
);
}

if (LE(swrcp[2], 0.0)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"alpha([1 / cm]) = %f (must > 0)\n",
swrcp[2]
);
}

if (LE(swrcp[3], 1.0)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"n = %f (must be > 1)\n",
swrcp[3]
);
}

if (LE(swrcp[4], 0.0)) {
res = swFALSE;
LogError(
logfp,
LOGWARN,
"SWRC_check_parameters_for_vanGenuchten1980(): invalid value of "
"K_sat = %f (must be > 0)\n",
swrcp[4]
);
}

return res;
}

Expand Down
2 changes: 2 additions & 0 deletions test/test_SW_Site.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace {
swrcp[0] = 24.2159;
swrcp[1] = 0.4436;
swrcp[2] = 10.3860;
swrcp[3] = 14.14351;
EXPECT_TRUE((bool) SWRC_check_parameters(swrc_type, swrcp));

// Param1 = psi_sat (> 0)
Expand Down Expand Up @@ -243,6 +244,7 @@ namespace {
swrcp[1] = 0.4445;
swrcp[2] = 0.0112;
swrcp[3] = 1.2673;
swrcp[4] = 7.7851;
EXPECT_TRUE((bool) SWRC_check_parameters(swrc_type, swrcp));


Expand Down
2 changes: 2 additions & 0 deletions test/test_SW_SoilWater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ namespace{
swrcp[1] = 0.4213539;
swrcp[2] = 0.007735474;
swrcp[3] = 1.344678;
swrcp[4] = 7.78506;

} else {
FAIL() << "No SWRC parameters available for " << swrc2str[swrc_type];
Expand Down Expand Up @@ -308,6 +309,7 @@ namespace{
swrcp[1] = 0.4445;
swrcp[2] = 0.0112;
swrcp[3] = 1.2673;
swrcp[4] = 7.78506;

EXPECT_DEATH_IF_SUPPORTED(
SWRC_SWCtoSWP(0.99 * swrcp[0], swrc_type, swrcp, gravel, width, LOGFATAL),
Expand Down
20 changes: 11 additions & 9 deletions testing/Input/swrc_params.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
# * param1 = air-entry suction [cm]
# * param2 = saturated volumetric water content for the matric component [cm/cm]
# * param3 = b, slope of the linear log-log retention curve [-]
# * param4 = saturated hydraulic conductivity [cm/day]

# swrc = "vanGenuchten1980"
# * param1 = residual volumetric water content for the matric component [cm/cm]
# * param2 = saturated volumetric water content for the matric component [cm/cm]
# * param3 = alpha, related to the inverse of air entry suction [cm-1]
# * param4 = n, measure of the pore-size distribution [-]
# * param5 = saturated hydraulic conductivity [cm/day]

# param1 param2 param3 param4 param5 param6
18.6080 0.42703 5.3020 0.0000 0.0000 0.0000
20.4644 0.43290 7.0500 0.0000 0.0000 0.0000
22.8402 0.44013 9.4320 0.0000 0.0000 0.0000
24.0381 0.44291 10.0690 0.0000 0.0000 0.0000
24.2159 0.44359 10.3860 0.0000 0.0000 0.0000
23.3507 0.44217 10.3830 0.0000 0.0000 0.0000
12.3880 0.41370 7.3250 0.0000 0.0000 0.0000
12.3880 0.41370 7.3250 0.0000 0.0000 0.0000
# param1 param2 param3 param4 param5 param6
18.6080 0.42703 5.3020 24.03047 0.0000 0.0000
20.4644 0.43290 7.0500 14.94351 0.0000 0.0000
22.8402 0.44013 9.4320 13.71177 0.0000 0.0000
24.0381 0.44291 10.0690 13.43171 0.0000 0.0000
24.2159 0.44359 10.3860 14.14351 0.0000 0.0000
23.3507 0.44217 10.3830 40.63764 0.0000 0.0000
12.3880 0.41370 7.3250 37.22899 0.0000 0.0000
12.3880 0.41370 7.3250 37.22899 0.0000 0.0000
19 changes: 10 additions & 9 deletions testing/Input/swrc_params_vanGenuchten1980.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
# * param2 = saturated volumetric water content for the matric component [cm/cm]
# * param3 = alpha, related to the inverse of air entry suction [cm-1]
# * param4 = n, measure of the pore-size distribution [-]
# * param5 = saturated hydraulic conductivity [cm/day]

# param1 param2 param3 param4 param5 param6
0.07564425 0.3925437 0.010035788 1.412233 0 0
0.10061329 0.4011315 0.009425738 1.352274 0 0
0.12060752 0.4278807 0.010424896 1.287923 0 0
0.12336711 0.4393192 0.010807529 1.274654 0 0
0.12461498 0.4444546 0.011155912 1.267327 0 0
0.12480807 0.4426857 0.011408809 1.264873 0 0
0.10129327 0.3878319 0.014241212 1.311722 0 0
0.10129327 0.3878319 0.014241212 1.311722 0 0
# param1 param2 param3 param4 param5 param6
0.07564425 0.3925437 0.010035788 1.412233 19.871040 0
0.10061329 0.4011315 0.009425738 1.352274 9.090754 0
0.12060752 0.4278807 0.010424896 1.287923 7.862807 0
0.12336711 0.4393192 0.010807529 1.274654 9.100139 0
0.12461498 0.4444546 0.011155912 1.267327 9.902011 0
0.12480807 0.4426857 0.011408809 1.264873 9.784818 0
0.10129327 0.3878319 0.014241212 1.311722 10.985124 0
0.10129327 0.3878319 0.014241212 1.311722 10.985124 0

0 comments on commit 5653f7f

Please sign in to comment.