OGS
RelPermGeneralizedPowerNonwettingPhase.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 <cmath>
7
9
10namespace MaterialPropertyLib
11{
13 std::string name,
14 const double residual_liquid_saturation,
15 const double residual_gas_saturation,
16 const double min_relative_permeability,
17 const double a,
18 const double lambda)
21 min_relative_permeability_(min_relative_permeability),
22 a_(a),
23 lambda_(lambda)
24{
25 name_ = std::move(name);
26}
27
29 VariableArray const& variable_array,
30 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
31 double const /*dt*/) const
32{
33 const double S_L = variable_array.liquid_saturation;
34
35 if (std::isnan(S_L))
36 {
38 "In RelPermGeneralizedPowerNonwettingPhase::value, the liquid "
39 "saturation is "
40 "NaN.");
41 }
42
43 auto const S_L_res = residual_liquid_saturation_;
44 auto const S_L_max = 1. - residual_gas_saturation_;
45
46 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
47
48 if (S_e >= 1.0)
49 {
50 // fully saturated medium
52 }
53 if (S_e <= 0.0)
54 {
55 // dry medium
56 return a_;
57 }
58
59 auto const S_e_g = (1. - S_e);
60
61 return std::max(a_ * std::pow(S_e_g, lambda_), min_relative_permeability_);
62}
64 VariableArray const& variable_array, Variable const variable,
65 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
66 double const /*dt*/) const
67{
68 if (variable != Variable::liquid_saturation)
69 {
71 "RelPermGeneralizedPowerNonwettingPhase::dValue is implemented for "
72 "derivatives with respect to liquid saturation only.");
73 }
74
75 const double S_L = variable_array.liquid_saturation;
76
77 auto const S_L_res = residual_liquid_saturation_;
78 auto const S_L_max = 1. - residual_gas_saturation_;
79 auto const S_e = (S_L - S_L_res) / (S_L_max - S_L_res);
80
81 if ((S_e < 0.) || (S_e > 1.))
82 {
83 return 0.;
84 }
85
86 auto const S_e_g = (1. - S_e);
87 auto const k_rel = a_ * std::pow(S_e_g, lambda_);
89 {
90 return 0.;
91 }
92
93 auto const dS_e_dS_L = 1. / (S_L_max - S_L_res);
94
95 auto const dk_rel_GR_dS_e = -lambda_ * k_rel / S_e_g;
96 return dk_rel_GR_dS_e * dS_e_dS_L;
97}
98
99} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual PropertyDataType value() const
RelPermGeneralizedPowerNonwettingPhase(std::string name, const double residual_liquid_saturation, const double residual_gas_saturation, const double min_relative_permeability, const double a, const double lambda)
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