31 "Fluid properties using bicubic interpolation on tabulated values provided");
44 std::vector<std::vector<Real>> data_matrix;
69 bool conversion_succeeded =
true;
70 unsigned int fail_counter_ve = 0;
71 unsigned int fail_counter_vh = 0;
83 unsigned int num_p_nans_ve = 0, num_T_nans_ve = 0, num_p_out_bounds_ve = 0,
84 num_T_out_bounds_ve = 0;
86 for (
unsigned int i = 0; i <
_num_v; ++i)
103 conversion_succeeded);
116 conversion_succeeded);
119 if (!conversion_succeeded)
170 std::vector<std::vector<Real>> p_from_v_h(
_num_v);
171 std::vector<std::vector<Real>> T_from_v_h(
_num_v);
173 unsigned int num_p_nans_vh = 0, num_T_nans_vh = 0, num_p_out_bounds_vh = 0,
174 num_T_out_bounds_vh = 0;
176 for (
unsigned int i = 0; i <
_num_v; ++i)
180 p_from_v_h[i].resize(
_num_e);
181 T_from_v_h[i].resize(
_num_e);
182 for (
unsigned int j = 0;
j <
_num_e; ++
j)
193 conversion_succeeded);
206 conversion_succeeded);
209 if (!conversion_succeeded)
229 p_from_v_h[i][
j] = p_vh;
230 T_from_v_h[i][
j] = T_vh;
256 const std::vector<Real> & vec,
257 std::vector<std::vector<Real>> & mat)
262 for (
unsigned int i = 0; i < nrow; ++i)
265 for (
unsigned int i = 0; i < nrow; ++i)
266 for (
unsigned int j = 0;
j < ncol; ++
j)
267 mat[i][
j] = vec[i * ncol +
j];
279 unsigned int & num_nans_1,
280 unsigned int & num_nans_2)
283 if (std::isnan(variable_1))
292 if (std::isnan(variable_2))
306 unsigned int & num_out_bounds)
313 else if (variable >
max)
322 unsigned int num_nans_T,
323 unsigned int num_out_bounds_p,
324 unsigned int num_out_bounds_T,
325 unsigned int convergence_failures,
326 unsigned int number_points,
327 std::string variable_set)
330 std::string while_creating =
331 "While creating (p,T) from " + variable_set +
" interpolation tables,\n";
332 std::string warning_message = while_creating;
333 std::string converge_fails =
"Inversion to (p,T) from " + variable_set +
" failed " +
334 std::to_string(convergence_failures) +
" times\n";
335 std::string p_nans =
"- " + std::to_string(num_nans_p) +
" nans generated out of " +
336 std::to_string(number_points) +
" points for pressure\n";
337 std::string T_nans =
"- " + std::to_string(num_nans_T) +
" nans generated out of " +
338 std::to_string(number_points) +
" points for temperature\n";
339 std::string p_oob =
"- " + std::to_string(num_out_bounds_p) +
" of " +
340 std::to_string(number_points) +
" pressure values were out of bounds\n";
341 std::string T_oob =
"- " + std::to_string(num_out_bounds_T) +
" of " +
342 std::to_string(number_points) +
" temperature values were out of bounds\n";
343 std::string outcome =
"The pressure and temperature values were replaced with their respective " 344 "min and max values.\n";
347 std::string source = (
_fp ?
"from input parameters" :
"from tabulation file");
350 if (convergence_failures)
351 warning_message += converge_fails;
353 warning_message += p_nans;
355 warning_message += T_nans;
356 if (num_out_bounds_p)
358 warning_message += p_oob;
359 warning_message += (
"Pressure bounds " + source +
": [" + std::to_string(
_pressure_min) +
", " +
362 if (num_out_bounds_T)
364 warning_message += T_oob;
365 warning_message += (
"Temperature bounds " + source +
": [" + std::to_string(
_temperature_min) +
369 if (num_nans_p || num_nans_T || num_out_bounds_p || num_out_bounds_T || convergence_failures)
registerMooseObject("FluidPropertiesApp", TabulatedBicubicFluidProperties)
const bool _create_direct_ve_interpolations
Whether to create direct (v,e) interpolations.
Class for fluid properties read from a tabulation in a file.
std::unique_ptr< BidimensionalInterpolation > _p_from_v_h_ipol
Bidimensional interpolation of pressure from (v,h)
void p_T_from_v_h(const T &v, const T &h, Real p0, Real T0, T &pressure, T &temperature, bool &conversion_succeeded) const
Determines (p,T) from (v,h) using Newton Solve in 2D Useful for conversion between different sets of ...
const bool _create_direct_pT_interpolations
Whether to create direct (p,T) interpolations.
Real _temperature_max
Maximum temperature in tabulated data.
virtual void constructInterpolation() override
void checkNaNs(Real min_1, Real max_1, Real min_2, Real max_2, unsigned int i, Real &variable_1, Real &variable_2, unsigned int &num_nans_1, unsigned int &num_nans_2)
If Newton Method jacobian produces NaNs, set variable to min or max depending on situation.
virtual Real T_from_v_e(Real v, Real e) const override
Real _pressure_max
Maximum pressure in tabulated data.
void createVEGridVectors()
MooseEnum _OOBBehavior
User-selected out-of-bounds behavior.
TabulatedBicubicFluidProperties(const InputParameters ¶meters)
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)
auto max(const L &left, const R &right)
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)
std::unique_ptr< BidimensionalInterpolation > _T_from_v_e_ipol
Bi-dimensional interpolation of temperature from (v,e)
std::vector< Real > _enthalpy
Specific enthalpy vector.
unsigned int _num_v
Number of specific volume points in the tabulated data.
bool _construct_pT_from_ve
if the lookup table p(v, e) and T(v, e) should be constructed
Real _temperature_min
Minimum temperature in tabulated data.
void createVHGridVectors()
Create (or reset) the grid vectors for the specific volume and enthalpy interpolation The order of pr...
bool _construct_pT_from_vh
if the lookup table p(v, h) and T(v, h) should be constructed
static InputParameters validParams()
Real _v_min
Minimum specific volume in tabulated data (can be user-specified)
std::vector< Real > _pressure
Pressure vector.
std::vector< Real > _temperature
Temperature vector.
Class for fluid properties read from a file.
unsigned int _num_T
Number of temperature points in the tabulated data.
static InputParameters validParams()
const SinglePhaseFluidProperties *const _fp
SinglePhaseFluidPropertiesPT UserObject.
registerMooseObjectRenamed("FluidPropertiesApp", TabulatedFluidProperties, "01/01/2023 00:00", TabulatedBicubicFluidProperties)
Real _pressure_min
Minimum pressure in tabulated data.
std::vector< std::vector< Real > > _properties
Tabulated fluid properties (read from file OR computed from _fp)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _num_p
Number of pressure points in the tabulated data.
std::vector< std::vector< Real > > _properties_ve
Tabulated fluid properties in (v,e) (read from file OR computed from _fp)
Real _v_max
Maximum specific volume in tabulated data (can be user-specified)
void checkOutofBounds(Real min, Real max, Real &variable, unsigned int &num_out_bounds)
If values go out of user defined range during Newton Method inversion, set variable to min or max dep...
const Real _p_initial_guess
Initial guess for pressure (or pressure used to compute the initial guess)
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 *...
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)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::unique_ptr< BidimensionalInterpolation > > _property_ipol
Vector of bi-dimensional interpolation of fluid properties.
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)
void reshapeData2D(unsigned int nrow, unsigned int ncol, const std::vector< Real > &vec, std::vector< std::vector< Real >> &mat)
Forms a 2D matrix from a single std::vector.
auto index_range(const T &sizable)
void outputWarnings(unsigned int num_nans_p, unsigned int num_nans_T, unsigned int num_out_bounds_p, unsigned int num_out_bounds_T, unsigned int convergence_failures, unsigned int number_points, std::string variable_set)
unsigned int _num_e
Number of internal energy points in tabulated data.