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 return s_L_max;
42
43 const double s_eff = std::pow(p_b / p_cap, lambda);
44 return s_eff * (s_L_max - s_L_res) + s_L_res;
45}
46
48 VariableArray const& variable_array, Variable const variable,
49 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
50 double const /*dt*/) const
51{
52 if (variable != Variable::capillary_pressure)
53 {
55 "SaturationBrooksCorey::dValue is implemented for derivatives with "
56 "respect to capillary pressure only.");
57 }
58
59 const double p_b = entry_pressure_;
60 const double p_cap = variable_array.capillary_pressure;
61
62 if (p_cap <= p_b)
63 {
64 return 0.;
65 }
66
67 const double s_L_res = residual_liquid_saturation_;
68 const double s_L_max = 1.0 - residual_gas_saturation_;
69 const double lambda = exponent_;
70
71 const double ds_eff_dp_cap =
72 -lambda * std::pow(p_b, lambda) / std::pow(p_cap, lambda + 1);
73 return ds_eff_dp_cap * (s_L_max - s_L_res);
74}
75
77 VariableArray const& variable_array, Variable const variable1,
78 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
79 double const /*t*/, double const /*dt*/) const
80{
81 if ((variable1 != Variable::capillary_pressure) &&
82 (variable2 != Variable::capillary_pressure))
83 {
85 "SaturationBrooksCorey::d2Value is implemented for derivatives "
86 "with respect to capillary pressure only.");
87 }
88
89 const double p_b = entry_pressure_;
90 const double p_cap = std::max(p_b, variable_array.capillary_pressure);
91
92 if (p_cap <= p_b)
93 {
94 return 0.;
95 }
96
97 const double s_L_res = residual_liquid_saturation_;
98 const double s_L_max = 1.0 - residual_gas_saturation_;
99
100 const double lambda = exponent_;
101
102 return lambda * (lambda + 1) * std::pow(p_b / p_cap, lambda) /
103 (p_cap * p_cap) * (s_L_max - s_L_res);
104}
105
106} // 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