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.");
1464 h_from_p_T(
pressure.value(), current_T.value(), new_h.value(), dh_dp.value(), dh_dT.value());
1466 new_h.derivatives() =
1467 dh_dp.value() *
pressure.derivatives() + dh_dT.value() * current_T.derivatives();
1477 ") and pressure (p = ",
1479 ") to temperature failed to converge.");
1493 Real h, Real
pressure, Real & s, Real & ds_dh, Real & ds_dp)
const 1499 mooseError(
"fp",
"s_from_h_p derivatives not implemented.");
1505 mooseError(
"TabulatedFluidProperties can only call the function '" + desired_routine +
1506 "' when the 'fp' parameter is provided. It is currently not implemented using " 1507 "tabulations, and this property is simply forwarded to the FluidProperties specified " 1508 "in the 'fp' parameter");
1514 file_name = file_name.empty() ?
"fluid_properties_" +
name() +
"_out.csv" : file_name;
1520 std::ofstream file_out(file_name.c_str());
1523 time_t now = std::time(&now);
1526 <<
" properties created by TabulatedFluidProperties on " << ctime(&now) <<
"\n";
1528 file_out <<
"# tabulated properties created by TabulatedFluidProperties on " << ctime(&now)
1532 file_out <<
"pressure, temperature";
1538 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1539 for (
unsigned int t = 0; t <
_num_T; ++t)
1542 for (std::size_t i = 0; i <
_properties.size(); ++i)
1547 file_out << std::flush;
1555 ? std::regex_replace(file_name, std::regex(
"\\.csv"),
"_ve.csv")
1558 std::ofstream file_out(file_name_ve.c_str());
1561 file_out <<
"specific_volume, internal_energy, pressure, temperature";
1578 bool add_comma =
true;
1580 file_out << 1 / v_val;
1606 file_out << std::flush;
1615 mooseAssert(
_fp,
"We should not try to generate (p,T) tabulated data without a _fp user object");
1632 for (
unsigned int j = 0;
j <
_num_T; ++
j)
1638 for (
unsigned int i = 0; i <
_num_p; ++i)
1645 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1646 for (
unsigned int t = 0; t <
_num_T; ++t)
1650 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1651 for (
unsigned int t = 0; t <
_num_T; ++t)
1655 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1656 for (
unsigned int t = 0; t <
_num_T; ++t)
1660 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1661 for (
unsigned int t = 0; t <
_num_T; ++t)
1665 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1666 for (
unsigned int t = 0; t <
_num_T; ++t)
1670 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1671 for (
unsigned int t = 0; t <
_num_T; ++t)
1675 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1676 for (
unsigned int t = 0; t <
_num_T; ++t)
1680 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1681 for (
unsigned int t = 0; t <
_num_T; ++t)
1685 for (
unsigned int p = 0;
p <
_num_p; ++
p)
1686 for (
unsigned int t = 0; t <
_num_T; ++t)
1694 mooseAssert(
_fp,
"We should not try to generate (v,e) tabulated data without a _fp user object");
1717 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1718 for (
unsigned int e = 0; e <
_num_e; ++e)
1722 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1723 for (
unsigned int e = 0; e <
_num_e; ++e)
1728 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1729 for (
unsigned int e = 0; e <
_num_e; ++e)
1733 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1734 for (
unsigned int e = 0; e <
_num_e; ++e)
1739 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1740 for (
unsigned int e = 0; e <
_num_e; ++e)
1745 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1746 for (
unsigned int e = 0; e <
_num_e; ++e)
1751 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1752 for (
unsigned int e = 0; e <
_num_e; ++e)
1757 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1758 for (
unsigned int e = 0; e <
_num_e; ++e)
1763 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1764 for (
unsigned int e = 0; e <
_num_e; ++e)
1769 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1770 for (
unsigned int e = 0; e <
_num_e; ++e)
1775 for (
unsigned int v = 0;
v <
_num_v; ++
v)
1776 for (
unsigned int e = 0; e <
_num_e; ++e)
1782 template <
typename T>
1786 using std::max, std::min;
1795 " is outside the range of tabulated pressure (" +
1803 flagInvalidSolution(
"Pressure out of bounds");
1805 flagSolutionWarning(
"Pressure out of bounds");
1814 " is outside the range of tabulated temperature (" +
1821 flagInvalidSolution(
"Temperature out of bounds");
1823 flagSolutionWarning(
"Temperature out of bounds");
1828 template <
typename T>
1832 using std::max, std::min;
1836 else if (e < _e_min || e >
_e_max)
1840 " is outside the range of tabulated specific internal energies (" +
1846 flagInvalidSolution(
"Specific internal energy out of bounds");
1848 flagSolutionWarning(
"Specific internal energy out of bounds");
1852 if (v < _v_min || v >
_v_max)
1856 " is outside the range of tabulated specific volumes (" +
1862 flagInvalidSolution(
"Specific volume out of bounds");
1864 flagSolutionWarning(
"Specific volume out of bounds");
1874 if (_p_initial_guess < _pressure_min || _p_initial_guess >
_pressure_max)
1875 mooseWarning(
"Pressure initial guess for (p,T), (v,e) conversions " +
1877 " is outside the range of tabulated " 1881 if (_T_initial_guess < _temperature_min || _T_initial_guess >
_temperature_max)
1882 mooseWarning(
"Temperature initial guess for (p,T), (v,e) conversions " +
1884 " is outside the range of tabulated " 1894 std::string file_name;
1912 std::vector<std::string> required_columns;
1914 required_columns = {
"pressure",
"temperature"};
1916 required_columns = {
"specific_volume",
"internal_energy"};
1919 for (std::size_t i = 0; i < required_columns.size(); ++i)
1921 if (std::find(column_names.begin(), column_names.end(), required_columns[i]) ==
1924 required_columns[i],
1927 ". A column named ",
1928 required_columns[i],
1929 " must be present");
1933 std::vector<std::string> property_columns = {
1934 "density",
"enthalpy",
"viscosity",
"k",
"c",
"cv",
"cp",
"entropy"};
1936 property_columns.push_back(
"internal_energy");
1939 property_columns.push_back(
"pressure");
1940 property_columns.push_back(
"temperature");
1945 for (std::size_t i = 0; i < column_names.size(); ++i)
1948 if (std::find(required_columns.begin(), required_columns.end(), column_names[i]) ==
1949 required_columns.end())
1951 if (std::find(property_columns.begin(), property_columns.end(), column_names[i]) ==
1952 property_columns.end())
1956 " tabulation file is not one of the properties that TabulatedFluidProperties " 1957 "understands. It will be ignored.");
1967 std::map<std::string, unsigned int> data_index;
1968 for (std::size_t i = 0; i < column_names.size(); ++i)
1970 auto it = std::find(column_names.begin(), column_names.end(), column_names[i]);
1971 data_index[column_names[i]] = std::distance(column_names.begin(), it);
1979 _pressure = column_data[data_index.find(
"pressure")->second];
1980 _temperature = column_data[data_index.find(
"temperature")->second];
1984 _specific_volume = column_data[data_index.find(
"specific_volume")->second];
1985 _internal_energy = column_data[data_index.find(
"internal_energy")->second];
1995 "specific internal energy");
2028 "Reading a (v,e) tabulation and generating (p,T) to (v,e) interpolation tables is " 2029 "not supported at this time.");
2044 std::vector<Real> & v2,
2045 const std::string & file_name,
2046 const std::string & v1_name,
2047 const std::string & v2_name)
2052 if (!std::is_sorted(v1.begin(), v1.end()))
2053 mooseError(
"The column data for ", v1_name,
" is not monotonically increasing in ", file_name);
2057 auto num_v2 = std::count(v1.begin(), v1.end(), v1.front());
2060 auto last_unique = std::unique(v1.begin(), v1.end());
2061 v1.erase(last_unique, v1.end());
2065 if (v2.size() != v1.size() * libMesh::cast_int<unsigned int>(num_v2))
2068 " is not equal to the number of unique ",
2072 " multiplied by the number of unique ",
2078 std::vector<Real> base_v2(v2.begin(), v2.begin() + num_v2);
2079 if (!std::is_sorted(base_v2.begin(), base_v2.end()))
2080 mooseError(
"The column data for ", v2_name,
" is not monotonically increasing in ", file_name);
2083 auto it_v2 = v2.begin() + num_v2;
2084 for (
const auto i :
make_range(v1.size() - 1))
2086 std::vector<Real> repeated_v2(it_v2, it_v2 + num_v2);
2087 if (repeated_v2 != base_v2)
2093 " are not identical to values for ",
2096 std::advance(it_v2, num_v2);
2101 v2.erase(v2.begin() + num_v2, v2.end());
2169 "' is present in the tabulation but is not currently leveraged by the code in the " 2170 "TabulatedFluidProperties. If it is spelled correctly, then please contact a " 2171 "MOOSE or fluid properties module developer.");
2178 mooseAssert(
_file_name_ve_in.empty(),
"We should be reading the specific volume grid from file");
2188 _v_min = std::min({v1, v2, v3, v4});
2189 _v_max = std::max({v1, v2, v3, v4});
2213 for (
unsigned int j = 0;
j <
_num_v; ++
j)
2219 for (
unsigned int j = 0;
j <
_num_v; ++
j)
2237 _e_min = std::min({e1, e2, e3, e4});
2238 _e_max = std::max({e1, e2, e3, e4});
2257 mooseError(
"Logarithmic grid in specific energy can only be used with a positive specific " 2258 "energy. Current minimum: " +
2285 _h_min = std::min({h1, h2, h3, h4});
2286 _h_max = std::max({h1, h2, h3, h4});
2300 mooseError(
"Need a source to compute the enthalpy grid bounds: either a FP object, or a (p,T) " 2301 "tabulation file or a (v,e) tabulation file");
2311 mooseError(
"Logarithmic grid in specific energy can only be used with a positive enthalpy. " 2312 "Current minimum: " +
2331 ": to call this function you must:\n-add this property to the list to the list of " 2332 "'interpolated_properties'\n and then either:\n-construct (p, T) from (v, e) " 2333 "tabulations using the 'construct_pT_from_ve' parameter\n-load (v,e) interpolation " 2334 "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
void paramError(const std::string ¶m, Args... args) const
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
unsigned int _internal_energy_idx
std::vector< std::unique_ptr< BidimensionalInterpolation > > _property_ve_ipol
Vector of bi-dimensional interpolation of fluid properties directly in (v,e)
auto max(const L &left, const R &right)
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.
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.
const std::string & name() const
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.
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
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.
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)
void mooseWarning(Args &&... args) const
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 *...
void mooseError(Args &&... args) const
unsigned int _entropy_idx
virtual Real cp_from_v_e(Real v, Real e) const override
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")
bool checkFileWriteable(const std::string &filename, bool throw_on_unwritable)
virtual std::vector< Real > henryCoefficients() const override
The following routines are simply forwarded to the 'fp' companion FluidProperties as they are not inc...
bool isParamValid(const std::string &name) const
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
auto min(const L &left, const R &right)
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...
bool isParamSetByUser(const std::string &name) const
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)
FileName _file_name_in
File name of input tabulated data file.
unsigned int _num_e
Number of internal energy points in tabulated data.