OGS
WaterThermalConductivityIAPWS.cpp
Go to the documentation of this file.
1
13
14#include <cmath>
15
16#include "BaseLib/Error.h"
18
19namespace MaterialPropertyLib
20{
21// Li and Lij are coefficients from Tables 1 and 2 (Daucik and Dooley, 2011)
22static const double Li[5] = {2.443221e-3, 1.323095e-2, 6.770357e-3,
23 -3.454586e-3, 4.096266e-4};
24static const double Lij[5][6] = {
25 {1.60397357, -0.646013523, 0.111443906, 0.102997357, -0.0504123634,
26 0.00609859258},
27 {2.33771842, -2.78843778, 1.53616167, -0.463045512, 0.0832827019,
28 -0.00719201245},
29 {2.19650529, -4.54580785, 3.55777244, -1.40944978, 0.275418278,
30 -0.0205938816},
31 {-1.21051378, 1.60812989, -0.621178141, 0.0716373224, 0, 0},
32 {-2.7203370, 4.57586331, -3.18369245, 1.1168348, -0.19268305, 0.012913842}};
33
34static double computeBarLambda0Factor(const double barT);
35
36static std::array<double, 5> computeSeriesFactorTForLambda1(const double barT);
37static std::array<double, 6> computeSeriesFactorRhoForLambda1(
38 const double bar_rho);
39static double computeBarLambda1Factor(
40 const std::array<double, 5>& series_factorT,
41 const std::array<double, 6>& series_factorRho);
42
43static double computedBarLambda_dbarT(const double barT, double bar_rho);
44static double computedBarLambda_dbarRho(const double barT, double bar_rho);
45
47 VariableArray const& variable_array,
48 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
49 double const /*dt*/) const
50{
51 const double bar_T = variable_array.temperature / ref_T_;
52 const double bar_rho = variable_array.density / ref_rho_;
53
54 const double lambda0 = std::sqrt(bar_T) / computeBarLambda0Factor(bar_T);
55
56 const auto& series_factorT = computeSeriesFactorTForLambda1(bar_T);
57 const auto& series_factorRho = computeSeriesFactorRhoForLambda1(bar_rho);
58 const double lambda1 = std::exp(
59 bar_rho * computeBarLambda1Factor(series_factorT, series_factorRho));
60
61 return lambda0 * lambda1 * ref_lambda_;
62}
63
65 VariableArray const& variable_array, Variable const variable,
66 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
67 double const /*dt*/) const
68{
69 const double bar_T = variable_array.temperature / ref_T_;
70 const double bar_rho = variable_array.density / ref_rho_;
71
72 switch (variable)
73 {
75 return ref_lambda_ * computedBarLambda_dbarT(bar_T, bar_rho) /
76 ref_T_;
78 return ref_lambda_ * computedBarLambda_dbarRho(bar_T, bar_rho) /
80 default:
82 "WaterThermalConductivityIAPWS::dValue is implemented for "
83 "derivatives with respect to temperature and liquid density "
84 "only.");
85 }
86}
87
88double computeBarLambda0Factor(const double barT)
89{
90 double sum_val = 0.;
91 double barT_i = 1.;
92 for (double value : Li)
93 {
94 sum_val += (value / barT_i);
95 barT_i *= barT;
96 }
97 return sum_val;
98}
99
100std::array<double, 5> computeSeriesFactorTForLambda1(const double barT)
101{
102 std::array<double, 5> series_factorT;
103 series_factorT[0] = 1.;
104 const double barT_fac = 1 / barT - 1.0;
105 for (int i = 1; i < 5; i++)
106 {
107 series_factorT[i] = series_factorT[i - 1] * barT_fac;
108 }
109
110 return series_factorT;
111}
112
113std::array<double, 6> computeSeriesFactorRhoForLambda1(const double bar_rho)
114{
115 std::array<double, 6> series_factorRho;
116 series_factorRho[0] = 1.;
117 for (int i = 1; i < 6; i++)
118 {
119 series_factorRho[i] = series_factorRho[i - 1] * (bar_rho - 1.0);
120 }
121
122 return series_factorRho;
123}
124
125double computeBarLambda1Factor(const std::array<double, 5>& series_factorT,
126 const std::array<double, 6>& series_factorRho)
127{
128 double sum_val = 0.;
129 for (int i = 0; i < 5; i++)
130 {
131 double sum_val_j = 0;
132 for (int j = 0; j < 6; j++)
133 {
134 sum_val_j += Lij[i][j] * series_factorRho[j];
135 }
136 sum_val += series_factorT[i] * sum_val_j;
137 }
138
139 return sum_val;
140}
141
142double computedBarLambda_dbarT(const double barT, double bar_rho)
143{
144 const double lambda0_factor = computeBarLambda0Factor(barT);
145 const double sqrt_barT = std::sqrt(barT);
146
147 double dlambda0_factor_dbarT = 0.0;
148 double barT_i = barT * barT;
149 for (int i = 1; i < 5; i++)
150 {
151 dlambda0_factor_dbarT -= static_cast<double>(i) * (Li[i] / barT_i);
152 barT_i *= barT;
153 }
154
155 const double dbar_lambda0_dbarT =
156 0.5 / (lambda0_factor * sqrt_barT) -
157 sqrt_barT * dlambda0_factor_dbarT / (lambda0_factor * lambda0_factor);
158
159 const auto& series_factorT = computeSeriesFactorTForLambda1(barT);
160 const auto& series_factorRho = computeSeriesFactorRhoForLambda1(bar_rho);
161
162 double dlambda1_factor_dbarT = 0.0;
163 for (int i = 1; i < 5; i++)
164 {
165 double sum_val_j = 0;
166 for (int j = 0; j < 6; j++)
167 {
168 sum_val_j += Lij[i][j] * series_factorRho[j];
169 }
170 dlambda1_factor_dbarT -= static_cast<double>(i) *
171 series_factorT[i - 1] * sum_val_j /
172 (barT * barT);
173 }
174
175 const double lambda1_factor =
176 computeBarLambda1Factor(series_factorT, series_factorRho);
177 const double dbar_lambda1_dbarT =
178 bar_rho * std::exp(bar_rho * lambda1_factor) * dlambda1_factor_dbarT;
179
180 return dbar_lambda0_dbarT * std::exp(bar_rho * lambda1_factor) +
181 dbar_lambda1_dbarT * sqrt_barT / lambda0_factor;
182}
183
184double computedBarLambda_dbarRho(const double barT, double bar_rho)
185{
186 const auto& series_factorT = computeSeriesFactorTForLambda1(barT);
187 const auto& series_factorRho = computeSeriesFactorRhoForLambda1(bar_rho);
188
189 double dlambda1_factor_dbar_rho = 0.0;
190 for (int i = 0; i < 5; i++)
191 {
192 double sum_val_j = 0;
193 for (int j = 1; j < 6; j++)
194 {
195 sum_val_j +=
196 static_cast<double>(j) * Lij[i][j] * series_factorRho[j - 1];
197 }
198 dlambda1_factor_dbar_rho += series_factorT[i] * sum_val_j;
199 }
200
201 const double lambda0 = std::sqrt(barT) / computeBarLambda0Factor(barT);
202
203 const double lambda1_factor =
204 computeBarLambda1Factor(series_factorT, series_factorRho);
205 return lambda0 * std::exp(bar_rho * lambda1_factor) *
206 (lambda1_factor + bar_rho * dlambda1_factor_dbar_rho);
207}
208
209} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType value() const
Definition Property.cpp:76
static constexpr double ref_lambda_
reference thermal conductivity in W.K^-1.m^-1
static constexpr double ref_T_
reference temperature in K
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
static constexpr double ref_rho_
reference density in kg/m^3
static double computeBarLambda1Factor(const std::array< double, 5 > &series_factorT, const std::array< double, 6 > &series_factorRho)
static std::array< double, 6 > computeSeriesFactorRhoForLambda1(const double bar_rho)
static double computedBarLambda_dbarT(const double barT, double bar_rho)
static double computeBarLambda0Factor(const double barT)
static std::array< double, 5 > computeSeriesFactorTForLambda1(const double barT)
static const double Lij[5][6]
static double computedBarLambda_dbarRho(const double barT, double bar_rho)
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