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.");
71 return x == 0 ? rel_step : rel_step * std::abs(
x);
77 return "TemperaturePressureFunctionFluidProperties";
90 bool conversion_succeeded =
true;
92 if (conversion_succeeded)
102 auto lambda = [&](Real
p, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT)
103 {
h_from_p_T(
p, current_T, new_h, dh_dp, dh_dT); };
111 ") and enthalpy (h = ",
113 ") to temperature failed to converge.");
120 auto lambda = [&](Real
p, Real current_T, Real & new_rho, Real & drho_dp, Real & drho_dT)
129 ") and density (rho = ",
131 ") to temperature failed to converge.");
149 bool conversion_succeeded =
true;
151 if (conversion_succeeded)
154 mooseError(
"cp_from_v_e calculation failed. p= ",
p,
" T = ",
T);
160 Real
v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de)
const
164 const Real dv =
fdStep(
v, 1e-10);
166 const Real de =
fdStep(e, 1e-10);
180 bool conversion_succeeded =
true;
182 if (conversion_succeeded)
185 mooseError(
"cv_from_v_e calculation failed.");
191 Real
v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de)
const
204 bool conversion_succeeded =
true;
208 if (!conversion_succeeded)
209 mooseError(
"cv_from_v_e and derivatives calculation failed.");
212 const Real dv =
fdStep(
v, 1e-6);
213 p_T_from_v_e(
v + dv, e, p0, T0, p1, T1, conversion_succeeded);
214 Real dp_dv = (p1 -
p) / dv;
215 Real dT_dv = (T1 -
T) / dv;
216 if (!conversion_succeeded)
217 mooseError(
"cv_from_v_e and derivatives calculation failed.");
220 const Real de =
fdStep(e, 1e-6);
221 p_T_from_v_e(
v, e + de, p0, T0, p2, T2, conversion_succeeded);
222 Real dp_de = (p2 -
p) / de;
223 Real dT_de = (T2 -
T) / de;
224 if (!conversion_succeeded)
225 mooseError(
"cv_from_v_e and derivatives calculation failed.");
227 dcv_dv = dcv_dp * dp_dv + dcv_dT * dT_dv;
228 dcv_de = dcv_dp * dp_de + dcv_dT * dT_de;
237 auto lambda = [&](Real
T, Real current_p, Real & new_rho, Real & drho_dT, Real & drho_dp)
244 mooseError(
"Conversion from specific volume (v = ",
246 ") and specific energy (e = ",
248 ") to pressure failed to converge.");
266 bool conversion_succeeded =
true;
268 if (conversion_succeeded)
271 mooseError(
"mu_from_v_e calculation failed.");
289 bool conversion_succeeded =
true;
291 if (conversion_succeeded)
308 Real pressure, Real temperature, Real &
rho, Real & drho_dp, Real & drho_dT)
const
312 drho_dT = grad_function(0);
313 drho_dp = grad_function(1);
318 const ADReal & temperature,
326 drho_dT = grad_function(0);
327 drho_dp = grad_function(1);
338 Real pressure, Real temperature, Real &
v, Real & dv_dp, Real & dv_dT)
const
342 Real
rho, drho_dp, drho_dT;
345 dv_dp = -
v *
v * drho_dp;
346 dv_dT = -
v *
v * drho_dT;
354 return e + pressure /
rho;
359 Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT)
const
361 Real e, de_dp, de_dT;
362 e_from_p_T(pressure, temperature, e, de_dp, de_dT);
363 Real
rho, drho_dp, drho_dT;
365 h = e + pressure /
rho;
366 dh_dp = de_dp + 1. /
rho - pressure /
rho /
rho * drho_dp;
367 dh_dT = de_dT - pressure * drho_dT /
rho /
rho;
378 const auto h = (temperature -
_T_ref) / n_intervals;
381 for (
const auto i : make_range(n_intervals))
392 Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT)
const
403 const Real dp =
fdStep(pressure, 1e-8);
404 de_dp = (
e_from_p_T(pressure + dp, temperature) - e) / dp;
427 Real
rho, drho_dp, drho_dT;
429 return -drho_dT /
rho;
437 Real
rho, drho_dp, drho_dT;
440 Real alpha = -drho_dT /
rho;
441 Real beta = drho_dp /
rho;
442 if (!MooseUtils::absoluteFuzzyEqual(beta, 0))
457 Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT)
const
462 const Real dp =
fdStep(pressure, 1e-8);
463 const Real dT =
fdStep(temperature, 1e-8);
464 dcp_dp = (
cp_from_p_T(pressure + dp, temperature) - cp) / dp;
465 dcp_dT = (
cp_from_p_T(pressure, temperature + dT) - cp) / dT;
470 const RealVectorValue grad_function =
472 dcp_dT = grad_function(0);
473 dcp_dp = grad_function(1);
484 Real
rho, drho_dp, drho_dT;
487 Real alpha = -drho_dT /
rho;
488 Real beta = drho_dp /
rho;
489 if (!MooseUtils::absoluteFuzzyEqual(beta, 0))
499 Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT)
const
510 const Real dp =
fdStep(pressure, 1e-10);
511 const Real dT =
fdStep(temperature, 1e-10);
512 dcv_dp = (
cv_from_p_T(pressure + dp, temperature) - cv) / dp;
513 dcv_dT = (
cv_from_p_T(pressure, temperature + dT) - cv) / dT;
527 Real pressure, Real temperature, Real &
mu, Real & dmu_dp, Real & dmu_dT)
const
530 const RealVectorValue grad_function =
_mu_function->
gradient(0, Point(temperature, pressure, 0));
531 dmu_dT = grad_function(0);
532 dmu_dp = grad_function(1);
545 Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT)
const
548 const RealVectorValue grad_function =
_k_function->
gradient(0, Point(temperature, pressure, 0));
549 dk_dT = grad_function(0);
550 dk_dp = grad_function(1);
DualNumber< Real, DNDerivativeType, true > ADReal
const std::vector< double > x
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()
static Real fdStep(Real x, Real rel_step)
Finite-difference step for argument x that does not vanish when x is zero.
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.