DeadOilPvt.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_DEAD_OIL_PVT_HPP
26 #define OPM_DEAD_OIL_PVT_HPP
27 
31 
32 #if HAVE_OPM_PARSER
33 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
34 #endif
35 
36 namespace Opm {
37 template <class Scalar>
38 class GasPvtMultiplexer;
39 
44 template <class Scalar>
46 {
48 
50  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
51 
52 public:
53 #if HAVE_OPM_PARSER
54 
57  void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr eclState)
58  {
59  const auto& pvdoTables = eclState->getTableManager()->getPvdoTables();
60  DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
61 
62  assert(pvdoTables.size() == densityKeyword->size());
63 
64  size_t numRegions = pvdoTables.size();
65  setNumRegions(numRegions);
66 
67  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
68  Scalar rhoRefO = densityKeyword->getRecord(regionIdx)->getItem("OIL")->getSIDouble(0);
69  Scalar rhoRefG = densityKeyword->getRecord(regionIdx)->getItem("GAS")->getSIDouble(0);
70  Scalar rhoRefW = densityKeyword->getRecord(regionIdx)->getItem("WATER")->getSIDouble(0);
71 
72  setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW);
73 
74  const auto& pvdoTable = pvdoTables.getTable<PvdoTable>(regionIdx);
75 
76  const auto& BColumn(pvdoTable.getFormationFactorColumn());
77  std::vector<Scalar> invBColumn(BColumn.size());
78  for (unsigned i = 0; i < invBColumn.size(); ++i)
79  invBColumn[i] = 1/BColumn[i];
80 
81  inverseOilB_[regionIdx].setXYArrays(pvdoTable.numRows(),
82  pvdoTable.getPressureColumn(),
83  invBColumn);
84  oilMu_[regionIdx].setXYArrays(pvdoTable.numRows(),
85  pvdoTable.getPressureColumn(),
86  pvdoTable.getViscosityColumn());
87  }
88  }
89 #endif // HAVE_OPM_PARSER
90 
91  void setNumRegions(size_t numRegions)
92  {
93  oilReferenceDensity_.resize(numRegions);
94  inverseOilB_.resize(numRegions);
95  inverseOilBMu_.resize(numRegions);
96  oilMu_.resize(numRegions);
97  }
98 
102  void setReferenceDensities(unsigned regionIdx,
103  Scalar rhoRefOil,
104  Scalar /*rhoRefGas*/,
105  Scalar /*rhoRefWater*/)
106  {
107  oilReferenceDensity_[regionIdx] = rhoRefOil;
108  }
109 
120  void setInverseOilFormationVolumeFactor(unsigned regionIdx, const TabulatedOneDFunction& invBo)
121  { inverseOilB_[regionIdx] = invBo; }
122 
128  void setOilViscosity(unsigned regionIdx, const TabulatedOneDFunction& muo)
129  { oilMu_[regionIdx] = muo; }
130 
134  void initEnd(const GasPvtMultiplexer */*gasPvt*/)
135  {
136  // calculate the final 2D functions which are used for interpolation.
137  size_t numRegions = oilMu_.size();
138  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
139  // calculate the table which stores the inverse of the product of the oil
140  // formation volume factor and the oil viscosity
141  const auto& oilMu = oilMu_[regionIdx];
142  const auto& invOilB = inverseOilB_[regionIdx];
143  assert(oilMu.numSamples() == invOilB.numSamples());
144 
145  std::vector<Scalar> invBMuColumn;
146  std::vector<Scalar> pressureColumn;
147  invBMuColumn.resize(oilMu.numSamples());
148  pressureColumn.resize(oilMu.numSamples());
149 
150  for (unsigned pIdx = 0; pIdx < oilMu.numSamples(); ++pIdx) {
151  pressureColumn[pIdx] = invOilB.xAt(pIdx);
152  invBMuColumn[pIdx] = invOilB.valueAt(pIdx)*1/oilMu.valueAt(pIdx);
153  }
154 
155  inverseOilBMu_[regionIdx].setXYArrays(pressureColumn.size(),
156  pressureColumn,
157  invBMuColumn);
158  }
159  }
160 
164  template <class Evaluation>
165  Evaluation viscosity(unsigned regionIdx,
166  const Evaluation& /*temperature*/,
167  const Evaluation& pressure,
168  const Evaluation& /*XoG*/) const
169  {
170  const Evaluation& invBo = inverseOilB_[regionIdx].eval(pressure, /*extrapolate=*/true);
171  const Evaluation& invMuoBo = inverseOilBMu_[regionIdx].eval(pressure, /*extrapolate=*/true);
172 
173  return invBo/invMuoBo;
174  }
175 
179  template <class Evaluation>
180  Evaluation density(unsigned regionIdx,
181  const Evaluation& temperature,
182  const Evaluation& pressure,
183  const Evaluation& XoG) const
184  {
185  Scalar rhooRef = oilReferenceDensity_[regionIdx];
186 
187  const Evaluation& Bo = formationVolumeFactor(regionIdx, temperature, pressure, XoG);
188  return rhooRef/Bo;
189  }
190 
194  template <class Evaluation>
195  Evaluation formationVolumeFactor(unsigned regionIdx,
196  const Evaluation& /*temperature*/,
197  const Evaluation& pressure,
198  const Evaluation& /*XoG*/) const
199  { return 1.0 / inverseOilB_[regionIdx].eval(pressure, /*extrapolate=*/true); }
200 
205  template <class Evaluation>
206  Evaluation fugacityCoefficientOil(unsigned /*regionIdx*/,
207  const Evaluation& /*temperature*/,
208  const Evaluation& pressure) const
209  {
210  // set the oil component fugacity coefficient in oil phase
211  // arbitrarily. we use some pseudo-realistic value for the vapor
212  // pressure to ease physical interpretation of the results
213  return 20e3/pressure;
214  }
215 
216  template <class Evaluation>
217  Evaluation fugacityCoefficientWater(unsigned regionIdx,
218  const Evaluation& temperature,
219  const Evaluation& pressure) const
220  {
221  // assume that the affinity of the water component to the
222  // oil phase is one million times smaller than that of the
223  // oil component
224  return 1e8*fugacityCoefficientOil(regionIdx, temperature, pressure);
225  }
226 
227  template <class Evaluation>
228  Evaluation fugacityCoefficientGas(unsigned regionIdx,
229  const Evaluation& temperature,
230  const Evaluation& pressure) const
231  {
232  // gas is immiscible with dead oil as well...
233  return 1.01e8*fugacityCoefficientOil(regionIdx, temperature, pressure);
234  }
235 
239  template <class Evaluation>
240  Evaluation gasDissolutionFactor(unsigned /*regionIdx*/,
241  const Evaluation& /*temperature*/,
242  const Evaluation& /*pressure*/) const
243  { return 0.0; /* this is dead oil! */ }
244 
251  template <class Evaluation>
252  Evaluation oilSaturationPressure(unsigned /*regionIdx*/,
253  const Evaluation& /*temperature*/,
254  const Evaluation& /*XoG*/) const
255  { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
256 
257  template <class Evaluation>
258  Evaluation saturatedOilGasMassFraction(unsigned /*regionIdx*/,
259  const Evaluation& /*temperature*/,
260  const Evaluation& /*pressure*/) const
261  { return 0.0; /* this is dead oil! */ }
262 
263  template <class Evaluation>
264  Evaluation saturatedOilGasMoleFraction(unsigned /*regionIdx*/,
265  const Evaluation& /*temperature*/,
266  const Evaluation& /*pressure*/) const
267  { return 0.0; /* this is dead oil! */ }
268 
269 private:
270  std::vector<Scalar> oilReferenceDensity_;
271  std::vector<TabulatedOneDFunction> inverseOilB_;
272  std::vector<TabulatedOneDFunction> oilMu_;
273  std::vector<TabulatedOneDFunction> inverseOilBMu_;
274 };
275 
276 } // namespace Opm
277 
278 #endif
Evaluation gasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: DeadOilPvt.hpp:240
Evaluation viscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: DeadOilPvt.hpp:165
Implements a scalar function that depends on two variables and which is sampled uniformly in the X di...
Evaluation saturatedOilGasMoleFraction(unsigned, const Evaluation &, const Evaluation &) const
Definition: DeadOilPvt.hpp:264
Definition: Air_Mesitylene.hpp:31
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: ConstantCompressibilityOilPvt.hpp:39
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
Definition: DeadOilPvt.hpp:45
void setNumRegions(size_t numRegions)
Definition: DeadOilPvt.hpp:91
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: DeadOilPvt.hpp:102
Class implementing cubic splines.
void setInverseOilFormationVolumeFactor(unsigned regionIdx, const TabulatedOneDFunction &invBo)
Initialize the function for the oil formation volume factor.
Definition: DeadOilPvt.hpp:120
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: DeadOilPvt.hpp:206
Implements a linearly interpolated scalar function that depends on one variable.
Evaluation saturatedOilGasMassFraction(unsigned, const Evaluation &, const Evaluation &) const
Definition: DeadOilPvt.hpp:258
void initEnd(const GasPvtMultiplexer *)
Finish initializing the oil phase PVT properties.
Definition: DeadOilPvt.hpp:134
Evaluation formationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition: DeadOilPvt.hpp:195
void setOilViscosity(unsigned regionIdx, const TabulatedOneDFunction &muo)
Initialize the viscosity of the oil phase.
Definition: DeadOilPvt.hpp:128
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: DeadOilPvt.hpp:252
Evaluation fugacityCoefficientWater(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Definition: DeadOilPvt.hpp:217
Evaluation fugacityCoefficientGas(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Definition: DeadOilPvt.hpp:228
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: DeadOilPvt.hpp:180
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:44