30 for (std::size_t i = 0; i < _p.size(); ++i)
32 REL_TEST(_fp->rho_from_p_T(_p[i],
T), _rho_sc / _B[i], REL_TOL_CONSISTENCY);
33 REL_TEST(_fp->mu_from_p_T(_p[i],
T), _mu[i], REL_TOL_CONSISTENCY);
34 REL_TEST(_fp_bounds->rho_from_p_T(_p[i],
T), _rho_sc / _B[i], REL_TOL_CONSISTENCY);
35 REL_TEST(_fp_bounds->mu_from_p_T(_p[i],
T), _mu[i], REL_TOL_CONSISTENCY);
36 REL_TEST(_fp_throw->rho_from_p_T(_p[i],
T), _rho_sc / _B[i], REL_TOL_CONSISTENCY);
37 REL_TEST(_fp_throw->mu_from_p_T(_p[i],
T), _mu[i], REL_TOL_CONSISTENCY);
49 const Real inv_B = 0.5 * (1.0 / _B[1] + 1.0 / _B[2]);
50 const Real inv_B_mu = 0.5 * (1.0 / (_B[1] * _mu[1]) + 1.0 / (_B[2] * _mu[2]));
51 const Real
rho = _rho_sc * inv_B;
52 const Real
mu = inv_B / inv_B_mu;
54 REL_TEST(_fp->rho_from_p_T(
p,
T),
rho, REL_TOL_CONSISTENCY);
55 REL_TEST(_fp->mu_from_p_T(
p,
T),
mu, REL_TOL_CONSISTENCY);
56 REL_TEST(_fp->e_from_p_T(
p,
T), _cv *
T, REL_TOL_CONSISTENCY);
57 REL_TEST(_fp->h_from_p_T(
p,
T), _cv *
T +
p /
rho, REL_TOL_CONSISTENCY);
60 REL_TEST(_fp->rho_from_p_T(
p,
T), 814.20313790256, REL_TOL_SAVED_VALUE);
61 REL_TEST(_fp->mu_from_p_T(
p,
T), 1.1341216986149e-3, REL_TOL_SAVED_VALUE);
65 _fp->rho_mu_from_p_T(
p,
T, rho2, mu2);
66 REL_TEST(rho2,
rho, REL_TOL_CONSISTENCY);
67 REL_TEST(mu2,
mu, REL_TOL_CONSISTENCY);
81 const Real inv_B = 1.0 / _B[3] + 0.5 * (1.0 / _B[3] - 1.0 / _B[2]);
83 1.0 / (_B[3] * _mu[3]) + 0.5 * (1.0 / (_B[3] * _mu[3]) - 1.0 / (_B[2] * _mu[2]));
84 REL_TEST(_fp->rho_from_p_T(
p,
T), _rho_sc * inv_B, REL_TOL_CONSISTENCY);
85 REL_TEST(_fp->mu_from_p_T(
p,
T), inv_B / inv_B_mu, REL_TOL_CONSISTENCY);
91 const Real inv_B = 1.0 / _B[0] - 0.125 * (1.0 / _B[1] - 1.0 / _B[0]);
93 1.0 / (_B[0] * _mu[0]) - 0.125 * (1.0 / (_B[1] * _mu[1]) - 1.0 / (_B[0] * _mu[0]));
94 REL_TEST(_fp->rho_from_p_T(
p,
T), _rho_sc * inv_B, REL_TOL_CONSISTENCY);
95 REL_TEST(_fp->mu_from_p_T(
p,
T), inv_B / inv_B_mu, REL_TOL_CONSISTENCY);
104 const Real
T = 350.0;
105 Real
rho, drho_dp, drho_dT,
mu, dmu_dp, dmu_dT;
107 _fp_bounds->rho_from_p_T(3.5e7,
T,
rho, drho_dp, drho_dT);
108 _fp_bounds->mu_from_p_T(3.5e7,
T,
mu, dmu_dp, dmu_dT);
109 REL_TEST(
rho, _rho_sc / _B[3], REL_TOL_CONSISTENCY);
110 REL_TEST(
mu, _mu[3], REL_TOL_CONSISTENCY);
111 ABS_TEST(drho_dp, 0.0, REL_TOL_CONSISTENCY);
112 ABS_TEST(dmu_dp, 0.0, REL_TOL_CONSISTENCY);
114 _fp_bounds->rho_from_p_T(1.0e6,
T,
rho, drho_dp, drho_dT);
115 _fp_bounds->mu_from_p_T(1.0e6,
T,
mu, dmu_dp, dmu_dT);
116 REL_TEST(
rho, _rho_sc / _B[0], REL_TOL_CONSISTENCY);
117 REL_TEST(
mu, _mu[0], REL_TOL_CONSISTENCY);
118 ABS_TEST(drho_dp, 0.0, REL_TOL_CONSISTENCY);
119 ABS_TEST(dmu_dp, 0.0, REL_TOL_CONSISTENCY);
129 const Real
T = 350.0;
130 const Real
tol = REL_TOL_DERIVATIVE;
132 for (
const Real
p : {1.0e6, 5.0e6, 1.5e7, 2.5e7, 3.5e7})
134 DERIV_TEST(_fp->rho_from_p_T,
p,
T,
tol);
135 DERIV_TEST(_fp->mu_from_p_T,
p,
T,
tol);
136 DERIV_TEST(_fp->e_from_p_T,
p,
T,
tol);
137 DERIV_TEST(_fp->h_from_p_T,
p,
T,
tol);
139 DERIV_TEST(_fp_bounds->rho_from_p_T,
p,
T,
tol);
140 DERIV_TEST(_fp_bounds->mu_from_p_T,
p,
T,
tol);
141 DERIV_TEST(_fp_bounds->h_from_p_T,
p,
T,
tol);
145 for (
const Real
p : {5.0e6, 1.5e7, 2.5e7})
147 DERIV_TEST(_fp_throw->rho_from_p_T,
p,
T,
tol);
148 DERIV_TEST(_fp_throw->mu_from_p_T,
p,
T,
tol);
149 DERIV_TEST(_fp_throw->h_from_p_T,
p,
T,
tol);
158 const Real
p = 1.5e7;
159 const Real
T = 350.0;
166 Real
rho, drho_dp, drho_dT,
mu, dmu_dp, dmu_dT;
167 _fp->rho_from_p_T(
p,
T,
rho, drho_dp, drho_dT);
168 _fp->mu_from_p_T(
p,
T,
mu, dmu_dp, dmu_dT);
170 const ADReal ad_rho = _fp->rho_from_p_T(ad_p, ad_T);
171 const ADReal ad_mu = _fp->mu_from_p_T(ad_p, ad_T);
173 REL_TEST(ad_rho.value(),
rho, REL_TOL_CONSISTENCY);
174 REL_TEST(ad_rho.derivatives()[0], drho_dp, REL_TOL_CONSISTENCY);
175 ABS_TEST(ad_rho.derivatives()[1], drho_dT, REL_TOL_CONSISTENCY);
176 REL_TEST(ad_mu.value(),
mu, REL_TOL_CONSISTENCY);
177 REL_TEST(ad_mu.derivatives()[0], dmu_dp, REL_TOL_CONSISTENCY);
178 ABS_TEST(ad_mu.derivatives()[1], dmu_dT, REL_TOL_CONSISTENCY);
187 const Real
T = 350.0;
195 EXPECT_NO_THROW(_fp_throw->rho_from_p_T(_p.front(),
T));
196 EXPECT_NO_THROW(_fp_throw->rho_from_p_T(_p.back(),
T));
200 _fp_throw->rho_from_p_T(3.5e7,
T);
201 FAIL() <<
"missing expected exception";
205 EXPECT_NE(std::string(err.what()).find(
"is outside the range of tabulated pressure"),
217 const Real
T = 350.0;
219 for (
const auto *
fp : {_fp_declare_invalid, _fp_warn_invalid})
221 Real
rho, drho_dp, drho_dT,
mu, dmu_dp, dmu_dT;
223 fp->rho_from_p_T(3.5e7,
T,
rho, drho_dp, drho_dT);
224 fp->mu_from_p_T(3.5e7,
T,
mu, dmu_dp, dmu_dT);
225 REL_TEST(
rho, _rho_sc / _B[3], REL_TOL_CONSISTENCY);
226 REL_TEST(
mu, _mu[3], REL_TOL_CONSISTENCY);
227 ABS_TEST(drho_dp, 0.0, REL_TOL_CONSISTENCY);
228 ABS_TEST(dmu_dp, 0.0, REL_TOL_CONSISTENCY);
230 fp->rho_from_p_T(1.0e6,
T,
rho, drho_dp, drho_dT);
231 fp->mu_from_p_T(1.0e6,
T,
mu, dmu_dp, dmu_dT);
232 REL_TEST(
rho, _rho_sc / _B[0], REL_TOL_CONSISTENCY);
233 REL_TEST(
mu, _mu[0], REL_TOL_CONSISTENCY);
258 _fe_problem->addUserObject(
"TabulatedPVTFluidProperties",
name, params);
259 FAIL() <<
"missing expected error: " << msg;
261 catch (
const std::exception & err)
263 EXPECT_NE(std::string(err.what()).find(msg), std::string::npos) << err.what();
269 params.
set<std::vector<Real>>(
"pressure") = {2.0e6, 1.0e7, 1.0e7, 3.0e7};
270 expect_error(params,
"non_increasing",
"Tabulated pressures must be strictly increasing");
274 params.
set<std::vector<Real>>(
"pressure") = {2.0e6};
275 params.
set<std::vector<Real>>(
"formation_volume_factor") = {1.062};
276 params.
set<std::vector<Real>>(
"viscosity") = {1.04e-3};
277 expect_error(params,
"one_point",
"At least two tabulated pressures are required");
281 params.
set<std::vector<Real>>(
"formation_volume_factor") = {1.062, 1.050, 1.038};
282 expect_error(params,
"wrong_size_B",
"Must have the same number of entries as 'pressure'");
286 params.
set<std::vector<Real>>(
"viscosity") = {1.04e-3, 1.10e-3};
287 expect_error(params,
"wrong_size_mu",
"Must have the same number of entries as 'pressure'");
291 params.
set<std::vector<Real>>(
"formation_volume_factor") = {1.062, 0.0, 1.038, 1.028};
292 expect_error(params,
"zero_B",
"All entries must be positive");
296 params.
set<std::vector<Real>>(
"viscosity") = {1.04e-3, -1.10e-3, 1.17e-3, 1.24e-3};
297 expect_error(params,
"negative_mu",
"All entries must be positive");
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)