OGS
RelPermNonWettingPhaseVanGenuchtenMualem.cpp
Go to the documentation of this file.
1
13
14#include <algorithm>
15#include <cmath>
16#include <limits>
17
18#include "BaseLib/Error.h"
22
23namespace MaterialPropertyLib
24{
25double computeVanGenuchtenMualemValue(const double S_L, const double S_L_r,
26 const double S_L_max, const double m)
27{
28 const double Se = (S_L - S_L_r) / (S_L_max - S_L_r);
29 return std::sqrt(1.0 - Se) * std::pow(1.0 - std::pow(Se, 1.0 / m), 2.0 * m);
30}
31
34 const double S_L_r,
35 const double S_n_r,
36 const double m,
37 const double krel_min)
38 : S_L_r_(S_L_r),
39 S_L_max_(1. - S_n_r),
40 m_(m),
41 krel_min_(krel_min),
42 S_L_for_krel_min_(computeSaturationForMinimumRelativePermeability())
43{
44 name_ = std::move(name);
46}
47
49 VariableArray const& variable_array,
50 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
51 double const /*dt*/) const
52{
53 const double S_L =
54 std::clamp(variable_array.liquid_saturation, S_L_r_, S_L_max_);
55
56 const double krel =
58 return std::max(krel_min_, krel);
59}
60
62 VariableArray const& variable_array, Variable const variable,
63 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
64 double const /*dt*/) const
65{
66 if (variable != Variable::liquid_saturation)
67 {
69 "RelPermNonWettingPhaseVanGenuchtenMualem::dValue is implemented "
70 "for the derivative with respect to liquid saturation only.");
71 }
72
73 const double S_L = variable_array.liquid_saturation;
74 if (S_L < S_L_r_ || S_L > S_L_for_krel_min_)
75 {
76 return 0.0;
77 }
78
79 if (std::fabs(S_L - S_L_max_) < std::numeric_limits<double>::epsilon())
80 {
81 return 0.0;
82 }
83
84 const double Se = (S_L - S_L_r_) / (S_L_max_ - S_L_r_);
85
86 const double val1 = std::sqrt(1.0 - Se);
87 const double val2 = 1.0 - std::pow(Se, 1.0 / m_);
88
89 return (-0.5 * std::pow(val2, 2.0 * m_) / val1 -
90 2.0 * std::pow(Se, -1.0 + 1.0 / m_) * val1 *
91 std::pow(val2, 2.0 * m_ - 1.0)) /
92 (S_L_max_ - S_L_r_);
93}
94
97{
98 auto f = [this](double S_L) -> double
99 {
100 return computeVanGenuchtenMualemValue(S_L, this->S_L_r_, this->S_L_max_,
101 this->m_) -
102 this->krel_min_;
103 };
104
105 auto root_finder =
107 f, S_L_r_, S_L_max_);
108
109 root_finder.step(1000);
110
111 return root_finder.getResult();
112}
113} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
RelPermNonWettingPhaseVanGenuchtenMualem(std::string name, const double S_L_r, const double S_n_r, const double m, const double krel_min)
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
double computeVanGenuchtenMualemValue(const double S_L, const double S_L_r, const double S_L_max, const double m)
void checkVanGenuchtenExponentRange(const double m)
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
RegulaFalsi< SubType, Function > makeRegulaFalsi(Function &&f, double const a, double const b)
Definition Root1D.h:137