63template <
class Scalar>
71 static const Scalar Rs;
77 static std::string_view
name()
140 template <
class Evaluation>
162 template <
class Evaluation>
185 template <
class Evaluation>
187 const Evaluation& pressure)
204 return enthalpyRegion2_<Evaluation>(temperature,
triplePressure() - 100);
217 enthalpyRegion2_(temperature, pv) +
218 (pressure - pv)*dh_dp;
221 return enthalpyRegion2_(temperature, pressure);
236 template <
class Evaluation>
238 const Evaluation& pressure)
252 const Evaluation& dh_dp =
259 enthalpyRegion1_(temperature, pv) +
260 (pressure - pv)*dh_dp;
263 return enthalpyRegion1_(temperature, pressure);
278 template <
class Evaluation>
280 const Evaluation& pressure)
291 return heatCap_p_Region2_(temperature, Evaluation(
triplePressure() - 100));
296 return heatCap_p_Region2_(temperature, pv);
298 return heatCap_p_Region2_(temperature, pressure);
313 template <
class Evaluation>
315 const Evaluation& pressure)
329 return heatCap_p_Region1_(temperature, pv);
332 return heatCap_p_Region1_(temperature, pressure);
347 template <
class Evaluation>
349 const Evaluation& pressure)
360 Scalar pv = vaporPressure<Scalar>(scalarValue(temperature));
384 const Evaluation& uv = internalEnergyRegion1_(temperature, Evaluation(pv));
385 const Evaluation& uvPEps = internalEnergyRegion1_(temperature, Evaluation(pv + eps));
386 const Evaluation& du_dp = (uvPEps - uv)/eps;
387 return uv + du_dp*(pressure - pv);
390 return internalEnergyRegion1_(temperature, pressure);
405 template <
class Evaluation>
426 enthalpyRegion2_(temperature, Evaluation(
triplePressure() - 100.0))
458 const Evaluation& uv = internalEnergyRegion2_(temperature, Evaluation(pv));
459 const Evaluation& uvMEps = internalEnergyRegion2_(temperature, Evaluation(pv - eps));
460 const Evaluation& du_dp = (uv - uvMEps)/eps;
461 return uv + du_dp*(pressure - pv);
464 return internalEnergyRegion2_(temperature, pressure);
479 template <
class Evaluation>
481 const Evaluation& pressure)
496 return heatCap_v_Region1_(temperature, pv);
499 return heatCap_v_Region1_(temperature, pressure);
514 template <
class Evaluation>
531 return heatCap_v_Region2_(temperature, pv);
534 return heatCap_v_Region2_(temperature, pressure);
561 template <
class Evaluation>
562 static Evaluation
gasDensity(
const Evaluation& temperature,
const Evaluation& pressure)
575 const Evaluation& rho0IAPWS =
576 1.0/volumeRegion2_(temperature,
578 const Evaluation& rho0Id =
596 Scalar eps = scalarValue(pv)*1e-8;
597 Evaluation v0 = volumeRegion2_(temperature, pv);
598 Evaluation v1 = volumeRegion2_(temperature, pv + eps);
599 Evaluation dv_dp = (v1 - v0)/eps;
615 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
618 return 1.0/v0 + (pressure - pv)*drho_dp;
621 return 1.0/volumeRegion2_(temperature, pressure);
642 template <
class Evaluation>
643 static Evaluation
gasPressure(
const Evaluation& temperature, Scalar density)
645 Valgrind::CheckDefined(temperature);
646 Valgrind::CheckDefined(density);
651 Scalar eps = pressure*1e-7;
653 Evaluation deltaP = pressure*2;
654 Valgrind::CheckDefined(pressure);
655 Valgrind::CheckDefined(deltaP);
656 for (
int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
657 Evaluation f =
gasDensity(temperature, pressure) - density;
660 df_dp =
gasDensity(temperature, pressure + eps);
661 df_dp -=
gasDensity(temperature, pressure - eps);
667 Valgrind::CheckDefined(pressure);
668 Valgrind::CheckDefined(deltaP);
686 template <
class Evaluation>
688 const Evaluation& pressure,
689 bool extrapolate =
false)
706 Scalar eps = scalarValue(pv)*1e-8;
707 Evaluation v0 = volumeRegion1_(temperature, pv);
708 Evaluation v1 = volumeRegion1_(temperature, pv + eps);
709 Evaluation dv_dp = (v1 - v0)/eps;
727 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
730 return 1.0/v0 + (pressure - pv)*drho_dp;
733 return 1/volumeRegion1_(temperature, pressure);
749 template <
class Evaluation>
756 Scalar eps = scalarValue(pressure)*1e-7;
758 Evaluation deltaP = pressure*2;
759 for (
int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
760 Evaluation f =
liquidDensity(temperature, pressure) - density;
789 template <
class Evaluation>
790 static Evaluation
gasViscosity(
const Evaluation& temperature,
const Evaluation& pressure)
799 Evaluation rho =
gasDensity(temperature, pressure);
814 template <
class Evaluation>
816 const Evaluation& pressure,
817 bool extrapolate =
false)
826 const Evaluation& rho =
liquidDensity(temperature, pressure, extrapolate);
843 template <
class Evaluation>
846 const Evaluation& rho =
liquidDensity(temperature, pressure);
863 template <
class Evaluation>
866 const Evaluation& rho =
gasDensity(temperature, pressure);
872 template <
class Evaluation>
873 static Evaluation enthalpyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
882 template <
class Evaluation>
883 static Evaluation heatCap_p_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
892 template <
class Evaluation>
893 static Evaluation heatCap_v_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
900 - std::pow(tau, 2 ) *
906 template <
class Evaluation>
907 static Evaluation internalEnergyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
916 template <
class Evaluation>
917 static Evaluation volumeRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
922 Rs * temperature / pressure;
926 template <
class Evaluation>
927 static Evaluation enthalpyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
936 template <
class Evaluation>
937 static Evaluation internalEnergyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
946 template <
class Evaluation>
947 static Evaluation heatCap_p_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
956 template <
class Evaluation>
957 static Evaluation heatCap_v_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
964 - std::pow(tau, 2 ) *
970 template <
class Evaluation>
971 static Evaluation volumeRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
976 Rs * temperature / pressure;
980 template<
class Evaluation>
981 static std::string domainError(
const std::string& type,
982 const Evaluation& temperature,
983 const Evaluation& pressure)
985 auto cast = [](
const auto d)
988 if constexpr (std::is_same_v<
decltype(d),
const quad>)
989 return static_cast<double>(d);
994 auto tostring = [cast](
const auto& val) -> std::string
996 if constexpr (DenseAd::is_evaluation<Evaluation>::value) {
997 return std::to_string(cast(getValue(val.value())));
1000 return std::to_string(cast(getValue(val)));
1003 return type +
" is only implemented for temperatures "
1004 "below 623.15K and pressures below 100MPa. (T = " +
1005 tostring(temperature) +
", p=" + tostring(pressure);
1009template <
class Scalar>
1010const 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:687
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition H2O.hpp:95
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition H2O.hpp:562
static std::string_view name()
A human readable name for the water.
Definition H2O.hpp:77
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition H2O.hpp:540
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition H2O.hpp:643
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition H2O.hpp:141
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition H2O.hpp:790
static Evaluation gasHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of steam and water vapor .
Definition H2O.hpp:515
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition H2O.hpp:279
static const Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition H2O.hpp:113
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition H2O.hpp:237
static Evaluation liquidThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition H2O.hpp:844
static const Scalar acentricFactor()
The acentric factor of water.
Definition H2O.hpp:89
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition H2O.hpp:348
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition H2O.hpp:627
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition H2O.hpp:101
static const Scalar molarMass()
The molar mass in of water.
Definition H2O.hpp:83
static Evaluation vaporTemperature(const Evaluation &pressure)
The vapor temperature in of pure water at a given pressure.
Definition H2O.hpp:163
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition H2O.hpp:546
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity of pure water.
Definition H2O.hpp:815
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition H2O.hpp:406
static Evaluation gasThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition H2O.hpp:864
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition H2O.hpp:186
static Evaluation liquidHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of liquid water .
Definition H2O.hpp:480
static Evaluation liquidPressure(const Evaluation &temperature, Scalar density)
The pressure of liquid water in at a given density and temperature.
Definition H2O.hpp:750
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition H2O.hpp:119
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition H2O.hpp:314
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition H2O.hpp:125
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition H2O.hpp:107
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition Common.hpp:55
static const Scalar criticalVolume
Critical volume of water .
Definition Common.hpp:73
static const Scalar criticalPressure
Critical pressure of water .
Definition Common.hpp:67
static Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition Common.hpp:102
static const Scalar criticalMolarVolume
Critical molar volume of water .
Definition Common.hpp:76
static const Scalar criticalTemperature
Critical temperature of water .
Definition Common.hpp:64
static Evaluation thermalConductivityIAPWS(const Evaluation &T, const Evaluation &rho)
Thermal conductivity water (IAPWS) .
Definition Common.hpp:162
static const Scalar tripleTemperature
Triple temperature of water .
Definition Common.hpp:82
static const Scalar triplePressure
Triple pressure of water .
Definition Common.hpp:85
static const Scalar molarMass
The molar mass of water .
Definition Common.hpp:58
static const Scalar acentricFactor
The acentric factor of water .
Definition Common.hpp:79
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 Evaluation pressure(const Evaluation &temperature, const Evaluation &rhoMolar)
The pressure of the gas in , depending on the molar density and temperature.
Definition IdealGas.hpp:58
static 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:48
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...