OGS
RelPermNonWettingPhaseVanGenuchtenMualem.cpp
Go to the documentation of this file.
1
12
#include "
RelPermNonWettingPhaseVanGenuchtenMualem.h
"
13
14
#include <algorithm>
15
#include <cmath>
16
#include <limits>
17
18
#include "
BaseLib/Error.h
"
19
#include "
MaterialLib/MPL/Medium.h
"
20
#include "
MaterialLib/MPL/Utils/CheckVanGenuchtenExponentRange.h
"
21
#include "
MathLib/Nonlinear/Root1D.h
"
22
23
namespace
MaterialPropertyLib
24
{
25
double
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
32
RelPermNonWettingPhaseVanGenuchtenMualem::
33
RelPermNonWettingPhaseVanGenuchtenMualem
(std::string
name
,
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
);
45
checkVanGenuchtenExponentRange
(
m_
);
46
}
47
48
PropertyDataType
RelPermNonWettingPhaseVanGenuchtenMualem::value
(
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 =
57
computeVanGenuchtenMualemValue
(S_L,
S_L_r_
,
S_L_max_
,
m_
);
58
return
std::max(
krel_min_
, krel);
59
}
60
61
PropertyDataType
RelPermNonWettingPhaseVanGenuchtenMualem::dValue
(
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
{
68
OGS_FATAL
(
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
95
double
RelPermNonWettingPhaseVanGenuchtenMualem::
96
computeSaturationForMinimumRelativePermeability
()
const
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 =
106
MathLib::Nonlinear::makeRegulaFalsi<MathLib::Nonlinear::Pegasus>
(
107
f,
S_L_r_
,
S_L_max_
);
108
109
root_finder.step(1000);
110
111
return
root_finder.getResult();
112
}
113
}
// namespace MaterialPropertyLib
CheckVanGenuchtenExponentRange.h
Error.h
OGS_FATAL
#define OGS_FATAL(...)
Definition
Error.h:26
Medium.h
RelPermNonWettingPhaseVanGenuchtenMualem.h
Root1D.h
MaterialPropertyLib::Property::value
virtual PropertyDataType value() const
Definition
Property.cpp:76
MaterialPropertyLib::Property::name_
std::string name_
Definition
Property.h:290
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::S_L_for_krel_min_
const double S_L_for_krel_min_
Liquid saturation that gives krel_min_.
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.h:100
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::m_
const double m_
Exponent .
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.h:97
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::S_L_r_
const double S_L_r_
Residual saturation of wetting phase.
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.h:95
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::computeSaturationForMinimumRelativePermeability
double computeSaturationForMinimumRelativePermeability() const
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.cpp:96
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::RelPermNonWettingPhaseVanGenuchtenMualem
RelPermNonWettingPhaseVanGenuchtenMualem(std::string name, const double S_L_r, const double S_n_r, const double m, const double krel_min)
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.cpp:33
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::S_L_max_
const double S_L_max_
Maximum saturation of wetting phase.
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.h:96
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::dValue
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.cpp:61
MaterialPropertyLib::RelPermNonWettingPhaseVanGenuchtenMualem::krel_min_
const double krel_min_
Minimum relative permeability.
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.h:98
MaterialPropertyLib::VariableArray
Definition
VariableType.h:97
MaterialPropertyLib::VariableArray::liquid_saturation
double liquid_saturation
Definition
VariableType.h:179
ParameterLib::SpatialPosition
Definition
SpatialPosition.h:27
MaterialPropertyLib
Definition
ChemicalSolverInterface.h:21
MaterialPropertyLib::computeVanGenuchtenMualemValue
double computeVanGenuchtenMualemValue(const double S_L, const double S_L_r, const double S_L_max, const double m)
Definition
RelPermNonWettingPhaseVanGenuchtenMualem.cpp:25
MaterialPropertyLib::Variable
Variable
Definition
VariableType.h:30
MaterialPropertyLib::Variable::liquid_saturation
@ liquid_saturation
MaterialPropertyLib::name
@ name
Definition
PropertyType.h:66
MaterialPropertyLib::checkVanGenuchtenExponentRange
void checkVanGenuchtenExponentRange(const double m)
Definition
CheckVanGenuchtenExponentRange.cpp:18
MaterialPropertyLib::PropertyDataType
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
MathLib::Nonlinear::makeRegulaFalsi
RegulaFalsi< SubType, Function > makeRegulaFalsi(Function &&f, double const a, double const b)
Definition
Root1D.h:137
MaterialLib
MPL
Properties
RelativePermeability
RelPermNonWettingPhaseVanGenuchtenMualem.cpp
Generated by
1.12.0