Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
3 : //*
4 : //* All rights reserved, see COPYRIGHT for full restrictions
5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 : //*
7 : //* Licensed under LGPL 2.1, please see LICENSE for details
8 : //* https://www.gnu.org/licenses/lgpl-2.1.html
9 :
10 : #include "HeliumFluidProperties.h"
11 :
12 : registerMooseObject("FluidPropertiesApp", HeliumFluidProperties);
13 :
14 : InputParameters
15 22 : HeliumFluidProperties::validParams()
16 : {
17 22 : InputParameters params = SinglePhaseFluidProperties::validParams();
18 22 : params.addClassDescription("Fluid properties for helium");
19 22 : return params;
20 0 : }
21 :
22 11 : HeliumFluidProperties::HeliumFluidProperties(const InputParameters & parameters)
23 11 : : SinglePhaseFluidProperties(parameters), _cv(3117.0), _cp(5195.0)
24 : {
25 11 : }
26 :
27 : std::string
28 1 : HeliumFluidProperties::fluidName() const
29 : {
30 1 : return "helium";
31 : }
32 :
33 : Real
34 1 : HeliumFluidProperties::e_from_p_rho(Real p, Real rho) const
35 : {
36 : // Initial guess using ideal gas law
37 1 : Real e = p / (_cp / _cv - 1.) / rho;
38 1 : const Real v = 1. / rho;
39 :
40 : Real p_from_props, dp_dv, dp_de;
41 : const unsigned int max_its = 10;
42 : unsigned int it = 0;
43 :
44 : do
45 : {
46 2 : p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
47 : const Real & jacobian = dp_de;
48 2 : const Real residual = p_from_props - p;
49 :
50 2 : if (std::abs(residual) / p < 1e-12)
51 : break;
52 :
53 1 : const Real delta_e = -residual / jacobian;
54 1 : e += delta_e;
55 1 : } while (++it < max_its);
56 :
57 1 : if (it >= max_its)
58 0 : mooseWarning("The e_from_p_rho iteration failed to converge");
59 :
60 1 : return e;
61 : }
62 :
63 : ADReal
64 0 : HeliumFluidProperties::e_from_p_rho(const ADReal & p, const ADReal & rho) const
65 : {
66 : // Initial guess using ideal gas law
67 0 : ADReal e = p / (_cp / _cv - 1.) / rho;
68 0 : const ADReal v = 1. / rho;
69 :
70 : ADReal p_from_props, dp_dv, dp_de;
71 : const unsigned int max_its = 10;
72 : unsigned int it = 0;
73 :
74 : do
75 : {
76 0 : p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
77 : const ADReal & jacobian = dp_de;
78 : const ADReal residual = p_from_props - p;
79 :
80 0 : if (std::abs(residual.value()) / p.value() < 1e-12)
81 : break;
82 :
83 0 : const ADReal delta_e = -residual / jacobian;
84 0 : e += delta_e;
85 0 : } while (++it < max_its);
86 :
87 0 : if (it >= max_its)
88 0 : mooseWarning("The e_from_p_rho iteration failed to converge");
89 :
90 0 : return e;
91 : }
92 :
93 : Real
94 16 : HeliumFluidProperties::p_from_v_e(Real v, Real e) const
95 : {
96 16 : Real T = T_from_v_e(v, e);
97 16 : return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
98 : }
99 :
100 : ADReal
101 0 : HeliumFluidProperties::p_from_v_e(const ADReal & v, const ADReal & e) const
102 : {
103 : using std::pow;
104 0 : const ADReal T = T_from_v_e(v, e);
105 0 : return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
106 : }
107 :
108 : void
109 4 : HeliumFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
110 : {
111 4 : p = p_from_v_e(v, e);
112 :
113 : Real T, dT_dv, dT_de;
114 4 : T_from_v_e(v, e, T, dT_dv, dT_de);
115 :
116 4 : Real val = 48.14 * v - 0.4446 / std::pow(T, 0.2);
117 4 : Real dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * std::pow(T, -0.2) / (val * val);
118 :
119 4 : dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
120 4 : dp_de = dp_dT * dT_de;
121 4 : }
122 :
123 : void
124 0 : HeliumFluidProperties::p_from_v_e(
125 : const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
126 : {
127 : using std::pow;
128 0 : p = p_from_v_e(v, e);
129 :
130 : ADReal T, dT_dv, dT_de;
131 0 : T_from_v_e(v, e, T, dT_dv, dT_de);
132 :
133 0 : auto val = 48.14 * v - 0.4446 / pow(T, 0.2);
134 0 : auto dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * pow(T, -0.2) / (val * val);
135 :
136 0 : dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
137 0 : dp_de = dp_dT * dT_de;
138 0 : }
139 :
140 : Real
141 0 : HeliumFluidProperties::p_from_T_v(const Real T, const Real v) const
142 : {
143 : // Formula taken from p_from_v_e method
144 0 : return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
145 : }
146 :
147 : ADReal
148 0 : HeliumFluidProperties::p_from_T_v(const ADReal & T, const ADReal & v) const
149 : {
150 : using std::pow;
151 : // Formula taken from p_from_v_e method
152 0 : return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
153 : }
154 :
155 : Real
156 0 : HeliumFluidProperties::e_from_T_v(const Real T, const Real /*v*/) const
157 : {
158 : // Formula taken from e_from_p_T method
159 0 : return _cv * T;
160 : }
161 :
162 : void
163 0 : HeliumFluidProperties::e_from_T_v(
164 : const Real T, const Real v, Real & e, Real & de_dT, Real & de_dv) const
165 : {
166 0 : e = e_from_T_v(T, v);
167 0 : de_dT = _cv;
168 0 : de_dv = 0;
169 0 : }
170 :
171 : ADReal
172 0 : HeliumFluidProperties::e_from_T_v(const ADReal & T, const ADReal & /*v*/) const
173 : {
174 : // Formula taken from e_from_p_T method
175 0 : return _cv * T;
176 : }
177 :
178 : void
179 0 : HeliumFluidProperties::e_from_T_v(
180 : const ADReal & T, const ADReal & v, ADReal & e, ADReal & de_dT, ADReal & de_dv) const
181 : {
182 0 : e = e_from_T_v(T, v);
183 0 : de_dT = _cv;
184 0 : de_dv = 0;
185 0 : }
186 :
187 : Real
188 42 : HeliumFluidProperties::T_from_v_e(Real /*v*/, Real e) const
189 : {
190 42 : return e / _cv;
191 : }
192 :
193 : ADReal
194 0 : HeliumFluidProperties::T_from_v_e(const ADReal & /*v*/, const ADReal & e) const
195 : {
196 0 : return e / _cv;
197 : }
198 :
199 : void
200 6 : HeliumFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
201 : {
202 6 : T = T_from_v_e(v, e);
203 6 : dT_dv = 0.0;
204 6 : dT_de = 1.0 / _cv;
205 6 : }
206 :
207 : void
208 0 : HeliumFluidProperties::T_from_v_e(
209 : const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
210 : {
211 0 : T = SinglePhaseFluidProperties::T_from_v_e(v, e);
212 0 : dT_dv = 0.0;
213 0 : dT_de = 1.0 / _cv;
214 0 : }
215 :
216 : Real
217 1 : HeliumFluidProperties::T_from_p_h(Real /* p */, Real h) const
218 : {
219 1 : return h / _cp;
220 : }
221 :
222 : ADReal
223 0 : HeliumFluidProperties::T_from_p_h(const ADReal & /* p */, const ADReal & h) const
224 : {
225 0 : return h / _cp;
226 : }
227 :
228 : Real
229 0 : HeliumFluidProperties::c_from_v_e(Real v, Real e) const
230 : {
231 0 : Real p = p_from_v_e(v, e);
232 0 : Real T = T_from_v_e(v, e);
233 :
234 : Real rho, drho_dp, drho_dT;
235 0 : rho_from_p_T(p, T, rho, drho_dp, drho_dT);
236 :
237 0 : Real c2 = -(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT);
238 0 : return std::sqrt(c2);
239 : }
240 :
241 : void
242 0 : HeliumFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
243 : {
244 : using std::sqrt;
245 :
246 0 : ADReal myv = v;
247 : Moose::derivInsert(myv.derivatives(), 0, 1);
248 : Moose::derivInsert(myv.derivatives(), 1, 0);
249 0 : ADReal mye = e;
250 : Moose::derivInsert(mye.derivatives(), 0, 0);
251 : Moose::derivInsert(mye.derivatives(), 1, 1);
252 :
253 0 : auto p = SinglePhaseFluidProperties::p_from_v_e(myv, mye);
254 0 : auto T = SinglePhaseFluidProperties::T_from_v_e(myv, mye);
255 :
256 : ADReal rho, drho_dp, drho_dT;
257 0 : rho_from_p_T(p, T, rho, drho_dp, drho_dT);
258 :
259 0 : auto cc = sqrt(-(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT));
260 0 : c = cc.value();
261 0 : dc_dv = cc.derivatives()[0];
262 0 : dc_de = cc.derivatives()[1];
263 0 : }
264 :
265 : Real
266 7 : HeliumFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const
267 : {
268 7 : return _cp;
269 : }
270 :
271 : void
272 1 : HeliumFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
273 : {
274 1 : cp = cp_from_v_e(v, e);
275 1 : dcp_dv = 0.0;
276 1 : dcp_de = 0.0;
277 1 : }
278 :
279 : Real
280 7 : HeliumFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const
281 : {
282 7 : return _cv;
283 : }
284 :
285 : void
286 1 : HeliumFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
287 : {
288 1 : cv = cv_from_v_e(v, e);
289 1 : dcv_dv = 0.0;
290 1 : dcv_de = 0.0;
291 1 : }
292 :
293 : Real
294 7 : HeliumFluidProperties::mu_from_v_e(Real v, Real e) const
295 : {
296 7 : return 3.674e-7 * std::pow(T_from_v_e(v, e), 0.7);
297 : }
298 :
299 : void
300 1 : HeliumFluidProperties::mu_from_v_e(Real v, Real e, Real & mu, Real & dmu_dv, Real & dmu_de) const
301 : {
302 1 : mu = mu_from_v_e(v, e);
303 1 : const Real dmu_dT = 0.7 * 3.674e-7 * std::pow(T_from_v_e(v, e), -0.3);
304 1 : dmu_dv = 0.0; // dmu_dp = 0, dT_dv is zero
305 1 : dmu_de = dmu_dT / _cv; // dmu_dp = 0
306 1 : }
307 :
308 : Real
309 6 : HeliumFluidProperties::k_from_v_e(Real v, Real e) const
310 : {
311 6 : Real p_in_bar = p_from_v_e(v, e) * 1.0e-5;
312 6 : Real T = T_from_v_e(v, e);
313 6 : return 2.682e-3 * (1.0 + 1.123e-3 * p_in_bar) * std::pow(T, 0.71 * (1.0 - 2.0e-4 * p_in_bar));
314 : }
315 :
316 : void
317 1 : HeliumFluidProperties::k_from_v_e(Real v, Real e, Real & k, Real & dk_dv, Real & dk_de) const
318 : {
319 1 : Real T = 0., p = 0., dT_dv = 0., dT_de = 0., dp_dv = 0., dp_de = 0.;
320 1 : T_from_v_e(v, e, T, dT_dv, dT_de);
321 1 : p_from_v_e(v, e, p, dp_dv, dp_de);
322 :
323 : // b and d scaled by 1e-5 to account for conversion to bar
324 : constexpr Real a = 2.682e-3;
325 : constexpr Real b = 1.123e-8;
326 : constexpr Real c = 0.71;
327 : constexpr Real d = 2.0e-9;
328 :
329 1 : k = a * (1.0 + b * p) * std::pow(T, c * (1.0 - d * p));
330 1 : Real dk_dT = a * c * (1.0 + b * p) * (1.0 - d * p) * std::pow(T, c * (1.0 - d * p) - 1.0);
331 1 : Real dk_dp = a * std::pow(T, c * (1.0 - d * p)) * (b - c * d * (1 + b * p) * std::log(T));
332 :
333 1 : dk_dv = dk_dp * dp_dv; // dT_dv is zero
334 1 : dk_de = dk_dT * dT_de + dk_dp * dp_de;
335 1 : }
336 :
337 : Real
338 0 : HeliumFluidProperties::beta_from_p_T(Real pressure, Real temperature) const
339 : {
340 : Real rho;
341 : Real drho_dT;
342 : Real drho_dp;
343 0 : rho_from_p_T(pressure, temperature, rho, drho_dp, drho_dT);
344 :
345 0 : return -drho_dT / rho;
346 : }
347 :
348 : Real
349 14 : HeliumFluidProperties::rho_from_p_T(Real pressure, Real temperature) const
350 : {
351 14 : Real p_in_bar = pressure * 1.0e-5;
352 14 : return 48.14 * p_in_bar / (temperature + 0.4446 * p_in_bar / std::pow(temperature, 0.2));
353 : }
354 :
355 : void
356 1 : HeliumFluidProperties::rho_from_p_T(
357 : Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
358 : {
359 1 : rho = rho_from_p_T(pressure, temperature);
360 1 : Real val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2));
361 1 : drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / std::pow(temperature, 0.2));
362 1 : drho_dT =
363 1 : -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / std::pow(temperature, 1.2));
364 1 : }
365 :
366 : void
367 0 : HeliumFluidProperties::rho_from_p_T(const ADReal & pressure,
368 : const ADReal & temperature,
369 : ADReal & rho,
370 : ADReal & drho_dp,
371 : ADReal & drho_dT) const
372 : {
373 : using std::pow;
374 0 : rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
375 0 : auto val = 1.0 / (temperature + 0.4446e-5 * pressure / pow(temperature, 0.2));
376 0 : drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / pow(temperature, 0.2));
377 : drho_dT =
378 0 : -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / pow(temperature, 1.2));
379 0 : }
380 :
381 : Real
382 13 : HeliumFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
383 : {
384 13 : return _cv * temperature;
385 : }
386 :
387 : void
388 1 : HeliumFluidProperties::e_from_p_T(
389 : Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
390 : {
391 1 : e = e_from_p_T(pressure, temperature);
392 1 : de_dp = 0.0;
393 1 : de_dT = _cv;
394 1 : }
395 :
396 : Real
397 7 : HeliumFluidProperties::e_from_v_h(Real /*v*/, Real h) const
398 : {
399 7 : return _cv * (h / _cp);
400 : }
401 :
402 : void
403 1 : HeliumFluidProperties::e_from_v_h(Real v, Real h, Real & e, Real & de_dv, Real & de_dh) const
404 : {
405 1 : e = e_from_v_h(v, h);
406 1 : de_dv = 0.;
407 1 : de_dh = _cv / _cp;
408 1 : }
409 :
410 : Real
411 16 : HeliumFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
412 : {
413 16 : return _cp * temperature;
414 : }
415 :
416 : void
417 3 : HeliumFluidProperties::h_from_p_T(
418 : Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
419 : {
420 3 : h = h_from_p_T(pressure, temperature);
421 3 : dh_dp = 0.0;
422 3 : dh_dT = _cp;
423 3 : }
424 :
425 : void
426 1 : HeliumFluidProperties::h_from_p_T(const ADReal & /*pressure*/,
427 : const ADReal & temperature,
428 : ADReal & h,
429 : ADReal & dh_dp,
430 : ADReal & dh_dT) const
431 : {
432 2 : h = _cp * temperature;
433 1 : dh_dp = 0.0;
434 1 : dh_dT = _cp;
435 1 : }
436 :
437 : Real
438 1 : HeliumFluidProperties::molarMass() const
439 : {
440 1 : return 4.002602e-3;
441 : }
442 :
443 : Real
444 7 : HeliumFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
445 : {
446 7 : return _cp;
447 : }
448 :
449 : void
450 1 : HeliumFluidProperties::cp_from_p_T(
451 : Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
452 : {
453 1 : cp = cp_from_p_T(pressure, temperature);
454 1 : dcp_dp = 0.0;
455 1 : dcp_dT = 0.0;
456 1 : }
457 :
458 : Real
459 7 : HeliumFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
460 : {
461 7 : return _cv;
462 : }
463 :
464 : void
465 1 : HeliumFluidProperties::cv_from_p_T(
466 : Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
467 : {
468 1 : cv = cv_from_p_T(pressure, temperature);
469 1 : dcv_dp = 0.0;
470 1 : dcv_dT = 0.0;
471 1 : }
472 :
473 : Real
474 7 : HeliumFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
475 : {
476 7 : return 3.674e-7 * std::pow(temperature, 0.7);
477 : }
478 :
479 : void
480 1 : HeliumFluidProperties::mu_from_p_T(
481 : Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
482 : {
483 1 : mu = mu_from_p_T(pressure, temperature);
484 1 : dmu_dp = 0.0;
485 1 : dmu_dT = 3.674e-7 * 0.7 * std::pow(temperature, -0.3);
486 1 : }
487 :
488 : Real
489 7 : HeliumFluidProperties::k_from_p_T(Real pressure, Real temperature) const
490 : {
491 7 : return 2.682e-3 * (1.0 + 1.123e-8 * pressure) *
492 7 : std::pow(temperature, 0.71 * (1.0 - 2.0e-9 * pressure));
493 : }
494 :
495 : void
496 1 : HeliumFluidProperties::k_from_p_T(
497 : Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
498 : {
499 1 : k = k_from_p_T(pressure, temperature);
500 :
501 1 : Real term = 1.0 + 1.123e-8 * pressure;
502 1 : Real exp = 0.71 * (1.0 - 2.0e-9 * pressure);
503 :
504 1 : dk_dp = 2.682e-3 * (term * 0.71 * (-2.0e-9) * std::log(temperature) * std::pow(temperature, exp) +
505 1 : std::pow(temperature, exp) * 1.123e-8);
506 :
507 1 : dk_dT = 2.682e-3 * term * exp * std::pow(temperature, exp - 1.0);
508 1 : }
|