All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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  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_WATER_PVT_HPP
28 #define OPM_CONSTANT_COMPRESSIBILITY_WATER_PVT_HPP
29 
31 
32 #if HAVE_OPM_PARSER
33 #include <opm/parser/eclipse/Deck/Deck.hpp>
34 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
35 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
36 #include <opm/parser/eclipse/Deck/DeckItem.hpp>
37 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
38 #endif
39 
40 #include <vector>
41 
42 namespace Opm {
47 template <class Scalar>
49 {
51  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
52 
53 public:
54 #if HAVE_OPM_PARSER
55 
59  void initFromDeck(const Deck& deck, const EclipseState& /*eclState*/)
60  {
61  const auto& pvtwKeyword = deck.getKeyword("PVTW");
62  const auto& densityKeyword = deck.getKeyword("DENSITY");
63 
64  assert(pvtwKeyword.size() == densityKeyword.size());
65 
66  size_t numRegions = pvtwKeyword.size();
67  setNumRegions(numRegions);
68 
69  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
70  auto pvtwRecord = pvtwKeyword.getRecord(regionIdx);
71  auto densityRecord = densityKeyword.getRecord(regionIdx);
72 
73  waterReferenceDensity_[regionIdx] =
74  densityRecord.getItem("WATER").getSIDouble(0);
75 
76  waterReferencePressure_[regionIdx] =
77  pvtwRecord.getItem("P_REF").getSIDouble(0);
78  waterReferenceFormationVolumeFactor_[regionIdx] =
79  pvtwRecord.getItem("WATER_VOL_FACTOR").getSIDouble(0);
80  waterCompressibility_[regionIdx] =
81  pvtwRecord.getItem("WATER_COMPRESSIBILITY").getSIDouble(0);
82  waterViscosity_[regionIdx] =
83  pvtwRecord.getItem("WATER_VISCOSITY").getSIDouble(0);
84  waterViscosibility_[regionIdx] =
85  pvtwRecord.getItem("WATER_VISCOSIBILITY").getSIDouble(0);
86  }
87 
88  initEnd();
89  }
90 #endif
91 
92  void setNumRegions(size_t numRegions)
93  {
94  waterReferenceDensity_.resize(numRegions);
95  waterReferencePressure_.resize(numRegions);
96  waterReferenceFormationVolumeFactor_.resize(numRegions);
97  waterCompressibility_.resize(numRegions);
98  waterViscosity_.resize(numRegions);
99  waterViscosibility_.resize(numRegions);
100 
101  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
102  setReferenceDensities(regionIdx, 650.0, 1.0, 1000.0);
103  setReferenceFormationVolumeFactor(regionIdx, 1.0);
104  setReferencePressure(regionIdx, 1e5);
105  }
106  }
107 
111  void setReferenceDensities(unsigned regionIdx,
112  Scalar /*rhoRefOil*/,
113  Scalar /*rhoRefGas*/,
114  Scalar rhoRefWater)
115  { waterReferenceDensity_[regionIdx] = rhoRefWater; }
116 
120  void setReferencePressure(unsigned regionIdx, Scalar p)
121  { waterReferencePressure_[regionIdx] = p; }
122 
126  void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility = 0.0)
127  {
128  waterViscosity_[regionIdx] = muw;
129  waterViscosibility_[regionIdx] = waterViscosibility;
130  }
131 
135  void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
136  { waterCompressibility_[regionIdx] = waterCompressibility; }
137 
141  void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
142  { waterReferenceFormationVolumeFactor_[regionIdx] = BwRef; }
143 
147  void setViscosibility(unsigned regionIdx, Scalar muComp)
148  { waterViscosibility_[regionIdx] = muComp; }
149 
153  void initEnd()
154  { }
155 
159  unsigned numRegions() const
160  { return waterReferenceDensity_.size(); }
161 
165  template <class Evaluation>
166  Evaluation viscosity(unsigned regionIdx,
167  const Evaluation& temperature,
168  const Evaluation& pressure) const
169  {
170  Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
171  const Evaluation& bw = inverseFormationVolumeFactor(regionIdx, temperature, pressure);
172 
173  Scalar pRef = waterReferencePressure_[regionIdx];
174  const Evaluation& Y =
175  (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
176  * (pressure - pRef);
177  return BwMuwRef*bw/(1 + Y*(1 + Y/2));
178  }
179 
183  template <class Evaluation>
184  Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
185  const Evaluation& /*temperature*/,
186  const Evaluation& pressure) const
187  {
188  // cf. ECLiPSE 2011 technical description, p. 116
189  Scalar pRef = waterReferencePressure_[regionIdx];
190  const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
191 
192  Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
193 
194  // TODO (?): consider the salt concentration of the brine
195  return (1.0 + X*(1.0 + X/2.0))/BwRef;
196  }
197 
198 private:
199  std::vector<Scalar> waterReferenceDensity_;
200  std::vector<Scalar> waterReferencePressure_;
201  std::vector<Scalar> waterReferenceFormationVolumeFactor_;
202  std::vector<Scalar> waterCompressibility_;
203  std::vector<Scalar> waterViscosity_;
204  std::vector<Scalar> waterViscosibility_;
205 };
206 
207 } // namespace Opm
208 
209 #endif
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition: ConstantCompressibilityWaterPvt.hpp:184
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
Set the water reference formation volume factor [-].
Definition: ConstantCompressibilityWaterPvt.hpp:141
void initEnd()
Finish initializing the water phase PVT properties.
Definition: ConstantCompressibilityWaterPvt.hpp:153
void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
Set the compressibility of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:135
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityWaterPvt.hpp:48
void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility=0.0)
Set the viscosity and &quot;viscosibility&quot; of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:126
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:166
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar, Scalar rhoRefWater)
Set the water reference density [kg / m^3].
Definition: ConstantCompressibilityWaterPvt.hpp:111
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: ConstantCompressibilityWaterPvt.hpp:159
Implements a linearly interpolated scalar function that depends on one variable.
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the water &quot;viscosibility&quot; [1/ (Pa s)].
Definition: ConstantCompressibilityWaterPvt.hpp:147
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:47
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the water reference pressure [Pa].
Definition: ConstantCompressibilityWaterPvt.hpp:120