OGS
SaturationExponential.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 p_cap_max,
29 const double exponent)
30 : residual_liquid_saturation_(residual_liquid_saturation),
31 residual_gas_saturation_(residual_gas_saturation),
32 p_cap_max_(p_cap_max),
33 exponent_(exponent)
34{
35 name_ = std::move(name);
36 if (p_cap_max_ <= 0.)
37 {
39 "Reference capillary pressure must be positive in "
40 "MPL::SaturationExponential.");
41 }
42};
43
45 VariableArray const& variable_array,
46 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
47 double const /*dt*/) const
48{
49 const double p_cap = variable_array.capillary_pressure;
50
51 const double S_res = residual_liquid_saturation_;
52 const double S_max = 1. - residual_gas_saturation_;
53
54 const double pc = std::clamp(p_cap, 0., p_cap_max_);
55 const double S_e = 1. - std::pow(pc / p_cap_max_, exponent_);
56 return S_e * (S_max - S_res) + S_res;
57}
58
60 VariableArray const& variable_array, Variable const variable,
61 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
62 double const /*dt*/) const
63{
64 if (variable != Variable::capillary_pressure)
65 {
67 "SaturationExponential::dValue is implemented for derivatives with "
68 "respect to capillary pressure only.");
69 }
70
71 const double p_cap = variable_array.capillary_pressure;
72
73 const double S_res = residual_liquid_saturation_;
74 const double S_max = 1. - residual_gas_saturation_;
75
76 if ((p_cap > p_cap_max_) || (p_cap <= 0.))
77 {
78 return 0.;
79 }
80 return (exponent_ / p_cap) * (S_res - S_max) *
81 std::pow(p_cap / p_cap_max_, exponent_);
82}
83
85 VariableArray const& /*variable_array*/, Variable const /*variable1*/,
86 Variable const /*variable2*/, ParameterLib::SpatialPosition const& /*pos*/,
87 double const /*t*/, double const /*dt*/) const
88{
89 OGS_FATAL("SaturationExponential::d2Value() is not implemented.");
90}
91
92} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
const double residual_gas_saturation_
Residual saturation of the liquid phase.
const double exponent_
Exponent to govern the shape of the curve.
SaturationExponential(std::string name, const double residual_liquid_saturation, const double residual_gas_saturation, const double p_cap_max, const double exponent)
const double residual_liquid_saturation_
Residual saturation of the gas phase.
PropertyDataType d2Value(VariableArray const &variable_array, Variable const, Variable const, 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