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 pressure_exponent,
25 double const saturation_exponent,
26 double const p_b)
28 S_L_max_(1. - residual_gas_saturation),
29 m_(pressure_exponent),
30 n_(saturation_exponent),
31 p_b_(p_b)
32{
33 name_ = std::move(name);
34
35 if (!(m_ > 0 && m_ < 1))
36 {
38 "The pressure exponent value m = {:g} of van Genuchten saturation "
39 "model, is out of its range of (0, 1)",
40 m_);
41 }
42
43 if (n_ < 1)
44 {
46 "The saturation exponent value n = {:g} of van Genuchten "
47 "saturation model, is out of its range of [1, +inf)",
48 n_);
49 }
50}
51
53 VariableArray const& variable_array,
54 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
55 double const /*dt*/) const
56{
57 const double p_cap = variable_array.capillary_pressure;
58
59 if (p_cap <= 0)
60 {
61 return S_L_max_;
62 }
63
64 double const p = p_cap / p_b_;
65 double const p_to_n = std::pow(p, n_);
66
67 double const S_eff = std::pow(p_to_n + 1., -m_);
68 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
69 return std::clamp(S, S_L_res_, S_L_max_);
70}
71
73 VariableArray const& variable_array, Variable const variable,
74 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
75 double const /*dt*/) const
76{
77 if (variable != Variable::capillary_pressure)
78 {
80 "SaturationVanGenuchten::dValue is implemented for derivatives "
81 "with respect to capillary pressure only.");
82 }
83
84 const double p_cap = variable_array.capillary_pressure;
85
86 if (p_cap <= 0)
87 {
88 return 0.;
89 }
90
91 double const p = p_cap / p_b_;
92 double const p_to_n = std::pow(p, n_);
93
94 double const S_eff = std::pow(p_to_n + 1., -m_);
95 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
96
97 if (S < S_L_res_ || S > S_L_max_)
98 {
99 return 0.;
100 }
101
102 double const dS_eff_dp_cap =
103 -m_ * n_ * p_to_n * S_eff / (p_cap * (p_to_n + 1.));
104 return dS_eff_dp_cap * (S_L_max_ - S_L_res_);
105}
106
108 VariableArray const& variable_array, Variable const variable1,
109 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
110 double const /*t*/, double const /*dt*/) const
111{
112 (void)variable1;
113 (void)variable2;
114 assert((variable1 == Variable::capillary_pressure) &&
115 (variable2 == Variable::capillary_pressure) &&
116 "SaturationVanGenuchten::d2Value is implemented for derivatives "
117 "with respect to capillary pressure only.");
118
119 const double p_cap = variable_array.capillary_pressure;
120
121 if (p_cap <= 0)
122 {
123 return 0.;
124 }
125
126 double const p = p_cap / p_b_;
127 double const p_to_n = std::pow(p, n_);
128
129 double const S_eff = std::pow(p_to_n + 1., -m_);
130 double const S = S_eff * S_L_max_ - S_eff * S_L_res_ + S_L_res_;
131
132 if (S < S_L_res_ || S > S_L_max_)
133 {
134 return 0.;
135 }
136
137 double const d2S_eff_dp_cap2 =
138 m_ * n_ * n_ * p_to_n * S_eff * (p_to_n - m_) /
139 ((p_cap * p_to_n + p_cap) * (p_cap * p_to_n + p_cap));
140 return d2S_eff_dp_cap2 * (S_L_max_ - S_L_res_);
141}
142} // 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 pressure_exponent, double const saturation_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