12 #include "libmesh/utility.h" 28 _p_critical(22.064e6),
164 const Real
p,
const Real
rho, Real & e, Real & de_dp, Real & de_drho)
const 301 dmu_dp = dmu_drho * drho_dp;
318 const Real mu_star = 1.0e-6;
325 Real sum0 = 0.0, dsum0_dTbar = 0.0;
326 for (std::size_t i = 0; i <
_mu_H0.size(); ++i)
332 const Real mu0 = 100.0 * std::sqrt(Tbar) / sum0;
333 const Real dmu0_dTbar =
334 50.0 / std::sqrt(Tbar) / sum0 - 100.0 * std::sqrt(Tbar) * dsum0_dTbar / sum0 / sum0;
337 Real sum1 = 0.0, dsum1_drhobar = 0.0, dsum1_dTbar = 0.0;
338 for (
unsigned int i = 0; i < 6; ++i)
343 for (
unsigned int j = 0;
j < 7; ++
j)
351 const Real mu1 = std::exp(rhobar * sum1);
352 const Real dmu1_drhobar = (sum1 + rhobar * dsum1_drhobar) * mu1;
353 const Real dmu1_dTbar = (rhobar * dsum1_dTbar) * mu1;
356 mu = mu_star * mu0 * mu1;
357 dmu_drho = mu_star * mu0 * dmu1_drhobar * drhobar_drho;
358 dmu_dT = mu_star * (dmu0_dTbar * mu1 + mu0 * dmu1_dTbar) * dTbar_dT + dmu_drho * ddensity_dT;
391 dmu_dp = dmu_drho * drho_dp;
409 mooseError(
"k_from_p_T() is not implemented.");
443 Water97FluidProperties::s_from_p_T(
465 const Real enthalpy,
const Real
pressure, Real & s, Real & ds_dh, Real & ds_dp)
const 474 ADReal entropy = s_from_p_T_template(
p,
T);
476 ds_dh = entropy.derivatives()[1];
477 ds_dp = entropy.derivatives()[0];
525 if (temperature < 273.15 || temperature >
_T_critical)
526 mooseException(
name(),
527 ": vaporPressure(): Temperature ",
529 " is outside range 273.15 K <= T " 534 theta2 = theta * theta;
535 a = theta2 +
_n4[0] * theta +
_n4[1];
536 b =
_n4[2] * theta2 +
_n4[3] * theta +
_n4[4];
537 c =
_n4[5] * theta2 +
_n4[6] * theta +
_n4[7];
538 p = Utility::pow<4>(2.0 *
c / (-
b + std::sqrt(
b *
b - 4.0 *
a *
c)));
550 mooseException(
name() +
": vaporTemperature(): Pressure ",
552 " is outside range 611.213 Pa <= p <= 22.064 MPa");
555 const ADReal beta2 = beta * beta;
581 dTsat_dp =
T.derivatives()[0];
589 if (temperature < 623.15 || temperature > 863.15)
590 mooseException(
name(),
591 ": b23p(): Temperature ",
593 " is outside range of 623.15 K <= T <= 863.15 K");
603 if (pressure < 16.529e6 || pressure > 100.0e6)
605 name(),
": b23T(): Pressure ",
pressure,
"is outside range 16.529 MPa <= p <= 100 MPa");
620 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
639 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
652 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
663 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
666 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegionPH()");
674 unsigned int subregion;
694 unsigned int subregion;
708 if (pressure < 6.5467e6 || pressure > 100.0e6)
710 name(),
": b2bc(): Pressure ",
pressure,
" is outside range of 6.5467 MPa <= p <= 100 MPa");
714 return (0.26526571908428e4 + std::sqrt((
pi - 0.45257578905948e1) / 0.12809002730136e-3)) * 1.0e3;
738 dT_dp =
T.derivatives()[0];
739 dT_dh =
T.derivatives()[1];
769 else if (subregion == 2)
794 Real T_min = 1073.15;
795 Real T_max = 2273.15;
802 T_find = 0.5 * (T_min + T_max);
805 if (h_find > enthalpy.value())
810 T_error = std::abs((T_max - T_min) / T_find);
814 mooseWarning(
"The derivatives for T_from_p_h_ad are currently neglected, set to 0."));
820 mooseError(
"inRegionPH() has given an incorrect region");
832 const ADReal eta = enthalpy / 2500.0e3;
835 for (std::size_t i = 0; i <
_nph1.size(); ++i)
843 const ADReal & enthalpy)
const 848 const ADReal eta = enthalpy / 2000.0e3;
854 for (std::size_t i = 0; i <
_nph2a.size(); ++i)
862 const ADReal & enthalpy)
const 867 const ADReal eta = enthalpy / 2000.0e3;
875 for (std::size_t i = 0; i <
_nph2b.size(); ++i)
884 const ADReal & enthalpy)
const 889 const ADReal eta = enthalpy / 2000.0e3;
895 for (std::size_t i = 0; i <
_nph2c.size(); ++i)
908 name(),
": b3ab(): Pressure ",
pressure,
"is outside range of 16.529 MPa <= p <= 100 MPa");
911 Real eta = 0.201464004206875e4 + 0.374696550136983e1 *
pi - 0.219921901054187e-1 *
pi *
pi +
912 0.87513168600995e-4 *
pi *
pi *
pi;
919 const ADReal & enthalpy)
const 924 const ADReal eta = enthalpy / 2300.0e3;
927 for (std::size_t i = 0; i <
_nph3a.size(); ++i)
935 const ADReal & enthalpy)
const 940 const ADReal eta = enthalpy / 2800.0e3;
943 for (
size_t i = 0; i <
_nph3b.size(); ++i)
952 const Real A = coeffs[0];
953 const Real B = coeffs[1];
954 const Real C = coeffs[2];
957 const Real tau = 1.0 - Tr;
963 const std::vector<Real>
a{
964 -7.85951783, 1.84408259, -11.7866497, 22.6807411, -15.9618719, 1.80122502};
965 const std::vector<Real>
b{1.0, 1.5, 3.0, 3.5, 4.0, 7.5};
968 for (std::size_t i = 0; i <
a.size(); ++i)
971 return 22.064e6 * std::exp(sum / Tr) * std::exp(lnkh);
976 const std::vector<Real> & coeffs,
980 const Real A = coeffs[0];
981 const Real B = coeffs[1];
982 const Real C = coeffs[2];
984 const Real pc = 22.064e6;
985 const Real Tc = 647.096;
988 const Real tau = 1.0 - Tr;
992 const Real dlnkh_dT =
993 (-
A / Tr / Tr -
B *
std::pow(tau, 0.355) / Tr / Tr - 0.355 *
B *
std::pow(tau, -0.645) / Tr -
994 0.41 *
C *
std::pow(Tr, -1.41) * std::exp(tau) -
C *
std::pow(Tr, -0.41) * std::exp(tau)) /
998 const std::vector<Real>
a{
999 -7.85951783, 1.84408259, -11.7866497, 22.6807411, -15.9618719, 1.80122502};
1000 const std::vector<Real>
b{1.0, 1.5, 3.0, 3.5, 4.0, 7.5};
1004 for (std::size_t i = 0; i <
a.size(); ++i)
1010 const Real p = pc * std::exp(sum / Tr);
1011 const Real dp_dT = -
p / Tc / Tr * (sum / Tr + dsum);
1014 Kh =
p * std::exp(lnkh);
1015 dKh_dT = (
p * dlnkh_dT + dp_dT) * std::exp(lnkh);
1020 const std::vector<Real> & coeffs)
const 1024 Real dKh_dT_real = 0.0;
1028 Kh.derivatives() =
temperature.derivatives() * dKh_dT_real;
1037 const Real P3cd = 19.00881189173929;
1038 unsigned int subregion = 0;
1040 if (pMPa > 40.0 && pMPa <= 100.0)
1047 else if (pMPa > 25.0 && pMPa <= 40.0)
1058 else if (pMPa > 23.5 && pMPa <= 25.0)
1073 else if (pMPa > 23.0 && pMPa <= 23.5)
1088 else if (pMPa > 22.5 && pMPa <= 23.0)
1116 if (pMPa > 22.11 && pMPa <= 22.5)
1127 else if (pMPa > 22.064 && pMPa <= 22.11)
1140 if (pMPa > 21.93161551 && pMPa <= 22.064)
1150 if (pMPa > 21.90096265 && pMPa <= 22.064)
1166 else if (pMPa > 20.5 &&
1178 else if (pMPa > P3cd && pMPa <= 20.5)
1187 else if (pMPa >
vaporPressure(623.15) * 1.0e-6 && pMPa <= P3cd)
1194 else if (pMPa > 22.11 && pMPa <= 22.5)
1205 else if (pMPa > 22.064 && pMPa <= 22.11)
1217 mooseError(
"subregion3(): Shouldn't have got here!");
1230 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegion()");
1234 if (pressure < 0.0 || pressure > 50.0e6)
1235 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegion()");
1238 mooseException(
"Temperature ",
temperature,
" is out of range in ",
name(),
": inRegion()");
1241 unsigned int region;
T v_from_p_T_template(const T &pressure, const T &temperature) const
const Real _T_critical
Critical temperature (K)
T dgamma2_dtau(const T &pi, const T &tau) const
Derivative of Gibbs free energy in Region 2 wrt tau.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
virtual Real mu_from_p_T(Real pressure, Real temperature) const override
e e e e s T T T T T rho T
static InputParameters validParams()
virtual void rho_mu_from_p_T(Real pressure, Real temperature, Real &rho, Real &mu) const override
Combined methods.
virtual Real triplePointTemperature() const override
Triple point temperature.
ADReal temperature_from_ph3b(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 3b Eq.
ADReal temperature_from_ph3a(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 3a Eq.
unsigned int inRegion(Real pressure, Real temperature) const
Determines the phase region that the given pressure and temperature values lie in.
const std::array< Real, 5 > _n23
Constants for the boundary between regions 2 and 3.
T tempXY(const T &pressure, subregionEnum xy) const
Boundaries between subregions in region 3.
std::pair< T, T > rho_T_from_v_e(const T &v, const T &e) const
Computes the density (first member of the pair) and temperature (second member of the pair) as functi...
Real vaporTemperature(Real pressure) const override
Saturation temperature as a function of pressure.
const bool _allow_imperfect_jacobians
Flag to set unimplemented Jacobian entries to zero.
Real p_from_v_e(Real v, Real e) const override
ADReal temperature_from_ph2b(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 2b Eq.
const Real _p_critical
Critical pressure (Pa)
const std::array< int, 33 > _Jph3b
Real T_from_v_e(Real v, Real e) const override
const std::array< int, 20 > _Iph1
virtual Real e_from_p_T(Real pressure, Real temperature) const override
Real b2bc(Real pressure) const
Boundary between subregions b and c in region 2.
static InputParameters validParams()
virtual std::string fluidName() const override
Fluid name.
const std::array< int, 23 > _Jph2c
static constexpr Real TOLERANCE
const std::array< Real, 36 > _nph2a
T k_from_v_e_template(const T &v, const T &e) const
T e_from_p_T_template(const T &pressure, const T &temperature) const
registerMooseObject("FluidPropertiesApp", Water97FluidProperties)
virtual Real criticalDensity() const override
Critical density.
T k_from_p_T_template(const T &pressure, const T &temperature) const
Real b23T(Real pressure) const
Auxillary equation for the boundary between regions 2 and 3.
Water97FluidProperties(const InputParameters ¶meters)
virtual ADReal cv_from_v_e(const ADReal &v, const ADReal &e) const override
T c_from_p_T_template(const T &pressure, const T &temperature) const
T rho_from_p_T_template(const T &pressure, const T &temperature) const
unsigned int subregion3(Real pressure, Real temperature) const
Provides the correct subregion index for a (P,T) point in region 3.
const std::array< int, 36 > _Jph2a
static const std::string density
const std::array< std::array< Real, 7 >, 6 > _mu_Hij
ADReal vaporTemperature_ad(const ADReal &pressure) const
AD version of saturation temperature as a function of pressure (used internally)
int sgn(T val)
The sign function.
T h_from_p_T_template(const T &pressure, const T &temperature) const
const std::array< Real, 33 > _nph3b
static const std::string temperature
const std::array< Real, 38 > _nph2b
std::pair< T, T > p_T_from_v_h(const T &v, const T &h) const
Computes the pressure (first member of the pair) and temperature (second member of the pair) as funct...
virtual Real h_from_p_T(Real pressure, Real temperature) const override
virtual Real criticalTemperature() const override
Critical temperature.
const std::array< int, 33 > _Iph3b
virtual Real k_from_p_T(Real pressure, Real temperature) const override
ADReal mu_from_v_e(const ADReal &v, const ADReal &e) const override
unsigned int subregion2ph(Real pressure, Real enthalpy) const
Provides the correct subregion index for a (P,h) point in region 2.
const Real _T_triple
Triple point temperature (K)
std::pair< T, T > p_T_from_v_e(const T &v, const T &e) const
Computes the pressure (first member of the pair) and temperature (second member of the pair) as funct...
DualNumber< Real, DNDerivativeType, false > ADReal
const std::array< int, 23 > _Iph2c
ADReal temperature_from_ph2a(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 2a Eq.
const std::array< Real, 5 > _p_star
Pressure scale for each region.
T cv_from_p_T_template(const T &pressure, const T &temperature) const
const std::array< int, 20 > _Jph1
const std::array< Real, 5 > _T_star
Temperature scale for each region.
e e e e s T T T T T rho v v T e h
const std::string & name() const
const std::array< int, 36 > _Iph2a
Real k_from_v_e(Real v, Real e) const override
const std::array< int, 38 > _Jph2b
Real f(Real x)
Test function for Brents method.
const std::array< int, 31 > _Jph3a
virtual Real s_from_h_p(Real enthalpy, Real pressure) const override
ADReal T_from_p_h_ad(const ADReal &pressure, const ADReal &enthalpy) const
AD version of backwards equation T(p, h) (used internally) From Revised Release on the IAPWS Industri...
const std::array< int, 31 > _Iph3a
virtual Real v_from_p_T(Real pressure, Real temperature) const override
virtual Real triplePointPressure() const override
Triple point pressure.
T dgamma1_dtau(const T &pi, const T &tau) const
Derivative of Gibbs free energy in Region 1 wrt tau.
Common class for single phase fluid properties.
const std::array< Real, 20 > _nph1
ADReal temperature_from_ph1(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 1 Eq.
ADReal e_from_v_h(const ADReal &v, const ADReal &h) const override
unsigned int subregion3ph(Real pressure, Real enthalpy) const
Provides the correct subregion index for a (P,h) point in region 3.
virtual ~Water97FluidProperties()
virtual Real T_from_p_h(Real pressure, Real enthalpy) const override
Backwards equation T(p, h) From Revised Release on the IAPWS Industrial Formulation 1997 for the Ther...
T mu_from_rho_T_template(const T &density, const T &temperature) const
virtual Real c_from_p_T(Real pressure, Real temperature) const override
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
T p_from_v_e_template(const T &v, const T &e) const
const std::array< Real, 31 > _nph3a
T k_from_rho_T_template(const T &density, const T &temperature) const
Real b23p(Real temperature) const
Auxillary equation for the boundary between regions 2 and 3.
const Real _rho_critical
Critical density (kg/m^3)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::array< int, 38 > _Iph2b
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
virtual Real e_from_p_rho(Real p, Real rho) const override
virtual Real criticalPressure() const override
Critical pressure.
Real b3ab(Real pressure) const
Boundary between subregions a and b in region 3.
Water (H2O) fluid properties as a function of pressure (Pa) and temperature (K) from IAPWS-IF97: Revi...
static const std::string pressure
virtual Real vaporPressure(Real temperature) const override
Vapor pressure.
void mooseWarning(Args &&... args) const
void mooseError(Args &&... args) const
Real henryConstant(Real temperature, const std::vector< Real > &coeffs) const
IAPWS formulation of Henry's law constant for dissolution in water From Guidelines on the Henry's con...
unsigned int inRegionPH(Real pressure, Real enthalpy) const
Determines the phase region that the given pressure and enthaply values lie in.
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
virtual Real k_from_rho_T(Real density, Real temperature) const override
T cp_from_p_T_template(const T &pressure, const T &temperature) const
const Real _Rw
Specific gas constant for H2O (universal gas constant / molar mass of water - J/kg/K) ...
virtual Real rho_from_p_T(Real pressure, Real temperature) const override
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const Real _p_triple
Triple point pressure (Pa)
T mu_from_p_T_template(const T &pressure, const T &temperature) const
T e_from_p_rho_template(const T &p, const T &rho) const
virtual ADReal c_from_v_e(const ADReal &v, const ADReal &e) const override
virtual Real cv_from_p_T(Real pressure, Real temperature) const override
ADReal temperature_from_ph2c(const ADReal &pressure, const ADReal &enthalpy) const
Backwards equation T(p, h) in Region 2c Eq.
virtual Real mu_from_rho_T(Real density, Real temperature) const override
const std::array< Real, 23 > _nph2c
virtual Real cp_from_p_T(Real pressure, Real temperature) const override
const Real _Mh2o
Water molar mass (kg/mol)
MooseUnits pow(const MooseUnits &, int)
static const std::string C
virtual ADReal cp_from_v_e(const ADReal &v, const ADReal &e) const override
virtual Real molarMass() const override
Molar mass [kg/mol].
const std::array< Real, 10 > _n4
Constants for region 4 (the saturation curve up to the critical point)
const std::array< Real, 4 > _mu_H0
Constants from Release on the IAPWS Formulation 2008 for the Viscosity of Ordinary Water Substance...