OGS
WaterVapourLatentHeatWithCriticalTemperature.cpp
Go to the documentation of this file.
1
13
14#include <array>
15#include <cmath>
16#include <numeric>
17
20
21namespace MaterialPropertyLib
22{
24constexpr double T_c =
26constexpr double alpha = 1. / 8.;
27constexpr double beta = 1. / 3.;
28constexpr double Delta = 0.79 - beta;
29// Coefficients a_1, a_2, a_4, b_1, ... b_5
30constexpr std::array c = {1989.41582, 11178.45586, 26923.68994,
31 -28989.28947, -19797.03646, 28403.32283,
32 -30382.306422, 15210.380};
33
35 const VariableArray& variable_array,
36 const ParameterLib::SpatialPosition& /*pos*/, const double /*t*/,
37 const double /*dt*/) const
38{
39 const double T = variable_array.temperature;
40
41 if (T >= T_c)
42 {
43 return 0.0;
44 }
45
46 double const tau = (T_c - T) / T_c;
47 double const tau_p2 = tau * tau;
48 double const tau_p3 = tau_p2 * tau;
49 double const tau_p4 = tau_p3 * tau;
50 double const tau_p5 = tau_p4 * tau;
51
52 std::array v = {std::pow(tau, beta),
53 std::pow(tau, beta + Delta),
54 std::pow(tau, 1 - alpha + beta),
55 tau,
56 tau_p2,
57 tau_p3,
58 tau_p4,
59 tau_p5};
60
61 // The formula gives the value in kJ/kg, and the return value is in the
62 // units of J/kg.
63
64 return 1000.0 *
65#if __GNUC__ < 9 || (__GNUC__ == 9 && (__GNUC_MINOR__ < 3))
66 std::inner_product
67#else
68 std::transform_reduce
69#endif
70 (begin(c), end(c), begin(v), 0.);
71}
72
74 VariableArray const& variable_array, Variable const variable,
75 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
76 double const /*dt*/) const
77{
78 if (variable != Variable::temperature)
79 {
81 "WaterVapourLatentHeatWithCriticalTemperature::dValue is "
82 "implemented "
83 "for "
84 "the derivative with respect to temperature only.");
85 }
86 const double T = variable_array.temperature;
87
88 if (T >= T_c)
89 {
90 return 0.0;
91 }
92
93 constexpr std::array dc = {c[0] * beta,
94 c[1] * (beta + Delta),
95 c[2] * (1 - alpha + beta),
96 c[3],
97 c[4] * 2,
98 c[5] * 3,
99 c[6] * 4,
100 c[7] * 5};
101
102 double const tau = (T_c - T) / T_c;
103 double const tau_p2 = tau * tau;
104 double const tau_p3 = tau_p2 * tau;
105 double const tau_p4 = tau_p3 * tau;
106 std::array v = {std::pow(tau, beta - 1),
107 std::pow(tau, beta + Delta - 1),
108 std::pow(tau, -alpha + beta),
109 1.,
110 tau,
111 tau_p2,
112 tau_p3,
113 tau_p4};
114
115 // The formula gives the value in kJ/kg/K, and the value is return in
116 // the unit of J/kg/K.
117 return -1000.0 *
118#if __GNUC__ < 9 || (__GNUC__ == 9 && (__GNUC_MINOR__ < 3))
119 std::inner_product
120#else
121 std::transform_reduce
122#endif
123 (begin(dc), end(dc), begin(v), 0.) /
124 T_c;
125}
126
127} // 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 &pos, double const t, double const dt) const override
constexpr double CelsiusZeroInKelvin
Zero degrees Celsius in Kelvin.
constexpr double T_c
Critical temperature.
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