My Project
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_ECL_INPUT
33 #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
34 #endif
35 
36 #include <vector>
37 
38 namespace Opm {
43 template <class Scalar>
45 {
47  typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
48 
49 public:
51  ConstantCompressibilityWaterPvt(const std::vector<Scalar>& waterReferenceDensity,
52  const std::vector<Scalar>& waterReferencePressure,
53  const std::vector<Scalar>& waterReferenceFormationVolumeFactor,
54  const std::vector<Scalar>& waterCompressibility,
55  const std::vector<Scalar>& waterViscosity,
56  const std::vector<Scalar>& waterViscosibility)
57  : waterReferenceDensity_(waterReferenceDensity)
58  , waterReferencePressure_(waterReferencePressure)
59  , waterReferenceFormationVolumeFactor_(waterReferenceFormationVolumeFactor)
60  , waterCompressibility_(waterCompressibility)
61  , waterViscosity_(waterViscosity)
62  , waterViscosibility_(waterViscosibility)
63  { }
64 #if HAVE_ECL_INPUT
69  void initFromState(const EclipseState& eclState, const Schedule&)
70  {
71  const auto& pvtwTable = eclState.getTableManager().getPvtwTable();
72  const auto& densityTable = eclState.getTableManager().getDensityTable();
73 
74  assert(pvtwTable.size() == densityTable.size());
75 
76  size_t numRegions = pvtwTable.size();
77  setNumRegions(numRegions);
78 
79  for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
80  waterReferenceDensity_[regionIdx] = densityTable[regionIdx].water;
81 
82  waterReferencePressure_[regionIdx] = pvtwTable[regionIdx].reference_pressure;
83  waterReferenceFormationVolumeFactor_[regionIdx] = pvtwTable[regionIdx].volume_factor;
84  waterCompressibility_[regionIdx] = pvtwTable[regionIdx].compressibility;
85  waterViscosity_[regionIdx] = pvtwTable[regionIdx].viscosity;
86  waterViscosibility_[regionIdx] = pvtwTable[regionIdx].viscosibility;
87  }
88 
89  initEnd();
90  }
91 #endif
92 
93  void setNumRegions(size_t numRegions)
94  {
95  waterReferenceDensity_.resize(numRegions);
96  waterReferencePressure_.resize(numRegions);
97  waterReferenceFormationVolumeFactor_.resize(numRegions);
98  waterCompressibility_.resize(numRegions);
99  waterViscosity_.resize(numRegions);
100  waterViscosibility_.resize(numRegions);
101 
102  for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
103  setReferenceDensities(regionIdx, 650.0, 1.0, 1000.0);
104  setReferenceFormationVolumeFactor(regionIdx, 1.0);
105  setReferencePressure(regionIdx, 1e5);
106  }
107  }
108 
112  void setReferenceDensities(unsigned regionIdx,
113  Scalar /*rhoRefOil*/,
114  Scalar /*rhoRefGas*/,
115  Scalar rhoRefWater)
116  { waterReferenceDensity_[regionIdx] = rhoRefWater; }
117 
121  void setReferencePressure(unsigned regionIdx, Scalar p)
122  { waterReferencePressure_[regionIdx] = p; }
123 
127  void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility = 0.0)
128  {
129  waterViscosity_[regionIdx] = muw;
130  waterViscosibility_[regionIdx] = waterViscosibility;
131  }
132 
136  void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
137  { waterCompressibility_[regionIdx] = waterCompressibility; }
138 
142  void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
143  { waterReferenceFormationVolumeFactor_[regionIdx] = BwRef; }
144 
148  void setViscosibility(unsigned regionIdx, Scalar muComp)
149  { waterViscosibility_[regionIdx] = muComp; }
150 
154  void initEnd()
155  { }
156 
160  unsigned numRegions() const
161  { return waterReferenceDensity_.size(); }
162 
166  template <class Evaluation>
167  Evaluation internalEnergy(unsigned,
168  const Evaluation&,
169  const Evaluation&) const
170  {
171  throw std::runtime_error("Requested the enthalpy of water but the thermal option is not enabled");
172  }
173 
174 
178  template <class Evaluation>
179  Evaluation viscosity(unsigned regionIdx,
180  const Evaluation& temperature,
181  const Evaluation& pressure,
182  const Evaluation& saltconcentration) const
183  {
184  Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
185  const Evaluation& bw = inverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration);
186 
187  Scalar pRef = waterReferencePressure_[regionIdx];
188  const Evaluation& Y =
189  (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
190  * (pressure - pRef);
191  return BwMuwRef*bw/(1 + Y*(1 + Y/2));
192  }
193 
197  template <class Evaluation>
198  Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
199  const Evaluation& /*temperature*/,
200  const Evaluation& pressure,
201  const Evaluation& /*saltconcentration*/) const
202  {
203  // cf. ECLiPSE 2011 technical description, p. 116
204  Scalar pRef = waterReferencePressure_[regionIdx];
205  const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
206 
207  Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
208 
209  // TODO (?): consider the salt concentration of the brine
210  return (1.0 + X*(1.0 + X/2.0))/BwRef;
211  }
212 
213  const Scalar waterReferenceDensity(unsigned regionIdx) const
214  { return waterReferenceDensity_[regionIdx]; }
215 
216  const std::vector<Scalar>& waterReferencePressure() const
217  { return waterReferencePressure_; }
218 
219  const std::vector<Scalar>& waterReferenceFormationVolumeFactor() const
220  { return waterReferenceFormationVolumeFactor_; }
221 
222  const std::vector<Scalar>& waterCompressibility() const
223  { return waterCompressibility_; }
224 
225  const std::vector<Scalar>& waterViscosity() const
226  { return waterViscosity_; }
227 
228  const std::vector<Scalar>& waterViscosibility() const
229  { return waterViscosibility_; }
230 
231  bool operator==(const ConstantCompressibilityWaterPvt<Scalar>& data) const
232  {
233  return this->waterReferenceDensity_ == data.waterReferenceDensity_ &&
234  this->waterReferencePressure() == data.waterReferencePressure() &&
235  this->waterReferenceFormationVolumeFactor() == data.waterReferenceFormationVolumeFactor() &&
236  this->waterCompressibility() == data.waterCompressibility() &&
237  this->waterViscosity() == data.waterViscosity() &&
238  this->waterViscosibility() == data.waterViscosibility();
239  }
240 
241 private:
242  std::vector<Scalar> waterReferenceDensity_;
243  std::vector<Scalar> waterReferencePressure_;
244  std::vector<Scalar> waterReferenceFormationVolumeFactor_;
245  std::vector<Scalar> waterCompressibility_;
246  std::vector<Scalar> waterViscosity_;
247  std::vector<Scalar> waterViscosibility_;
248 };
249 
250 } // namespace Opm
251 
252 #endif
Implements a linearly interpolated scalar function that depends on one variable.
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityWaterPvt.hpp:45
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
Set the water reference formation volume factor [-].
Definition: ConstantCompressibilityWaterPvt.hpp:142
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the water "viscosibility" [1/ (Pa s)].
Definition: ConstantCompressibilityWaterPvt.hpp:148
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition: ConstantCompressibilityWaterPvt.hpp:198
void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
Set the compressibility of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:136
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar, Scalar rhoRefWater)
Set the water reference density [kg / m^3].
Definition: ConstantCompressibilityWaterPvt.hpp:112
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: ConstantCompressibilityWaterPvt.hpp:160
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of water given a set of parameters.
Definition: ConstantCompressibilityWaterPvt.hpp:167
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the water reference pressure [Pa].
Definition: ConstantCompressibilityWaterPvt.hpp:121
void initEnd()
Finish initializing the water phase PVT properties.
Definition: ConstantCompressibilityWaterPvt.hpp:154
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: ConstantCompressibilityWaterPvt.hpp:179
void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility=0.0)
Set the viscosity and "viscosibility" of the water phase.
Definition: ConstantCompressibilityWaterPvt.hpp:127
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:47