My Project
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 "iapws/Common.hpp"
31 #include "iapws/Region1.hpp"
32 #include "iapws/Region2.hpp"
33 #include "iapws/Region4.hpp"
34 
35 #include "Component.hpp"
36 
40 
41 #include <cmath>
42 #include <cassert>
43 #include <sstream>
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 criticalVolume()
105  { return Common::criticalVolume; }
106 
110  static const Scalar criticalMolarVolume()
111  { return Common::criticalMolarVolume; }
112 
116  static const Scalar tripleTemperature()
117  { return Common::tripleTemperature; }
118 
122  static const Scalar triplePressure()
123  { return Common::triplePressure; }
124 
137  template <class Evaluation>
138  static Evaluation vaporPressure(Evaluation temperature)
139  {
140  if (temperature > criticalTemperature())
141  temperature = criticalTemperature();
142  if (temperature < tripleTemperature())
143  temperature = tripleTemperature();
144 
145  return Region4::saturationPressure(temperature);
146  }
159  template <class Evaluation>
160  static Evaluation vaporTemperature(const Evaluation& pressure)
161  {
162  if (pressure > criticalPressure())
163  pressure = criticalPressure();
164  if (pressure < triplePressure())
165  pressure = triplePressure();
166 
167  return Region4::vaporTemperature(pressure);
168  }
169 
182  template <class Evaluation>
183  static Evaluation gasEnthalpy(const Evaluation& temperature,
184  const Evaluation& pressure)
185  {
186  if (!Region2::isValid(temperature, pressure))
187  {
188  std::ostringstream oss;
189  oss << "Enthalpy of steam is only implemented for temperatures below 623.15K and "
190  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
191 
192  throw NumericalIssue(oss.str());
193  }
194 
195  // regularization
196  if (pressure < triplePressure() - 100) {
197  // We assume an ideal gas for low pressures to avoid the
198  // 0/0 for the gas enthalpy at very low pressures. The
199  // enthalpy of an ideal gas does not exhibit any
200  // dependence on pressure, so we can just return the
201  // specific enthalpy at the point of regularization, i.e.
202  // the triple pressure - 100Pa
203  return enthalpyRegion2_<Evaluation>(temperature, triplePressure() - 100);
204  }
205  Evaluation pv = vaporPressure(temperature);
206  if (pressure > pv) {
207  // the pressure is too high, in this case we use the slope
208  // of the enthalpy at the vapor pressure to regularize
209  Evaluation dh_dp =
210  Rs*temperature*
211  Region2::tau(temperature)*
212  Region2::dpi_dp(pv)*
213  Region2::ddgamma_dtaudpi(temperature, pv);
214 
215  return
216  enthalpyRegion2_(temperature, pv) +
217  (pressure - pv)*dh_dp;
218  };
219 
220  return enthalpyRegion2_(temperature, pressure);
221  }
222 
235  template <class Evaluation>
236  static Evaluation liquidEnthalpy(const Evaluation& temperature,
237  const Evaluation& pressure)
238  {
239  if (!Region1::isValid(temperature, pressure))
240  {
241  std::ostringstream oss;
242  oss << "Enthalpy of water is only implemented for temperatures below 623.15K and "
243  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
244 
245  throw NumericalIssue(oss.str());
246  }
247 
248  // regularization
249  const Evaluation& pv = vaporPressure(temperature);
250  if (pressure < pv) {
251  // the pressure is too low, in this case we use the slope
252  // of the enthalpy at the vapor pressure to regularize
253  const Evaluation& dh_dp =
254  Rs * temperature*
255  Region1::tau(temperature)*
256  Region1::dpi_dp(pv)*
257  Region1::ddgamma_dtaudpi(temperature, pv);
258 
259  return
260  enthalpyRegion1_(temperature, pv) +
261  (pressure - pv)*dh_dp;
262  };
263 
264  return enthalpyRegion1_(temperature, pressure);
265  }
266 
279  template <class Evaluation>
280  static Evaluation gasHeatCapacity(const Evaluation& temperature,
281  const Evaluation& pressure)
282  {
283  if (!Region2::isValid(temperature, pressure))
284  {
285  std::ostringstream oss;
286  oss << "Heat capacity of steam is only implemented for temperatures below 623.15K and "
287  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
288 
289  throw NumericalIssue(oss.str());
290  }
291 
292  // regularization
293  if (pressure < triplePressure() - 100)
294  return heatCap_p_Region2_(temperature, Evaluation(triplePressure() - 100));
295  const Evaluation& pv = vaporPressure(temperature);
296  if (pressure > pv)
297  // the pressure is too high, in this case we use the heat
298  // cap at the vapor pressure to regularize
299  return heatCap_p_Region2_(temperature, pv);
300 
301  return heatCap_p_Region2_(temperature, pressure);
302  }
303 
316  template <class Evaluation>
317  static Evaluation liquidHeatCapacity(const Evaluation& temperature,
318  const Evaluation& pressure)
319  {
320  if (!Region1::isValid(temperature, pressure))
321  {
322  std::ostringstream oss;
323  oss << "Heat capacity of water is only implemented for temperatures below 623.15K and "
324  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
325  throw NumericalIssue(oss.str());
326  }
327 
328  // regularization
329  const Evaluation& pv = vaporPressure(temperature);
330  if (pressure < pv) {
331  // the pressure is too low, in this case we use the heat capacity at the
332  // vapor pressure to regularize
333  return heatCap_p_Region1_(temperature, pv);
334  };
335 
336  return heatCap_p_Region1_(temperature, pressure);
337  }
338 
351  template <class Evaluation>
352  static Evaluation liquidInternalEnergy(const Evaluation& temperature,
353  const Evaluation& pressure)
354  {
355  if (!Region1::isValid(temperature, pressure))
356  {
357  std::ostringstream oss;
358  oss << "Internal Energy of water is only implemented for temperatures below 623.15K and "
359  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
360 
361  throw NumericalIssue(oss.str());
362  }
363 
364 
365  // regularization
366  Scalar pv = vaporPressure<Scalar>(scalarValue(temperature));
367  if (pressure < pv) {
368  // the pressure is too low, in this case we use the slope
369  // of the internal energy at the vapor pressure to
370  // regularize
371 
372  /*
373  // calculate the partial derivative of the internal energy
374  // to the pressure at the vapor pressure.
375  Scalar tau = Region1::tau(temperature);
376  Scalar dgamma_dpi = Region1::dgamma_dpi(temperature, pv);
377  Scalar ddgamma_dtaudpi = Region1::ddgamma_dtaudpi(temperature, pv);
378  Scalar ddgamma_ddpi = Region1::ddgamma_ddpi(temperature, pv);
379  Scalar pi = Region1::pi(pv);
380  Scalar dpi_dp = Region1::dpi_dp(pv);
381  Scalar du_dp =
382  Rs*temperature*
383  (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi);
384  */
385 
386  // use a straight line for extrapolation. use forward
387  // differences to calculate the partial derivative to the
388  // pressure at the vapor pressure
389  Scalar eps = 1e-7;
390  const Evaluation& uv = internalEnergyRegion1_(temperature, Evaluation(pv));
391  const Evaluation& uvPEps = internalEnergyRegion1_(temperature, Evaluation(pv + eps));
392  const Evaluation& du_dp = (uvPEps - uv)/eps;
393  return uv + du_dp*(pressure - pv);
394  };
395 
396  return internalEnergyRegion1_(temperature, pressure);
397  }
398 
411  template <class Evaluation>
412  static Evaluation gasInternalEnergy(const Evaluation& temperature, const Evaluation& pressure)
413  {
414  if (!Region2::isValid(temperature, pressure))
415  {
416  std::ostringstream oss;
417  oss <<"Internal energy of steam is only implemented for temperatures below 623.15K and "
418  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
419  throw NumericalIssue(oss.str());
420  }
421 
422  // regularization
423  if (pressure < triplePressure() - 100) {
424  // We assume an ideal gas for low pressures to avoid the
425  // 0/0 for the internal energy of gas at very low
426  // pressures. The enthalpy of an ideal gas does not
427  // exhibit any dependence on pressure, so we can just
428  // return the specific enthalpy at the point of
429  // regularization, i.e. the triple pressure - 100Pa, and
430  // subtract the work required to change the volume for an
431  // ideal gas.
432  return
433  enthalpyRegion2_(temperature, Evaluation(triplePressure() - 100.0))
434  -
435  Rs*temperature; // = p*v for an ideal gas!
436  }
437  Scalar pv = vaporPressure(scalarValue(temperature));
438  if (pressure > pv) {
439  // the pressure is too high, in this case we use the slope
440  // of the internal energy at the vapor pressure to
441  // regularize
442 
443  /*
444  // calculate the partial derivative of the internal energy
445  // to the pressure at the vapor pressure.
446  Scalar tau = Region2::tau(temperature);
447  Scalar dgamma_dpi = Region2::dgamma_dpi(temperature, pv);
448  Scalar ddgamma_dtaudpi = Region2::ddgamma_dtaudpi(temperature, pv);
449  Scalar ddgamma_ddpi = Region2::ddgamma_ddpi(temperature, pv);
450  Scalar pi = Region2::pi(pv);
451  Scalar dpi_dp = Region2::dpi_dp(pv);
452  Scalar du_dp =
453  Rs*temperature*
454  (tau*dpi_dp*ddgamma_dtaudpi + dpi_dp*dpi_dp*dgamma_dpi + pi*dpi_dp*ddgamma_ddpi);
455 
456  // use a straight line for extrapolation
457  Scalar uv = internalEnergyRegion2_(temperature, pv);
458  return uv + du_dp*(pressure - pv);
459  */
460 
461  // use a straight line for extrapolation. use backward
462  // differences to calculate the partial derivative to the
463  // pressure at the vapor pressure
464  Scalar eps = 1e-7;
465  const Evaluation& uv = internalEnergyRegion2_(temperature, Evaluation(pv));
466  const Evaluation& uvMEps = internalEnergyRegion2_(temperature, Evaluation(pv - eps));
467  const Evaluation& du_dp = (uv - uvMEps)/eps;
468  return uv + du_dp*(pressure - pv);
469  };
470 
471  return internalEnergyRegion2_(temperature, pressure);
472  }
473 
486  template <class Evaluation>
487  static Evaluation liquidHeatCapacityConstVolume(const Evaluation& temperature,
488  const Evaluation& pressure)
489  {
490  if (!Region1::isValid(temperature, pressure))
491  {
492  std::ostringstream oss;
493  oss << "Heat capacity of water is only implemented for temperatures below 623.15K and "
494  "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
495 
496  throw NumericalIssue(oss.str());
497  }
498 
499 
500  // regularization
501  Scalar pv = vaporPressure(temperature);
502  if (pressure < pv) {
503  // the pressure is too low, in this case we use the heat cap at the vapor pressure to regularize
504 
505  return heatCap_v_Region1_(temperature, pv);
506  }
507 
508  return heatCap_v_Region1_(temperature, pressure);
509  }
510 
523  template <class Evaluation>
524  static Evaluation gasHeatCapacityConstVolume(const Evaluation& temperature, const Evaluation& pressure)
525  {
526  if (!Region2::isValid(temperature, pressure))
527  {
528  std::ostringstream oss;
529  oss << "Heat capacity of steam is only implemented for temperatures below 623.15K and "
530  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
531  throw NumericalIssue(oss.str());
532  }
533 
534  // regularization
535  if (pressure < triplePressure() - 100) {
536  return
537  heatCap_v_Region2_(temperature, triplePressure() - 100);
538  }
539  Scalar pv = vaporPressure(temperature);
540  if (pressure > pv) {
541  return heatCap_v_Region2_(temperature, pv);
542  };
543 
544  return heatCap_v_Region2_(temperature, pressure);
545  }
546 
550  static bool gasIsCompressible()
551  { return true; }
552 
556  static bool liquidIsCompressible()
557  { return true; }
558 
571  template <class Evaluation>
572  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
573  {
574  if (!Region2::isValid(temperature, pressure))
575  {
576  std::ostringstream oss;
577  oss << "Density of steam is only implemented for temperatures below 623.15K and "
578  "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
579  throw NumericalIssue(oss.str());
580  }
581 
582  // regularization
583  if (pressure < triplePressure() - 100) {
584  // We assume an ideal gas for low pressures to avoid the
585  // 0/0 for the internal energy and enthalpy.
586  const Evaluation& rho0IAPWS =
587  1.0/volumeRegion2_(temperature,
588  Evaluation(triplePressure() - 100));
589  const Evaluation& rho0Id =
590  IdealGas<Scalar>::density(Evaluation(molarMass()),
591  temperature,
592  Evaluation(triplePressure() - 100));
593  return
594  rho0IAPWS/rho0Id
595  *IdealGas<Scalar>::density(Evaluation(molarMass()),
596  temperature,
597  pressure);
598  }
599  Evaluation pv = vaporPressure(temperature);
600  if (pressure > pv) {
601  // the pressure is too high, in this case we use the slope
602  // of the density energy at the vapor pressure to
603  // regularize
604 
605  // calculate the partial derivative of the specific volume
606  // to the pressure at the vapor pressure.
607  Scalar eps = scalarValue(pv)*1e-8;
608  Evaluation v0 = volumeRegion2_(temperature, pv);
609  Evaluation v1 = volumeRegion2_(temperature, pv + eps);
610  Evaluation dv_dp = (v1 - v0)/eps;
611  /*
612  Scalar pi = Region2::pi(pv);
613  Scalar dp_dpi = Region2::dp_dpi(pv);
614  Scalar dgamma_dpi = Region2::dgamma_dpi(temperature, pv);
615  Scalar ddgamma_ddpi = Region2::ddgamma_ddpi(temperature, pv);
616 
617  Scalar RT = Rs*temperature;
618  Scalar dv_dp =
619  RT/(dp_dpi*pv)
620  *
621  (dgamma_dpi + pi*ddgamma_ddpi - v0*dp_dpi/RT);
622  */
623 
624  // calculate the partial derivative of the density to the
625  // pressure at vapor pressure
626  Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
627 
628  // use a straight line for extrapolation
629  return 1.0/v0 + (pressure - pv)*drho_dp;
630  };
631 
632  return 1.0/volumeRegion2_(temperature, pressure);
633  }
634 
638  static bool gasIsIdeal()
639  { return false; }
640 
653  template <class Evaluation>
654  static Evaluation gasPressure(const Evaluation& temperature, Scalar density)
655  {
656  Valgrind::CheckDefined(temperature);
657  Valgrind::CheckDefined(density);
658 
659  // We use the newton method for this. For the initial value we
660  // assume steam to be an ideal gas
661  Evaluation pressure = IdealGas<Scalar>::pressure(temperature, density/molarMass());
662  Scalar eps = pressure*1e-7;
663 
664  Evaluation deltaP = pressure*2;
665  Valgrind::CheckDefined(pressure);
666  Valgrind::CheckDefined(deltaP);
667  for (int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
668  Evaluation f = gasDensity(temperature, pressure) - density;
669 
670  Evaluation df_dp;
671  df_dp = gasDensity(temperature, pressure + eps);
672  df_dp -= gasDensity(temperature, pressure - eps);
673  df_dp /= 2*eps;
674 
675  deltaP = - f/df_dp;
676 
677  pressure += deltaP;
678  Valgrind::CheckDefined(pressure);
679  Valgrind::CheckDefined(deltaP);
680  }
681 
682  return pressure;
683  }
684 
697  template <class Evaluation>
698  static Evaluation liquidDensity(const Evaluation& temperature,
699  const Evaluation& pressure,
700  bool extrapolate = false)
701  {
702  if (!extrapolate && !Region1::isValid(temperature, pressure))
703  {
704  std::ostringstream oss;
705  oss << "Density of water is only implemented for temperatures below 623.15K and "
706  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
707  throw NumericalIssue(oss.str());
708  }
709 
710  // regularization
711  Evaluation pv = vaporPressure(temperature);
712  if (pressure < pv) {
713  // the pressure is too low, in this case we use the slope
714  // of the density at the vapor pressure to regularize
715 
716  // calculate the partial derivative of the specific volume
717  // to the pressure at the vapor pressure.
718  Scalar eps = scalarValue(pv)*1e-8;
719  Evaluation v0 = volumeRegion1_(temperature, pv);
720  Evaluation v1 = volumeRegion1_(temperature, pv + eps);
721  Evaluation dv_dp = (v1 - v0)/eps;
722 
723  /*
724  Scalar v0 = volumeRegion1_(temperature, pv);
725  Scalar pi = Region1::pi(pv);
726  Scalar dp_dpi = Region1::dp_dpi(pv);
727  Scalar dgamma_dpi = Region1::dgamma_dpi(temperature, pv);
728  Scalar ddgamma_ddpi = Region1::ddgamma_ddpi(temperature, pv);
729 
730  Scalar RT = Rs*temperature;
731  Scalar dv_dp =
732  RT/(dp_dpi*pv)
733  *
734  (dgamma_dpi + pi*ddgamma_ddpi - v0*dp_dpi/RT);
735  */
736 
737  // calculate the partial derivative of the density to the
738  // pressure at vapor pressure
739  Evaluation drho_dp = - 1/(v0*v0)*dv_dp;
740 
741  // use a straight line for extrapolation
742  return 1.0/v0 + (pressure - pv)*drho_dp;
743  };
744 
745  return 1/volumeRegion1_(temperature, pressure);
746  }
747 
761  template <class Evaluation>
762  static Evaluation liquidPressure(const Evaluation& temperature, Scalar density)
763  {
764  // We use the Newton method for this. For the initial value we
765  // assume the pressure to be 10% higher than the vapor
766  // pressure
767  Evaluation pressure = 1.1*vaporPressure(temperature);
768  Scalar eps = scalarValue(pressure)*1e-7;
769 
770  Evaluation deltaP = pressure*2;
771  for (int i = 0; i < 5 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP)); ++i) {
772  Evaluation f = liquidDensity(temperature, pressure) - density;
773 
774  Evaluation df_dp;
775  df_dp = liquidDensity(temperature, pressure + eps);
776  df_dp -= liquidDensity(temperature, pressure - eps);
777  df_dp /= 2*eps;
778 
779  deltaP = - f/df_dp;
780 
781  pressure += deltaP;
782  }
783 
784  return pressure;
785  }
786 
801  template <class Evaluation>
802  static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
803  {
804  if (!Region2::isValid(temperature, pressure))
805  {
806  std::ostringstream oss;
807  oss << "Viscosity of steam is only implemented for temperatures below 623.15K and "
808  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
809  throw NumericalIssue(oss.str());
810  }
811 
812  Evaluation rho = gasDensity(temperature, pressure);
813  return Common::viscosity(temperature, rho);
814  }
815 
827  template <class Evaluation>
828  static Evaluation liquidViscosity(const Evaluation& temperature,
829  const Evaluation& pressure,
830  bool extrapolate = false)
831  {
832  if (!extrapolate && !Region1::isValid(temperature, pressure))
833  {
834  std::ostringstream oss;
835  oss << "Viscosity of water is only implemented for temperatures below 623.15K and "
836  << "pressures below 100MPa. (T = " << temperature << ", p=" << pressure;
837  throw NumericalIssue(oss.str());
838  };
839 
840  const Evaluation& rho = liquidDensity(temperature, pressure, extrapolate);
841  return Common::viscosity(temperature, rho);
842  }
843 
857  template <class Evaluation>
858  static Evaluation liquidThermalConductivity(const Evaluation& temperature, const Evaluation& pressure)
859  {
860  const Evaluation& rho = liquidDensity(temperature, pressure);
861  return Common::thermalConductivityIAPWS(temperature, rho);
862  }
863 
877  template <class Evaluation>
878  static Evaluation gasThermalConductivity(const Evaluation& temperature, const Evaluation& pressure)
879  {
880  const Evaluation& rho = gasDensity(temperature, pressure);
881  return Common::thermalConductivityIAPWS(temperature, rho);
882  }
883 
884 private:
885  // the unregularized specific enthalpy for liquid water
886  template <class Evaluation>
887  static Evaluation enthalpyRegion1_(const Evaluation& temperature, const Evaluation& pressure)
888  {
889  return
890  Region1::tau(temperature) *
891  Region1::dgamma_dtau(temperature, pressure) *
892  Rs*temperature;
893  }
894 
895  // the unregularized specific isobaric heat capacity
896  template <class Evaluation>
897  static Evaluation heatCap_p_Region1_(const Evaluation& temperature, const Evaluation& pressure)
898  {
899  return
900  - pow(Region1::tau(temperature), 2.0) *
901  Region1::ddgamma_ddtau(temperature, pressure) *
902  Rs;
903  }
904 
905  // the unregularized specific isochoric heat capacity
906  template <class Evaluation>
907  static Evaluation heatCap_v_Region1_(const Evaluation& temperature, const Evaluation& pressure)
908  {
909  double tau = Region1::tau(temperature);
910  double num = Region1::dgamma_dpi(temperature, pressure) - tau * Region1::ddgamma_dtaudpi(temperature, pressure);
911  double diff = std::pow(num, 2) / Region1::ddgamma_ddpi(temperature, pressure);
912 
913  return
914  - std::pow(tau, 2 ) *
915  Region1::ddgamma_ddtau(temperature, pressure) * Rs +
916  diff;
917  }
918 
919  // the unregularized specific internal energy for liquid water
920  template <class Evaluation>
921  static Evaluation internalEnergyRegion1_(const Evaluation& temperature, const Evaluation& pressure)
922  {
923  return
924  Rs * temperature *
925  ( Region1::tau(temperature)*Region1::dgamma_dtau(temperature, pressure) -
926  Region1::pi(pressure)*Region1::dgamma_dpi(temperature, pressure));
927  }
928 
929  // the unregularized specific volume for liquid water
930  template <class Evaluation>
931  static Evaluation volumeRegion1_(const Evaluation& temperature, const Evaluation& pressure)
932  {
933  return
934  Region1::pi(pressure)*
935  Region1::dgamma_dpi(temperature, pressure) *
936  Rs * temperature / pressure;
937  }
938 
939  // the unregularized specific enthalpy for steam
940  template <class Evaluation>
941  static Evaluation enthalpyRegion2_(const Evaluation& temperature, const Evaluation& pressure)
942  {
943  return
944  Region2::tau(temperature) *
945  Region2::dgamma_dtau(temperature, pressure) *
946  Rs*temperature;
947  }
948 
949  // the unregularized specific internal energy for steam
950  template <class Evaluation>
951  static Evaluation internalEnergyRegion2_(const Evaluation& temperature, const Evaluation& pressure)
952  {
953  return
954  Rs * temperature *
955  ( Region2::tau(temperature)*Region2::dgamma_dtau(temperature, pressure) -
956  Region2::pi(pressure)*Region2::dgamma_dpi(temperature, pressure));
957  }
958 
959  // the unregularized specific isobaric heat capacity
960  template <class Evaluation>
961  static Evaluation heatCap_p_Region2_(const Evaluation& temperature, const Evaluation& pressure)
962  {
963  return
964  - pow(Region2::tau(temperature), 2 ) *
965  Region2::ddgamma_ddtau(temperature, pressure) *
966  Rs;
967  }
968 
969  // the unregularized specific isochoric heat capacity
970  template <class Evaluation>
971  static Evaluation heatCap_v_Region2_(const Evaluation& temperature, const Evaluation& pressure)
972  {
973  const Evaluation& tau = Region2::tau(temperature);
974  const Evaluation& pi = Region2::pi(pressure);
975  const Evaluation& num = 1 + pi * Region2::dgamma_dpi(temperature, pressure) + tau * pi * Region2::ddgamma_dtaudpi(temperature, pressure);
976  const Evaluation& diff = num * num / (1 - pi * pi * Region2::ddgamma_ddpi(temperature, pressure));
977  return
978  - std::pow(tau, 2 ) *
979  Region2::ddgamma_ddtau(temperature, pressure) * Rs
980  - diff;
981  }
982 
983  // the unregularized specific volume for steam
984  template <class Evaluation>
985  static Evaluation volumeRegion2_(const Evaluation& temperature, const Evaluation& pressure)
986  {
987  return
988  Region2::pi(pressure)*
989  Region2::dgamma_dpi(temperature, pressure) *
990  Rs * temperature / pressure;
991  }
992 }; // end class
993 
994 template <class Scalar>
995 const Scalar H2O<Scalar>::Rs = Common::Rs;
996 } // namespace Opm
997 
998 #endif
Implements relations which are common for all regions of the IAPWS '97 formulation.
Abstract base class of a pure chemical species.
Provides the opm-material 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:42
Material properties of pure water .
Definition: H2O.hpp:62
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:698
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: H2O.hpp:92
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition: H2O.hpp:572
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: H2O.hpp:550
static const char * name()
A human readable name for the water.
Definition: H2O.hpp:74
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition: H2O.hpp:654
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition: H2O.hpp:138
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: H2O.hpp:802
static Evaluation gasHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of steam and water vapor .
Definition: H2O.hpp:524
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: H2O.hpp:280
static const Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition: H2O.hpp:110
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition: H2O.hpp:236
static Evaluation liquidThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition: H2O.hpp:858
static const Scalar acentricFactor()
The acentric factor of water.
Definition: H2O.hpp:86
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: H2O.hpp:352
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: H2O.hpp:638
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition: H2O.hpp:98
static const Scalar molarMass()
The molar mass in of water.
Definition: H2O.hpp:80
static Evaluation vaporTemperature(const Evaluation &pressure)
The vapor temperature in of pure water at a given pressure.
Definition: H2O.hpp:160
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: H2O.hpp:556
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity of pure water.
Definition: H2O.hpp:828
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition: H2O.hpp:412
static Evaluation gasThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
Thermal conductivity of water (IAPWS) .
Definition: H2O.hpp:878
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition: H2O.hpp:183
static Evaluation liquidHeatCapacityConstVolume(const Evaluation &temperature, const Evaluation &pressure)
Specific isochoric heat capacity of liquid water .
Definition: H2O.hpp:487
static Evaluation liquidPressure(const Evaluation &temperature, Scalar density)
The pressure of liquid water in at a given density and temperature.
Definition: H2O.hpp:762
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: H2O.hpp:116
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition: H2O.hpp:317
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: H2O.hpp:122
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition: H2O.hpp:104
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:46