ConstantCompressibilityWaterPvt.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_WATER_PVT_HPP
26 #define OPM_CONSTANT_COMPRESSIBILITY_WATER_PVT_HPP
27 
29 
30 #if HAVE_OPM_PARSER
31 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
32 #endif
33 
34 #include <vector>
35 
36 namespace Opm {
37 
42 template <class Scalar>
44 {
46  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
47 
48 public:
49 #if HAVE_OPM_PARSER
50 
54  void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr /*eclState*/)
55  {
56  DeckKeywordConstPtr pvtwKeyword = deck->getKeyword("PVTW");
57  DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
58 
59  assert(pvtwKeyword->size() == densityKeyword->size());
60 
61  size_t numRegions = pvtwKeyword->size();
62  setNumRegions(numRegions);
63 
64  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
65  auto pvtwRecord = pvtwKeyword->getRecord(regionIdx);
66  auto densityRecord = densityKeyword->getRecord(regionIdx);
67 
68  waterReferenceDensity_[regionIdx] =
69  densityRecord->getItem("WATER")->getSIDouble(0);
70 
71  waterReferencePressure_[regionIdx] =
72  pvtwRecord->getItem("P_REF")->getSIDouble(0);
73  waterReferenceFormationVolumeFactor_[regionIdx] =
74  pvtwRecord->getItem("WATER_VOL_FACTOR")->getSIDouble(0);
75  waterCompressibility_[regionIdx] =
76  pvtwRecord->getItem("WATER_COMPRESSIBILITY")->getSIDouble(0);
77  waterViscosity_[regionIdx] =
78  pvtwRecord->getItem("WATER_VISCOSITY")->getSIDouble(0);
79  waterViscosibility_[regionIdx] =
80  pvtwRecord->getItem("WATER_VISCOSIBILITY")->getSIDouble(0);
81  }
82  }
83 #endif
84 
85  void setNumRegions(size_t numRegions)
86  {
87  waterReferenceDensity_.resize(numRegions);
88  waterReferencePressure_.resize(numRegions);
89  waterReferenceFormationVolumeFactor_.resize(numRegions);
90  waterCompressibility_.resize(numRegions);
91  waterViscosity_.resize(numRegions);
92  waterViscosibility_.resize(numRegions);
93 
94  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
95  setReferenceDensities(regionIdx, 650.0, 1.0, 1000.0);
96  setReferenceFormationVolumeFactor(regionIdx, 1.0);
97  setReferencePressure(regionIdx, 1e5);
98  }
99  }
100 
104  void setReferenceDensities(unsigned regionIdx,
105  Scalar /*rhoRefOil*/,
106  Scalar /*rhoRefGas*/,
107  Scalar rhoRefWater)
108  { waterReferenceDensity_[regionIdx] = rhoRefWater; }
109 
113  void setReferencePressure(unsigned regionIdx, Scalar p)
114  { waterReferencePressure_[regionIdx] = p; }
115 
119  void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility = 0.0)
120  {
121  waterViscosity_[regionIdx] = muw;
122  waterViscosibility_[regionIdx] = waterViscosibility;
123  }
124 
128  void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
129  { waterCompressibility_[regionIdx] = waterCompressibility; }
130 
134  void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
135  { waterReferenceFormationVolumeFactor_[regionIdx] = BwRef; }
136 
140  void setViscosibility(unsigned regionIdx, Scalar muComp)
141  { waterViscosibility_[regionIdx] = muComp; }
142 
146  void initEnd()
147  { }
148 
152  template <class Evaluation>
153  Evaluation viscosity(unsigned regionIdx,
154  const Evaluation& temperature,
155  const Evaluation& pressure) const
156  {
157  // Eclipse calculates the viscosity in a weird way: it
158  // calcultes the product of B_w and mu_w and then divides the
159  // result by B_w...
160  Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
161  const Evaluation& Bw = formationVolumeFactor(regionIdx, temperature, pressure);
162 
163  Scalar pRef = waterReferencePressure_[regionIdx];
164  const Evaluation& Y =
165  (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
166  * (pressure - pRef);
167  return BwMuwRef/((1 + Y*(1 + Y/2))*Bw);
168  }
169 
173  template <class Evaluation>
174  Evaluation density(unsigned regionIdx,
175  const Evaluation& temperature,
176  const Evaluation& pressure) const
177  {
178  const Evaluation& Bw = formationVolumeFactor(regionIdx, temperature, pressure);
179  return waterReferenceDensity_[regionIdx]/Bw;
180  }
181 
185  template <class Evaluation>
186  Evaluation formationVolumeFactor(unsigned regionIdx,
187  const Evaluation& /*temperature*/,
188  const Evaluation& pressure) const
189  {
190  // cf. ECLiPSE 2011 technical description, p. 116
191  Scalar pRef = waterReferencePressure_[regionIdx];
192  const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
193 
194  Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
195 
196  // TODO (?): consider the salt concentration of the brine
197  return BwRef/(1 + X*(1 + X/2));
198  }
199 
204  template <class Evaluation>
205  Evaluation fugacityCoefficientOil(unsigned /*regionIdx*/,
206  const Evaluation& /*temperature*/,
207  const Evaluation& pressure) const
208  {
209  // set the affinity of the gas and oil components to the water phase to be 10
210  // orders of magnitude smaller than that of the water component. for this we use
211  // a pseudo-realistic vapor pressure of water as a starting point. (we just set
212  // it to 30 kPa to ease interpreting the results.)
213  const Scalar pvWater = 30e3;
214 
215  return 1e10*pvWater / pressure;
216  }
217 
222  template <class Evaluation>
223  Evaluation fugacityCoefficientGas(unsigned /*regionIdx*/,
224  const Evaluation& /*temperature*/,
225  const Evaluation& pressure) const
226  {
227  // set the affinity of the gas and oil components to the water phase to be 10
228  // orders of magnitude smaller than that of the water component. for this we use
229  // a pseudo-realistic vapor pressure of water as a starting point. (we just set
230  // it to 30 kPa to ease interpreting the results.)
231  const Scalar pvWater = 30e3;
232 
233  return 1.01e10*pvWater / pressure;
234  }
235 
240  template <class Evaluation>
241  Evaluation fugacityCoefficientWater(unsigned /*regionIdx*/,
242  const Evaluation& /*temperature*/,
243  const Evaluation& pressure) const
244  {
245  // set the affinity of the gas and oil components to the water phase to be 10
246  // orders of magnitude smaller than that of the water component. for this we use
247  // a pseudo-realistic vapor pressure of water as a starting point. (we just set
248  // it to 30 kPa to ease interpreting the results.)
249  const Scalar pvWater = 30e3;
250 
251  return pvWater / pressure;
252  }
253 
254 private:
255  std::vector<Scalar> waterReferenceDensity_;
256  std::vector<Scalar> waterReferencePressure_;
257  std::vector<Scalar> waterReferenceFormationVolumeFactor_;
258  std::vector<Scalar> waterCompressibility_;
259  std::vector<Scalar> waterViscosity_;
260  std::vector<Scalar> waterViscosibility_;
261 };
262 
263 } // namespace Opm
264 
265 #endif
Evaluation density(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the density [kg/m^3] of the fluid phase given a set of parameters.
Definition: ConstantCompressibilityWaterPvt.hpp:174
Definition: Air_Mesitylene.hpp:31
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityWaterPvt.hpp:43
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the water "viscosibility" [1/ (Pa s)].
Definition: ConstantCompressibilityWaterPvt.hpp:140
void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility=0.0)
Set the viscosity and "viscosibility" of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:119
Evaluation fugacityCoefficientGas(unsigned, const Evaluation &, const Evaluation &pressure) const
Returns the fugacity coefficient [Pa] of the gas component in the water phase given a set of paramete...
Definition: ConstantCompressibilityWaterPvt.hpp:223
void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
Set the compressibility of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:128
Implements a linearly interpolated scalar function that depends on one variable.
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
Set the water reference formation volume factor [-].
Definition: ConstantCompressibilityWaterPvt.hpp:134
void setNumRegions(size_t numRegions)
Definition: ConstantCompressibilityWaterPvt.hpp:85
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar, Scalar rhoRefWater)
Set the water reference density [kg / m^3].
Definition: ConstantCompressibilityWaterPvt.hpp:104
Evaluation fugacityCoefficientWater(unsigned, const Evaluation &, const Evaluation &pressure) const
Returns the fugacity coefficient [Pa] of the water component in the water phase given a set of parame...
Definition: ConstantCompressibilityWaterPvt.hpp:241
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the water reference pressure [Pa].
Definition: ConstantCompressibilityWaterPvt.hpp:113
void initEnd()
Finish initializing the water phase PVT properties.
Definition: ConstantCompressibilityWaterPvt.hpp:146
Evaluation formationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition: ConstantCompressibilityWaterPvt.hpp:186
Evaluation fugacityCoefficientOil(unsigned, const Evaluation &, const Evaluation &pressure) const
Returns the fugacity coefficient [Pa] of the oil component in the water phase given a set of paramete...
Definition: ConstantCompressibilityWaterPvt.hpp:205
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: ConstantCompressibilityWaterPvt.hpp:153
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:44