H2O.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef OPM_H2O_HPP
28 #define OPM_H2O_HPP
29 
30 #include <cmath>
31 #include <cassert>
32 
34 #include <opm/common/Exceptions.hpp>
35 #include <opm/common/ErrorMacros.hpp>
36 #include <opm/common/Valgrind.hpp>
37 
38 #include "Component.hpp"
39 
40 #include "iapws/Common.hpp"
41 #include "iapws/Region1.hpp"
42 #include "iapws/Region2.hpp"
43 #include "iapws/Region4.hpp"
44 
45 namespace Opm {
46 
60 template <class Scalar>
61 class H2O : public Component<Scalar, H2O<Scalar> >
62 {
67 
68  static const Scalar Rs; // specific gas constant of water
69 
70 public:
74  static const char* name()
75  { return "H2O"; }
76 
80  static const Scalar molarMass()
81  { return Common::molarMass; }
82 
86  static const Scalar acentricFactor()
87  { return Common::acentricFactor; }
88 
92  static const Scalar criticalTemperature()
93  { return Common::criticalTemperature; }
94 
98  static const Scalar criticalPressure()
99  { return Common::criticalPressure; }
100 
104  static const Scalar criticalMolarVolume()
105  { return Common::criticalMolarVolume; }
106 
110  static const Scalar tripleTemperature()
111  { return Common::tripleTemperature; }
112 
116  static const Scalar triplePressure()
117  { return Common::triplePressure; }
118 
131  template <class Evaluation>
132  static Evaluation vaporPressure(Evaluation temperature)
133  {
134  if (temperature > criticalTemperature())
135  temperature = criticalTemperature();
136  if (temperature < tripleTemperature())
137  temperature = tripleTemperature();
138 
139  return Region4::saturationPressure(temperature);
140  }
153  template <class Evaluation>
154  static Evaluation vaporTemperature(const Evaluation& pressure)
155  {
156  if (pressure > criticalPressure())
157  pressure = criticalPressure();
158  if (pressure < triplePressure())
159  pressure = triplePressure();
160 
161  return Region4::vaporTemperature(pressure);
162  }
163 
176  template <class Evaluation>
177  static Evaluation gasEnthalpy(const Evaluation& temperature,
178  const Evaluation& pressure)
179  {
180  if (!Region2::isValid(temperature, pressure))
181  {
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);
185  }
186 
187  // regularization
188  if (pressure < triplePressure() - 100) {
189  // We assume an ideal gas for low pressures to avoid the
190  // 0/0 for the gas enthalpy at very low pressures. The
191  // enthalpy of an ideal gas does not exhibit any
192  // dependence on pressure, so we can just return the
193  // specific enthalpy at the point of regularization, i.e.
194  // the triple pressure - 100Pa
195  return enthalpyRegion2_<Evaluation>(temperature, triplePressure() - 100);
196  }
197  Evaluation pv = vaporPressure(temperature);
198  if (pressure > pv) {
199  // the pressure is too high, in this case we use the slope
200  // of the enthalpy at the vapor pressure to regularize
201  Evaluation dh_dp =
202  Rs*temperature*
203  Region2::tau(temperature)*
204  Region2::dpi_dp(pv)*
205  Region2::ddgamma_dtaudpi(temperature, pv);
206 
207  return
208  enthalpyRegion2_(temperature, pv) +
209  (pressure - pv)*dh_dp;
210  };
211 
212  return enthalpyRegion2_(temperature, pressure);
213  }
214 
227  template <class Evaluation>
228  static Evaluation liquidEnthalpy(const Evaluation& temperature,
229  const Evaluation& pressure)
230  {
231  if (!Region1::isValid(temperature, pressure))
232  {
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);
236  }
237 
238  // regularization
239  const Evaluation& pv = vaporPressure(temperature);
240  if (pressure < pv) {
241  // the pressure is too low, in this case we use the slope
242  // of the enthalpy at the vapor pressure to regularize
243  const Evaluation& dh_dp =
244  Rs * temperature*
245  Region1::tau(temperature)*
246  Region1::dpi_dp(pv)*
247  Region1::ddgamma_dtaudpi(temperature, pv);
248 
249  return
250  enthalpyRegion1_(temperature, pv) +
251  (pressure - pv)*dh_dp;
252  };
253 
254  return enthalpyRegion1_(temperature, pressure);
255  }
256 
269  template <class Evaluation>
270  static Evaluation gasHeatCapacity(const Evaluation& temperature,
271  const Evaluation& pressure)
272  {
273  if (!Region2::isValid(temperature, pressure))
274  {
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);
278  }
279 
280  // regularization
281  if (pressure < triplePressure() - 100)
282  return heatCap_p_Region2_(temperature, Evaluation(triplePressure() - 100));
283  const Evaluation& pv = vaporPressure(temperature);
284  if (pressure > pv)
285  // the pressure is too high, in this case we use the heat
286  // cap at the vapor pressure to regularize
287  return heatCap_p_Region2_(temperature, pv);
288 
289  return heatCap_p_Region2_(temperature, pressure);
290  }
291 
304  template <class Evaluation>
305  static Evaluation liquidHeatCapacity(const Evaluation& temperature,
306  const Evaluation& pressure)
307  {
308  if (!Region1::isValid(temperature, pressure))
309  {
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);
313  }
314 
315  // regularization
316  const Evaluation& pv = vaporPressure(temperature);
317  if (pressure < pv) {
318  // the pressure is too low, in this case we use the heat capacity at the
319  // vapor pressure to regularize
320  return heatCap_p_Region1_(temperature, pv);
321  };
322 
323  return heatCap_p_Region1_(temperature, pressure);
324  }
325 
338  template <class Evaluation>
339  static Evaluation liquidInternalEnergy(const Evaluation& temperature,
340  const Evaluation& pressure)
341  {
342  if (!Region1::isValid(temperature, pressure))
343  {
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);
347  }
348 
349 
350  // regularization
351  Scalar pv = vaporPressure<Scalar>(Opm::scalarValue(temperature));
352  if (pressure < pv) {
353  // the pressure is too low, in this case we use the slope
354  // of the internal energy at the vapor pressure to
355  // regularize
356 
357  /*
358  // calculate the partial derivative of the internal energy
359  // to the pressure at the vapor pressure.
360  Scalar tau = Region1::tau(temperature);
361  Scalar dgamma_dpi = Region1::dgamma_dpi(temperature, pv);
362  Scalar ddgamma_dtaudpi = Region1::ddgamma_dtaudpi(temperature, pv);
363  Scalar ddgamma_ddpi = Region1::ddgamma_ddpi(temperature, pv);
364  Scalar pi = Region1::pi(pv);
365  Scalar dpi_dp = Region1::dpi_dp(pv);
366  Scalar du_dp =
367  Rs*temperature*
368  (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi);
369  */
370 
371  // use a straight line for extrapolation. use forward
372  // differences to calculate the partial derivative to the
373  // pressure at the vapor pressure
374  Scalar eps = 1e-7;
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);
379  };
380 
381  return internalEnergyRegion1_(temperature, pressure);
382  }
383 
396  template <class Evaluation>
397  static Evaluation gasInternalEnergy(const Evaluation& temperature, const Evaluation& pressure)
398  {
399  if (!Region2::isValid(temperature, pressure))
400  {
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);
404  }
405 
406  // regularization
407  if (pressure < triplePressure() - 100) {
408  // We assume an ideal gas for low pressures to avoid the
409  // 0/0 for the internal energy of gas at very low
410  // pressures. The enthalpy of an ideal gas does not
411  // exhibit any dependence on pressure, so we can just
412  // return the specific enthalpy at the point of
413  // regularization, i.e. the triple pressure - 100Pa, and
414  // subtract the work required to change the volume for an
415  // ideal gas.
416  return
417  enthalpyRegion2_(temperature, Evaluation(triplePressure() - 100.0))
418  -
419  Rs*temperature; // = p*v for an ideal gas!
420  }
421  Scalar pv = vaporPressure(Opm::scalarValue(temperature));
422  if (pressure > pv) {
423  // the pressure is too high, in this case we use the slope
424  // of the internal energy at the vapor pressure to
425  // regularize
426 
427  /*
428  // calculate the partial derivative of the internal energy
429  // to the pressure at the vapor pressure.
430  Scalar tau = Region2::tau(temperature);
431  Scalar dgamma_dpi = Region2::dgamma_dpi(temperature, pv);
432  Scalar ddgamma_dtaudpi = Region2::ddgamma_dtaudpi(temperature, pv);
433  Scalar ddgamma_ddpi = Region2::ddgamma_ddpi(temperature, pv);
434  Scalar pi = Region2::pi(pv);
435  Scalar dpi_dp = Region2::dpi_dp(pv);
436  Scalar du_dp =
437  Rs*temperature*
438  (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi);
439 
440  // use a straight line for extrapolation
441  Scalar uv = internalEnergyRegion2_(temperature, pv);
442  return uv + du_dp*(pressure - pv);
443  */
444 
445  // use a straight line for extrapolation. use backward
446  // differences to calculate the partial derivative to the
447  // pressure at the vapor pressure
448  Scalar eps = 1e-7;
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);
453  };
454 
455  return internalEnergyRegion2_(temperature, pressure);
456  }
457 
470  template <class Evaluation>
471  static Evaluation liquidHeatCapacityConstVolume(const Evaluation& temperature,
472  const Evaluation& pressure)
473  {
474  if (!Region1::isValid(temperature, pressure))
475  {
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);
479  }
480 
481 
482  // regularization
483  Scalar pv = vaporPressure(temperature);
484  if (pressure < pv) {
485  // the pressure is too low, in this case we use the heat cap at the vapor pressure to regularize
486 
487  return heatCap_v_Region1_(temperature, pv);
488  }
489 
490  return heatCap_v_Region1_(temperature, pressure);
491  }
492 
505  template <class Evaluation>
506  static Evaluation gasHeatCapacityConstVolume(const Evaluation& temperature, const Evaluation& pressure)
507  {
508  if (!Region2::isValid(temperature, pressure))
509  {
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);
513  }
514 
515  // regularization
516  if (pressure < triplePressure() - 100) {
517  return
518  heatCap_v_Region2_(temperature, triplePressure() - 100);
519  }
520  Scalar pv = vaporPressure(temperature);
521  if (pressure > pv) {
522  return heatCap_v_Region2_(temperature, pv);
523  };
524 
525  return heatCap_v_Region2_(temperature, pressure);
526  }
527 
531  static bool gasIsCompressible()
532  { return true; }
533 
537  static bool liquidIsCompressible()
538  { return true; }
539 
552  template <class Evaluation>
553  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
554  {
555  if (!Region2::isValid(temperature, pressure))
556  {
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);
560  }
561 
562  // regularization
563  if (pressure < triplePressure() - 100) {
564  // We assume an ideal gas for low pressures to avoid the
565  // 0/0 for the internal energy and enthalpy.
566  const Evaluation& rho0IAPWS =
567  1.0/volumeRegion2_(temperature,
568  Evaluation(triplePressure() - 100));
569  const Evaluation& rho0Id =
570  IdealGas<Scalar>::density(Evaluation(molarMass()),
571  temperature,
572  Evaluation(triplePressure() - 100));
573  return
574  rho0IAPWS/rho0Id
575  *IdealGas<Scalar>::density(Evaluation(molarMass()),
576  temperature,
577  pressure);
578  }
579  Evaluation pv = vaporPressure(temperature);
580  if (pressure > pv) {
581  // the pressure is too high, in this case we use the slope
582  // of the density energy at the vapor pressure to
583  // regularize
584 
585  // calculate the partial derivative of the specific volume
586  // to the pressure at the vapor pressure.
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;
591  /*
592  Scalar pi = Region2::pi(pv);
593  Scalar dp_dpi = Region2::dp_dpi(pv);
594  Scalar dgamma_dpi = Region2::dgamma_dpi(temperature, pv);
595  Scalar ddgamma_ddpi = Region2::ddgamma_ddpi(temperature, pv);
596 
597  Scalar RT = Rs*temperature;
598  Scalar dv_dp =
599  RT/(dp_dpi*pv)
600  *
601  (dgamma_dpi + pi*ddgamma_ddpi - v0*dp_dpi/RT);
602  */
603 
604  // calculate the partial derivative of the density to the
605  // pressure at vapor pressure
606  Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
607 
608  // use a straight line for extrapolation
609  return 1.0/v0 + (pressure - pv)*drho_dp;
610  };
611 
612  return 1.0/volumeRegion2_(temperature, pressure);
613  }
614 
618  static bool gasIsIdeal()
619  { return false; }
620 
633  template <class Evaluation>
634  static Evaluation gasPressure(const Evaluation& temperature, Scalar density)
635  {
636  Valgrind::CheckDefined(temperature);
637  Valgrind::CheckDefined(density);
638 
639  // We use the newton method for this. For the initial value we
640  // assume steam to be an ideal gas
641  Evaluation pressure = IdealGas<Scalar>::pressure(temperature, density/molarMass());
642  Scalar eps = pressure*1e-7;
643 
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;
649 
650  Evaluation df_dp;
651  df_dp = gasDensity(temperature, pressure + eps);
652  df_dp -= gasDensity(temperature, pressure - eps);
653  df_dp /= 2*eps;
654 
655  deltaP = - f/df_dp;
656 
657  pressure += deltaP;
658  Valgrind::CheckDefined(pressure);
659  Valgrind::CheckDefined(deltaP);
660  }
661 
662  return pressure;
663  }
664 
677  template <class Evaluation>
678  static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure)
679  {
680  if (!Region1::isValid(temperature, pressure))
681  {
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);
685  }
686 
687  // regularization
688  Evaluation pv = vaporPressure(temperature);
689  if (pressure < pv) {
690  // the pressure is too low, in this case we use the slope
691  // of the density at the vapor pressure to regularize
692 
693  // calculate the partial derivative of the specific volume
694  // to the pressure at the vapor 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;
699 
700  /*
701  Scalar v0 = volumeRegion1_(temperature, pv);
702  Scalar pi = Region1::pi(pv);
703  Scalar dp_dpi = Region1::dp_dpi(pv);
704  Scalar dgamma_dpi = Region1::dgamma_dpi(temperature, pv);
705  Scalar ddgamma_ddpi = Region1::ddgamma_ddpi(temperature, pv);
706 
707  Scalar RT = Rs*temperature;
708  Scalar dv_dp =
709  RT/(dp_dpi*pv)
710  *
711  (dgamma_dpi + pi*ddgamma_ddpi - v0*dp_dpi/RT);
712  */
713 
714  // calculate the partial derivative of the density to the
715  // pressure at vapor pressure
716  Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
717 
718  // use a straight line for extrapolation
719  return 1.0/v0 + (pressure - pv)*drho_dp;
720  };
721 
722  return 1/volumeRegion1_(temperature, pressure);
723  }
724 
738  template <class Evaluation>
739  static Evaluation liquidPressure(const Evaluation& temperature, Scalar density)
740  {
741  // We use the Newton method for this. For the initial value we
742  // assume the pressure to be 10% higher than the vapor
743  // pressure
744  Evaluation pressure = 1.1*vaporPressure(temperature);
745  Scalar eps = Opm::scalarValue(pressure)*1e-7;
746 
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;
750 
751  Evaluation df_dp;
752  df_dp = liquidDensity(temperature, pressure + eps);
753  df_dp -= liquidDensity(temperature, pressure - eps);
754  df_dp /= 2*eps;
755 
756  deltaP = - f/df_dp;
757 
758  pressure += deltaP;
759  }
760 
761  return pressure;
762  }
763 
778  template <class Evaluation>
779  static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
780  {
781  if (!Region2::isValid(temperature, pressure))
782  {
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);
786  }
787 
788  Evaluation rho = gasDensity(temperature, pressure);
789  return Common::viscosity(temperature, rho);
790  }
791 
803  template <class Evaluation>
804  static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& pressure)
805  {
806  if (!Region1::isValid(temperature, pressure))
807  {
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);
811  };
812 
813  const Evaluation& rho = liquidDensity(temperature, pressure);
814  return Common::viscosity(temperature, rho);
815  }
816 
830  template <class Evaluation>
831  static Evaluation liquidThermalConductivity(const Evaluation& temperature, const Evaluation& pressure)
832  {
833  const Evaluation& rho = liquidDensity(temperature, pressure);
834  return Common::thermalConductivityIAPWS(temperature, rho);
835  }
836 
850  template <class Evaluation>
851  static Evaluation gasThermalConductivity(const Evaluation& temperature, const Evaluation& pressure)
852  {
853  const Evaluation& rho = gasDensity(temperature, pressure);
854  return Common::thermalConductivityIAPWS(temperature, rho);
855  }
856 
857 private:
858  // the unregularized specific enthalpy for liquid water
859  template <class Evaluation>
860  static Evaluation enthalpyRegion1_(const Evaluation& temperature, const Evaluation& pressure)
861  {
862  return
863  Region1::tau(temperature) *
864  Region1::dgamma_dtau(temperature, pressure) *
865  Rs*temperature;
866  }
867 
868  // the unregularized specific isobaric heat capacity
869  template <class Evaluation>
870  static Evaluation heatCap_p_Region1_(const Evaluation& temperature, const Evaluation& pressure)
871  {
872  return
873  - Opm::pow(Region1::tau(temperature), 2.0) *
874  Region1::ddgamma_ddtau(temperature, pressure) *
875  Rs;
876  }
877 
878  // the unregularized specific isochoric heat capacity
879  template <class Evaluation>
880  static Evaluation heatCap_v_Region1_(const Evaluation& temperature, const Evaluation& pressure)
881  {
882  double tau = Region1::tau(temperature);
883  double num = Region1::dgamma_dpi(temperature, pressure) - tau * Region1::ddgamma_dtaudpi(temperature, pressure);
884  double diff = std::pow(num, 2) / Region1::ddgamma_ddpi(temperature, pressure);
885 
886  return
887  - std::pow(tau, 2 ) *
888  Region1::ddgamma_ddtau(temperature, pressure) * Rs +
889  diff;
890  }
891 
892  // the unregularized specific internal energy for liquid water
893  template <class Evaluation>
894  static Evaluation internalEnergyRegion1_(const Evaluation& temperature, const Evaluation& pressure)
895  {
896  return
897  Rs * temperature *
898  ( Region1::tau(temperature)*Region1::dgamma_dtau(temperature, pressure) -
899  Region1::pi(pressure)*Region1::dgamma_dpi(temperature, pressure));
900  }
901 
902  // the unregularized specific volume for liquid water
903  template <class Evaluation>
904  static Evaluation volumeRegion1_(const Evaluation& temperature, const Evaluation& pressure)
905  {
906  return
907  Region1::pi(pressure)*
908  Region1::dgamma_dpi(temperature, pressure) *
909  Rs * temperature / pressure;
910  }
911 
912  // the unregularized specific enthalpy for steam
913  template <class Evaluation>
914  static Evaluation enthalpyRegion2_(const Evaluation& temperature, const Evaluation& pressure)
915  {
916  return
917  Region2::tau(temperature) *
918  Region2::dgamma_dtau(temperature, pressure) *
919  Rs*temperature;
920  }
921 
922  // the unregularized specific internal energy for steam
923  template <class Evaluation>
924  static Evaluation internalEnergyRegion2_(const Evaluation& temperature, const Evaluation& pressure)
925  {
926  return
927  Rs * temperature *
928  ( Region2::tau(temperature)*Region2::dgamma_dtau(temperature, pressure) -
929  Region2::pi(pressure)*Region2::dgamma_dpi(temperature, pressure));
930  }
931 
932  // the unregularized specific isobaric heat capacity
933  template <class Evaluation>
934  static Evaluation heatCap_p_Region2_(const Evaluation& temperature, const Evaluation& pressure)
935  {
936  return
937  - Opm::pow(Region2::tau(temperature), 2 ) *
938  Region2::ddgamma_ddtau(temperature, pressure) *
939  Rs;
940  }
941 
942  // the unregularized specific isochoric heat capacity
943  template <class Evaluation>
944  static Evaluation heatCap_v_Region2_(const Evaluation& temperature, const Evaluation& pressure)
945  {
946  const Evaluation& tau = Region2::tau(temperature);
947  const Evaluation& pi = Region2::pi(pressure);
948  const Evaluation& num = 1 + pi * Region2::dgamma_dpi(temperature, pressure) + tau * pi * Region2::ddgamma_dtaudpi(temperature, pressure);
949  const Evaluation& diff = num * num / (1 - pi * pi * Region2::ddgamma_ddpi(temperature, pressure));
950  return
951  - std::pow(tau, 2 ) *
952  Region2::ddgamma_ddtau(temperature, pressure) * Rs
953  - diff;
954  }
955 
956  // the unregularized specific volume for steam
957  template <class Evaluation>
958  static Evaluation volumeRegion2_(const Evaluation& temperature, const Evaluation& pressure)
959  {
960  return
961  Region2::pi(pressure)*
962  Region2::dgamma_dpi(temperature, pressure) *
963  Rs * temperature / pressure;
964  }
965 }; // end class
966 
967 template <class Scalar>
968 const Scalar H2O<Scalar>::Rs = Common::Rs;
969 } // namespace Opm
970 
971 #endif
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&#39;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 &#39;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
Definition: Air_Mesitylene.hpp:33
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 &#39;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 &#39;97 formulation.
Definition: Region2.hpp:51
Implements the equations for region 4 of the IAPWS &#39;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 &#39;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 &#39;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 &#39;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 &#39;97 formulation.
static const Scalar triplePressure()
Returns the pressure at water&#39;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