OGS
SaturationExponential.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{
15 std::string name,
16 const double residual_liquid_saturation,
17 const double residual_gas_saturation,
18 const double p_cap_max,
19 const double exponent)
22 p_cap_max_(p_cap_max),
23 exponent_(exponent)
24{
25 name_ = std::move(name);
26 if (p_cap_max_ <= 0.)
27 {
29 "Reference capillary pressure must be positive in "
30 "MPL::SaturationExponential.");
31 }
32};
33
35 VariableArray const& variable_array,
36 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
37 double const /*dt*/) const
38{
39 const double p_cap = variable_array.capillary_pressure;
40
41 const double S_res = residual_liquid_saturation_;
42 const double S_max = 1. - residual_gas_saturation_;
43
44 const double pc = std::clamp(p_cap, 0., p_cap_max_);
45 const double S_e = 1. - std::pow(pc / p_cap_max_, exponent_);
46 return S_e * (S_max - S_res) + S_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 "SaturationExponential::dValue is implemented for derivatives with "
58 "respect to capillary pressure only.");
59 }
60
61 const double p_cap = variable_array.capillary_pressure;
62
63 const double S_res = residual_liquid_saturation_;
64 const double S_max = 1. - residual_gas_saturation_;
65
66 if ((p_cap > p_cap_max_) || (p_cap <= 0.))
67 {
68 return 0.;
69 }
70 return (exponent_ / p_cap) * (S_res - S_max) *
71 std::pow(p_cap / p_cap_max_, exponent_);
72}
73
75 VariableArray const& /*variable_array*/, Variable const /*variable1*/,
76 Variable const /*variable2*/, ParameterLib::SpatialPosition const& /*pos*/,
77 double const /*t*/, double const /*dt*/) const
78{
79 OGS_FATAL("SaturationExponential::d2Value() is not implemented.");
80}
81
82} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual PropertyDataType value() const
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