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