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