25 "The name of the fluid properties object to query.");
26 params.
addParam<
bool>(
"json",
false,
"Output in JSON format");
28 params.
addParam<
Real>(
"rhou",
"Momentum density; rho * u");
29 params.
addParam<
Real>(
"rhoE",
"Total energy density; rho * E");
34 params.
addParam<std::vector<Real>>(
"x_ncg",
"Mass fractions of NCGs");
35 params.
addRequiredParam<
unsigned int>(
"precision",
"Precision for printing values");
38 "User object for querying a single-phase or two-phase fluid properties object");
45 _json(getParam<bool>(
"json")),
50 _fp_2phase_ncg_partial_pressure(
52 _has_1phase(_fp_1phase),
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
63 _fp_vapor_mixture(_has_vapor_mixture
66 _fp_2phase_ncg->getVaporMixtureName())
68 _nan_encountered(false),
69 _precision(getParam<unsigned
int>(
"precision"))
73 "The type of the parameter 'fp' must be derived from type 'SinglePhaseFluidProperties', " 74 "'VaporMixtureFluidProperties', or 'TwoPhaseFluidProperties'.");
95 auto & json_2phase = json[
"2-phase"];
97 auto & json_liquid = json[
"liquid"];
99 auto & json_mixture = json[
"vapor-mixture"];
102 Moose::out <<
"**START JSON DATA**\n";
103 Moose::out << json <<
"\n";
104 Moose::out <<
"**END JSON DATA**" << std::endl;
123 auto & json_2phase = json[
"2-phase"];
127 auto & json_liquid = json[
"liquid"];
132 auto & json_vapor = json[
"vapor"];
136 Moose::out <<
"**START JSON DATA**\n";
137 Moose::out << json <<
"\n";
138 Moose::out <<
"**END JSON DATA**" << std::endl;
157 Moose::out <<
"**START JSON DATA**\n";
158 Moose::out << json <<
"\n";
159 Moose::out <<
"**END JSON DATA**" << std::endl;
174 Moose::out <<
"**START JSON DATA**\n";
175 Moose::out << json <<
"\n";
176 Moose::out <<
"**END JSON DATA**" << std::endl;
190 bool throw_error_if_no_match)
198 std::vector<std::vector<std::string>> parameter_sets = {{
"p",
"T"}, {
"rho",
"e"}, {
"rho",
"p"}};
200 parameter_sets.push_back({
"rho",
"rhou",
"rhoE"});
201 auto specified =
getSpecifiedSetMap(parameter_sets,
"one-phase", throw_error_if_no_match);
205 Real rho, e, p, T, vel = 0;
206 bool specified_a_set =
false;
207 if (specified[
"rho,e"])
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);
215 vel = getParam<Real>(
"vel");
217 specified_a_set =
true;
219 else if (specified[
"rho,p"])
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);
227 vel = getParam<Real>(
"vel");
229 specified_a_set =
true;
231 else if (specified[
"p,T"])
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);
238 vel = getParam<Real>(
"vel");
240 specified_a_set =
true;
242 else if (specified[
"rho,rhou,rhoE"])
244 rho = getParam<Real>(
"rho");
245 const Real rhou = getParam<Real>(
"rhou");
246 const Real rhoE = getParam<Real>(
"rhoE");
249 const Real E = rhoE / rho;
250 e = E - 0.5 * vel * vel;
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);
256 specified_a_set =
true;
261 params.
set<
bool>(
"specified") =
true;
263 const Real v = 1.0 / rho;
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);
281 const Real s = fp_1phase->s_from_v_e(
v, e);
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);
298 params.
set<
Real>(
"rho0") = rho0;
310 params.
set<
Real>(
"beta0") = beta0;
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).");
336 std::vector<std::vector<std::string>> parameter_sets = {{
"p",
"T"}, {
"p"}, {
"T"}};
340 params.
set<
Real>(
"p_critical") = p_critical;
343 const Real p = getParam<Real>(
"p");
348 params.
set<
Real>(
"T_sat") = T_sat;
349 params.
set<
Real>(
"h_lat") = h_lat;
351 else if (specified[
"T"])
353 const Real T = getParam<Real>(
"T");
359 params.
set<
Real>(
"p_sat") = p_sat;
360 params.
set<
Real>(
"h_lat") = h_lat;
363 else if (specified[
"p,T"])
365 const Real p = getParam<Real>(
"p");
366 const Real T = getParam<Real>(
"T");
371 params.
set<
Real>(
"h_lat") = h_lat;
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);
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"])
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;
410 vel = getParam<Real>(
"vel");
412 specified_a_set =
true;
414 else if (specified[
"p,T,x_ncg"])
416 p = getParam<Real>(
"p");
417 T = getParam<Real>(
"T");
418 x_ncg = getParam<std::vector<Real>>(
"x_ncg");
423 vel = getParam<Real>(
"vel");
425 specified_a_set =
true;
429 p = getParam<Real>(
"p");
430 T = getParam<Real>(
"T");
436 vel = getParam<Real>(
"vel");
438 specified_a_set =
true;
440 else if (specified[
"rho,rhou,rhoE,x_ncg"])
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");
448 const Real E = rhoE / rho;
449 e = E - 0.5 * vel * vel;
451 const Real v = 1.0 / rho;
455 specified_a_set =
true;
460 params.
set<
bool>(
"specified") =
true;
462 const Real v = 1.0 / rho;
463 const Real h = e + p / rho;
471 params.
set<std::vector<Real>>(
"x_ncg") = x_ncg;
485 if (
isParamValid(
"vel") || specified[
"rho,rhou,rhoE,x_ncg"])
487 const Real h = e + p / rho;
488 const Real h0 = h + 0.5 * vel * vel;
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).");
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);
514 for (
auto p : {
"vel",
528 json[
"stagnation"][p] = params.
get<
Real>(p);
534 json[
"p_critical"] = params.
get<
Real>(
"p_critical");
535 for (
auto p : {
"T_sat",
"p_sat",
"h_lat",
"sigma"})
544 for (
auto p : {
"p",
"T",
"rho",
"e",
"v",
"h",
"s",
"c",
"mu",
"cp",
"cv",
"k"})
546 json[
"static"][p] = params.
get<
Real>(p);
549 json[
"stagnation"][
"h0"] = params.
get<
Real>(
"h0");
599 std::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 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());
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)
619 std::stringstream ss;
620 for (
unsigned int i = 0; i < parameter_set.size(); i++)
622 ss << parameter_set[i];
624 ss <<
"," << parameter_set[i];
625 const std::string parameter_set_name = ss.str();
626 parameter_set_names.push_back(parameter_set_name);
629 bool all_parameters_provided =
true;
630 for (
const auto & parameter : parameter_set)
632 all_parameters_provided =
false;
634 if (all_parameters_provided)
637 if (!specified_a_set)
639 specified[parameter_set_name] =
true;
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)
654 ") has been specified; ",
656 " cannot be specified.");
659 specified_a_set =
true;
662 specified[parameter_set_name] =
false;
665 if (!specified_a_set && throw_error_if_no_match)
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";
684 << header <<
":" << std::endl
685 << std::setfill(
'-') << std::setw(80) <<
"-" << std::setfill(
' ') << std::endl;
691 const std::string & units)
693 const bool use_scientific_notation = ((
value < 0.001) || (
value >= 10000.0));
700 const std::string units_printed = is_nan ?
"" : units;
706 std::stringstream ss;
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
713 ss << std::setw(35) << std::left <<
name +
":" << std::setw(
_precision + 10) << std::right
714 << std::setprecision(
_precision) <<
value <<
" " << units_printed << std::endl;
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],
"-");
Base class for fluid properties of vapor mixtures.
InputParameters computeVaporMixture(bool throw_error_if_no_match)
Queries a vapor mixture fluid properties object.
static const std::string cv
const SinglePhaseFluidProperties *const _fp_vapor
pointer to vapor fluid properties object (if provided 2-phase object)
static InputParameters validParams()
void outputVaporMixtureStaticProperties(const InputParameters ¶ms)
Outputs static properties for a vapor mixture fluid properties object.
virtual void initialize() override
Two-phase fluid with single NCG using partial pressure mixture model.
const VaporMixtureFluidProperties *const _fp_vapor_mixture
pointer to vapor mixture fluid properties object (if provided 2-phase NCG object) ...
virtual void execute() override
void buildJSON1Phase(nlohmann::json &json, const InputParameters ¶ms)
Build 1-phase fluid properties in JSON format.
Base class for fluid properties used with 2-phase flow with non-condensable gases (NCGs) present...
InputParameters compute1Phase(const SinglePhaseFluidProperties *const fp_1phase, bool throw_error_if_no_match)
Queries a 1-phase fluid properties object.
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.
const TwoPhaseFluidProperties *const _fp_2phase
pointer to 2-phase fluid properties object (if provided 2-phase object)
User object for querying a single-phase or two-phase fluid properties object.
void outputStaticProperties(const InputParameters ¶ms)
Outputs static properties for a single-phase fluid properties object.
const bool _has_2phase_ncg
flag that user provided 2-phase NCG fluid properties
const unsigned int & _precision
Precision used for printing values.
virtual const std::string & name() const
const SinglePhaseFluidProperties *const _fp_liquid
pointer to liquid fluid properties object (if provided 2-phase object)
void mooseWarning(Args &&... args) const
bool _nan_encountered
flag that NaN has been encountered
bool isParamValid(const std::string &name) const
void outputProperty(const std::string &name, const Real &value, const std::string &units)
Outputs a property value.
Base class for fluid properties used with two-phase flow.
void outputStagnationProperties(const InputParameters ¶ms)
Outputs stagnation properties for a single-phase fluid properties object.
static const std::string cp
virtual Real h_lat(Real p, Real T) const
Computes latent heat of vaporization.
void outputASCII2Phase(const InputParameters ¶ms)
Output 2-phase fluid properties in plain text format.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static const std::string mu
void outputASCII1Phase(const std::string &description, const InputParameters ¶ms)
Output 1-phase fluid properties in plain text format.
Common class for single phase fluid properties.
const bool _has_1phase
flag that user provided 1-phase fluid properties
const TwoPhaseNCGPartialPressureFluidProperties *const _fp_2phase_ncg_partial_pressure
pointer to 2-phase NCG partial pressure fluid properties object (if provided)
void outputASCIIVaporMixture(const InputParameters ¶ms)
Output vapor mixture fluid properties in plain text format.
virtual Real p_critical() const =0
Returns the critical pressure.
void buildJSONVaporMixture(nlohmann::json &json, const InputParameters ¶ms)
Build vapor mixture fluid properties in JSON format.
std::map< std::string, bool > getSpecifiedSetMap(const std::vector< std::vector< std::string >> ¶meter_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.
virtual Real p_sat(Real T) const =0
Computes the saturation pressure at a temperature.
virtual Real T_sat(Real p) const =0
Computes the saturation temperature at a pressure.
void outputVaporMixtureStagnationProperties(const InputParameters ¶ms)
Outputs stagnation properties for a vapor mixture fluid properties object.
FluidPropertiesInterrogator(const InputParameters ¶meters)
const bool _has_2phase_ncg_partial_pressure
flag that user provided 2-phase NCG partial pressure fluid properties
const bool _has_vapor_mixture
flag that user provided vapor mixture fluid properties
void outputHeader(const std::string &header) const
Outputs a header for a section of properties.
registerMooseObject("FluidPropertiesApp", FluidPropertiesInterrogator)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
const bool & _json
true if the output should use JSON format
InputParameters compute2Phase()
Queries a 2-phase fluid properties object.
void buildJSON2Phase(nlohmann::json &json, const InputParameters ¶ms)
Build 2-phase fluid properties in JSON format.
const bool _has_2phase
flag that user provided 2-phase fluid properties
static InputParameters validParams()
const SinglePhaseFluidProperties *const _fp_1phase
pointer to 1-phase fluid properties object (if provided 1-phase object)
void mooseError(Args &&... args) const
const ConsoleStream _console
static const std::string k
void ErrorVector unsigned int
virtual Real sigma_from_T(Real T) const
Computes surface tension sigma of saturated liquid in contact with saturated vapor.
virtual void finalize() override