OGS
SaturationVanGenuchten.cpp
Go to the documentation of this file.
1
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 exponent,
25 double const p_b)
27 S_L_max_(1. - residual_gas_saturation),
28 m_(exponent),
29 p_b_(p_b)
30{
31 name_ = std::move(name);
32
33 if (!(m_ > 0 && m_ < 1))
34 {
36 "The exponent value m = {:g} of van Genuchten saturation model, is "
37 "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 const double p_cap = variable_array.capillary_pressure;
48
49 if (p_cap <= 0)
50 {
51 return S_L_max_;
52 }
53
54 double const p = p_cap / p_b_;
55 double const n = 1. / (1. - m_);
56 double const p_to_n = std::pow(p, n);
57
58 double const S_eff = std::pow(p_to_n + 1., -m_);
59 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
60 return std::clamp(S, S_L_res_, S_L_max_);
61}
62
64 VariableArray const& variable_array, Variable const variable,
65 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
66 double const /*dt*/) const
67{
68 if (variable != Variable::capillary_pressure)
69 {
71 "SaturationVanGenuchten::dValue is implemented for derivatives "
72 "with respect to capillary pressure only.");
73 }
74
75 const double p_cap = variable_array.capillary_pressure;
76
77 if (p_cap <= 0)
78 {
79 return 0.;
80 }
81
82 double const p = p_cap / p_b_;
83 double const n = 1. / (1. - m_);
84 double const p_to_n = std::pow(p, n);
85
86 double const S_eff = std::pow(p_to_n + 1., -m_);
87 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
88
89 if (S < S_L_res_ || S > S_L_max_)
90 {
91 return 0.;
92 }
93
94 double const dS_eff_dp_cap = -m_ * std::pow(p, n - 1) *
95 std::pow(1 + p_to_n, -1. - m_) /
96 (p_b_ * (1. - m_));
97 return dS_eff_dp_cap * (S_L_max_ - S_L_res_);
98}
99
101 VariableArray const& variable_array, Variable const variable1,
102 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
103 double const /*t*/, double const /*dt*/) const
104{
105 (void)variable1;
106 (void)variable2;
107 assert((variable1 == Variable::capillary_pressure) &&
108 (variable2 == Variable::capillary_pressure) &&
109 "SaturationVanGenuchten::d2Value is implemented for derivatives "
110 "with respect to capillary pressure only.");
111
112 const double p_cap = variable_array.capillary_pressure;
113
114 if (p_cap <= 0)
115 {
116 return 0.;
117 }
118
119 double const p = p_cap / p_b_;
120 double const n = 1. / (1. - m_);
121 double const p_to_n = std::pow(p, n);
122
123 double const S_eff = std::pow(p_to_n + 1., -m_);
124 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
125
126 if (S < S_L_res_ || S > S_L_max_)
127 {
128 return 0.;
129 }
130
131 double const d2S_eff_dp_cap2 =
132 m_ * p_to_n * std::pow(p_to_n + 1., -m_ - 2.) * (p_to_n - m_) /
133 (p_cap * p_cap * (m_ - 1.) * (m_ - 1.));
134 return d2S_eff_dp_cap2 * (S_L_max_ - S_L_res_);
135}
136} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
PropertyDataType d2Value(VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &, double const, double const) const override
Default implementation: 2nd derivative of any constant property is zero.
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
SaturationVanGenuchten(std::string name, double const residual_liquid_saturation, double const residual_gas_saturation, double const exponent, double const p_b)
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