OGS
SaturationBrooksCorey.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#include "MathLib/MathTools.h"
11
12namespace MaterialPropertyLib
13{
27
29 VariableArray const& variable_array,
30 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
31 double const /*dt*/) const
32{
33 const double p_cap = variable_array.capillary_pressure;
34
35 const double s_L_res = residual_liquid_saturation_;
36 const double s_L_max = 1.0 - residual_gas_saturation_;
37 const double lambda = exponent_;
38 const double p_b = entry_pressure_;
39
40 if (p_cap <= p_b)
41 {
42 return s_L_max;
43 }
44
45 const double s_eff = std::pow(p_b / p_cap, lambda);
46 return s_eff * (s_L_max - s_L_res) + s_L_res;
47}
48
50 VariableArray const& variable_array, Variable const variable,
51 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
52 double const /*dt*/) const
53{
54 if (variable != Variable::capillary_pressure)
55 {
57 "SaturationBrooksCorey::dValue is implemented for derivatives with "
58 "respect to capillary pressure only.");
59 }
60
61 const double p_b = entry_pressure_;
62 const double p_cap = variable_array.capillary_pressure;
63
64 if (p_cap <= p_b)
65 {
66 return 0.;
67 }
68
69 const double s_L_res = residual_liquid_saturation_;
70 const double s_L_max = 1.0 - residual_gas_saturation_;
71 const double lambda = exponent_;
72
73 const double ds_eff_dp_cap =
74 -lambda * std::pow(p_b, lambda) / std::pow(p_cap, lambda + 1);
75 return ds_eff_dp_cap * (s_L_max - s_L_res);
76}
77
79 VariableArray const& variable_array, Variable const variable1,
80 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
81 double const /*t*/, double const /*dt*/) const
82{
83 if ((variable1 != Variable::capillary_pressure) &&
84 (variable2 != Variable::capillary_pressure))
85 {
87 "SaturationBrooksCorey::d2Value is implemented for derivatives "
88 "with respect to capillary pressure only.");
89 }
90
91 const double p_b = entry_pressure_;
92 const double p_cap = std::max(p_b, variable_array.capillary_pressure);
93
94 if (p_cap <= p_b)
95 {
96 return 0.;
97 }
98
99 const double s_L_res = residual_liquid_saturation_;
100 const double s_L_max = 1.0 - residual_gas_saturation_;
101
102 const double lambda = exponent_;
103
104 return lambda * (lambda + 1) * std::pow(p_b / p_cap, lambda) /
105 (p_cap * p_cap) * (s_L_max - s_L_res);
106}
107
108} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual PropertyDataType value() const
SaturationBrooksCorey(std::string name, const double residual_liquid_saturation, const double residual_gas_saturation, const double exponent, const double entry_pressure)
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType d2Value(VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &, double const, double const) const override
Default implementation: 2nd derivative of any constant property is zero.
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