34 #include <opm/common/Exceptions.hpp>
35 #include <opm/common/ErrorMacros.hpp>
36 #include <opm/common/Valgrind.hpp>
60 template <
class Scalar>
68 static const Scalar Rs;
131 template <
class Evaluation>
153 template <
class Evaluation>
176 template <
class Evaluation>
178 const Evaluation& pressure)
182 OPM_THROW(NumericalProblem,
183 "Enthalpy of steam is only implemented for temperatures below 623.15K and "
184 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
195 return enthalpyRegion2_<Evaluation>(temperature,
triplePressure() - 100);
208 enthalpyRegion2_(temperature, pv) +
209 (pressure - pv)*dh_dp;
212 return enthalpyRegion2_(temperature, pressure);
227 template <
class Evaluation>
229 const Evaluation& pressure)
233 OPM_THROW(NumericalProblem,
234 "Enthalpy of water is only implemented for temperatures below 623.15K and "
235 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
243 const Evaluation& dh_dp =
250 enthalpyRegion1_(temperature, pv) +
251 (pressure - pv)*dh_dp;
254 return enthalpyRegion1_(temperature, pressure);
269 template <
class Evaluation>
271 const Evaluation& pressure)
275 OPM_THROW(NumericalProblem,
276 "Heat capacity of steam is only implemented for temperatures below 623.15K and "
277 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
282 return heatCap_p_Region2_(temperature, Evaluation(
triplePressure() - 100));
287 return heatCap_p_Region2_(temperature, pv);
289 return heatCap_p_Region2_(temperature, pressure);
304 template <
class Evaluation>
306 const Evaluation& pressure)
310 OPM_THROW(NumericalProblem,
311 "heat Capacity of water is only implemented for temperatures below 623.15K and "
312 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
320 return heatCap_p_Region1_(temperature, pv);
323 return heatCap_p_Region1_(temperature, pressure);
338 template <
class Evaluation>
340 const Evaluation& pressure)
344 OPM_THROW(NumericalProblem,
345 "Internal Energy of water is only implemented for temperatures below 623.15K and "
346 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
351 Scalar pv = vaporPressure<Scalar>(Opm::scalarValue(temperature));
375 const Evaluation& uv = internalEnergyRegion1_(temperature, Evaluation(pv));
376 const Evaluation& uvPEps = internalEnergyRegion1_(temperature, Evaluation(pv + eps));
377 const Evaluation& du_dp = (uvPEps - uv)/eps;
378 return uv + du_dp*(pressure - pv);
381 return internalEnergyRegion1_(temperature, pressure);
396 template <
class Evaluation>
401 OPM_THROW(NumericalProblem,
402 "Internal Energy of steam is only implemented for temperatures below 623.15K and "
403 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
417 enthalpyRegion2_(temperature, Evaluation(
triplePressure() - 100.0))
449 const Evaluation& uv = internalEnergyRegion2_(temperature, Evaluation(pv));
450 const Evaluation& uvMEps = internalEnergyRegion2_(temperature, Evaluation(pv - eps));
451 const Evaluation& du_dp = (uv - uvMEps)/eps;
452 return uv + du_dp*(pressure - pv);
455 return internalEnergyRegion2_(temperature, pressure);
470 template <
class Evaluation>
472 const Evaluation& pressure)
476 OPM_THROW(NumericalProblem,
477 "Heat capacity of water is only implemented for temperatures below 623.15K and "
478 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
487 return heatCap_v_Region1_(temperature, pv);
490 return heatCap_v_Region1_(temperature, pressure);
505 template <
class Evaluation>
510 OPM_THROW(NumericalProblem,
511 "Heat capacity of steam is only implemented for temperatures below 623.15K and "
512 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
522 return heatCap_v_Region2_(temperature, pv);
525 return heatCap_v_Region2_(temperature, pressure);
552 template <
class Evaluation>
553 static Evaluation
gasDensity(
const Evaluation& temperature,
const Evaluation& pressure)
557 OPM_THROW(NumericalProblem,
558 "Density of steam is only implemented for temperatures below 623.15K and "
559 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
566 const Evaluation& rho0IAPWS =
567 1.0/volumeRegion2_(temperature,
569 const Evaluation& rho0Id =
587 Scalar eps = Opm::scalarValue(pv)*1e-8;
588 Evaluation v0 = volumeRegion2_(temperature, pv);
589 Evaluation v1 = volumeRegion2_(temperature, pv + eps);
590 Evaluation dv_dp = (v1 - v0)/eps;
606 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
609 return 1.0/v0 + (pressure - pv)*drho_dp;
612 return 1.0/volumeRegion2_(temperature, pressure);
633 template <
class Evaluation>
634 static Evaluation
gasPressure(
const Evaluation& temperature, Scalar density)
636 Valgrind::CheckDefined(temperature);
637 Valgrind::CheckDefined(density);
642 Scalar eps = pressure*1e-7;
644 Evaluation deltaP = pressure*2;
645 Valgrind::CheckDefined(pressure);
646 Valgrind::CheckDefined(deltaP);
647 for (
int i = 0; i < 5 && std::abs(Opm::scalarValue(pressure)*1e-9) < std::abs(Opm::scalarValue(deltaP)); ++i) {
648 Evaluation f =
gasDensity(temperature, pressure) - density;
651 df_dp =
gasDensity(temperature, pressure + eps);
652 df_dp -=
gasDensity(temperature, pressure - eps);
658 Valgrind::CheckDefined(pressure);
659 Valgrind::CheckDefined(deltaP);
677 template <
class Evaluation>
678 static Evaluation
liquidDensity(
const Evaluation& temperature,
const Evaluation& pressure)
682 OPM_THROW(NumericalProblem,
683 "Density of water is only implemented for temperatures below 623.15K and "
684 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
695 Scalar eps = Opm::scalarValue(pv)*1e-8;
696 Evaluation v0 = volumeRegion1_(temperature, pv);
697 Evaluation v1 = volumeRegion1_(temperature, pv + eps);
698 Evaluation dv_dp = (v1 - v0)/eps;
716 Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
719 return 1.0/v0 + (pressure - pv)*drho_dp;
722 return 1/volumeRegion1_(temperature, pressure);
738 template <
class Evaluation>
745 Scalar eps = Opm::scalarValue(pressure)*1e-7;
747 Evaluation deltaP = pressure*2;
748 for (
int i = 0; i < 5 && std::abs(Opm::scalarValue(pressure)*1e-9) < std::abs(Opm::scalarValue(deltaP)); ++i) {
749 Evaluation f =
liquidDensity(temperature, pressure) - density;
778 template <
class Evaluation>
779 static Evaluation
gasViscosity(
const Evaluation& temperature,
const Evaluation& pressure)
783 OPM_THROW(NumericalProblem,
784 "Viscosity of steam is only implemented for temperatures below 623.15K and "
785 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
788 Evaluation rho =
gasDensity(temperature, pressure);
803 template <
class Evaluation>
804 static Evaluation
liquidViscosity(
const Evaluation& temperature,
const Evaluation& pressure)
808 OPM_THROW(NumericalProblem,
809 "Viscosity of water is only implemented for temperatures below 623.15K and "
810 "pressures below 100MPa. (T = " << temperature <<
", p=" << pressure);
813 const Evaluation& rho =
liquidDensity(temperature, pressure);
830 template <
class Evaluation>
833 const Evaluation& rho =
liquidDensity(temperature, pressure);
850 template <
class Evaluation>
853 const Evaluation& rho =
gasDensity(temperature, pressure);
859 template <
class Evaluation>
860 static Evaluation enthalpyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
869 template <
class Evaluation>
870 static Evaluation heatCap_p_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
879 template <
class Evaluation>
880 static Evaluation heatCap_v_Region1_(
const Evaluation& temperature,
const Evaluation& pressure)
887 - std::pow(tau, 2 ) *
893 template <
class Evaluation>
894 static Evaluation internalEnergyRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
903 template <
class Evaluation>
904 static Evaluation volumeRegion1_(
const Evaluation& temperature,
const Evaluation& pressure)
909 Rs * temperature / pressure;
913 template <
class Evaluation>
914 static Evaluation enthalpyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
923 template <
class Evaluation>
924 static Evaluation internalEnergyRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
933 template <
class Evaluation>
934 static Evaluation heatCap_p_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
943 template <
class Evaluation>
944 static Evaluation heatCap_v_Region2_(
const Evaluation& temperature,
const Evaluation& pressure)
951 - std::pow(tau, 2 ) *
957 template <
class Evaluation>
958 static Evaluation volumeRegion2_(
const Evaluation& temperature,
const Evaluation& pressure)
963 Rs * temperature / pressure;
967 template <
class Scalar>
968 const Scalar H2O<Scalar>::Rs = Common::Rs;
Material properties of pure water .
Definition: H2O.hpp:61
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of pure water in at a given pressure and temperature.
Definition: H2O.hpp:678
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
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 bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: H2O.hpp:618
static Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition: Common.hpp:99
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: H2O.hpp:110
Relations valid for an ideal gas.
Abstract base class of a pure chemical species.
Definition: Component.hpp:43
static Evaluation thermalConductivityIAPWS(const Evaluation &T, const Evaluation &rho)
Thermal conductivity water (IAPWS) .
Definition: Common.hpp:159
static Evaluation vaporTemperature(const Evaluation &pressure)
Returns the saturation temperature in of pure water at a given pressure.
Definition: Region4.hpp:94
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 saturationPressure(const Evaluation &temperature)
Returns the saturation pressure in of pure water at a given temperature.
Definition: Region4.hpp:63
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
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: H2O.hpp:537
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: H2O.hpp:779
Implements the equations for region 1 of the IAPWS '97 formulation.
Definition: Region1.hpp:50
static const Scalar acentricFactor()
The acentric factor of water.
Definition: H2O.hpp:86
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: H2O.hpp:531
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: H2O.hpp:339
static Evaluation vaporTemperature(const Evaluation &pressure)
The vapor temperature in of pure water at a given pressure.
Definition: H2O.hpp:154
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition: H2O.hpp:553
static Evaluation liquidThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition: H2O.hpp:831
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition: H2O.hpp:228
static Evaluation pi(const Evaluation &pressure)
Returns the reduced pressure (dimensionless) for IAPWS region 2.
Definition: Region2.hpp:101
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 gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition: H2O.hpp:397
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition: H2O.hpp:305
static const Scalar criticalPressure
Critical pressure of water .
Definition: Common.hpp:67
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
Implements the equations for region 1 of the IAPWS '97 formulation.
static Evaluation liquidHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of liquid water .
Definition: H2O.hpp:471
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
Implements the equations for region 2 of the IAPWS '97 formulation.
Definition: Region2.hpp:51
Implements the equations for region 4 of the IAPWS '97 formulation.
Definition: Region4.hpp:51
Abstract base class of a pure chemical species.
static const char * name()
A human readable name for the water.
Definition: H2O.hpp:74
static const Scalar criticalTemperature
Critical temperature of water .
Definition: Common.hpp:64
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of pure water.
Definition: H2O.hpp:804
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: H2O.hpp:92
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: H2O.hpp:270
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 const Scalar triplePressure
Triple pressure of water .
Definition: Common.hpp:82
static Evaluation tau(const Evaluation &temperature)
Returns the reduced temperature for IAPWS region 1.
Definition: Region1.hpp:83
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition: H2O.hpp:132
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 const Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition: H2O.hpp:104
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 gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition: H2O.hpp:177
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition: Common.hpp:54
static Evaluation gasThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition: H2O.hpp:851
Implements the equations for region 4 of the IAPWS '97 formulation.
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 Evaluation pi(const Evaluation &pressure)
Returns the reduced pressure for IAPWS region 1.
Definition: Region1.hpp:102
static const Scalar acentricFactor
The acentric factor of water .
Definition: Common.hpp:76
static Evaluation tau(const Evaluation &temperature)
Returns the reduced temperature (dimensionless) for IAPWS region 2.
Definition: Region2.hpp:82
static const Scalar molarMass
The molar mass of water .
Definition: Common.hpp:58
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 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 const Scalar tripleTemperature
Triple temperature of water .
Definition: Common.hpp:79
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition: H2O.hpp:634
static Evaluation gasHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of steam and water vapor .
Definition: H2O.hpp:506
static const Scalar molarMass()
The molar mass in of water.
Definition: H2O.hpp:80
Implements the equations for region 2 of the IAPWS '97 formulation.
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
Implements relations which are common for all regions of the IAPWS '97 formulation.
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: H2O.hpp:116
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 const Scalar criticalPressure()
Returns the critical pressure of water.
Definition: H2O.hpp:98
static const Scalar criticalMolarVolume
Critical molar volume of water .
Definition: Common.hpp:73
static Evaluation liquidPressure(const Evaluation &temperature, Scalar density)
The pressure of liquid water in at a given density and temperature.
Definition: H2O.hpp:739
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