12 #include "metaphysicl/raw_type.h" 26 params.
addRequiredParam<FunctionName>(
"k",
"Thermal conductivity, [W/(m-K)]");
27 params.
addParam<
Real>(
"T_c", 0,
"Critical temperature, [K]");
28 params.
addParam<
Real>(
"rho_c", 0,
"Critical density, [kg/m3]");
29 params.
addParam<
Real>(
"e_c", 0,
"Specific internal energy at the critical point, [J/kg]");
31 "e",
"Specific internal energy as a function of temperature [J/kg]");
35 "temperature_resolution", 1,
"Step size in temperature for creating the inverse lookup T(e)");
36 params.
addParam<
bool>(
"out_of_bound_error",
true,
"Error if out of bounds");
37 params.
addClassDescription(
"Fluid properties for an ideal gas with imperfect caloric behavior.");
45 _molar_mass(getParam<
Real>(
"molar_mass")),
46 _R_specific(_R / _molar_mass),
47 _T_c(getParam<
Real>(
"T_c")),
48 _rho_c(getParam<
Real>(
"rho_c")),
49 _e_c(getParam<
Real>(
"e_c")),
50 _min_temperature(getParam<
Real>(
"min_temperature")),
51 _max_temperature(getParam<
Real>(
"max_temperature")),
52 _delta_T(getParam<
Real>(
"temperature_resolution")),
53 _out_of_bound_error(getParam<bool>(
"out_of_bound_error")),
78 for (
unsigned int j = 0;
j < n; ++
j)
85 if (
cv < 0 || (
cv == 0 &&
j > 0 &&
j < n - 1))
86 mooseError(
"e(T) is not monotonically increasing with T");
100 for (
unsigned int j = 0;
j < n; ++
j)
126 enthalpy = std::min(enthalpy,
_max_h);
131 auto h_diff = [&enthalpy,
this](
Real x) {
return this->
h_from_p_T(0.0,
x) - enthalpy; };
156 return "caloric_imperfect_gas";
193 dcv_dT = (cv_pert -
cv) / (
T * pert);
204 dcp_dT = (cp_pert -
cp) / (
T * pert);
210 if (e < _min_e || e >
_max_e)
226 if (h < _min_h || h >
_max_h)
262 if (
v.value() == 0.0)
267 Real raw1 =
v.value();
268 Real raw2 = e.value();
274 result.derivatives() =
v.derivatives() * dxd1 + e.derivatives() * dxd2;
296 if (
v.value() == 0.0)
301 Real raw1 =
v.value();
302 Real raw2 = e.value();
308 result.derivatives() =
v.derivatives() * dxd1 + e.derivatives() * dxd2;
330 return std::sqrt(c2);
340 return getNaN(
"Sound speed squared (gamma * R * T) is negative: c2 = " +
343 return std::sqrt(c2);
349 Real T, dT_dv, dT_de;
352 Real gamma, dgamma_dv, dgamma_dT;
357 dc_dv = dc_dT * dT_dv;
358 dc_de = dc_dT * dT_de;
375 const Real p,
const Real T, Real &
c, Real & dc_dp, Real & dc_dT)
const 377 Real gamma, dgamma_dp, dgamma_dT;
412 Real raw1 =
v.value();
413 Real raw2 = e.value();
419 result.derivatives() =
v.derivatives() * dxd1 + e.derivatives() * dxd2;
430 dcv_de = dcv_dT /
cv;
443 Real raw1 =
v.value();
444 Real raw2 = e.value();
450 result.derivatives() =
v.derivatives() * dxd1 + e.derivatives() * dxd2;
456 Real
v, Real e, Real & gamma, Real & dgamma_dv, Real & dgamma_de)
const 464 dgamma_de = 1.0 /
cv * dcp_de - gamma /
cv * dcv_de;
469 Real p, Real T, Real & gamma, Real & dgamma_dp, Real & dgamma_dT)
const 477 dgamma_dT = 1.0 /
cv * dcp_dT - gamma /
cv * dcv_dT;
490 Real raw1 =
p.value();
491 Real raw2 =
T.value();
496 result.derivatives() =
p.derivatives() * dxd1 +
T.derivatives() * dxd2;
643 Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT)
const 651 CaloricallyImperfectGas::e_from_p_rho(Real p, Real rho)
const 653 return e_from_p_rho_template(
p,
rho);
657 CaloricallyImperfectGas::e_from_p_rho(
const ADReal & p,
const ADReal & rho)
const 659 return e_from_p_rho_template(
p,
rho);
663 CaloricallyImperfectGas::e_from_p_rho(
664 Real p, Real rho, Real & e, Real & de_dp, Real & de_drho)
const 666 e_from_p_rho_template(
p,
rho, e, de_dp, de_drho);
670 CaloricallyImperfectGas::e_from_p_rho(
673 e_from_p_rho_template(
p,
rho, e, de_dp, de_drho);
694 Real raw1 =
T.value();
695 Real raw2 =
v.value();
701 result.derivatives() =
T.derivatives() * dxd1 +
v.derivatives() * dxd2;
743 Real p, dp_dT_v, dp_dv_T;
744 Real ds_dp_T, ds_dT_p;
747 ds_dT = ds_dT_p + ds_dp_T * dp_dT_v;
748 ds_dv = ds_dp_T * dp_dv_T;
790 Real raw1 =
p.value();
791 Real raw2 =
T.value();
797 result.derivatives() =
p.derivatives() * dxd1 +
T.derivatives() * dxd2;
855 Real , Real T, Real &
cv, Real & dcv_dp, Real & dcv_dT)
const 869 Real , Real T, Real &
cp, Real & dcp_dp, Real & dcp_dT)
const 888 dmu_dT = (mu2 -
mu) / (
T * pert);
904 dk_dT = (k2 -
k) / (
T * pert);
932 dp_dh = (p_pert -
p) / (
h * pert);
934 dp_ds = (p_pert -
p) / (s * pert);
943 std::stringstream ss;
944 ss <<
"Function " <<
function <<
" encountered argument value of " <<
value 945 <<
" which is outside of the bounds of " <<
min <<
" .. " <<
max;
virtual void initialSetup() override
e e e e s T T T T T rho T
static const std::string cv
virtual Real mu_from_p_T(Real p, Real T) const override
A calorically imperfect gas fluid property class This fluid property assumes that internal energy is ...
CaloricallyImperfectGas(const InputParameters ¶meters)
static InputParameters validParams()
virtual Real cv_from_T_v(Real T, Real v) const override
virtual Real criticalInternalEnergy() const override
Critical specific internal energy.
virtual Real p_from_h_s(Real h, Real s) const override
const Function & getFunction(const std::string &name) const
virtual Real e_from_v_h(Real v, Real h) const override
virtual Real timeDerivative(Real t, const Point &p) const
virtual Real cp_from_p_T(Real p, Real T) const override
Real _min_e
internal energy and enthalpy limits when creating lookup tables
const bool _out_of_bound_error
Flag to error if out of bounds.
Real _delta_e
step size in internal energy and enthalpy
virtual Real h_from_T_v(Real T, Real v) const override
virtual Real gamma_from_v_e(Real v, Real e) const override
void outOfBounds(const std::string &function, Real value, Real min, Real max) const
function that handles exceeding parameter limits
virtual void v_e_spndl_from_T(Real T, Real &v, Real &e) const override
Specific internal energy from temperature and specific volume.
Real getNaN() const
Throws an error or returns a NaN with or without a warning, with a default message.
virtual Real molarMass() const override
Molar mass [kg/mol].
static const Real _R
Universal gas constant (J/mol/K)
virtual Real T_from_p_h(Real p, Real h) const override
virtual Real criticalDensity() const override
Critical density.
virtual Real rho_from_p_s(Real p, Real s) const override
static const std::string temperature
virtual Real mu_from_v_e(Real v, Real e) const override
virtual Real g_from_v_e(Real v, Real e) const override
DualNumber< Real, DNDerivativeType, true > ADReal
virtual Real k_from_v_e(Real v, Real e) const override
void mooseWarning(Args &&... args) const
auto max(const L &left, const R &right)
virtual Real cv_from_v_e(Real v, Real e) const override
static InputParameters validParams()
Real T_from_e(Real e) const
Real e_from_T(Real T) const
helper functions for e(T) and h(T), T(e), T(h), cv(T), cp(T)
virtual Real k_from_p_T(Real pressure, Real temperature) const override
virtual Real criticalTemperature() const override
Critical temperature.
static const std::string cp
e e e e s T T T T T rho v v T e h
virtual Real T_from_v_e(Real v, Real e) const override
Real h_from_T(Real T) const
Real T_from_h(Real h) const
virtual std::string fluidName() const override
Fluid name.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const Function * _k_T
Thermal conductivity.
const std::vector< double > x
virtual Real s_from_p_T(Real p, Real T) const override
static const std::string mu
Real cv_from_T(const CppType &T) const
Real cp_from_T(Real T) const
virtual Real e_spndl_from_v(Real v) const override
Specific internal energy from temperature and specific volume.
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent's method.
void setupLookupTables()
sets up the T(e) reverse lookup table
std::vector< Real > _T_h_lookup
inverse lookup table data
virtual Real e_from_p_T(Real p, Real T) const override
virtual Real e_from_T_v(Real T, Real v) const override
Common class for single phase fluid properties.
const Function * _mu_T
Dynamic viscosity.
virtual Real cp_from_v_e(Real v, Real e) const override
virtual Real rho_from_p_T(Real p, Real T) const override
virtual Real c_from_v_e(Real v, Real e) const override
virtual Real s_from_v_e(Real v, Real e) const override
std::string stringify(const T &t)
const Function * _e_T
Internal energy as a function of temperature.
virtual Real h_from_p_T(Real p, Real T) const override
virtual Real p_from_T_v(Real T, Real v) const override
static const std::string Z
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Real _delta_T
temperature interval in lookup tables
virtual Real p_from_v_e(Real v, Real e) const override
Real Z_from_T(Real T) const
void mooseError(Args &&... args) const
static const std::string internal_energy
virtual Real gamma_from_p_T(Real p, Real T) const override
static InputParameters validParams()
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual Real s_from_h_p(Real h, Real p) const override
virtual Real value(Real t, const Point &p) const
virtual void initialSetup()
registerMooseObject("FluidPropertiesApp", CaloricallyImperfectGas)
const Real & _molar_mass
molar mass
Interface class for producing errors, warnings, or just quiet NaNs.
Real _min_temperature
temperature limits when creating lookup tables
auto min(const L &left, const R &right)
const Real _R_specific
Specific gas constant (R / molar mass)
static const std::string k
virtual Real s_from_T_v(Real T, Real v) const override
virtual Real cv_from_p_T(Real p, Real T) const override
std::vector< Real > _Z_T_lookup
Z(T) lookup table on uniform grid between _min_temperature and _max_temperature.
virtual Real c_from_p_T(Real p, Real T) const override
std::vector< Real > _T_e_lookup
void bracket(std::function< Real(Real)> const &f, Real &x1, Real &x2)
Function to bracket a root of a given function.