63template <
class Scalar>
71 static const Scalar Rs;
79 static std::string_view
name()
142 template <
class Evaluation>
164 template <
class Evaluation>
187 template <
class Evaluation>
189 const Evaluation& pressure)
206 return enthalpyRegion2_<Evaluation>(temperature,
triplePressure() - 100);
219 enthalpyRegion2_(temperature, pv) +
220 (pressure - pv)*dh_dp;
223 return enthalpyRegion2_(temperature, pressure);
238 template <
class Evaluation>
240 const Evaluation& pressure)
254 const Evaluation& dh_dp =
261 enthalpyRegion1_(temperature, pv) +
262 (pressure - pv)*dh_dp;
265 return enthalpyRegion1_(temperature, pressure);
280 template <
class Evaluation>
282 const Evaluation& pressure)
293 return heatCap_p_Region2_(temperature, Evaluation(
triplePressure() - 100));
298 return heatCap_p_Region2_(temperature, pv);
300 return heatCap_p_Region2_(temperature, pressure);
315 template <
class Evaluation>
317 const Evaluation& pressure)
331 return heatCap_p_Region1_(temperature, pv);
334 return heatCap_p_Region1_(temperature, pressure);
349 template <
class Evaluation>
351 const Evaluation& pressure)
386 const Evaluation& uv = internalEnergyRegion1_(temperature, Evaluation(pv));
387 const Evaluation& uvPEps = internalEnergyRegion1_(temperature, Evaluation(pv + eps));
388 const Evaluation& du_dp = (uvPEps - uv)/eps;
389 return uv + du_dp*(pressure - pv);
392 return internalEnergyRegion1_(temperature, pressure);
407 template <
class Evaluation>
428 enthalpyRegion2_(temperature, Evaluation(
triplePressure() - 100.0))
460 const Evaluation& uv = internalEnergyRegion2_(temperature, Evaluation(pv));
461 const Evaluation& uvMEps = internalEnergyRegion2_(temperature, Evaluation(pv - eps));
462 const Evaluation& du_dp = (uv - uvMEps)/eps;
463 return uv + du_dp*(pressure - pv);
466 return internalEnergyRegion2_(temperature, pressure);
481 template <
class Evaluation>
483 const Evaluation& pressure)
498 return heatCap_v_Region1_(temperature, pv);
501 return heatCap_v_Region1_(temperature, pressure);
516 template <
class Evaluation>
533 return heatCap_v_Region2_(temperature, pv);
536 return heatCap_v_Region2_(temperature, pressure);
563 template <
class Evaluation>
564 static Evaluation
gasDensity(
const Evaluation& temperature,
const Evaluation& pressure)
577 const Evaluation& rho0IAPWS =
578 1.0/volumeRegion2_(temperature,
580 const Evaluation& rho0Id =
598 Scalar eps = scalarValue(pv)*1e-8;
599 Evaluation v0 = volumeRegion2_(temperature, pv);
600 Evaluation v1 = volumeRegion2_(temperature, pv + eps);
601 Evaluation dv_dp = (v1 - v0)/eps;
617 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
620 return 1.0/v0 + (pressure - pv)*drho_dp;
623 return 1.0/volumeRegion2_(temperature, pressure);
644 template <
class Evaluation>
645 static Evaluation
gasPressure(
const Evaluation& temperature, Scalar density)
653 Scalar eps = pressure*1e-7;
655 Evaluation deltaP = pressure*2;
658 for (
int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
659 Evaluation f =
gasDensity(temperature, pressure) - density;
662 df_dp =
gasDensity(temperature, pressure + eps);
663 df_dp -=
gasDensity(temperature, pressure - eps);
689 template <
class Evaluation>
691 const Evaluation& pressure,
692 bool extrapolate =
false)
709 Scalar eps = scalarValue(pv)*1e-8;
710 Evaluation v0 = volumeRegion1_(temperature, pv);
711 Evaluation v1 = volumeRegion1_(temperature, pv + eps);
712 Evaluation dv_dp = (v1 - v0)/eps;
730 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
733 return 1.0/v0 + (pressure - pv)*drho_dp;
736 return 1/volumeRegion1_(temperature, pressure);
752 template <
class Evaluation>
759 Scalar eps = scalarValue(pressure)*1e-7;
761 Evaluation deltaP = pressure*2;
762 for (
int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
763 Evaluation f =
liquidDensity(temperature, pressure) - density;
792 template <
class Evaluation>
793 static Evaluation
gasViscosity(
const Evaluation& temperature,
const Evaluation& pressure)
802 Evaluation rho =
gasDensity(temperature, pressure);
818 template <
class Evaluation>
820 const Evaluation& pressure,
821 bool extrapolate =
false)
830 const Evaluation& rho =
liquidDensity(temperature, pressure, extrapolate);
847 template <
class Evaluation>
850 const Evaluation& rho =
liquidDensity(temperature, pressure);
867 template <
class Evaluation>
870 const Evaluation& rho =
gasDensity(temperature, pressure);
876 template <
class Evaluation>
877 static Evaluation enthalpyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
886 template <
class Evaluation>
887 static Evaluation heatCap_p_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
896 template <
class Evaluation>
897 static Evaluation heatCap_v_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
904 - std::pow(tau, 2 ) *
910 template <
class Evaluation>
911 static Evaluation internalEnergyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
920 template <
class Evaluation>
921 static Evaluation volumeRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
926 Rs * temperature / pressure;
930 template <
class Evaluation>
931 static Evaluation enthalpyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
940 template <
class Evaluation>
941 static Evaluation internalEnergyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
950 template <
class Evaluation>
951 static Evaluation heatCap_p_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
960 template <
class Evaluation>
961 static Evaluation heatCap_v_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
968 - std::pow(tau, 2 ) *
974 template <
class Evaluation>
975 static Evaluation volumeRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
980 Rs * temperature / pressure;
984 template<
class Evaluation>
985 static std::string domainError(
const std::string& type,
986 const Evaluation& temperature,
987 const Evaluation& pressure)
989 auto cast = [](
const auto d)
992 if constexpr (std::is_same_v<
decltype(d),
const quad>)
993 return static_cast<double>(d);
998 auto tostring = [cast](
const auto& val) -> std::string
1000 if constexpr (DenseAd::is_evaluation<Evaluation>::value) {
1001 return std::to_string(cast(getValue(val.value())));
1004 return std::to_string(cast(getValue(val)));
1007 return type +
" is only implemented for temperatures "
1008 "below 623.15K and pressures below 100MPa. (T = " +
1009 tostring(temperature) +
", p=" + tostring(pressure);
1013template <
class Scalar>
1014const Scalar H2O<Scalar>::Rs = Common::Rs;
Implements relations which are common for all regions of the IAPWS '97 formulation.
Abstract base class of a pure chemical species.
Representation of an evaluation of a function and its derivatives w.r.t.
Provides the OPM specific exception classes.
Relations valid for an ideal gas.
Implements the equations for region 1 of the IAPWS '97 formulation.
Implements the equations for region 2 of the IAPWS '97 formulation.
Implements the equations for region 4 of the IAPWS '97 formulation.
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
Abstract base class of a pure chemical species.
Definition Component.hpp:44
Material properties of pure water .
Definition H2O.hpp:65
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of pure water in at a given pressure and temperature.
Definition H2O.hpp:690
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition H2O.hpp:97
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition H2O.hpp:564
static std::string_view name()
A human readable name for the water.
Definition H2O.hpp:79
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition H2O.hpp:542
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition H2O.hpp:645
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition H2O.hpp:143
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition H2O.hpp:793
static Evaluation gasHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of steam and water vapor .
Definition H2O.hpp:517
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition H2O.hpp:281
static const Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition H2O.hpp:115
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition H2O.hpp:239
static Evaluation liquidThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition H2O.hpp:848
static const Scalar acentricFactor()
The acentric factor of water.
Definition H2O.hpp:91
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition H2O.hpp:350
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition H2O.hpp:629
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition H2O.hpp:103
static const Scalar molarMass()
The molar mass in of water.
Definition H2O.hpp:85
static Evaluation vaporTemperature(const Evaluation &pressure)
The vapor temperature in of pure water at a given pressure.
Definition H2O.hpp:165
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition H2O.hpp:548
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity of pure water.
Definition H2O.hpp:819
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition H2O.hpp:408
static Evaluation gasThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition H2O.hpp:868
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition H2O.hpp:188
static Evaluation liquidHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of liquid water .
Definition H2O.hpp:482
static Evaluation liquidPressure(const Evaluation &temperature, Scalar density)
The pressure of liquid water in at a given density and temperature.
Definition H2O.hpp:753
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition H2O.hpp:121
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition H2O.hpp:316
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition H2O.hpp:127
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition H2O.hpp:109
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition Common.hpp:56
static OPM_HOST_DEVICE Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition Common.hpp:103
static const Scalar criticalVolume
Critical volume of water .
Definition Common.hpp:74
static const Scalar criticalPressure
Critical pressure of water .
Definition Common.hpp:68
static const Scalar criticalMolarVolume
Critical molar volume of water .
Definition Common.hpp:77
static const Scalar criticalTemperature
Critical temperature of water .
Definition Common.hpp:65
static OPM_HOST_DEVICE Evaluation thermalConductivityIAPWS(const Evaluation &T, const Evaluation &rho)
Thermal conductivity water (IAPWS) .
Definition Common.hpp:163
static const Scalar tripleTemperature
Triple temperature of water .
Definition Common.hpp:83
static const Scalar triplePressure
Triple pressure of water .
Definition Common.hpp:86
static const Scalar molarMass
The molar mass of water .
Definition Common.hpp:59
static const Scalar acentricFactor
The acentric factor of water .
Definition Common.hpp:80
Implements the equations for region 1 of the IAPWS '97 formulation.
Definition Region1.hpp:51
static Evaluation ddgamma_ddpi(const Evaluation &temperature, const Evaluation &pressure)
The second partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 1 ...
Definition Region1.hpp:252
static Evaluation tau(const Evaluation &temperature)
Returns the reduced temperature for IAPWS region 1.
Definition Region1.hpp:83
static Evaluation ddgamma_ddtau(const Evaluation &temperature, const Evaluation &pressure)
The second partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region...
Definition Region1.hpp:282
static Evaluation pi(const Evaluation &pressure)
Returns the reduced pressure for IAPWS region 1.
Definition Region1.hpp:102
static Evaluation dgamma_dtau(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region 1 (i....
Definition Region1.hpp:162
static bool isValid(const Evaluation &temperature, const Evaluation &pressure)
Returns true if IAPWS region 1 applies for a (temperature in , pressure in ) pair.
Definition Region1.hpp:61
static Evaluation ddgamma_dtaudpi(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized pressure and to the normalized temp...
Definition Region1.hpp:221
static Scalar dpi_dp(const Evaluation &)
Returns the derivative of the reduced pressure to the pressure for IAPWS region 1 in .
Definition Region1.hpp:112
static Evaluation dgamma_dpi(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 1 (i....
Definition Region1.hpp:191
Implements the equations for region 2 of the IAPWS '97 formulation.
Definition Region2.hpp:52
static Scalar dpi_dp(const Evaluation &)
Returns the derivative of the reduced pressure to the pressure for IAPWS region 2 in .
Definition Region2.hpp:111
static Evaluation ddgamma_ddtau(const Evaluation &temperature, const Evaluation &pressure)
The second partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region...
Definition Region2.hpp:310
static Evaluation ddgamma_ddpi(const Evaluation &temperature, const Evaluation &pressure)
The second partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 2 ...
Definition Region2.hpp:276
static Evaluation pi(const Evaluation &pressure)
Returns the reduced pressure (dimensionless) for IAPWS region 2.
Definition Region2.hpp:101
static Evaluation dgamma_dtau(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region 2 (i....
Definition Region2.hpp:170
static Evaluation tau(const Evaluation &temperature)
Returns the reduced temperature (dimensionless) for IAPWS region 2.
Definition Region2.hpp:82
static Evaluation ddgamma_dtaudpi(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized pressure and to the normalized temp...
Definition Region2.hpp:242
static bool isValid(const Evaluation &temperature, const Evaluation &pressure)
Returns true if IAPWS region 2 applies for a (temperature, pressure) pair.
Definition Region2.hpp:62
static Evaluation dgamma_dpi(const Evaluation &temperature, const Evaluation &pressure)
The partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 2 (i....
Definition Region2.hpp:209
Implements the equations for region 4 of the IAPWS '97 formulation.
Definition Region4.hpp:52
static Evaluation vaporTemperature(const Evaluation &pressure)
Returns the saturation temperature in of pure water at a given pressure.
Definition Region4.hpp:94
static Evaluation saturationPressure(const Evaluation &temperature)
Returns the saturation pressure in of pure water at a given temperature.
Definition Region4.hpp:63
static OPM_HOST_DEVICE Evaluation pressure(const Evaluation &temperature, const Evaluation &rhoMolar)
The pressure of the gas in , depending on the molar density and temperature.
Definition IdealGas.hpp:59
static OPM_HOST_DEVICE Evaluation density(const Evaluation &avgMolarMass, const Evaluation &temperature, const Evaluation &pressure)
The density of the gas in , depending on pressure, temperature and average molar mass of the gas.
Definition IdealGas.hpp:49
Definition Exceptions.hpp:40
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
This file provides the infrastructure to use quad-precision floating point values in the numerical mo...