All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ConstantCompressibilityOilPvt.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_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
28 #define OPM_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
29 
34 
35 #if HAVE_OPM_PARSER
36 #include <opm/parser/eclipse/Deck/Deck.hpp>
37 #include <opm/parser/eclipse/Deck/DeckItem.hpp>
38 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
39 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
40 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
41 #endif
42 
43 namespace Opm {
48 template <class Scalar>
50 {
52  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
53 
54 public:
55 #if HAVE_OPM_PARSER
56 
63  void initFromDeck(const Deck& deck, const EclipseState& /*eclState*/)
64  {
65  const auto& pvcdoKeyword = deck.getKeyword("PVCDO");
66  const auto& densityKeyword = deck.getKeyword("DENSITY");
67 
68  assert(pvcdoKeyword.size() == densityKeyword.size());
69 
70  size_t numRegions = pvcdoKeyword.size();
71  setNumRegions(numRegions);
72 
73  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
74  Scalar rhoRefO = densityKeyword.getRecord(regionIdx).getItem("OIL").getSIDouble(0);
75  Scalar rhoRefG = densityKeyword.getRecord(regionIdx).getItem("GAS").getSIDouble(0);
76  Scalar rhoRefW = densityKeyword.getRecord(regionIdx).getItem("WATER").getSIDouble(0);
77 
78  setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW);
79 
80  auto pvcdoRecord = pvcdoKeyword.getRecord(regionIdx);
81  oilReferencePressure_[regionIdx] =
82  pvcdoRecord.getItem("P_REF").getSIDouble(0);
83  oilReferenceFormationVolumeFactor_[regionIdx] =
84  pvcdoRecord.getItem("OIL_VOL_FACTOR").getSIDouble(0);
85  oilCompressibility_[regionIdx] =
86  pvcdoRecord.getItem("OIL_COMPRESSIBILITY").getSIDouble(0);
87  oilViscosity_[regionIdx] =
88  pvcdoRecord.getItem("OIL_VISCOSITY").getSIDouble(0);
89  oilViscosibility_[regionIdx] =
90  pvcdoRecord.getItem("OIL_VISCOSIBILITY").getSIDouble(0);
91  }
92 
93  initEnd();
94  }
95 #endif
96 
97  void setNumRegions(size_t numRegions)
98  {
99  oilReferenceDensity_.resize(numRegions);
100  oilReferencePressure_.resize(numRegions);
101  oilReferenceFormationVolumeFactor_.resize(numRegions);
102  oilCompressibility_.resize(numRegions);
103  oilViscosity_.resize(numRegions);
104  oilViscosibility_.resize(numRegions);
105 
106  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
107  setReferenceFormationVolumeFactor(regionIdx, 1.0);
108  setReferencePressure(regionIdx, 1.03125);
109  }
110  }
111 
115  void setReferenceDensities(unsigned regionIdx,
116  Scalar rhoRefOil,
117  Scalar /*rhoRefGas*/,
118  Scalar /*rhoRefWater*/)
119  { oilReferenceDensity_[regionIdx] = rhoRefOil; }
120 
124  void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility = 0.0)
125  {
126  oilViscosity_[regionIdx] = muo;
127  oilViscosibility_[regionIdx] = oilViscosibility;
128  }
129 
133  void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
134  { oilCompressibility_[regionIdx] = oilCompressibility; }
135 
139  void setReferencePressure(unsigned regionIdx, Scalar p)
140  { oilReferencePressure_[regionIdx] = p; }
141 
145  void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
146  { oilReferenceFormationVolumeFactor_[regionIdx] = BoRef; }
147 
151  void setViscosibility(unsigned regionIdx, Scalar muComp)
152  { oilViscosibility_[regionIdx] = muComp; }
153 
157  void initEnd()
158  { }
159 
163  unsigned numRegions() const
164  { return oilViscosity_.size(); }
165 
170  template <class Evaluation>
171  Evaluation viscosity(unsigned regionIdx,
172  const Evaluation& temperature,
173  const Evaluation& pressure,
174  const Evaluation& /*Rs*/) const
175  { return saturatedViscosity(regionIdx, temperature, pressure); }
176 
180  template <class Evaluation>
181  Evaluation saturatedViscosity(unsigned regionIdx,
182  const Evaluation& temperature,
183  const Evaluation& pressure) const
184  {
185  Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
186  const Evaluation& bo = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
187 
188  Scalar pRef = oilReferencePressure_[regionIdx];
189  const Evaluation& Y =
190  (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx])
191  * (pressure - pRef);
192  return BoMuoRef*bo/(1.0 + Y*(1.0 + Y/2.0));
193  }
194 
198  template <class Evaluation>
199  Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
200  const Evaluation& temperature,
201  const Evaluation& pressure,
202  const Evaluation& /*Rs*/) const
203  { return saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure); }
204 
211  template <class Evaluation>
212  Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
213  const Evaluation& /*temperature*/,
214  const Evaluation& pressure) const
215  {
216  // cf. ECLiPSE 2011 technical description, p. 116
217  Scalar pRef = oilReferencePressure_[regionIdx];
218  const Evaluation& X = oilCompressibility_[regionIdx]*(pressure - pRef);
219 
220  Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
221  return (1 + X*(1 + X/2))/BoRef;
222  }
223 
227  template <class Evaluation>
228  Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
229  const Evaluation& /*temperature*/,
230  const Evaluation& /*pressure*/) const
231  { return 0.0; /* this is dead oil! */ }
232 
236  template <class Evaluation>
237  Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
238  const Evaluation& /*temperature*/,
239  const Evaluation& /*pressure*/,
240  const Evaluation& /*oilSaturation*/,
241  Scalar /*maxOilSaturation*/) const
242  { return 0.0; /* this is dead oil! */ }
243 
250  template <class Evaluation>
251  Evaluation saturationPressure(unsigned /*regionIdx*/,
252  const Evaluation& /*temperature*/,
253  const Evaluation& /*Rs*/) const
254  { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
255 
256 private:
257  std::vector<Scalar> oilReferenceDensity_;
258  std::vector<Scalar> oilReferencePressure_;
259  std::vector<Scalar> oilReferenceFormationVolumeFactor_;
260  std::vector<Scalar> oilCompressibility_;
261  std::vector<Scalar> oilViscosity_;
262  std::vector<Scalar> oilViscosibility_;
263 };
264 
265 } // namespace Opm
266 
267 #endif
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
Set the compressibility of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:133
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure.
Definition: ConstantCompressibilityOilPvt.hpp:181
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the oil &quot;viscosibility&quot; [1/ (Pa s)].
Definition: ConstantCompressibilityOilPvt.hpp:151
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition: ConstantCompressibilityOilPvt.hpp:199
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the oil phase [Pa] depending on its mass fraction of the gas compo...
Definition: ConstantCompressibilityOilPvt.hpp:251
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, Scalar) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:237
Implements a scalar function that depends on two variables and which is sampled uniformly in the X di...
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
Definition: ConstantCompressibilityOilPvt.hpp:49
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility=0.0)
Set the viscosity and &quot;viscosibility&quot; of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:124
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
Set the oil reference formation volume factor [-].
Definition: ConstantCompressibilityOilPvt.hpp:145
void initEnd()
Finish initializing the oil phase PVT properties.
Definition: ConstantCompressibilityOilPvt.hpp:157
Class implementing cubic splines.
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure and a phase composition...
Definition: ConstantCompressibilityOilPvt.hpp:171
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: ConstantCompressibilityOilPvt.hpp:163
Implements a linearly interpolated scalar function that depends on one variable.
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the oil reference pressure [Pa].
Definition: ConstantCompressibilityOilPvt.hpp:139
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas saturated oil.
Definition: ConstantCompressibilityOilPvt.hpp:212
This file provides a wrapper around the &quot;final&quot; C++-2011 statement.
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:47
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: ConstantCompressibilityOilPvt.hpp:115
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:228