28 "Single phase fluid properties computed using bi-dimensional interpolation of tabulated " 32 params.
addParam<
bool>(
"create_pT_interpolations",
34 "Whether to load (from file) or create (from a fluid property object) " 35 "properties interpolations from pressure and temperature");
36 params.
addParam<
bool>(
"create_ve_interpolations",
38 "Whether to load (from file) or create (from a fluid property object) " 39 "properties interpolations from pressure and temperature");
42 params.
addParam<UserObjectName>(
"fp",
"The name of the FluidProperties UserObject");
43 params.
addParam<FileName>(
"fluid_property_file",
44 "Name of the csv file containing the tabulated fluid property data.");
46 "fluid_property_ve_file",
47 "Name of the csv file containing the tabulated (v,e) fluid property data.");
48 params.
addParam<FileName>(
"fluid_property_output_file",
49 "Name of the CSV file which can be output with the tabulation. This " 50 "file can then be read as a 'fluid_property_file'");
52 "fluid_property_ve_output_file",
53 "Name of the CSV file which can be output with the (v,e) tabulation. This " 54 "file can then be read as a 'fluid_property_ve_file'");
57 "Whether to save the csv fluid properties file",
58 "This parameter is no longer required. Whether to save a CSV tabulation file is controlled " 59 "by specifying the 'fluid_property_output_file' parameter");
63 "density enthalpy internal_energy viscosity k c cv cp entropy pressure temperature",
64 "density enthalpy internal_energy viscosity");
67 "Properties to interpolate if no data file is provided");
71 "temperature_min", 300,
"temperature_min > 0",
"Minimum temperature for tabulated data.");
72 params.
addParam<
Real>(
"temperature_max", 500,
"Maximum temperature for tabulated data.");
74 "pressure_min", 1e5,
"pressure_min > 0",
"Minimum pressure for tabulated data.");
75 params.
addParam<
Real>(
"pressure_max", 50.0e6,
"Maximum pressure for tabulated data.");
77 "num_T", 100,
"num_T > 0",
"Number of points to divide temperature range.");
79 "num_p", 100,
"num_p > 0",
"Number of points to divide pressure range.");
82 params.
addParam<
Real>(
"e_min",
"Minimum specific internal energy for tabulated data.");
83 params.
addParam<
Real>(
"e_max",
"Maximum specific internal energy for tabulated data.");
85 "v_min",
"v_min > 0",
"Minimum specific volume for tabulated data.");
87 "v_max",
"v_max > 0",
"Maximum specific volume for tabulated data.");
88 params.
addParam<
bool>(
"construct_pT_from_ve",
90 "If the lookup table (p, T) as functions of (v, e) should be constructed.");
91 params.
addParam<
bool>(
"construct_pT_from_vh",
93 "If the lookup table (p, T) as functions of (v, h) should be constructed.");
98 "Number of points to divide specific volume range for (v,e) lookups.");
102 "Number of points to divide specific internal energy " 103 "range for (v,e) lookups.");
107 "Option to use a base-10 logarithmically-spaced grid for specific volume instead of a " 108 "linearly-spaced grid.");
112 "Option to use a base-10 logarithmically-spaced grid for specific internal energy instead " 113 "of a linearly-spaced grid.");
117 "Option to use a base-10 logarithmically-spaced grid for specific enthalpy instead " 118 "of a linearly-spaced grid.");
122 "error_on_out_of_bounds",
123 "Whether pressure or temperature from tabulation exceeding user-specified bounds leads to " 125 "This parameter has been replaced by the 'out_of_bounds_behavior' parameter which offers " 126 "more flexibility. The option to error is called 'throw' in that parameter.");
128 MooseEnum OOBBehavior(
"ignore throw declare_invalid warn_invalid set_to_closest_bound",
"throw");
131 "Property evaluation behavior when evaluated outside the " 132 "user-specified or tabulation-specified bounds");
138 "allow_fp_and_tabulation",
false,
"Whether to allow the two sources of data concurrently");
141 "fluid_property_output_file fluid_property_ve_output_file",
142 "Tabulation file read/write");
144 "Variable set conversion");
146 "e_max v_min v_max error_on_out_of_bounds out_of_bounds_behavior",
147 "Tabulation and interpolation bounds");
149 "num_T num_p num_v num_e use_log_grid_v use_log_grid_e use_log_grid_h",
150 "Tabulation and interpolation discretization");
157 _file_name_in(isParamValid(
"fluid_property_file") ? getParam<FileName>(
"fluid_property_file")
160 isParamValid(
"fluid_property_ve_file") ? getParam<FileName>(
"fluid_property_ve_file") :
""),
161 _file_name_out(isParamValid(
"fluid_property_output_file")
162 ? getParam<FileName>(
"fluid_property_output_file")
164 _file_name_ve_out(isParamValid(
"fluid_property_ve_output_file")
165 ? getParam<FileName>(
"fluid_property_ve_output_file")
167 _save_file(isParamValid(
"save_file") ? getParam<bool>(
"save_file")
168 : isParamValid(
"fluid_property_output_file")),
169 _create_direct_pT_interpolations(getParam<bool>(
"create_pT_interpolations")),
170 _create_direct_ve_interpolations(getParam<bool>(
"create_ve_interpolations")),
171 _temperature_min(getParam<
Real>(
"temperature_min")),
172 _temperature_max(getParam<
Real>(
"temperature_max")),
173 _pressure_min(getParam<
Real>(
"pressure_min")),
174 _pressure_max(getParam<
Real>(
"pressure_max")),
175 _num_T(getParam<unsigned
int>(
"num_T")),
176 _num_p(getParam<unsigned
int>(
"num_p")),
178 _allow_fp_and_tabulation(getParam<bool>(
"allow_fp_and_tabulation")),
179 _interpolated_properties_enum(getParam<
MultiMooseEnum>(
"interpolated_properties")),
180 _interpolated_properties(),
181 _interpolate_density(false),
182 _interpolate_enthalpy(false),
183 _interpolate_internal_energy(false),
184 _interpolate_viscosity(false),
185 _interpolate_k(false),
186 _interpolate_c(false),
187 _interpolate_cp(false),
188 _interpolate_cv(false),
189 _interpolate_entropy(false),
190 _interpolate_pressure(false),
191 _interpolate_temperature(false),
203 _csv_reader(_file_name_in, &_communicator),
204 _construct_pT_from_ve(getParam<bool>(
"construct_pT_from_ve")),
205 _construct_pT_from_vh(getParam<bool>(
"construct_pT_from_vh")),
206 _initial_setup_done(false),
207 _num_v(getParam<unsigned
int>(
"num_v")),
208 _num_e(getParam<unsigned
int>(
"num_e")),
209 _log_space_v(getParam<bool>(
"use_log_grid_v")),
210 _log_space_e(getParam<bool>(
"use_log_grid_e")),
211 _log_space_h(getParam<bool>(
"use_log_grid_h")),
212 _OOBBehavior(getParam<
MooseEnum>(
"out_of_bounds_behavior"))
218 mooseError(
"temperature_max must be greater than temperature_min");
220 mooseError(
"pressure_max must be greater than pressure_min");
225 _e_min = getParam<Real>(
"e_min");
226 _e_max = getParam<Real>(
"e_max");
231 "Either both or none of the min and max values of the specific internal energy " 232 "should be specified");
237 _v_min = getParam<Real>(
"v_min");
238 _v_max = getParam<Real>(
"v_max");
243 "Either both or none of the min and max values of the specific volume " 244 "should be specified");
249 if (
isParamValid(
"error_on_out_of_bounds") && getParam<bool>(
"error_on_out_of_bounds") &&
251 paramError(
"out_of_bounds_behavior",
"Inconsistent selection of out of bounds behavior.");
252 else if (
isParamValid(
"error_on_out_of_bounds") && !getParam<bool>(
"error_on_out_of_bounds"))
261 "Cannot supply both a fluid properties object with 'fp' and a source tabulation " 262 "file with 'fluid_property_file', unless 'allow_fp_and_tabulation' is set to true");
265 "Either a fluid properties object with the parameter 'fp' and a source tabulation " 266 "file with the parameter 'fluid_property_file' or 'fluid_property_ve_file' should " 269 paramError(
"create_pT_interpolations",
"Must create either (p,T) or (v,e) interpolations");
275 mooseWarning(
"User-specified bounds in pressure and temperature are ignored when reading a " 276 "'fluid_property_file'. The tabulation bounds are selected " 277 "from the bounds of the input tabulation.");
279 mooseWarning(
"User-specified grid sizes in pressure and temperature are ignored when reading a " 280 "'fluid_property_file'. The tabulation bounds are selected " 281 "from the bounds of the input tabulation.");
286 "User-specified bounds in specific volume and internal energy are ignored when reading a " 287 "'fluid_property_ve_file'. The tabulation bounds are selected " 288 "from the bounds of the input tabulation.");
290 mooseWarning(
"User-specified grid sizes in specific volume and internal energy are ignored " 291 "when reading a 'fluid_property_ve_file'. The tabulation widths are read " 292 "from the input tabulation.");
295 "User specfied logarithmic grids in specific volume and energy are ignored when reading a " 296 "'fluid_properties_ve_file'. The tabulation grid is read from the input tabulation");
315 "create_pT_interpolations",
316 "No FluidProperties (specified with 'fp' parameter) exists. Either specify a 'fp' or " 317 "specify a (p, T) tabulation file with the 'fluid_property_file' parameter");
318 _console <<
name() +
": Generating (p, T) tabulated data\n";
334 "create_ve_interpolations",
335 "No FluidProperties (specified with 'fp' parameter) exists. Either specify a 'fp' or " 336 "specify a (v, e) tabulation file with the 'fluid_property_ve_file' parameter");
337 _console <<
name() +
": Generating (v, e) tabulated data\n";
361 return "TabulationFromFile";
386 paramError(
"fp",
"No fluid properties or csv data provided for density.");
394 Real rho = 0, drho_dp = 0, drho_dT = 0;
406 paramError(
"fp",
"No fluid properties or csv data provided for density.");
410 dv_dp = -drho_dp / (
rho *
rho);
411 dv_dT = -drho_dT / (
rho *
rho);
427 paramError(
"fp",
"No fluid properties or csv data provided for density.");
446 paramError(
"fp",
"No fluid properties or csv data provided for density.");
468 paramError(
"fp",
"No fluid properties or csv data provided for density.");
481 Real p, Real s, Real & rho, Real & drho_dp, Real & drho_ds)
const 483 Real T, dT_dp, dT_ds;
485 Real drho_dp_T, drho_dT;
487 drho_dp = drho_dT * dT_dp + drho_dp_T;
488 drho_ds = drho_dT * dT_ds;
504 paramError(
"fp",
"No fluid properties or csv data provided for internal energy.");
523 paramError(
"fp",
"No fluid properties or csv data provided for internal energy.");
537 Real
pressure, Real rho, Real & e, Real & de_dp, Real & de_drho)
const 540 Real T, dT_dp, dT_drho;
544 Real de_dp_at_const_T, de_dT;
548 Real rho_pT, drho_dp, drho_dT;
552 de_drho = de_dT * dT_drho;
553 de_dp = de_dp_at_const_T - (de_drho * drho_dp);
566 name() +
"::T_from_p_rho",
573 ") and density (rho = ",
575 ") to temperature failed to converge.");
581 Real
pressure, Real rho, Real & T, Real & dT_dp, Real & dT_drho)
const 593 {
s_from_p_T(
p, current_T, new_s, ds_dp, ds_dT); };
599 name() +
"::T_from_p_s",
606 ") and entropy (s = ",
608 ") to temperature failed to converge.");
614 Real
pressure, Real s, Real & T, Real & dT_dp, Real & dT_ds)
const 635 paramError(
"fp",
"No fluid properties or csv data provided for enthalpy.");
663 paramError(
"fp",
"No fluid properties or csv data provided for enthalpy.");
680 paramError(
"fp",
"No fluid properties or csv data provided for viscosity.");
699 paramError(
"fp",
"No fluid properties or csv data provided for viscosity.");
716 paramError(
"interpolated_properties",
"No data to interpolate for speed of sound.");
734 paramError(
"interpolated_properties",
"No data to interpolate for speed of sound.");
752 "No data to interpolate for specific heat capacity at constant pressure.");
771 "No data to interpolate for specific heat capacity at constant pressure.");
789 "No data to interpolate for specific heat capacity at constant volume.");
808 "No data to interpolate for specific heat capacity at constant volume.");
825 paramError(
"interpolated_properties",
"No data to interpolate for thermal conductivity.");
844 paramError(
"interpolated_properties",
"No data to interpolate for thermal conductivity.");
861 paramError(
"interpolated_properties",
"No data to interpolate for entropy.");
876 _fp->s_from_p_T(
p,
T, s, ds_dp, ds_dT);
878 paramError(
"interpolated_properties",
"No data to interpolate for entropy.");
895 { h_from_v_e(
v, current_e, new_h, dh_dv, dh_de); };
901 name() +
"::e_from_v_h",
907 return _fp->e_from_v_h(
v,
h);
910 "\nNo tabulation or fluid property 'fp' object to compute value");
918 Real p = 0, dp_dv = 0, dp_dh = 0;
920 Real T = 0, dT_dv = 0, dT_dh = 0;
924 de_dv = de_dp * dp_dv + de_dT * dT_dv;
925 de_dh = de_dp * dp_dh + de_dT * dT_dh;
931 { h_from_v_e(
v, current_e, new_h, dh_dv, dh_de); };
938 name() +
"::e_from_v_h",
943 de_dv = (e2 - e) / (TOLERANCE *
v);
944 de_dh = 1. / e_data.second;
947 _fp->e_from_v_h(
v,
h, e, de_dv, de_dh);
950 "\nNo tabulation or fluid property 'fp' object to compute value");
1060 return _fp->p_from_v_e(
v, e);
1063 "\nNo tabulation or fluid property 'fp' object to compute value");
1078 _fp->p_from_v_e(
v, e,
p, dp_dv, dp_de);
1081 "\nNo tabulation or fluid property 'fp' object to compute value");
1096 return _fp->T_from_v_e(
v, e);
1099 "\nNo tabulation or fluid property 'fp' object to compute value");
1114 _fp->T_from_v_e(
v, e,
T, dT_dv, dT_de);
1117 "\nNo tabulation or fluid property 'fp' object to compute value");
1136 return _fp->c_from_v_e(
v, e);
1139 "\nNo tabulation or fluid property 'fp' object to compute value");
1153 Real p, dp_dv, dp_de;
1155 Real T, dT_dv, dT_de;
1159 dc_dv = dc_dp * dp_dv + dc_dT * dT_dv;
1160 dc_de = dc_dp * dp_de + dc_dT * dT_de;
1163 _fp->c_from_v_e(
v, e,
c, dc_dv, dc_de);
1166 "\nNo tabulation or fluid property 'fp' object to compute value");
1185 return _fp->cp_from_v_e(
v, e);
1188 "\nNo tabulation or fluid property 'fp' object to compute value");
1202 Real p, dp_dv, dp_de;
1204 Real T, dT_dv, dT_de;
1206 Real dcp_dp, dcp_dT;
1208 dcp_dv = dcp_dp * dp_dv + dcp_dT * dT_dv;
1209 dcp_de = dcp_dp * dp_de + dcp_dT * dT_de;
1212 _fp->cp_from_v_e(
v, e,
cp, dcp_dv, dcp_de);
1215 "\nNo tabulation or fluid property 'fp' object to compute value");
1234 return _fp->cv_from_v_e(
v, e);
1237 "\nNo tabulation or fluid property 'fp' object to compute value");
1251 Real p, dp_dv, dp_de;
1253 Real T, dT_dv, dT_de;
1255 Real dcv_dp, dcv_dT;
1257 dcv_dv = dcv_dp * dp_dv + dcv_dT * dT_dv;
1258 dcv_de = dcv_dp * dp_de + dcv_dT * dT_de;
1261 _fp->cv_from_v_e(
v, e,
cv, dcv_dv, dcv_de);
1264 "\nNo tabulation or fluid property 'fp' object to compute value");
1283 return _fp->mu_from_v_e(
v, e);
1286 "\nNo tabulation or fluid property 'fp' object to compute value");
1300 Real p, dp_dv, dp_de;
1302 Real T, dT_dv, dT_de;
1304 Real dmu_dp, dmu_dT;
1306 dmu_dv = dmu_dp * dp_dv + dmu_dT * dT_dv;
1307 dmu_de = dmu_dp * dp_de + dmu_dT * dT_de;
1310 _fp->mu_from_v_e(
v, e,
mu, dmu_dv, dmu_de);
1313 "\nNo tabulation or fluid property 'fp' object to compute value");
1332 return _fp->k_from_v_e(
v, e);
1335 "\nNo tabulation or fluid property 'fp' object to compute value");
1349 Real p, dp_dv, dp_de;
1351 Real T, dT_dv, dT_de;
1355 dk_dv = dk_dp * dp_dv + dk_dT * dT_dv;
1356 dk_de = dk_dp * dp_de + dk_dT * dT_de;
1359 _fp->k_from_v_e(
v, e,
k, dk_dv, dk_de);
1362 "\nNo tabulation or fluid property 'fp' object to compute value");
1381 return _fp->s_from_v_e(
v, e);
1384 "\nNo tabulation or fluid property 'fp' object to compute value");
1408 bool conversion_succeeded;
1415 "\nNo tabulation or fluid property 'fp' object to compute value");
1425 bool conversion_succeeded;
1446 ") and pressure (p = ",
1448 ") to temperature failed to converge.");
1463 h_from_p_T(
pressure.value(), current_T.value(), new_h.value(), dh_dp.value(), dh_dT.value());
1465 new_h.derivatives() =
1466 dh_dp.value() *
pressure.derivatives() + dh_dT.value() * current_T.derivatives();
1476 ") and pressure (p = ",
1478 ") to temperature failed to converge.");
1492 Real h, Real
pressure, Real & s, Real & ds_dh, Real & ds_dp)
const 1498 mooseError(
"fp",
"s_from_h_p derivatives not implemented.");
1504 mooseError(
"TabulatedFluidProperties can only call the function '" + desired_routine +
1505 "' when the 'fp' parameter is provided. It is currently not implemented using " 1506 "tabulations, and this property is simply forwarded to the FluidProperties specified " 1507 "in the 'fp' parameter");
1513 file_name = file_name.empty() ?
"fluid_properties_" +
name() +
"_out.csv" : file_name;
1519 std::ofstream file_out(file_name.c_str());
1522 time_t now = std::time(&now);
1525 <<
" properties created by TabulatedFluidProperties on " << ctime(&now) <<
"\n";
1527 file_out <<
"# tabulated properties created by TabulatedFluidProperties on " << ctime(&now)
1531 file_out <<
"pressure, temperature";
1537 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1538 for (
unsigned int t = 0; t <
_num_T; ++t)
1541 for (std::size_t i = 0; i <
_properties.size(); ++i)
1546 file_out << std::flush;
1554 ? std::regex_replace(file_name, std::regex(
"\\.csv"),
"_ve.csv")
1557 std::ofstream file_out(file_name_ve.c_str());
1560 file_out <<
"specific_volume, internal_energy, pressure, temperature";
1577 bool add_comma =
true;
1579 file_out << 1 / v_val;
1605 file_out << std::flush;
1614 mooseAssert(
_fp,
"We should not try to generate (p,T) tabulated data without a _fp user object");
1631 for (
unsigned int j = 0;
j <
_num_T; ++
j)
1637 for (
unsigned int i = 0; i <
_num_p; ++i)
1644 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1645 for (
unsigned int t = 0; t <
_num_T; ++t)
1649 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1650 for (
unsigned int t = 0; t <
_num_T; ++t)
1654 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1655 for (
unsigned int t = 0; t <
_num_T; ++t)
1659 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1660 for (
unsigned int t = 0; t <
_num_T; ++t)
1664 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1665 for (
unsigned int t = 0; t <
_num_T; ++t)
1669 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1670 for (
unsigned int t = 0; t <
_num_T; ++t)
1674 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1675 for (
unsigned int t = 0; t <
_num_T; ++t)
1679 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1680 for (
unsigned int t = 0; t <
_num_T; ++t)
1684 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1685 for (
unsigned int t = 0; t <
_num_T; ++t)
1693 mooseAssert(
_fp,
"We should not try to generate (v,e) tabulated data without a _fp user object");
1716 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1717 for (
unsigned int e = 0; e <
_num_e; ++e)
1721 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1722 for (
unsigned int e = 0; e <
_num_e; ++e)
1727 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1728 for (
unsigned int e = 0; e <
_num_e; ++e)
1732 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1733 for (
unsigned int e = 0; e <
_num_e; ++e)
1738 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1739 for (
unsigned int e = 0; e <
_num_e; ++e)
1744 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1745 for (
unsigned int e = 0; e <
_num_e; ++e)
1750 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1751 for (
unsigned int e = 0; e <
_num_e; ++e)
1756 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1757 for (
unsigned int e = 0; e <
_num_e; ++e)
1762 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1763 for (
unsigned int e = 0; e <
_num_e; ++e)
1768 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1769 for (
unsigned int e = 0; e <
_num_e; ++e)
1774 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1775 for (
unsigned int e = 0; e <
_num_e; ++e)
1781 template <
typename T>
1792 " is outside the range of tabulated pressure (" +
1800 flagInvalidSolution(
"Pressure out of bounds");
1802 flagSolutionWarning(
"Pressure out of bounds");
1811 " is outside the range of tabulated temperature (" +
1818 flagInvalidSolution(
"Temperature out of bounds");
1820 flagSolutionWarning(
"Temperature out of bounds");
1825 template <
typename T>
1831 else if (e < _e_min || e >
_e_max)
1835 " is outside the range of tabulated specific internal energies (" +
1841 flagInvalidSolution(
"Specific internal energy out of bounds");
1843 flagSolutionWarning(
"Specific internal energy out of bounds");
1847 if (v < _v_min || v >
_v_max)
1851 " is outside the range of tabulated specific volumes (" +
1857 flagInvalidSolution(
"Specific volume out of bounds");
1859 flagSolutionWarning(
"Specific volume out of bounds");
1869 if (_p_initial_guess < _pressure_min || _p_initial_guess >
_pressure_max)
1870 mooseWarning(
"Pressure initial guess for (p,T), (v,e) conversions " +
1872 " is outside the range of tabulated " 1876 if (_T_initial_guess < _temperature_min || _T_initial_guess >
_temperature_max)
1877 mooseWarning(
"Temperature initial guess for (p,T), (v,e) conversions " +
1879 " is outside the range of tabulated " 1889 std::string file_name;
1907 std::vector<std::string> required_columns;
1909 required_columns = {
"pressure",
"temperature"};
1911 required_columns = {
"specific_volume",
"internal_energy"};
1914 for (std::size_t i = 0; i < required_columns.size(); ++i)
1916 if (std::find(column_names.begin(), column_names.end(), required_columns[i]) ==
1919 required_columns[i],
1922 ". A column named ",
1923 required_columns[i],
1924 " must be present");
1928 std::vector<std::string> property_columns = {
1929 "density",
"enthalpy",
"viscosity",
"k",
"c",
"cv",
"cp",
"entropy"};
1931 property_columns.push_back(
"internal_energy");
1934 property_columns.push_back(
"pressure");
1935 property_columns.push_back(
"temperature");
1940 for (std::size_t i = 0; i < column_names.size(); ++i)
1943 if (std::find(required_columns.begin(), required_columns.end(), column_names[i]) ==
1944 required_columns.end())
1946 if (std::find(property_columns.begin(), property_columns.end(), column_names[i]) ==
1947 property_columns.end())
1951 " tabulation file is not one of the properties that TabulatedFluidProperties " 1952 "understands. It will be ignored.");
1962 std::map<std::string, unsigned int> data_index;
1963 for (std::size_t i = 0; i < column_names.size(); ++i)
1965 auto it = std::find(column_names.begin(), column_names.end(), column_names[i]);
1966 data_index[column_names[i]] = std::distance(column_names.begin(), it);
1974 _pressure = column_data[data_index.find(
"pressure")->second];
1975 _temperature = column_data[data_index.find(
"temperature")->second];
1979 _specific_volume = column_data[data_index.find(
"specific_volume")->second];
1980 _internal_energy = column_data[data_index.find(
"internal_energy")->second];
1990 "specific internal energy");
2023 "Reading a (v,e) tabulation and generating (p,T) to (v,e) interpolation tables is " 2024 "not supported at this time.");
2039 std::vector<Real> & v2,
2040 const std::string & file_name,
2041 const std::string & v1_name,
2042 const std::string & v2_name)
2047 if (!std::is_sorted(v1.begin(), v1.end()))
2048 mooseError(
"The column data for ", v1_name,
" is not monotonically increasing in ", file_name);
2052 auto num_v2 = std::count(v1.begin(), v1.end(), v1.front());
2055 auto last_unique = std::unique(v1.begin(), v1.end());
2056 v1.erase(last_unique, v1.end());
2060 if (v2.size() != v1.size() * libMesh::cast_int<unsigned int>(num_v2))
2063 " is not equal to the number of unique ",
2067 " multiplied by the number of unique ",
2073 std::vector<Real> base_v2(v2.begin(), v2.begin() + num_v2);
2074 if (!std::is_sorted(base_v2.begin(), base_v2.end()))
2075 mooseError(
"The column data for ", v2_name,
" is not monotonically increasing in ", file_name);
2078 auto it_v2 = v2.begin() + num_v2;
2079 for (
const auto i :
make_range(v1.size() - 1))
2081 std::vector<Real> repeated_v2(it_v2, it_v2 + num_v2);
2082 if (repeated_v2 != base_v2)
2088 " are not identical to values for ",
2091 std::advance(it_v2, num_v2);
2096 v2.erase(v2.begin() + num_v2, v2.end());
2164 "' is present in the tabulation but is not currently leveraged by the code in the " 2165 "TabulatedFluidProperties. If it is spelled correctly, then please contact a " 2166 "MOOSE or fluid properties module developer.");
2173 mooseAssert(
_file_name_ve_in.empty(),
"We should be reading the specific volume grid from file");
2183 _v_min = std::min({v1, v2, v3, v4});
2184 _v_max = std::max({v1, v2, v3, v4});
2208 for (
unsigned int j = 0;
j <
_num_v; ++
j)
2214 for (
unsigned int j = 0;
j <
_num_v; ++
j)
2232 _e_min = std::min({e1, e2, e3, e4});
2233 _e_max = std::max({e1, e2, e3, e4});
2252 mooseError(
"Logarithmic grid in specific energy can only be used with a positive specific " 2253 "energy. Current minimum: " +
2280 _h_min = std::min({h1, h2, h3, h4});
2281 _h_max = std::max({h1, h2, h3, h4});
2295 mooseError(
"Need a source to compute the enthalpy grid bounds: either a FP object, or a (p,T) " 2296 "tabulation file or a (v,e) tabulation file");
2306 mooseError(
"Logarithmic grid in specific energy can only be used with a positive enthalpy. " 2307 "Current minimum: " +
2326 ": to call this function you must:\n-add this property to the list to the list of " 2327 "'interpolated_properties'\n and then either:\n-construct (p, T) from (v, e) " 2328 "tabulations using the 'construct_pT_from_ve' parameter\n-load (v,e) interpolation " 2329 "tables using the 'fluid_property_ve_file' parameter");
virtual Real k_from_p_T(Real pressure, Real temperature) const override
bool _log_space_v
log-space the specific volume interpolation grid axis instead of linear
FileName _file_name_ve_in
File name of input (v,e) tabulated data file.
void readFileTabulationData(bool use_pT)
Read tabulation data from file.
virtual void initialSetup() override
virtual Real rho_from_p_s(Real p, Real s) const override
virtual Real triplePointTemperature() const override
Triple point temperature.
e e e e s T T T T T rho T
virtual Real v_from_p_T(Real pressure, Real temperature) const override
const bool _create_direct_ve_interpolations
Whether to create direct (v,e) interpolations.
static const std::string cv
bool _interpolate_viscosity
void checkFileTabulationGrids(std::vector< Real > &v1, std::vector< Real > &v2, const std::string &file_name, const std::string &v1_name, const std::string &v2_name)
Check that the tabulation grids in the file are correct (no repeats etc)
virtual Real criticalDensity() const override
Critical density.
std::unique_ptr< BidimensionalInterpolation > _p_from_v_h_ipol
Bidimensional interpolation of pressure from (v,h)
virtual Real triplePointTemperature() const
Triple point temperature.
const unsigned int invalid_uint
const bool _create_direct_pT_interpolations
Whether to create direct (p,T) interpolations.
virtual Real e_from_v_h(Real v, Real h) const override
void setComment(const std::string &value)
unsigned int _viscosity_idx
static InputParameters validParams()
static constexpr Real TOLERANCE
Real _temperature_max
Maximum temperature in tabulated data.
Real _h_max
Maximum specific enthalpy in tabulated data.
Real _e_max
Maximum internal energy in tabulated data (can be user-specified)
virtual Real T_from_p_s(Real p, Real s) const
bool _interpolate_entropy
virtual Real T_from_v_e(Real v, Real e) const override
virtual Real molarMass() const
Molar mass [kg/mol].
virtual void checkInitialGuess() const
Checks initial guess for Newton Method.
Real _e_min
Minimum internal energy in tabulated data (can be user-specified)
Real _pressure_max
Maximum pressure in tabulated data.
bool _e_bounds_specified
Whether the specific internal energy bounds were set by the user.
bool _interpolate_temperature
unsigned int size() const
MooseUtils::DelimitedFileReader _csv_reader
The MOOSE delimited file reader.
virtual std::vector< Real > henryCoefficients() const
Henry's law coefficients for dissolution in water.
static const std::string temperature
bool _log_space_e
log-space the internal energy interpolation grid axis instead of linear
void createVEGridVectors()
virtual Real s_from_p_T(Real pressure, Real temperature) const override
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
MooseEnum _OOBBehavior
User-selected out-of-bounds behavior.
MultiMooseEnum _interpolated_properties_enum
Properties to be interpolated entered in the input file.
void computePropertyIndicesInInterpolationVectors()
Retrieves the index for each property in the vector of interpolations.
bool _v_bounds_specified
Whether the specific volume bounds were set by the user.
DualNumber< Real, DNDerivativeType, true > ADReal
virtual const std::string & name() const
unsigned int _internal_energy_idx
void mooseWarning(Args &&... args) const
std::vector< std::unique_ptr< BidimensionalInterpolation > > _property_ve_ipol
Vector of bi-dimensional interpolation of fluid properties directly in (v,e)
std::pair< T, T > NewtonSolve(const T &x, const T &y, const Real z_initial_guess, const Real tolerance, const Functor &func, const std::string &caller_name, const unsigned int max_its=100)
NewtonSolve does a 1D Newton Solve to solve the equation y = f(x, z) for variable z...
void p_T_from_v_e(const CppType &v, const CppType &e, Real p0, Real T0, CppType &p, CppType &T, bool &conversion_succeeded) const
Determines (p,T) from (v,e) using Newton Solve in 2D Useful for conversion between different sets of ...
std::unique_ptr< BidimensionalInterpolation > _p_from_v_e_ipol
Bi-dimensional interpolation of pressure from (v,e)
Real _h_min
Minimum specific enthalpy in tabulated data.
bool isParamValid(const std::string &name) const
virtual Real s_from_h_p(Real h, Real pressure) const override
virtual Real vaporTemperature(Real pressure) const override
Vapor temperature.
std::unique_ptr< BidimensionalInterpolation > _T_from_v_e_ipol
Bi-dimensional interpolation of temperature from (v,e)
FileName _file_name_ve_out
File name of output (v,e) tabulated data file.
std::vector< Real > _enthalpy
Specific enthalpy vector.
unsigned int _num_v
Number of specific volume points in the tabulated data.
static const std::string cp
const Real _tolerance
Newton's method may be used to convert between variable sets.
bool _construct_pT_from_ve
if the lookup table p(v, e) and T(v, e) should be constructed
bool _interpolate_pressure
void setFileName(const std::string &new_file)
e e e e s T T T T T rho v v T e h
Real _temperature_min
Minimum temperature in tabulated data.
virtual Real vaporTemperature(Real p) const
Vapor temperature.
void createVHGridVectors()
Create (or reset) the grid vectors for the specific volume and enthalpy interpolation The order of pr...
void FluidPropertiesForwardError(const std::string &desired_routine) const
bool _construct_pT_from_vh
if the lookup table p(v, h) and T(v, h) should be constructed
virtual Real molarMass() const override
Molar mass [kg/mol].
FileName _file_name_out
File name of output tabulated data file.
virtual Real h_from_p_T(Real p, Real T) const override
virtual Real e_from_p_rho(Real pressure, Real rho) const override
virtual Real vaporPressure(Real temperature) const override
Vapor pressure.
void checkInputVariablesVE(T &v, T &e) const
Checks that the inputs are within the range of the tabulated data, and throws an error if they are no...
virtual Real criticalTemperature() const
Critical temperature.
static InputParameters validParams()
virtual Real k_from_v_e(Real v, Real e) const override
static const std::string mu
bool _interpolate_internal_energy
virtual void generateVETabulatedData()
Generates a table of fluid properties by looping over specific volume and internal energy and calcula...
virtual Real cv_from_v_e(Real v, Real e) const override
virtual Real c_from_p_T(Real pressure, Real temperature) const override
Common class for single phase fluid properties.
bool _log_space_h
log-space the enthalpy interpolation grid axis instead of linear
Real _v_min
Minimum specific volume in tabulated data (can be user-specified)
virtual Real triplePointPressure() const override
Triple point pressure.
std::vector< std::string > _interpolated_properties
List of properties to be interpolated.
void paramError(const std::string ¶m, Args... args) const
virtual Real g_from_v_e(Real v, Real e) const override
std::string stringify(const T &t)
virtual Real e_from_p_T(Real pressure, Real temperature) const override
virtual Real c_from_v_e(Real v, Real e) const override
bool checkFileWriteable(const std::string &filename, bool throw_on_unwritable=true)
const std::vector< std::vector< T > > & getData() const
TabulatedFluidProperties(const InputParameters ¶meters)
virtual Real triplePointPressure() const
Triple point pressure.
std::vector< Real > _pressure
Pressure vector.
std::vector< Real > _temperature
Temperature vector.
virtual Real rho_from_p_T(Real pressure, Real temperature) const override
void p_T_from_h_s(const T &h, const T &s, Real p0, Real T0, T &pressure, T &temperature, bool &conversion_succeeded) const
Determines (p,T) from (h,s) using Newton Solve in 2D Useful for conversion between different sets of ...
virtual Real criticalTemperature() const override
Critical temperature.
unsigned int _num_T
Number of temperature points in the tabulated data.
bool _initial_setup_done
keeps track of whether initialSetup has been performed
void checkInputVariables(T &pressure, T &temperature) const
Checks that the inputs are within the range of the tabulated data, and throws an error if they are no...
virtual Real criticalPressure() const override
Critical pressure.
virtual std::string fluidName() const override
Fluid name.
const SinglePhaseFluidProperties *const _fp
SinglePhaseFluidPropertiesPT UserObject.
void missingVEInterpolationError(const std::string &function_name) const
Standardized error message for missing interpolation.
virtual Real s_from_v_e(Real v, Real e) const override
Real _pressure_min
Minimum pressure in tabulated data.
bool isParamSetByUser(const std::string &nm) const
std::vector< std::vector< Real > > _properties
Tabulated fluid properties (read from file OR computed from _fp)
virtual Real mu_from_p_T(Real pressure, Real temperature) const override
virtual Real cp_from_p_T(Real pressure, Real temperature) const override
virtual Real criticalDensity() const
Critical density.
unsigned int _enthalpy_idx
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _num_p
Number of pressure points in the tabulated data.
static const std::string v
virtual Real T_from_p_h(Real pressure, Real enthalpy) const override
const bool _allow_fp_and_tabulation
Whether to allow a fp object when a tabulation is in use.
virtual Real cv_from_p_T(Real pressure, Real temperature) const override
std::vector< std::vector< Real > > _properties_ve
Tabulated fluid properties in (v,e) (read from file OR computed from _fp)
const unsigned int _max_newton_its
Maximum number of iterations for the variable conversion newton solves.
Real _v_max
Maximum specific volume in tabulated data (can be user-specified)
static const std::string pressure
virtual Real T_from_h_s(Real h, Real s) const
const Real _p_initial_guess
Initial guess for pressure (or pressure used to compute the initial guess)
IntRange< T > make_range(T beg, T end)
std::vector< Real > _specific_volume
Specific volume vector.
virtual Real p_from_v_e(Real v, Real e) const override
Derivatives like dc_dv & dc_de are computed using the chain rule dy/dx(p,T) = dy/dp * dp/dx + dy/dT *...
unsigned int _entropy_idx
virtual Real cp_from_v_e(Real v, Real e) const override
void mooseError(Args &&... args) const
unsigned int _density_idx
Index of each property.
virtual Real criticalPressure() const
Critical pressure.
e e e e s T T T T T rho v v T e p T T virtual T std::string fluidName() const
Fluid name.
std::vector< Real > _internal_energy
Specific internal energy vector.
std::unique_ptr< BidimensionalInterpolation > _T_from_v_h_ipol
Bi-dimensional interpolation of temperature from (v,h)
bool _interpolate_density
Set of flags to note whether a property is to be interpolated.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual std::vector< Real > henryCoefficients() const override
The following routines are simply forwarded to the 'fp' companion FluidProperties as they are not inc...
const ConsoleStream _console
void createVGridVector()
Create (or reset) the grid vectors for the specific volume and internal energy interpolations The ord...
std::vector< std::unique_ptr< BidimensionalInterpolation > > _property_ipol
Vector of bi-dimensional interpolation of fluid properties.
const bool _save_file
Whether to save a generated fluid properties file to disk.
virtual Real mu_from_v_e(Real v, Real e) const override
OOBBehavior
Enum specifying all the behavior on out of bounds data options.
const std::vector< std::string > & getNames() const
processor_id_type processor_id() const
virtual Real vaporPressure(Real T) const
Vapor pressure.
bool _interpolate_enthalpy
const Real _T_initial_guess
Initial guess for temperature (or temperature used to compute the initial guess)
virtual void generateTabulatedData()
Generates a table of fluid properties by looping over pressure and temperature and calculating proper...
MooseUnits pow(const MooseUnits &, int)
virtual void constructInterpolation()=0
static const std::string k
void writeTabulatedData(std::string file_name)
Writes tabulated data to a file.
virtual Real T_from_p_rho(Real pressure, Real rho) const
void ErrorVector unsigned int
auto index_range(const T &sizable)
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
FileName _file_name_in
File name of input tabulated data file.
unsigned int _num_e
Number of internal energy points in tabulated data.