20 "k",
"Thermal conductivity function of temperature and pressure [W/(m-K)]");
22 "Density function of temperature and pressure [kg/m^3]");
24 "mu",
"Dynamic viscosity function of temperature and pressure [Pa-s]");
27 "cp",
"Isobaric specific heat function of temperature and pressure [J/(kg-K)]");
29 "cv", 0,
"cv >= 0",
"Constant isochoric specific heat [J/(kg-K)]");
30 params.
addParam<Real>(
"e_ref", 0,
"Specific internal energy at the reference temperature");
31 params.
addParam<Real>(
"T_ref", 0,
"Reference temperature for the specific internal energy");
32 params.
addParam<Real>(
"dT_integration_intervals",
34 "Size of intervals for integrating cv(T) to compute e(T) from e(T_ref)");
37 "Single-phase fluid properties that allows to provide thermal "
38 "conductivity, density, and viscosity as functions of temperature and pressure.");
46 _cv(getParam<Real>(
"cv")),
47 _cv_is_constant(_cv != 0),
48 _e_ref(getParam<Real>(
"e_ref")),
49 _T_ref(getParam<Real>(
"T_ref")),
50 _integration_dT(getParam<Real>(
"dT_integration_intervals"))
53 paramError(
"cp",
"The parameter 'cp' may only be specified if 'cv' is unspecified or is zero.");
69 return "TemperaturePressureFunctionFluidProperties";
82 bool conversion_succeeded =
true;
84 if (conversion_succeeded)
94 auto lambda = [&](Real
p, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT)
103 ") and enthalpy (h = ",
105 ") to temperature failed to converge.");
112 auto lambda = [&](Real
p, Real current_T, Real & new_rho, Real & drho_dp, Real & drho_dT)
121 ") and density (rho = ",
123 ") to temperature failed to converge.");
141 bool conversion_succeeded =
true;
143 if (conversion_succeeded)
146 mooseError(
"cp_from_v_e calculation failed. p= ",
p,
" T = ",
T);
152 Real
v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de)
const
158 dcp_dv = (cp_pert - cp) /
eps /
v;
160 dcp_de = (cp_pert - cp) /
eps / e;
173 bool conversion_succeeded =
true;
175 if (conversion_succeeded)
178 mooseError(
"cp_from_v_e calculation failed.");
184 Real
v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de)
const
197 bool conversion_succeeded =
true;
201 if (!conversion_succeeded)
202 mooseError(
"cp_from_v_e and derivatives calculation failed.");
205 p_T_from_v_e(
v * (1 + 1e-6), e, p0, T0, p1, T1, conversion_succeeded);
206 Real dp_dv = (p1 -
p) / (
v * 1e-6);
207 Real dT_dv = (T1 -
T) / (
v * 1e-6);
208 if (!conversion_succeeded)
209 mooseError(
"cp_from_v_e and derivatives calculation failed.");
212 p_T_from_v_e(
v, e * (1 + 1e-6), p0, T0, p2, T2, conversion_succeeded);
213 Real dp_de = (p2 -
p) / (e * 1e-6);
214 Real dT_de = (T2 -
T) / (e * 1e-6);
215 if (!conversion_succeeded)
216 mooseError(
"cp_from_v_e and derivatives calculation failed.");
218 dcv_dv = dcv_dp * dp_dv + dcv_dT * dT_dv;
219 dcv_de = dcv_dp * dp_de + dcv_dT * dT_de;
228 auto lambda = [&](Real
T, Real current_p, Real & new_rho, Real & drho_dT, Real & drho_dp)
235 mooseError(
"Conversion from specific volume (v = ",
237 ") and specific energy (e = ",
239 ") to pressure failed to converge.");
257 bool conversion_succeeded =
true;
259 if (conversion_succeeded)
262 mooseError(
"mu_from_v_e calculation failed.");
280 bool conversion_succeeded =
true;
282 if (conversion_succeeded)
299 Real pressure, Real temperature, Real &
rho, Real & drho_dp, Real & drho_dT)
const
303 drho_dT = grad_function(0);
304 drho_dp = grad_function(1);
309 const ADReal & temperature,
317 drho_dT = grad_function(0);
318 drho_dp = grad_function(1);
329 Real pressure, Real temperature, Real &
v, Real & dv_dp, Real & dv_dT)
const
333 Real
rho, drho_dp, drho_dT;
336 dv_dp = -
v *
v * drho_dp;
337 dv_dT = -
v *
v * drho_dT;
345 return e + pressure /
rho;
350 Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT)
const
352 Real e, de_dp, de_dT;
353 e_from_p_T(pressure, temperature, e, de_dp, de_dT);
354 Real
rho, drho_dp, drho_dT;
356 h = e + pressure /
rho;
357 dh_dp = de_dp + 1. /
rho - pressure /
rho /
rho * drho_dp;
358 dh_dT = de_dT - pressure * drho_dT /
rho /
rho;
369 const auto h = (temperature -
_T_ref) / n_intervals;
372 for (
const auto i : make_range(n_intervals))
383 Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT)
const
394 Real ep =
e_from_p_T(pressure * (1 + 1e-8), temperature);
395 de_dp = (ep - e) / (pressure * 1e-8);
418 Real
rho, drho_dp, drho_dT;
420 return -drho_dT /
rho;
428 Real
rho, drho_dp, drho_dT;
431 Real alpha = -drho_dT /
rho;
432 Real beta = -drho_dp /
rho;
433 if (!MooseUtils::absoluteFuzzyEqual(beta, 0))
448 Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT)
const
456 dcp_dp = (cp_1p - cp) / (pressure *
eps);
457 dcp_dT = (cp_1T - cp) / (temperature *
eps);
462 const RealVectorValue grad_function =
464 dcp_dT = grad_function(0);
465 dcp_dp = grad_function(1);
476 Real
rho, drho_dp, drho_dT;
479 Real alpha = -drho_dT /
rho;
480 Real beta = -drho_dp /
rho;
481 if (!MooseUtils::absoluteFuzzyEqual(beta, 0))
491 Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT)
const
505 dcv_dp = (cv_1p - cv) / (pressure *
eps);
506 dcv_dT = (cv_1T - cv) / (temperature *
eps);
520 Real pressure, Real temperature, Real &
mu, Real & dmu_dp, Real & dmu_dT)
const
523 const RealVectorValue grad_function =
_mu_function->
gradient(0, Point(temperature, pressure, 0));
524 dmu_dT = grad_function(0);
525 dmu_dp = grad_function(1);
538 Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT)
const
541 const RealVectorValue grad_function =
_k_function->
gradient(0, Point(temperature, pressure, 0));
542 dk_dT = grad_function(0);
543 dk_dp = grad_function(1);
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("FluidPropertiesApp", TemperaturePressureFunctionFluidProperties)
const Function & getFunction(const std::string &name) const
virtual RealGradient gradient(Real t, const Point &p) const
virtual Real value(Real t, const Point &p) const
const std::string & name() const
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
Common class for single phase fluid properties.
const Real _T_initial_guess
Initial guess for temperature (or temperature used to compute the initial guess)
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 ...
const Real _p_initial_guess
Initial guess for pressure (or pressure used to compute the initial guess)
static InputParameters validParams()
e e e e s T T T T T rho T
const Real _tolerance
Newton's method may be used to convert between variable sets.
const unsigned int _max_newton_its
Maximum number of iterations for the variable conversion newton solves.
e e e e s T T T T T rho v v T e h
Fluid properties provided as multiple-variable functions of temperature and pressure.
virtual Real e_from_p_rho(Real p, Real rho) const override
Specific internal energy from pressure and density.
void initialSetup() override
Functions are constructed after fluid properties, so we delay the getting of the Function.
virtual Real cv_from_v_e(Real v, Real e) const override
Isochoric specific heat from specific volume and specific internal energy.
bool _initialized
whether the object is initialized, eg, the functions have been retrieved from the problem
virtual Real T_from_v_e(Real v, Real e) const override
Temperature from specific volume and specific internal energy.
virtual Real k_from_p_T(Real p, Real T) const override
Thermal conductivity from pressure and temperature.
const Real _integration_dT
Size of temperature intervals when integrating the specific heat to compute the specific energy.
const Function * _rho_function
function defining density as a function of temperature and pressure
const bool _cv_is_constant
whether a constant isochoric specific heat is used
virtual Real p_from_v_e(Real v, Real e) const override
Pressure from specific volume and specific internal energy.
const Real _e_ref
Reference specific energy.
virtual Real cv_from_p_T(Real p, Real T) const override
Isochoric specific heat capacity from pressure and temperature.
virtual Real k_from_v_e(Real v, Real e) const override
Thermal conductivity from specific volume and specific internal energy.
virtual Real e_from_p_T(Real p, Real T) const override
Specific internal energy from pressure and temperature.
virtual Real rho_from_p_T(Real p, Real T) const override
Density from pressure and temperature.
const Function * _mu_function
function defining dynamic viscosity as a function of temperature and pressure
virtual Real h_from_p_T(Real p, Real T) const override
Specific enthalpy from pressure and temperature.
virtual Real T_from_p_rho(Real p, Real rho) const
Temperature from pressure and density.
virtual std::string fluidName() const override
Fluid name.
TemperaturePressureFunctionFluidProperties(const InputParameters ¶meters)
virtual Real beta_from_p_T(Real p, Real T) const override
Thermal expansion coefficient from pressure and temperature.
virtual Real mu_from_v_e(Real v, Real e) const override
Dynamic viscosity from specific volume and specific internal energy.
const Function * _cp_function
function defining specific heat as a function of temperature and pressure
const Function * _k_function
function defining thermal conductivity as a function of temperature and pressure
virtual Real v_from_p_T(Real p, Real T) const override
Specific volume from pressure and temperature.
virtual Real cp_from_p_T(Real p, Real T) const override
Isobaric specific heat capacity from pressure and temperature.
static InputParameters validParams()
const Real _T_ref
Reference temperature for the reference specific energy.
const Real _cv
constant isochoric specific heat
virtual Real T_from_p_h(Real p, Real h) const override
Temperature from pressure and specific enthalpy.
virtual Real cp_from_v_e(Real v, Real e) const override
Isobaric specific heat from specific volume and specific internal energy.
virtual Real mu_from_p_T(Real p, Real T) const override
Dynamic viscosity from pressure and temperature.
std::pair< T, T > NewtonSolve(const T &x, const T &y, const Real z_initial_guess, const Real tolerance, const Functor &y_from_x_z, const std::string &caller_name, const unsigned int max_its=100, const bool verbose=false)
NewtonSolve does a 1D Newton Solve to solve the equation y = f(x, z) for variable z.