OGS
RelPermVanGenuchten.cpp
Go to the documentation of this file.
1
11#include "RelPermVanGenuchten.h"
12
13#include <algorithm>
14#include <cmath>
15
17
18namespace MaterialPropertyLib
19{
21 std::string name,
22 double const residual_liquid_saturation,
23 double const residual_gas_saturation,
24 double const min_relative_permeability_liquid,
25 double const exponent)
27 S_L_max_(1. - residual_gas_saturation),
28 k_rel_min_(min_relative_permeability_liquid),
29 m_(exponent)
30{
31 name_ = std::move(name);
32
33 if (!(m_ > 0 && m_ < 1))
34 {
36 "The exponent value m = {:g} of van Genuchten relative "
37 "permeability model, is out of its range of (0, 1)",
38 m_);
39 }
40}
41
43 VariableArray const& variable_array,
44 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
45 double const /*dt*/) const
46{
47 double const S_L =
48 std::clamp(variable_array.liquid_saturation, S_L_res_, S_L_max_);
49
50 double const S_eff = (S_L - S_L_res_) / (S_L_max_ - S_L_res_);
51 double const v = 1. - std::pow(1. - std::pow(S_eff, 1. / m_), m_);
52 double const k_rel = std::sqrt(S_eff) * v * v;
53 return std::max(k_rel_min_, k_rel);
54}
55
57 VariableArray const& variable_array, Variable const variable,
58 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
59 double const /*dt*/) const
60{
61 if (variable != Variable::liquid_saturation)
62 {
64 "RelativePermeabilityVanGenuchten::dValue is implemented for "
65 "derivatives with respect to liquid saturation only.");
66 }
67
68 double const S_L =
69 std::clamp(variable_array.liquid_saturation, S_L_res_, S_L_max_);
70
71 double const S_eff = (S_L - S_L_res_) / (S_L_max_ - S_L_res_);
72 if (S_eff <= 0) // prevent division by zero
73 {
74 return 0.;
75 }
76
77 if (S_eff >= 1) // prevent taking root of zero
78 {
79 return 0.;
80 }
81
82 double const S_eff_to_1_over_m = std::pow(S_eff, 1. / m_);
83 double const v = 1. - std::pow(1. - S_eff_to_1_over_m, m_);
84 double const sqrt_S_eff = std::sqrt(S_eff);
85 double const k_rel = sqrt_S_eff * v * v;
86
87 if (k_rel < k_rel_min_)
88 {
89 return 0.;
90 }
91
92 return (0.5 * v * v / sqrt_S_eff +
93 2. * sqrt_S_eff * v * std::pow(1. - S_eff_to_1_over_m, m_ - 1.) *
94 S_eff_to_1_over_m / S_eff) /
96}
97
98} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
RelPermVanGenuchten(std::string name, double const residual_liquid_saturation, double const residual_gas_saturation, double const min_relative_permeability_liquid, double const exponent)
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
std::variant< double, Eigen::Matrix< double, 2, 1 >, Eigen::Matrix< double, 3, 1 >, Eigen::Matrix< double, 2, 2 >, Eigen::Matrix< double, 3, 3 >, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 >, Eigen::MatrixXd > PropertyDataType
Definition Property.h:31