GasPvtThermal.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_GAS_PVT_THERMAL_HPP
28 #define OPM_GAS_PVT_THERMAL_HPP
29 
31 
36 
37 #if HAVE_OPM_PARSER
38 #include <opm/parser/eclipse/Deck/Deck.hpp>
39 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
40 #include <opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp>
41 #include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
42 #endif
43 
44 namespace Opm {
45 template <class Scalar, bool enableThermal>
46 class GasPvtMultiplexer;
47 
54 template <class Scalar>
56 {
58  typedef GasPvtMultiplexer<Scalar, /*enableThermal=*/false> IsothermalPvt;
59 
60 public:
61  ~GasPvtThermal()
62  { delete isothermalPvt_; }
63 
64 #if HAVE_OPM_PARSER
65 
68  void initFromDeck(const Deck& deck,
69  const EclipseState& eclState)
70  {
72  // initialize the isothermal part
74  isothermalPvt_ = new IsothermalPvt;
75  isothermalPvt_->initFromDeck(deck, eclState);
76 
78  // initialize the thermal part
80  const auto& tables = eclState.getTableManager();
81 
82  enableThermalDensity_ = deck.hasKeyword("TREF");
83  enableThermalViscosity_ = deck.hasKeyword("GASVISCT");
84 
85  unsigned numRegions = isothermalPvt_->numRegions();
86  setNumRegions(numRegions);
87 
88  // viscosity
89  if (enableThermalViscosity_) {
90  const auto& gasvisctTables = tables.getGasvisctTables();
91  int gasCompIdx = deck.getKeyword("GCOMPIDX").getRecord(0).getItem("GAS_COMPONENT_INDEX").get< int >(0) - 1;
92  std::string gasvisctColumnName = "Viscosity"+std::to_string(static_cast<long long>(gasCompIdx));
93 
94  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
95  const auto& T = gasvisctTables[regionIdx].getColumn("Temperature").vectorCopy();
96  const auto& mu = gasvisctTables[regionIdx].getColumn(gasvisctColumnName).vectorCopy();
97  gasvisctCurves_[regionIdx].setXYContainers(T, mu);
98  }
99  }
100 
101  // quantities required for density. note that we just always use the values
102  // for the first EOS. (since EOS != PVT region.)
103  refTemp_ = 0.0;
104  if (enableThermalDensity_) {
105  refTemp_ = deck.getKeyword("TREF").getRecord(0).getItem("TEMPERATURE").getSIDouble(0);
106  }
107  }
108 #endif // HAVE_OPM_PARSER
109 
113  void setNumRegions(size_t numRegions)
114  { gasvisctCurves_.resize(numRegions); }
115 
119  void initEnd()
120  { }
121 
122  size_t numRegions() const
123  { return gasvisctCurves_.size(); }
124 
128  bool enableThermalDensity() const
129  { return enableThermalDensity_; }
130 
135  { return enableThermalViscosity_; }
136 
140  template <class Evaluation>
141  Evaluation viscosity(unsigned regionIdx,
142  const Evaluation& temperature,
143  const Evaluation& pressure,
144  const Evaluation& Rv) const
145  {
146  if (!enableThermalViscosity())
147  return isothermalPvt_->viscosity(regionIdx, temperature, pressure, Rv);
148 
149  // compute the viscosity deviation due to temperature
150  const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature);
151  return muGasvisct;
152  }
153 
157  template <class Evaluation>
158  Evaluation saturatedViscosity(unsigned regionIdx,
159  const Evaluation& temperature,
160  const Evaluation& pressure) const
161  {
162  if (!enableThermalViscosity())
163  return isothermalPvt_->saturatedViscosity(regionIdx, temperature, pressure);
164 
165  // compute the viscosity deviation due to temperature
166  const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature);
167  return muGasvisct;
168  }
169 
173  template <class Evaluation>
174  Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
175  const Evaluation& temperature,
176  const Evaluation& pressure,
177  const Evaluation& Rv) const
178  {
179  const auto& b =
180  isothermalPvt_->inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv);
181  if (!enableThermalDensity())
182  return b;
183 
184  // the Eclipse TD/RM do not explicitly specify the relation of the gas
185  // density and the temperature, but equation (69.49) (for Eclipse 2011.1)
186  // implies that the temperature dependence of the gas phase is rho(T, p) =
187  // rho(tref_, p)*T/T_ref ...
188  return b*temperature/refTemp_;
189  }
190 
194  template <class Evaluation>
195  Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
196  const Evaluation& temperature,
197  const Evaluation& pressure) const
198  {
199  const auto& b =
200  isothermalPvt_->saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
201  if (!enableThermalDensity())
202  return b;
203 
204  // the Eclipse TD/RM do not explicitly specify the relation of the gas
205  // density and the temperature, but equation (69.49) (for Eclipse 2011.1)
206  // implies that the temperature dependence of the gas phase is rho(T, p) =
207  // rho(tref_, p)*T/T_ref ...
208  return b*temperature/refTemp_;
209  }
210 
218  template <class Evaluation>
219  Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
220  const Evaluation& temperature,
221  const Evaluation& pressure) const
222  { return isothermalPvt_->saturatedOilVaporizationFactor(regionIdx, temperature, pressure); }
223 
231  template <class Evaluation>
232  Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
233  const Evaluation& temperature,
234  const Evaluation& pressure,
235  const Evaluation& oilSaturation,
236  Scalar maxOilSaturation) const
237  { return isothermalPvt_->saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation); }
238 
246  template <class Evaluation>
247  Evaluation saturationPressure(unsigned regionIdx,
248  const Evaluation& temperature,
249  const Evaluation& pressure) const
250  { return isothermalPvt_->saturationPressure(regionIdx, temperature, pressure); }
251 
252 private:
253  IsothermalPvt* isothermalPvt_;
254 
255  // The PVT properties needed for temperature dependence of the viscosity. We need
256  // to store one value per PVT region.
257  std::vector<TabulatedOneDFunction> gasvisctCurves_;
258 
259  // The PVT properties needed for temperature dependence of the density. This is
260  // specified as one value per EOS in the manual, but we unconditionally use the
261  // expansion coefficient of the first EOS...
262  Scalar refTemp_;
263 
264  bool enableThermalDensity_;
265  bool enableThermalViscosity_;
266 };
267 
268 } // namespace Opm
269 
270 #endif
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:165
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:182
Implements a scalar function that depends on two variables and which is sampled uniformly in the X di...
bool enableThermalViscosity() const
Returns true iff the viscosity of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:134
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, Scalar maxOilSaturation) const
Returns the oil vaporization factor [m^3/m^3] of the gas phase.
Definition: GasPvtThermal.hpp:232
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtMultiplexer.hpp:191
void setNumRegions(size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition: GasPvtThermal.hpp:113
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil saturated gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:201
Definition: Air_Mesitylene.hpp:33
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:75
Class implementing cubic splines.
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the oil-saturated gas phase given a set of parameters...
Definition: GasPvtThermal.hpp:158
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtThermal.hpp:174
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of oil saturated gas.
Definition: GasPvtMultiplexer.hpp:210
bool enableThermalDensity() const
Returns true iff the density of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:128
Implements a linearly interpolated scalar function that depends on one variable.
A central place for various physical constants occuring in some equations.
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil-saturated gas.
Definition: GasPvtThermal.hpp:195
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtThermal.hpp:141
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:55
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rv) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the oil compo...
Definition: GasPvtMultiplexer.hpp:233
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtMultiplexer.hpp:172
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of the gas phase.
Definition: GasPvtThermal.hpp:219
This file provides a wrapper around the "final" C++-2011 statement.
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:47
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the saturation pressure of the gas phase [Pa].
Definition: GasPvtThermal.hpp:247
void initEnd()
Finish initializing the thermal part of the gas phase PVT properties.
Definition: GasPvtThermal.hpp:119