OGS
RelPermBrooksCorey.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <algorithm>
7#include <cmath>
8
10
11namespace MaterialPropertyLib
12{
14 const double residual_liquid_saturation,
15 const double residual_gas_saturation,
16 const double min_relative_permeability,
17 const double exponent)
20 min_relative_permeability_(min_relative_permeability),
21 exponent_(exponent)
22{
23 name_ = std::move(name);
24};
25
27 VariableArray const& variable_array,
28 ParameterLib::SpatialPosition const& pos, double const t,
29 double const dt) const
30{
35 auto const s_L = std::visit(
36 [&variable_array, &pos, t, dt](auto&& scale) -> double
37 {
38 return scale->property(PropertyType::saturation)
39 .template value<double>(variable_array, pos, t, dt);
40 },
41 scale_);
42
43 auto const s_L_res = residual_liquid_saturation_;
44 auto const s_L_max = 1. - residual_gas_saturation_;
45
46 auto const lambda = exponent_;
47
48 auto const s_eff = (s_L - s_L_res) / (s_L_max - s_L_res);
49
50 if (s_eff >= 1.0)
51 {
52 // fully saturated medium
53 return 1.0;
54 }
55 if (s_eff <= 0.0)
56 {
57 // dry medium
59 }
60
61 auto const k_rel_LR = std::pow(s_eff, (2. + 3. * lambda) / lambda);
62
63 return std::max(k_rel_LR, min_relative_permeability_);
64}
66 VariableArray const& variable_array, Variable const variable,
67 ParameterLib::SpatialPosition const& pos, double const t,
68 double const dt) const
69{
70 if (variable != Variable::liquid_saturation)
71 {
73 "RelPermBrooksCorey::dValue is implemented for derivatives with "
74 "respect to liquid saturation only.");
75 }
76
81 auto const s_L = std::visit(
82 [&variable_array, &pos, t, dt](auto&& scale) -> double
83 {
84 return scale->property(PropertyType::saturation)
85 .template value<double>(variable_array, pos, t, dt);
86 },
87 scale_);
88
89 auto const s_L_res = residual_liquid_saturation_;
90 auto const s_L_max = 1. - residual_gas_saturation_;
91 auto const lambda = exponent_;
92
93 auto const s_eff = (s_L - s_L_res) / (s_L_max - s_L_res);
94 if ((s_eff < 0.) || (s_eff > 1.))
95 {
96 return 0.;
97 }
98
99 auto const d_se_d_sL = 1. / (s_L_max - s_L_res);
100 auto const dk_rel_LRdse =
101 (3 * lambda + 2.) / lambda * std::pow(s_eff, 2. / lambda + 2.);
102
103 return dk_rel_LRdse * d_se_d_sL;
104}
105
106} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual PropertyDataType value() const
std::variant< Medium *, Phase *, Component * > scale_
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