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  Copyright (C) 2015 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef OPM_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
26 #define OPM_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
27 
32 
33 #if HAVE_OPM_PARSER
34 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
35 #endif
36 
37 namespace Opm {
38 template <class Scalar>
40 
45 template <class Scalar>
47 {
49 
51  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
52 
53 public:
54 #if HAVE_OPM_PARSER
55 
62  void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr /*eclState*/)
63  {
64  DeckKeywordConstPtr pvcdoKeyword = deck->getKeyword("PVCDO");
65  DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
66 
67  assert(pvcdoKeyword->size() == densityKeyword->size());
68 
69  size_t numRegions = pvcdoKeyword->size();
70  setNumRegions(numRegions);
71 
72  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
73  Scalar rhoRefO = densityKeyword->getRecord(regionIdx)->getItem("OIL")->getSIDouble(0);
74  Scalar rhoRefG = densityKeyword->getRecord(regionIdx)->getItem("GAS")->getSIDouble(0);
75  Scalar rhoRefW = densityKeyword->getRecord(regionIdx)->getItem("WATER")->getSIDouble(0);
76 
77  setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW);
78 
79  auto pvcdoRecord = pvcdoKeyword->getRecord(regionIdx);
80  oilReferencePressure_[regionIdx] =
81  pvcdoRecord->getItem("P_REF")->getSIDouble(0);
82  oilReferenceFormationVolumeFactor_[regionIdx] =
83  pvcdoRecord->getItem("OIL_VOL_FACTOR")->getSIDouble(0);
84  oilCompressibility_[regionIdx] =
85  pvcdoRecord->getItem("OIL_COMPRESSIBILITY")->getSIDouble(0);
86  oilViscosity_[regionIdx] =
87  pvcdoRecord->getItem("OIL_VISCOSITY")->getSIDouble(0);
88  oilViscosibility_[regionIdx] =
89  pvcdoRecord->getItem("OIL_VISCOSIBILITY")->getSIDouble(0);
90  }
91  }
92 #endif
93 
94  void setNumRegions(size_t numRegions)
95  {
96  oilReferenceDensity_.resize(numRegions);
97  oilReferencePressure_.resize(numRegions);
98  oilReferenceFormationVolumeFactor_.resize(numRegions);
99  oilCompressibility_.resize(numRegions);
100  oilViscosity_.resize(numRegions);
101  oilViscosibility_.resize(numRegions);
102 
103  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
104  setReferenceFormationVolumeFactor(regionIdx, 1.0);
105  setReferencePressure(regionIdx, 1.03125);
106  }
107  }
108 
112  void setReferenceDensities(unsigned regionIdx,
113  Scalar rhoRefOil,
114  Scalar /*rhoRefGas*/,
115  Scalar /*rhoRefWater*/)
116  {
117  oilReferenceDensity_[regionIdx] = rhoRefOil;
118  }
119 
123  void setMolarMasses(unsigned /*regionIdx*/,
124  Scalar /*MOil*/,
125  Scalar /*MGas*/,
126  Scalar /*MWater*/)
127  { }
128 
132  void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility = 0.0)
133  {
134  oilViscosity_[regionIdx] = muo;
135  oilViscosibility_[regionIdx] = oilViscosibility;
136  }
137 
141  void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
142  { oilCompressibility_[regionIdx] = oilCompressibility; }
143 
147  void setReferencePressure(unsigned regionIdx, Scalar p)
148  { oilReferencePressure_[regionIdx] = p; }
149 
153  void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
154  { oilReferenceFormationVolumeFactor_[regionIdx] = BoRef; }
155 
159  void setViscosibility(unsigned regionIdx, Scalar muComp)
160  { oilViscosibility_[regionIdx] = muComp; }
161 
165  void initEnd(const GasPvtMultiplexer */*gasPvt*/)
166  { }
167 
171  template <class Evaluation>
172  Evaluation viscosity(unsigned regionIdx,
173  const Evaluation& temperature,
174  const Evaluation& pressure,
175  const Evaluation& XoG) const
176  {
177  // Eclipse calculates the viscosity in a weird way: it
178  // calcultes the product of B_w and mu_w and then divides the
179  // result by B_w...
180  Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
181  const Evaluation& Bo = formationVolumeFactor(regionIdx, temperature, pressure, XoG);
182 
183  Scalar pRef = oilReferencePressure_[regionIdx];
184  const Evaluation& Y =
185  (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx])
186  * (pressure - pRef);
187  return BoMuoRef/((1 + Y*(1 + Y/2))*Bo);
188  }
189 
193  template <class Evaluation>
194  Evaluation density(unsigned regionIdx,
195  const Evaluation& temperature,
196  const Evaluation& pressure,
197  const Evaluation& XoG) const
198  {
199  const Evaluation& Bo = formationVolumeFactor(regionIdx, temperature, pressure, XoG);
200  Scalar rhooRef = oilReferenceDensity_[regionIdx];
201  return rhooRef/Bo;
202  }
203 
207  template <class Evaluation>
208  Evaluation formationVolumeFactor(unsigned regionIdx,
209  const Evaluation& /*temperature*/,
210  const Evaluation& pressure,
211  const Evaluation& /*XoG*/) const
212  {
213  // cf. ECLiPSE 2011 technical description, p. 116
214  Scalar pRef = oilReferencePressure_[regionIdx];
215  const Evaluation& X = oilCompressibility_[regionIdx]*(pressure - pRef);
216 
217  Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
218  return BoRef/(1 + X*(1 + X/2));
219  }
220 
225  template <class Evaluation>
226  Evaluation fugacityCoefficientOil(unsigned /*regionIdx*/,
227  const Evaluation& /*temperature*/,
228  const Evaluation& pressure) const
229  {
230  // set the oil component fugacity coefficient in oil phase
231  // arbitrarily. we use some pseudo-realistic value for the vapor
232  // pressure to ease physical interpretation of the results
233  return 20e3/pressure;
234  }
235 
236  template <class Evaluation>
237  Evaluation fugacityCoefficientWater(unsigned regionIdx,
238  const Evaluation& temperature,
239  const Evaluation& pressure) const
240  {
241  // assume that the affinity of the water component to the oil phase is many orders
242  // of magnitude smaller than that of the oil component
243  return 1e8*fugacityCoefficientOil(regionIdx, temperature, pressure);
244  }
245 
246  template <class Evaluation>
247  Evaluation fugacityCoefficientGas(unsigned regionIdx,
248  const Evaluation& temperature,
249  const Evaluation& pressure) const
250  {
251  // assume that the affinity of the gas component to the oil phase is many orders
252  // of magnitude smaller than that of the oil component
253  return 1.01e8*fugacityCoefficientOil(regionIdx, temperature, pressure);
254  }
255 
259  template <class Evaluation>
260  Evaluation gasDissolutionFactor(unsigned /*regionIdx*/,
261  const Evaluation& /*temperature*/,
262  const Evaluation& /*pressure*/) const
263  { return 0.0; /* this is dead oil! */ }
264 
271  template <class Evaluation>
272  Evaluation oilSaturationPressure(unsigned /*regionIdx*/,
273  const Evaluation& /*temperature*/,
274  const Evaluation& /*XoG*/) const
275  { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
276 
277  template <class Evaluation>
278  Evaluation saturatedOilGasMassFraction(unsigned /*regionIdx*/,
279  const Evaluation& /*temperature*/,
280  const Evaluation& /*pressure*/) const
281  { return 0.0; /* this is dead oil! */ }
282 
283  template <class Evaluation>
284  Evaluation saturatedOilGasMoleFraction(unsigned /*regionIdx*/,
285  const Evaluation& /*temperature*/,
286  const Evaluation& /*pressure*/) const
287  { return 0.0; /* this is dead oil! */ }
288 
289 private:
290  std::vector<Scalar> oilReferenceDensity_;
291  std::vector<Scalar> oilReferencePressure_;
292  std::vector<Scalar> oilReferenceFormationVolumeFactor_;
293  std::vector<Scalar> oilCompressibility_;
294  std::vector<Scalar> oilViscosity_;
295  std::vector<Scalar> oilViscosibility_;
296 };
297 
298 } // namespace Opm
299 
300 #endif
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
Set the oil reference formation volume factor [-].
Definition: ConstantCompressibilityOilPvt.hpp:153
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: ConstantCompressibilityOilPvt.hpp:112
Evaluation saturatedOilGasMassFraction(unsigned, const Evaluation &, const Evaluation &) const
Definition: ConstantCompressibilityOilPvt.hpp:278
Implements a scalar function that depends on two variables and which is sampled uniformly in the X di...
Definition: Air_Mesitylene.hpp:31
Evaluation gasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:260
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the oil "viscosibility" [1/ (Pa s)].
Definition: ConstantCompressibilityOilPvt.hpp:159
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: ConstantCompressibilityOilPvt.hpp:39
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &XoG) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: ConstantCompressibilityOilPvt.hpp:172
Class implementing cubic splines.
Implements a linearly interpolated scalar function that depends on one variable.
void setMolarMasses(unsigned, Scalar, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: ConstantCompressibilityOilPvt.hpp:123
This file provides a wrapper around the "final" C++-2011 statement.
Evaluation density(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &XoG) const
Returns the density [kg/m^3] of the fluid phase given a set of parameters.
Definition: ConstantCompressibilityOilPvt.hpp:194
void setNumRegions(size_t numRegions)
Definition: ConstantCompressibilityOilPvt.hpp:94
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
Set the compressibility of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:141
Evaluation fugacityCoefficientOil(unsigned, const Evaluation &, const Evaluation &pressure) const
Returns the fugacity coefficient [Pa] of a component in the fluid phase given a set of parameters...
Definition: ConstantCompressibilityOilPvt.hpp:226
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the oil reference pressure [Pa].
Definition: ConstantCompressibilityOilPvt.hpp:147
Evaluation saturatedOilGasMoleFraction(unsigned, const Evaluation &, const Evaluation &) const
Definition: ConstantCompressibilityOilPvt.hpp:284
Evaluation fugacityCoefficientGas(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Definition: ConstantCompressibilityOilPvt.hpp:247
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility=0.0)
Set the viscosity and "viscosibility" of the oil phase.
Definition: ConstantCompressibilityOilPvt.hpp:132
Evaluation fugacityCoefficientWater(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Definition: ConstantCompressibilityOilPvt.hpp:237
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
Definition: ConstantCompressibilityOilPvt.hpp:46
Evaluation oilSaturationPressure(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:272
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:44
void initEnd(const GasPvtMultiplexer *)
Finish initializing the oil phase PVT properties.
Definition: ConstantCompressibilityOilPvt.hpp:165
Evaluation formationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition: ConstantCompressibilityOilPvt.hpp:208