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)
362 Scalar pv = vaporPressure<Scalar>(scalarValue(temperature));
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)
647 Valgrind::CheckDefined(temperature);
648 Valgrind::CheckDefined(density);
653 Scalar eps = pressure*1e-7;
655 Evaluation deltaP = pressure*2;
656 Valgrind::CheckDefined(pressure);
657 Valgrind::CheckDefined(deltaP);
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);
669 Valgrind::CheckDefined(pressure);
670 Valgrind::CheckDefined(deltaP);
688 template <
class Evaluation>
690 const Evaluation& pressure,
691 bool extrapolate =
false)
708 Scalar eps = scalarValue(pv)*1e-8;
709 Evaluation v0 = volumeRegion1_(temperature, pv);
710 Evaluation v1 = volumeRegion1_(temperature, pv + eps);
711 Evaluation dv_dp = (v1 - v0)/eps;
729 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
732 return 1.0/v0 + (pressure - pv)*drho_dp;
735 return 1/volumeRegion1_(temperature, pressure);
751 template <
class Evaluation>
758 Scalar eps = scalarValue(pressure)*1e-7;
760 Evaluation deltaP = pressure*2;
761 for (
int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
762 Evaluation f =
liquidDensity(temperature, pressure) - density;
791 template <
class Evaluation>
792 static Evaluation
gasViscosity(
const Evaluation& temperature,
const Evaluation& pressure)
801 Evaluation rho =
gasDensity(temperature, pressure);
816 template <
class Evaluation>
818 const Evaluation& pressure,
819 bool extrapolate =
false)
828 const Evaluation& rho =
liquidDensity(temperature, pressure, extrapolate);
845 template <
class Evaluation>
848 const Evaluation& rho =
liquidDensity(temperature, pressure);
865 template <
class Evaluation>
868 const Evaluation& rho =
gasDensity(temperature, pressure);
874 template <
class Evaluation>
875 static Evaluation enthalpyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
884 template <
class Evaluation>
885 static Evaluation heatCap_p_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
894 template <
class Evaluation>
895 static Evaluation heatCap_v_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
902 - std::pow(tau, 2 ) *
908 template <
class Evaluation>
909 static Evaluation internalEnergyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
918 template <
class Evaluation>
919 static Evaluation volumeRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
924 Rs * temperature / pressure;
928 template <
class Evaluation>
929 static Evaluation enthalpyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
938 template <
class Evaluation>
939 static Evaluation internalEnergyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
948 template <
class Evaluation>
949 static Evaluation heatCap_p_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
958 template <
class Evaluation>
959 static Evaluation heatCap_v_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
966 - std::pow(tau, 2 ) *
972 template <
class Evaluation>
973 static Evaluation volumeRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
978 Rs * temperature / pressure;
982 template<
class Evaluation>
983 static std::string domainError(
const std::string& type,
984 const Evaluation& temperature,
985 const Evaluation& pressure)
987 auto cast = [](
const auto d)
990 if constexpr (std::is_same_v<
decltype(d),
const quad>)
991 return static_cast<double>(d);
996 auto tostring = [cast](
const auto& val) -> std::string
998 if constexpr (DenseAd::is_evaluation<Evaluation>::value) {
999 return std::to_string(cast(getValue(val.value())));
1002 return std::to_string(cast(getValue(val)));
1005 return type +
" is only implemented for temperatures "
1006 "below 623.15K and pressures below 100MPa. (T = " +
1007 tostring(temperature) +
", p=" + tostring(pressure);
1011template <
class Scalar>
1012const 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.
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:689
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:792
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:846
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:817
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:866
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:752
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...