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