OGS
SaturationBrooksCorey.cpp
Go to the documentation of this file.
1
15
16#include <algorithm>
17#include <cmath>
18
20#include "MathLib/MathTools.h"
21
22namespace MaterialPropertyLib
23{
25 std::string name,
26 const double residual_liquid_saturation,
27 const double residual_gas_saturation,
28 const double exponent,
29 const double entry_pressure)
30 : residual_liquid_saturation_(residual_liquid_saturation),
31 residual_gas_saturation_(residual_gas_saturation),
32 exponent_(exponent),
33 entry_pressure_(entry_pressure)
34{
35 name_ = std::move(name);
36};
37
39 VariableArray const& variable_array,
40 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
41 double const /*dt*/) const
42{
43 const double p_cap = variable_array.capillary_pressure;
44
45 const double s_L_res = residual_liquid_saturation_;
46 const double s_L_max = 1.0 - residual_gas_saturation_;
47 const double lambda = exponent_;
48 const double p_b = entry_pressure_;
49
50 if (p_cap <= p_b)
51 return s_L_max;
52
53 const double s_eff = std::pow(p_b / p_cap, lambda);
54 return s_eff * (s_L_max - s_L_res) + s_L_res;
55}
56
58 VariableArray const& variable_array, Variable const variable,
59 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
60 double const /*dt*/) const
61{
62 if (variable != Variable::capillary_pressure)
63 {
65 "SaturationBrooksCorey::dValue is implemented for derivatives with "
66 "respect to capillary pressure only.");
67 }
68
69 const double p_b = entry_pressure_;
70 const double p_cap = variable_array.capillary_pressure;
71
72 if (p_cap <= p_b)
73 {
74 return 0.;
75 }
76
77 const double s_L_res = residual_liquid_saturation_;
78 const double s_L_max = 1.0 - residual_gas_saturation_;
79 const double lambda = exponent_;
80
81 const double ds_eff_dp_cap =
82 -lambda * std::pow(p_b, lambda) / std::pow(p_cap, lambda + 1);
83 return ds_eff_dp_cap * (s_L_max - s_L_res);
84}
85
87 VariableArray const& variable_array, Variable const variable1,
88 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
89 double const /*t*/, double const /*dt*/) const
90{
91 if ((variable1 != Variable::capillary_pressure) &&
92 (variable2 != Variable::capillary_pressure))
93 {
95 "SaturationBrooksCorey::d2Value is implemented for derivatives "
96 "with respect to capillary pressure only.");
97 }
98
99 const double p_b = entry_pressure_;
100 const double p_cap = std::max(p_b, variable_array.capillary_pressure);
101
102 if (p_cap <= p_b)
103 {
104 return 0.;
105 }
106
107 const double s_L_res = residual_liquid_saturation_;
108 const double s_L_max = 1.0 - residual_gas_saturation_;
109
110 const double lambda = exponent_;
111
112 return lambda * (lambda + 1) * std::pow(p_b / p_cap, lambda) /
113 (p_cap * p_cap) * (s_L_max - s_L_res);
114}
115
116} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
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
Definition Property.h:31