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)));
549 mooseException(
name() +
": vaporTemperature(): Pressure ",
551 " is outside range 611.213 Pa <= p <= 22.064 MPa");
554 const ADReal beta2 = beta * beta;
558 const ADReal d = 2.0 * g / (-
f - std::sqrt(
f *
f - 4.0 * e * g));
560 return (
_n4[9] +
d - std::sqrt((
_n4[9] +
d) * (
_n4[9] +
d) - 4.0 * (
_n4[8] +
_n4[9] *
d))) / 2.0;
580 dTsat_dp =
T.derivatives()[0];
588 if (temperature < 623.15 || temperature > 863.15)
589 mooseException(
name(),
590 ": b23p(): Temperature ",
592 " is outside range of 623.15 K <= T <= 863.15 K");
602 if (pressure < 16.529e6 || pressure > 100.0e6)
604 name(),
": b23T(): Pressure ",
pressure,
"is outside range 16.529 MPa <= p <= 100 MPa");
629 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
644 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
657 mooseException(
"Enthalpy ", enthalpy,
" is out of range in ",
name(),
": inRegionPH()");
660 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegionPH()");
668 unsigned int subregion;
688 unsigned int subregion;
702 if (pressure < 6.5467e6 || pressure > 100.0e6)
704 name(),
": b2bc(): Pressure ",
pressure,
" is outside range of 6.5467 MPa <= p <= 100 MPa");
708 return (0.26526571908428e4 + std::sqrt((
pi - 0.45257578905948e1) / 0.12809002730136e-3)) * 1.0e3;
732 dT_dp =
T.derivatives()[0];
733 dT_dh =
T.derivatives()[1];
763 else if (subregion == 2)
783 mooseError(
"temperature_from_ph() not implemented for region 5");
787 mooseError(
"inRegionPH() has given an incorrect region");
797 const ADReal eta = enthalpy / 2500.0e3;
800 for (std::size_t i = 0; i <
_nph1.size(); ++i)
808 const ADReal & enthalpy)
const 811 const ADReal eta = enthalpy / 2000.0e3;
817 for (std::size_t i = 0; i <
_nph2a.size(); ++i)
826 const ADReal & enthalpy)
const 829 const ADReal eta = enthalpy / 2000.0e3;
837 for (std::size_t i = 0; i <
_nph2b.size(); ++i)
846 const ADReal & enthalpy)
const 849 const ADReal eta = enthalpy / 2000.0e3;
855 for (std::size_t i = 0; i <
_nph2c.size(); ++i)
868 name(),
": b3ab(): Pressure ",
pressure,
"is outside range of 16.529 MPa <= p <= 100 MPa");
871 Real eta = 0.201464004206875e4 + 0.374696550136983e1 *
pi - 0.219921901054187e-1 *
pi *
pi +
872 0.87513168600995e-4 *
pi *
pi *
pi;
879 const ADReal & enthalpy)
const 882 const ADReal eta = enthalpy / 2300.0e3;
885 for (std::size_t i = 0; i <
_nph3a.size(); ++i)
893 const ADReal & enthalpy)
const 896 const ADReal eta = enthalpy / 2800.0e3;
899 for (std::size_t i = 0; i <
_nph3b.size(); ++i)
908 const Real A = coeffs[0];
909 const Real B = coeffs[1];
910 const Real C = coeffs[2];
913 const Real tau = 1.0 - Tr;
919 const std::vector<Real>
a{
920 -7.85951783, 1.84408259, -11.7866497, 22.6807411, -15.9618719, 1.80122502};
921 const std::vector<Real>
b{1.0, 1.5, 3.0, 3.5, 4.0, 7.5};
924 for (std::size_t i = 0; i <
a.size(); ++i)
927 return 22.064e6 * std::exp(sum / Tr) * std::exp(lnkh);
932 const std::vector<Real> & coeffs,
936 const Real A = coeffs[0];
937 const Real B = coeffs[1];
938 const Real C = coeffs[2];
940 const Real pc = 22.064e6;
941 const Real Tc = 647.096;
944 const Real tau = 1.0 - Tr;
948 const Real dlnkh_dT =
949 (-
A / Tr / Tr -
B *
std::pow(tau, 0.355) / Tr / Tr - 0.355 *
B *
std::pow(tau, -0.645) / Tr -
950 0.41 *
C *
std::pow(Tr, -1.41) * std::exp(tau) -
C *
std::pow(Tr, -0.41) * std::exp(tau)) /
954 const std::vector<Real>
a{
955 -7.85951783, 1.84408259, -11.7866497, 22.6807411, -15.9618719, 1.80122502};
956 const std::vector<Real>
b{1.0, 1.5, 3.0, 3.5, 4.0, 7.5};
960 for (std::size_t i = 0; i <
a.size(); ++i)
966 const Real p = pc * std::exp(sum / Tr);
967 const Real dp_dT = -
p / Tc / Tr * (sum / Tr + dsum);
970 Kh =
p * std::exp(lnkh);
971 dKh_dT = (
p * dlnkh_dT + dp_dT) * std::exp(lnkh);
976 const std::vector<Real> & coeffs)
const 980 Real dKh_dT_real = 0.0;
984 Kh.derivatives() =
temperature.derivatives() * dKh_dT_real;
993 const Real P3cd = 19.00881189173929;
994 unsigned int subregion = 0;
996 if (pMPa > 40.0 && pMPa <= 100.0)
1003 else if (pMPa > 25.0 && pMPa <= 40.0)
1014 else if (pMPa > 23.5 && pMPa <= 25.0)
1029 else if (pMPa > 23.0 && pMPa <= 23.5)
1044 else if (pMPa > 22.5 && pMPa <= 23.0)
1072 if (pMPa > 22.11 && pMPa <= 22.5)
1083 else if (pMPa > 22.064 && pMPa <= 22.11)
1096 if (pMPa > 21.93161551 && pMPa <= 22.064)
1106 if (pMPa > 21.90096265 && pMPa <= 22.064)
1122 else if (pMPa > 20.5 &&
1134 else if (pMPa > P3cd && pMPa <= 20.5)
1143 else if (pMPa >
vaporPressure(623.15) * 1.0e-6 && pMPa <= P3cd)
1150 else if (pMPa > 22.11 && pMPa <= 22.5)
1161 else if (pMPa > 22.064 && pMPa <= 22.11)
1173 mooseError(
"subregion3(): Shouldn't have got here!");
1186 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegion()");
1190 if (pressure < 0.0 || pressure > 50.0e6)
1191 mooseException(
"Pressure ",
pressure,
" is out of range in ",
name(),
": inRegion()");
1194 mooseException(
"Temperature ",
temperature,
" is out of range in ",
name(),
": inRegion()");
1197 unsigned int region;
T v_from_p_T_template(const T &pressure, const T &temperature) const
const Real _T_critical
Critical temperature (K)
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.
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
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
DualNumber< Real, DNDerivativeType, true > ADReal
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)
virtual const std::string & name() const
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...
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.
T cv_from_p_T_template(const T &pressure, const T &temperature) const
const std::array< int, 20 > _Jph1
e e e e s T T T T T rho v v T e h
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
static const std::string mu
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.
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
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
static const std::string v
const std::array< int, 38 > _Iph2b
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.
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...
void mooseError(Args &&... args) const
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
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...