OGS
RelPermBrooksCoreyNonwettingPhase.cpp
Go to the documentation of this file.
1
15
16#include <algorithm>
17#include <cmath>
18
20
21namespace MaterialPropertyLib
22{
24 std::string name,
25 const double residual_liquid_saturation,
26 const double residual_gas_saturation,
27 const double min_relative_permeability,
28 const double exponent)
29 : residual_liquid_saturation_(residual_liquid_saturation),
30 residual_gas_saturation_(residual_gas_saturation),
31 min_relative_permeability_(min_relative_permeability),
32 exponent_(exponent)
33{
34 name_ = std::move(name);
35};
36
38 VariableArray const& variable_array,
39 ParameterLib::SpatialPosition const& pos, double const t,
40 double const dt) const
41{
46 auto const s_L = std::visit(
47 [&variable_array, &pos, t, dt](auto&& scale) -> double
48 {
49 return scale->property(PropertyType::saturation)
50 .template value<double>(variable_array, pos, t, dt);
51 },
52 scale_);
53
54 auto const s_L_res = residual_liquid_saturation_;
55 auto const s_L_max = 1. - residual_gas_saturation_;
56
57 auto const lambda = exponent_;
58
59 auto const s_eff = (s_L - s_L_res) / (s_L_max - s_L_res);
60
61 if (s_eff >= 1.0)
62 {
63 // fully saturated medium
65 }
66 if (s_eff <= 0.0)
67 {
68 // dry medium
69 return 1.0;
70 }
71
72 auto const k_rel_GR = (1. - s_eff) * (1. - s_eff) *
73 (1. - std::pow(s_eff, (2. + lambda) / lambda));
74
75 return std::max(k_rel_GR, min_relative_permeability_);
76}
78 VariableArray const& variable_array, Variable const variable,
79 ParameterLib::SpatialPosition const& pos, double const t,
80 double const dt) const
81{
82 if (variable != Variable::liquid_saturation)
83 {
85 "RelPermBrooksCoreyNonwettingPhase::dValue is implemented for "
86 "derivatives with respect to liquid saturation only.");
87 }
92 auto const s_L = std::visit(
93 [&variable_array, &pos, t, dt](auto&& scale) -> double
94 {
95 return scale->property(PropertyType::saturation)
96 .template value<double>(variable_array, pos, t, dt);
97 },
98 scale_);
99
100 auto const s_L_res = residual_liquid_saturation_;
101 auto const s_L_max = 1. - residual_gas_saturation_;
102 auto const lambda = exponent_;
103
104 auto const s_eff = (s_L - s_L_res) / (s_L_max - s_L_res);
105 if ((s_eff < 0.) || (s_eff > 1.))
106 {
107 return 0.0;
108 }
109
110 auto const twoL_L = (2. + lambda) / lambda;
111 auto const d_se_d_sL = 1. / (s_L_max - s_L_res);
112 auto const dk_rel_GRdse =
113 -2. * (1 - s_eff) * (1. - std::pow(s_eff, twoL_L)) -
114 twoL_L * std::pow(s_eff, twoL_L - 1.) * (1. - s_eff) * (1. - s_eff);
115
116 return dk_rel_GRdse * d_se_d_sL;
117}
118
119} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297
RelPermBrooksCoreyNonwettingPhase(std::string name, const double residual_liquid_saturation, const double residual_gas_saturation, const double min_relative_permeability, const double 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