https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FluidPropertiesInterrogator.C
Go to the documentation of this file.
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
11#include "FluidProperties.h"
17
19
22{
24 params.addRequiredParam<UserObjectName>("fp",
25 "The name of the fluid properties object to query.");
26 params.addParam<bool>("json", false, "Output in JSON format");
27 params.addParam<Real>("rho", "Density");
28 params.addParam<Real>("rhou", "Momentum density; rho * u");
29 params.addParam<Real>("rhoE", "Total energy density; rho * E");
30 params.addParam<Real>("e", "Specific internal energy");
31 params.addParam<Real>("p", "Pressure");
32 params.addParam<Real>("T", "Temperature");
33 params.addParam<Real>("vel", "Velocity");
34 params.addParam<std::vector<Real>>("x_ncg", "Mass fractions of NCGs");
35 params.addRequiredParam<unsigned int>("precision", "Precision for printing values");
36
38 "User object for querying a single-phase or two-phase fluid properties object");
39
40 return params;
41}
42
44 : GeneralUserObject(parameters),
45 _json(getParam<bool>("json")),
46 _fp(&getUserObject<FluidProperties>("fp")),
47 _fp_1phase(dynamic_cast<const SinglePhaseFluidProperties * const>(_fp)),
48 _fp_2phase(dynamic_cast<const TwoPhaseFluidProperties * const>(_fp)),
49 _fp_2phase_ncg(dynamic_cast<const TwoPhaseNCGFluidProperties * const>(_fp)),
50 _fp_2phase_ncg_partial_pressure(
51 dynamic_cast<const TwoPhaseNCGPartialPressureFluidProperties * const>(_fp)),
52 _has_1phase(_fp_1phase),
53 _has_vapor_mixture(dynamic_cast<const VaporMixtureFluidProperties * const>(_fp)),
54 _has_2phase(_fp_2phase),
55 _has_2phase_ncg(_fp_2phase_ncg),
56 _has_2phase_ncg_partial_pressure(_fp_2phase_ncg_partial_pressure),
57 _fp_liquid(_has_2phase
58 ? &getUserObjectByName<SinglePhaseFluidProperties>(_fp_2phase->getLiquidName())
59 : nullptr),
60 _fp_vapor(_has_2phase
61 ? &getUserObjectByName<SinglePhaseFluidProperties>(_fp_2phase->getVaporName())
62 : nullptr),
63 _fp_vapor_mixture(_has_vapor_mixture
64 ? dynamic_cast<const VaporMixtureFluidProperties * const>(_fp)
65 : (_has_2phase_ncg ? &getUserObjectByName<VaporMixtureFluidProperties>(
66 _fp_2phase_ncg->getVaporMixtureName())
67 : nullptr)),
68 _nan_encountered(false),
69 _precision(getParam<unsigned int>("precision"))
70{
73 "The type of the parameter 'fp' must be derived from type 'SinglePhaseFluidProperties', "
74 "'VaporMixtureFluidProperties', or 'TwoPhaseFluidProperties'.");
75}
76
77void
81
82void
84{
86 {
87 InputParameters pars_2phase = compute2Phase();
88 InputParameters pars_liquid = compute1Phase(_fp_liquid, false);
89 InputParameters pars_mixture = computeVaporMixture(false);
90
91 if (_json)
92 {
93 nlohmann::json json;
94
95 auto & json_2phase = json["2-phase"];
96 buildJSON2Phase(json_2phase, pars_2phase);
97 auto & json_liquid = json["liquid"];
98 buildJSON1Phase(json_liquid, pars_liquid);
99 auto & json_mixture = json["vapor-mixture"];
100 buildJSONVaporMixture(json_mixture, pars_mixture);
101
102 Moose::out << "**START JSON DATA**\n";
103 Moose::out << json << "\n";
104 Moose::out << "**END JSON DATA**" << std::endl;
105 }
106 else
107 {
108 outputASCII2Phase(pars_2phase);
109 outputASCII1Phase("LIQUID phase", pars_liquid);
110 outputASCIIVaporMixture(pars_mixture);
111 }
112 }
113 else if (_has_2phase)
114 {
115 InputParameters pars_2phase = compute2Phase();
116 InputParameters pars_liquid = compute1Phase(_fp_liquid, false);
117 InputParameters pars_vapor = compute1Phase(_fp_vapor, false);
118
119 if (_json)
120 {
121 nlohmann::json json;
122
123 auto & json_2phase = json["2-phase"];
124 buildJSON2Phase(json_2phase, pars_2phase);
125 if (pars_liquid.have_parameter<bool>("specified"))
126 {
127 auto & json_liquid = json["liquid"];
128 buildJSON1Phase(json_liquid, pars_liquid);
129 }
130 if (pars_vapor.have_parameter<bool>("specified"))
131 {
132 auto & json_vapor = json["vapor"];
133 buildJSON1Phase(json_vapor, pars_vapor);
134 }
135
136 Moose::out << "**START JSON DATA**\n";
137 Moose::out << json << "\n";
138 Moose::out << "**END JSON DATA**" << std::endl;
139 }
140 else
141 {
142 outputASCII2Phase(pars_2phase);
143 if (pars_liquid.have_parameter<bool>("specified"))
144 outputASCII1Phase("LIQUID phase", pars_liquid);
145 if (pars_vapor.have_parameter<bool>("specified"))
146 outputASCII1Phase("VAPOR phase", pars_vapor);
147 }
148 }
149 else if (_has_vapor_mixture)
150 {
151 InputParameters pars_mixture = computeVaporMixture(true);
152 if (_json)
153 {
154 nlohmann::json json;
155 buildJSONVaporMixture(json, pars_mixture);
156
157 Moose::out << "**START JSON DATA**\n";
158 Moose::out << json << "\n";
159 Moose::out << "**END JSON DATA**" << std::endl;
160 }
161 else
162 outputASCIIVaporMixture(pars_mixture);
163 }
164 else
165 {
166 InputParameters pars_1phase = compute1Phase(_fp_1phase, true);
167
168 if (_json)
169 {
170 nlohmann::json json;
171
172 buildJSON1Phase(json, pars_1phase);
173
174 Moose::out << "**START JSON DATA**\n";
175 Moose::out << json << "\n";
176 Moose::out << "**END JSON DATA**" << std::endl;
177 }
178 else
179 outputASCII1Phase("Single-phase", pars_1phase);
180 }
181}
182
183void
187
190 bool throw_error_if_no_match)
191{
193
194 // reset NaN flag
195 _nan_encountered = false;
196
197 // determine how state is specified
198 std::vector<std::vector<std::string>> parameter_sets = {{"p", "T"}, {"rho", "e"}, {"rho", "p"}};
199 if (_has_1phase)
200 parameter_sets.push_back({"rho", "rhou", "rhoE"});
201 auto specified = getSpecifiedSetMap(parameter_sets, "one-phase", throw_error_if_no_match);
202
203 // compute/determine rho, e, p, T, vel
204
205 Real rho, e, p, T, vel = 0;
206 bool specified_a_set = false;
207 if (specified["rho,e"])
208 {
209 rho = getParam<Real>("rho");
210 e = getParam<Real>("e");
211 const Real v = 1.0 / rho;
212 p = fp_1phase->p_from_v_e(v, e);
213 T = fp_1phase->T_from_v_e(v, e);
214 if (isParamValid("vel"))
215 vel = getParam<Real>("vel");
216
217 specified_a_set = true;
218 }
219 else if (specified["rho,p"])
220 {
221 rho = getParam<Real>("rho");
222 p = getParam<Real>("p");
223 const Real v = 1.0 / rho;
224 e = fp_1phase->e_from_p_rho(p, rho);
225 T = fp_1phase->T_from_v_e(v, e);
226 if (isParamValid("vel"))
227 vel = getParam<Real>("vel");
228
229 specified_a_set = true;
230 }
231 else if (specified["p,T"])
232 {
233 p = getParam<Real>("p");
234 T = getParam<Real>("T");
235 rho = fp_1phase->rho_from_p_T(p, T);
236 e = fp_1phase->e_from_p_rho(p, rho);
237 if (isParamValid("vel"))
238 vel = getParam<Real>("vel");
239
240 specified_a_set = true;
241 }
242 else if (specified["rho,rhou,rhoE"])
243 {
244 rho = getParam<Real>("rho");
245 const Real rhou = getParam<Real>("rhou");
246 const Real rhoE = getParam<Real>("rhoE");
247
248 vel = rhou / rho;
249 const Real E = rhoE / rho;
250 e = E - 0.5 * vel * vel;
251
252 const Real v = 1.0 / rho;
253 p = fp_1phase->p_from_v_e(v, e);
254 T = fp_1phase->T_from_v_e(v, e);
255
256 specified_a_set = true;
257 }
258
259 if (specified_a_set)
260 {
261 params.set<bool>("specified") = true;
262
263 const Real v = 1.0 / rho;
264
265 params.set<Real>("rho") = rho;
266 params.set<Real>("e") = e;
267 params.set<Real>("p") = p;
268 params.set<Real>("T") = T;
269 params.set<Real>("v") = v;
270 params.set<Real>("h") = fp_1phase->h_from_p_T(p, T);
271 params.set<Real>("s") = fp_1phase->s_from_v_e(v, e);
272 params.set<Real>("c") = fp_1phase->c_from_v_e(v, e);
273 params.set<Real>("mu") = fp_1phase->mu_from_v_e(v, e);
274 params.set<Real>("cp") = fp_1phase->cp_from_v_e(v, e);
275 params.set<Real>("cv") = fp_1phase->cv_from_v_e(v, e);
276 params.set<Real>("k") = fp_1phase->k_from_v_e(v, e);
277 params.set<Real>("beta") = fp_1phase->beta_from_p_T(p, T);
278
279 if (isParamValid("vel") || specified["rho,rhou,rhoE"])
280 {
281 const Real s = fp_1phase->s_from_v_e(v, e);
282 const Real s0 = s;
283 const Real h = fp_1phase->h_from_p_T(p, T);
284 const Real h0 = h + 0.5 * vel * vel;
285 const Real p0 = fp_1phase->p_from_h_s(h0, s0);
286 const Real rho0 = fp_1phase->rho_from_p_s(p0, s0);
287 const Real e0 = fp_1phase->e_from_p_rho(p0, rho0);
288 const Real v0 = 1.0 / rho0;
289 const Real T0 = fp_1phase->T_from_v_e(v0, e0);
290 const Real c0 = fp_1phase->c_from_v_e(v0, e0);
291 const Real mu0 = fp_1phase->mu_from_v_e(v0, e0);
292 const Real cp0 = fp_1phase->cp_from_v_e(v0, e0);
293 const Real cv0 = fp_1phase->cv_from_v_e(v0, e0);
294 const Real k0 = fp_1phase->k_from_v_e(v0, e0);
295 const Real beta0 = fp_1phase->beta_from_p_T(p0, T0);
296
297 params.set<Real>("vel") = vel;
298 params.set<Real>("rho0") = rho0;
299 params.set<Real>("s0") = s0;
300 params.set<Real>("v0") = v0;
301 params.set<Real>("e0") = e0;
302 params.set<Real>("h0") = h0;
303 params.set<Real>("p0") = p0;
304 params.set<Real>("T0") = T0;
305 params.set<Real>("c0") = c0;
306 params.set<Real>("mu0") = mu0;
307 params.set<Real>("cp0") = cp0;
308 params.set<Real>("cv0") = cv0;
309 params.set<Real>("k0") = k0;
310 params.set<Real>("beta0") = beta0;
311 }
312
313 // warn if NaN encountered
316 "At least one NaN was encountered. This implies one of the following:\n",
317 " 1. The specified thermodynamic state is inconsistent with the equation of state\n",
318 " (for example, the state corresponds to a different phase of the fluid).\n",
319 " 2. There is a problem with the equation of state package at this state\n",
320 " (for example, the supplied state is outside of the valid state space\n",
321 " that was programmed in the package).");
322 }
323
324 return params;
325}
326
329{
331
332 // reset NaN flag
333 _nan_encountered = false;
334
335 // determine how state is specified
336 std::vector<std::vector<std::string>> parameter_sets = {{"p", "T"}, {"p"}, {"T"}};
337 auto specified = getSpecifiedSetMap(parameter_sets, "two-phase", true);
338
339 const Real p_critical = _fp_2phase->p_critical();
340 params.set<Real>("p_critical") = p_critical;
341 if (specified["p"])
342 {
343 const Real p = getParam<Real>("p");
344 const Real T_sat = _fp_2phase->T_sat(p);
345 const Real h_lat = _fp_2phase->h_lat(p, T_sat);
346
347 params.set<Real>("p") = p;
348 params.set<Real>("T_sat") = T_sat;
349 params.set<Real>("h_lat") = h_lat;
350 }
351 else if (specified["T"])
352 {
353 const Real T = getParam<Real>("T");
354 const Real p_sat = _fp_2phase->p_sat(T);
355 const Real h_lat = _fp_2phase->h_lat(p_sat, T);
356 const Real sigma = _fp_2phase->sigma_from_T(T);
357
358 params.set<Real>("T") = T;
359 params.set<Real>("p_sat") = p_sat;
360 params.set<Real>("h_lat") = h_lat;
361 params.set<Real>("sigma") = sigma;
362 }
363 else if (specified["p,T"])
364 {
365 const Real p = getParam<Real>("p");
366 const Real T = getParam<Real>("T");
367 const Real h_lat = _fp_2phase->h_lat(p, T);
368
369 params.set<Real>("p") = p;
370 params.set<Real>("T") = T;
371 params.set<Real>("h_lat") = h_lat;
372 }
373
374 // warn if NaN encountered
376 mooseWarning("At least one NaN was encountered.");
377
378 return params;
379}
380
383{
385
386 // reset NaN flag
387 _nan_encountered = false;
388
389 // determine how state is specified
390 std::vector<std::vector<std::string>> parameter_sets = {
391 {"p", "T", "x_ncg"}, {"rho", "e", "x_ncg"}, {"rho", "rhou", "rhoE", "x_ncg"}};
393 parameter_sets.push_back({"p", "T"});
394 auto specified = getSpecifiedSetMap(parameter_sets, "vapor mixture", throw_error_if_no_match);
395
396 // compute/determine rho, e, p, T, vel
397
398 Real rho, e, p, T, vel = 0;
399 std::vector<Real> x_ncg;
400 bool specified_a_set = false;
401 if (specified["rho,e,x_ncg"])
402 {
403 rho = getParam<Real>("rho");
404 e = getParam<Real>("e");
405 x_ncg = getParam<std::vector<Real>>("x_ncg");
406 const Real v = 1.0 / rho;
407 p = _fp_vapor_mixture->p_from_v_e(v, e, x_ncg);
408 T = _fp_vapor_mixture->T_from_v_e(v, e, x_ncg);
409 if (isParamValid("vel"))
410 vel = getParam<Real>("vel");
411
412 specified_a_set = true;
413 }
414 else if (specified["p,T,x_ncg"])
415 {
416 p = getParam<Real>("p");
417 T = getParam<Real>("T");
418 x_ncg = getParam<std::vector<Real>>("x_ncg");
419 const Real v = _fp_vapor_mixture->v_from_p_T(p, T, x_ncg);
420 rho = 1.0 / v;
421 e = _fp_vapor_mixture->e_from_p_T(p, T, x_ncg);
422 if (isParamValid("vel"))
423 vel = getParam<Real>("vel");
424
425 specified_a_set = true;
426 }
427 else if (_has_2phase_ncg_partial_pressure && specified["p,T"])
428 {
429 p = getParam<Real>("p");
430 T = getParam<Real>("T");
432 const Real v = _fp_vapor_mixture->v_from_p_T(p, T, x_ncg);
433 rho = 1.0 / v;
434 e = _fp_vapor_mixture->e_from_p_T(p, T, x_ncg);
435 if (isParamValid("vel"))
436 vel = getParam<Real>("vel");
437
438 specified_a_set = true;
439 }
440 else if (specified["rho,rhou,rhoE,x_ncg"])
441 {
442 rho = getParam<Real>("rho");
443 const Real rhou = getParam<Real>("rhou");
444 const Real rhoE = getParam<Real>("rhoE");
445 x_ncg = getParam<std::vector<Real>>("x_ncg");
446
447 vel = rhou / rho;
448 const Real E = rhoE / rho;
449 e = E - 0.5 * vel * vel;
450
451 const Real v = 1.0 / rho;
452 p = _fp_vapor_mixture->p_from_v_e(v, e, x_ncg);
453 T = _fp_vapor_mixture->T_from_v_e(v, e, x_ncg);
454
455 specified_a_set = true;
456 }
457
458 if (specified_a_set)
459 {
460 params.set<bool>("specified") = true;
461
462 const Real v = 1.0 / rho;
463 const Real h = e + p / rho;
464 const Real s = _fp_vapor_mixture->s_from_p_T(p, T, x_ncg);
465 const Real c = _fp_vapor_mixture->c_from_p_T(p, T, x_ncg);
466 const Real mu = _fp_vapor_mixture->mu_from_p_T(p, T, x_ncg);
467 const Real cp = _fp_vapor_mixture->cp_from_p_T(p, T, x_ncg);
468 const Real cv = _fp_vapor_mixture->cv_from_p_T(p, T, x_ncg);
469 const Real k = _fp_vapor_mixture->k_from_p_T(p, T, x_ncg);
470
471 params.set<std::vector<Real>>("x_ncg") = x_ncg;
472 params.set<Real>("p") = p;
473 params.set<Real>("T") = T;
474 params.set<Real>("rho") = rho;
475 params.set<Real>("e") = e;
476 params.set<Real>("v") = v;
477 params.set<Real>("h") = h;
478 params.set<Real>("s") = s;
479 params.set<Real>("c") = c;
480 params.set<Real>("mu") = mu;
481 params.set<Real>("cp") = cp;
482 params.set<Real>("cv") = cv;
483 params.set<Real>("k") = k;
484
485 if (isParamValid("vel") || specified["rho,rhou,rhoE,x_ncg"])
486 {
487 const Real h = e + p / rho;
488 const Real h0 = h + 0.5 * vel * vel;
489
490 params.set<Real>("h0") = h0;
491 }
492
493 // warn if NaN encountered
496 "At least one NaN was encountered. This implies one of the following:\n",
497 " 1. The specified thermodynamic state is inconsistent with the equation of state\n",
498 " (for example, the state corresponds to a different phase of the fluid).\n",
499 " 2. There is a problem with the equation of state package at this state\n",
500 " (for example, the supplied state is outside of the valid state space\n",
501 " that was programmed in the package).");
502 }
503
504 return params;
505}
506
507void
509{
510 for (auto p : {"rho", "e", "p", "T", "v", "h", "s", "c", "mu", "cp", "cv", "k", "beta"})
511 json["static"][p] = params.get<Real>(p);
512
513 if (params.have_parameter<Real>("vel"))
514 for (auto p : {"vel",
515 "rho0",
516 "s0",
517 "v0",
518 "e0",
519 "h0",
520 "p0",
521 "T0",
522 "c0",
523 "mu0",
524 "cp0",
525 "cv0",
526 "k0",
527 "beta0"})
528 json["stagnation"][p] = params.get<Real>(p);
529}
530
531void
533{
534 json["p_critical"] = params.get<Real>("p_critical");
535 for (auto p : {"T_sat", "p_sat", "h_lat", "sigma"})
536 if (params.have_parameter<Real>(p))
537 json[p] = params.get<Real>(p);
538}
539
540void
542 const InputParameters & params)
543{
544 for (auto p : {"p", "T", "rho", "e", "v", "h", "s", "c", "mu", "cp", "cv", "k"})
545 if (params.have_parameter<Real>(p))
546 json["static"][p] = params.get<Real>(p);
547
548 if (params.have_parameter<Real>("vel"))
549 json["stagnation"]["h0"] = params.get<Real>("h0");
550}
551
552void
554 const InputParameters & params)
555{
556 // output static property values
557 outputHeader(description + " STATIC properties");
559
560 // output stagnation property values
561 if (params.have_parameter<Real>("vel"))
562 {
563 outputHeader(description + " STAGNATION properties");
565 }
566}
567
568void
570{
571 outputHeader("TWO-PHASE properties");
572 outputProperty("Critical pressure", params.get<Real>("p_critical"), "Pa");
573 if (params.have_parameter<Real>("T_sat"))
574 outputProperty("Saturation temperature", params.get<Real>("T_sat"), "K");
575 if (params.have_parameter<Real>("p_sat"))
576 outputProperty("Saturation pressure", params.get<Real>("p_sat"), "Pa");
577 if (params.have_parameter<Real>("h_lat"))
578 outputProperty("Latent heat of vaporization", params.get<Real>("h_lat"), "J/kg");
579 if (params.have_parameter<Real>("sigma"))
580 outputProperty("Surface tension", params.get<Real>("sigma"), "N/m");
581 _console << std::endl;
582}
583
584void
586{
587 // output static property values
588 outputHeader("Vapor mixture STATIC properties");
590
591 // output stagnation property values
592 if (params.have_parameter<Real>("vel"))
593 {
594 outputHeader("Vapor mixture STAGNATION properties");
596 }
597}
598
599std::map<std::string, bool>
601 const std::vector<std::vector<std::string>> & parameter_sets,
602 const std::string & fp_type,
603 bool throw_error_if_no_match) const
604{
605 // get union of parameters from all sets
606 std::vector<std::string> parameter_union;
607 for (auto & parameter_set : parameter_sets)
608 parameter_union.insert(parameter_union.end(), parameter_set.begin(), parameter_set.end());
609 std::sort(parameter_union.begin(), parameter_union.end());
610 parameter_union.erase(std::unique(parameter_union.begin(), parameter_union.end()),
611 parameter_union.end());
612
613 std::vector<std::string> parameter_set_names;
614 std::map<std::string, bool> specified;
615 bool specified_a_set = false;
616 for (const auto & parameter_set : parameter_sets)
617 {
618 // create unique string to identify parameter set
619 std::stringstream ss;
620 for (unsigned int i = 0; i < parameter_set.size(); i++)
621 if (i == 0)
622 ss << parameter_set[i];
623 else
624 ss << "," << parameter_set[i];
625 const std::string parameter_set_name = ss.str();
626 parameter_set_names.push_back(parameter_set_name);
627
628 // check if the set parameters were provided
629 bool all_parameters_provided = true;
630 for (const auto & parameter : parameter_set)
631 if (!isParamValid(parameter))
632 all_parameters_provided = false;
633
634 if (all_parameters_provided)
635 {
636 // exclude set if a superset (assumed to be ordered before this set) was specified
637 if (!specified_a_set)
638 {
639 specified[parameter_set_name] = true;
640
641 // check that there are no extraneous parameters
642 std::vector<std::string> parameter_set_sorted(parameter_set);
643 std::sort(parameter_set_sorted.begin(), parameter_set_sorted.end());
644 std::vector<std::string> extraneous_parameters;
645 std::set_difference(parameter_union.begin(),
646 parameter_union.end(),
647 parameter_set_sorted.begin(),
648 parameter_set_sorted.end(),
649 std::inserter(extraneous_parameters, extraneous_parameters.end()));
650 for (const auto & parameter : extraneous_parameters)
651 if (isParamValid(parameter))
652 mooseError("(",
653 parameter_set_name,
654 ") has been specified; ",
655 parameter,
656 " cannot be specified.");
657 }
658
659 specified_a_set = true;
660 }
661 else
662 specified[parameter_set_name] = false;
663 }
664
665 if (!specified_a_set && throw_error_if_no_match)
666 {
667 std::stringstream ss;
668 ss << "For " << fp_type
669 << " fluid properties, you must provide one of the following\n"
670 "combinations of thermodynamic properties:\n";
671 for (const auto & parameter_set_name : parameter_set_names)
672 ss << " * (" << parameter_set_name << ")\n";
673 mooseError(ss.str());
674 }
675
676 return specified;
677}
678
679void
680FluidPropertiesInterrogator::outputHeader(const std::string & header) const
681{
682 _console << std::endl
683 << std::endl
684 << header << ":" << std::endl
685 << std::setfill('-') << std::setw(80) << "-" << std::setfill(' ') << std::endl;
686}
687
688void
690 const Real & value,
691 const std::string & units)
692{
693 const bool use_scientific_notation = ((value < 0.001) || (value >= 10000.0));
694
695 // check for NaN value
696 const bool is_nan = value != value;
697 if (is_nan)
698 _nan_encountered = true;
699
700 const std::string units_printed = is_nan ? "" : units;
701
702 // The console output is not used directly because there is no way to reset
703 // format flags. For example, if scientific format is used, there is no way
704 // to restore the general format (not fixed format); for cout, there are
705 // methods to save and restore format flags, but Console does not provide these.
706 std::stringstream ss;
707
708 if (use_scientific_notation)
709 ss << std::setw(35) << std::left << name + ":" << std::setw(_precision + 10) << std::right
710 << std::setprecision(_precision) << std::scientific << value << " " << units_printed
711 << std::endl;
712 else
713 ss << std::setw(35) << std::left << name + ":" << std::setw(_precision + 10) << std::right
714 << std::setprecision(_precision) << value << " " << units_printed << std::endl;
715
716 _console << ss.str();
717}
718
719void
721{
722 outputProperty("Pressure", params.get<Real>("p"), "Pa");
723 outputProperty("Temperature", params.get<Real>("T"), "K");
724 outputProperty("Density", params.get<Real>("rho"), "kg/m^3");
725 outputProperty("Specific volume", params.get<Real>("v"), "m^3/kg");
726 outputProperty("Specific internal energy", params.get<Real>("e"), "J/kg");
727 outputProperty("Specific enthalpy", params.get<Real>("h"), "J/kg");
728 outputProperty("Specific entropy", params.get<Real>("s"), "J/(kg-K)");
729 _console << std::endl;
730 outputProperty("Sound speed", params.get<Real>("c"), "m/s");
731 outputProperty("Dynamic viscosity", params.get<Real>("mu"), "Pa-s");
732 outputProperty("Specific heat at constant pressure", params.get<Real>("cp"), "J/(kg-K)");
733 outputProperty("Specific heat at constant volume", params.get<Real>("cv"), "J/(kg-K)");
734 outputProperty("Thermal conductivity", params.get<Real>("k"), "W/(m-K)");
735 outputProperty("Volumetric expansion coefficient", params.get<Real>("beta"), "1/K");
736 _console << std::endl;
737}
738
739void
741{
742 outputProperty("Pressure", params.get<Real>("p0"), "Pa");
743 outputProperty("Temperature", params.get<Real>("T0"), "K");
744 outputProperty("Density", params.get<Real>("rho0"), "kg/m^3");
745 outputProperty("Specific volume", params.get<Real>("v0"), "m^3/kg");
746 outputProperty("Specific internal energy", params.get<Real>("e0"), "J/kg");
747 outputProperty("Specific enthalpy", params.get<Real>("h0"), "J/kg");
748 outputProperty("Specific entropy", params.get<Real>("s0"), "J/(kg-K)");
749 _console << std::endl;
750 outputProperty("Sound speed", params.get<Real>("c0"), "m/s");
751 outputProperty("Dynamic viscosity", params.get<Real>("mu0"), "Pa-s");
752 outputProperty("Specific heat at constant pressure", params.get<Real>("cp0"), "J/(kg-K)");
753 outputProperty("Specific heat at constant volume", params.get<Real>("cv0"), "J/(kg-K)");
754 outputProperty("Thermal conductivity", params.get<Real>("k0"), "W/(m-K)");
755 outputProperty("Volumetric expansion coefficient", params.get<Real>("beta0"), "1/K");
756 _console << std::endl;
757}
758
759void
761{
762 const auto x_ncg = params.get<std::vector<Real>>("x_ncg");
763 for (unsigned int i = 0; i < x_ncg.size(); i++)
764 outputProperty("Mass fraction " + std::to_string(i), x_ncg[i], "-");
765 outputProperty("Pressure", params.get<Real>("p"), "Pa");
766 outputProperty("Temperature", params.get<Real>("T"), "K");
767 outputProperty("Density", params.get<Real>("rho"), "kg/m^3");
768 outputProperty("Specific volume", params.get<Real>("v"), "m^3/kg");
769 outputProperty("Specific internal energy", params.get<Real>("e"), "J/kg");
770 outputProperty("Specific enthalpy", params.get<Real>("h"), "J/kg");
771 outputProperty("Specific entropy", params.get<Real>("s"), "J/kg");
772 _console << std::endl;
773 outputProperty("Sound speed", params.get<Real>("c"), "m/s");
774 outputProperty("Dynamic viscosity", params.get<Real>("mu"), "Pa-s");
775 outputProperty("Specific heat at constant pressure", params.get<Real>("cp"), "J/(kg-K)");
776 outputProperty("Specific heat at constant volume", params.get<Real>("cv"), "J/(kg-K)");
777 outputProperty("Thermal conductivity", params.get<Real>("k"), "W/(m-K)");
778 _console << std::endl;
779}
780
781void
783{
784 outputProperty("Specific enthalpy", params.get<Real>("h0"), "J/kg");
785 _console << std::endl;
786}
registerMooseObject("FluidPropertiesApp", FluidPropertiesInterrogator)
const double mu
const Real p
const double rho
const double T
const double v
InputParameters emptyInputParameters()
const std::string name
Definition Setup.h:21
void ErrorVector unsigned int
const ConsoleStream _console
User object for querying a single-phase or two-phase fluid properties object.
const SinglePhaseFluidProperties *const _fp_liquid
pointer to liquid fluid properties object (if provided 2-phase object)
void buildJSON2Phase(nlohmann::json &json, const InputParameters &params)
Build 2-phase fluid properties in JSON format.
const TwoPhaseFluidProperties *const _fp_2phase
pointer to 2-phase fluid properties object (if provided 2-phase object)
void outputVaporMixtureStagnationProperties(const InputParameters &params)
Outputs stagnation properties for a vapor mixture fluid properties object.
InputParameters compute2Phase()
Queries a 2-phase fluid properties object.
const bool _has_2phase
flag that user provided 2-phase fluid properties
void outputProperty(const std::string &name, const Real &value, const std::string &units)
Outputs a property value.
void outputASCIIVaporMixture(const InputParameters &params)
Output vapor mixture fluid properties in plain text format.
void outputVaporMixtureStaticProperties(const InputParameters &params)
Outputs static properties for a vapor mixture fluid properties object.
const bool _has_vapor_mixture
flag that user provided vapor mixture fluid properties
std::map< std::string, bool > getSpecifiedSetMap(const std::vector< std::vector< std::string > > &parameter_sets, const std::string &fp_type, bool throw_error_if_no_match) const
Gets a map of a parameter set to a flag telling whether that set was provided.
const VaporMixtureFluidProperties *const _fp_vapor_mixture
pointer to vapor mixture fluid properties object (if provided 2-phase NCG object)
void outputStaticProperties(const InputParameters &params)
Outputs static properties for a single-phase fluid properties object.
const SinglePhaseFluidProperties *const _fp_vapor
pointer to vapor fluid properties object (if provided 2-phase object)
void outputASCII2Phase(const InputParameters &params)
Output 2-phase fluid properties in plain text format.
bool _nan_encountered
flag that NaN has been encountered
InputParameters compute1Phase(const SinglePhaseFluidProperties *const fp_1phase, bool throw_error_if_no_match)
Queries a 1-phase fluid properties object.
const unsigned int & _precision
Precision used for printing values.
const SinglePhaseFluidProperties *const _fp_1phase
pointer to 1-phase fluid properties object (if provided 1-phase object)
void outputStagnationProperties(const InputParameters &params)
Outputs stagnation properties for a single-phase fluid properties object.
const bool & _json
true if the output should use JSON format
void outputHeader(const std::string &header) const
Outputs a header for a section of properties.
const bool _has_2phase_ncg_partial_pressure
flag that user provided 2-phase NCG partial pressure fluid properties
void buildJSON1Phase(nlohmann::json &json, const InputParameters &params)
Build 1-phase fluid properties in JSON format.
FluidPropertiesInterrogator(const InputParameters &parameters)
const bool _has_1phase
flag that user provided 1-phase fluid properties
void outputASCII1Phase(const std::string &description, const InputParameters &params)
Output 1-phase fluid properties in plain text format.
void buildJSONVaporMixture(nlohmann::json &json, const InputParameters &params)
Build vapor mixture fluid properties in JSON format.
const bool _has_2phase_ncg
flag that user provided 2-phase NCG fluid properties
InputParameters computeVaporMixture(bool throw_error_if_no_match)
Queries a vapor mixture fluid properties object.
const TwoPhaseNCGPartialPressureFluidProperties *const _fp_2phase_ncg_partial_pressure
pointer to 2-phase NCG partial pressure fluid properties object (if provided)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
bool have_parameter(std::string_view name) const
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const std::string & name() const
void mooseError(Args &&... args) const
void mooseWarning(Args &&... args) const
bool isParamValid(const std::string &name) const
Common class for single phase fluid properties.
Base class for fluid properties used with two-phase flow.
virtual Real p_critical() const =0
Returns the critical pressure.
virtual Real sigma_from_T(Real T) const
Computes surface tension sigma of saturated liquid in contact with saturated vapor.
virtual Real p_sat(Real T) const =0
Computes the saturation pressure at a temperature.
virtual Real h_lat(Real p, Real T) const
Computes latent heat of vaporization.
virtual Real T_sat(Real p) const =0
Computes the saturation temperature at a pressure.
Base class for fluid properties used with 2-phase flow with non-condensable gases (NCGs) present.
Two-phase fluid with single NCG using partial pressure mixture model.
Real x_sat_ncg_from_p_T(Real p, Real T) const
Computes the NCG mass fraction with the CG saturated at the given temperature.
Base class for fluid properties of vapor mixtures.