opm-common
Loading...
Searching...
No Matches
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#include <cstddef>
33#include <stdexcept>
34#include <vector>
35
36namespace Opm {
37
38class EclipseState;
39class Schedule;
40
45template <class Scalar>
47{
48public:
53 void initFromState(const EclipseState& eclState, const Schedule&);
54
55 void setNumRegions(std::size_t numRegions);
56
57 void setVapPars(const Scalar, const Scalar)
58 {
59 }
60
64 void setReferenceDensities(unsigned regionIdx,
65 Scalar /*rhoRefOil*/,
66 Scalar /*rhoRefGas*/,
67 Scalar rhoRefWater)
68 { waterReferenceDensity_[regionIdx] = rhoRefWater; }
69
73 void setReferencePressure(unsigned regionIdx, Scalar p)
74 { waterReferencePressure_[regionIdx] = p; }
75
79 void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility = 0.0)
80 {
81 waterViscosity_[regionIdx] = muw;
82 waterViscosibility_[regionIdx] = waterViscosibility;
83 }
84
88 void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
89 { waterCompressibility_[regionIdx] = waterCompressibility; }
90
94 void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
95 { waterReferenceFormationVolumeFactor_[regionIdx] = BwRef; }
96
100 void setViscosibility(unsigned regionIdx, Scalar muComp)
101 { waterViscosibility_[regionIdx] = muComp; }
102
106 void initEnd()
107 { }
108
112 unsigned numRegions() const
113 { return waterReferenceDensity_.size(); }
114
118 template <class Evaluation>
119 Evaluation internalEnergy(unsigned,
120 const Evaluation&,
121 const Evaluation&,
122 const Evaluation&,
123 const Evaluation&) const
124 {
125 throw std::runtime_error("Requested the enthalpy of water but the thermal "
126 "option is not enabled");
127 }
128
129 Scalar hVap(unsigned) const
130 {
131 throw std::runtime_error("Requested the hvap of oil but the thermal "
132 "option is not enabled");
133 }
134
138 template <class Evaluation>
139 Evaluation saturatedViscosity(unsigned regionIdx,
140 const Evaluation& temperature,
141 const Evaluation& pressure,
142 const Evaluation& saltconcentration) const
143 {
144 Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
145 const Evaluation& bw = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration);
146
147 Scalar pRef = waterReferencePressure_[regionIdx];
148 const Evaluation& Y =
149 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
150 * (pressure - pRef);
151 return BwMuwRef * bw / (1 + Y * (1 + Y / 2));
152 }
153
157 template <class Evaluation>
158 Evaluation viscosity(unsigned regionIdx,
159 const Evaluation& temperature,
160 const Evaluation& pressure,
161 const Evaluation& Rsw,
162 const Evaluation& saltconcentration) const
163 {
164 Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
165 const Evaluation& bw = inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration);
166
167 Scalar pRef = waterReferencePressure_[regionIdx];
168 const Evaluation& Y =
169 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
170 * (pressure - pRef);
171 return BwMuwRef * bw / (1 + Y * (1 + Y / 2));
172 }
173
177 template <class Evaluation>
178 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
179 const Evaluation& temperature,
180 const Evaluation& pressure,
181 const Evaluation& saltconcentration) const
182 {
183 Evaluation Rsw = 0.0;
184 return inverseFormationVolumeFactor(regionIdx, temperature, pressure,
185 Rsw, saltconcentration);
186 }
187
191 template <class Evaluation>
192 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
193 const Evaluation& /*temperature*/,
194 const Evaluation& pressure,
195 const Evaluation& /*Rsw*/,
196 const Evaluation& /*saltconcentration*/) const
197 {
198 Scalar pRef = waterReferencePressure_[regionIdx];
199 const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
200
201 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
202
203 // TODO (?): consider the salt concentration of the brine
204 return (1.0 + X * (1.0 + X / 2.0)) / BwRef;
205 }
206
210 template <class FluidState, class LhsEval = typename FluidState::ValueType>
211 std::pair<LhsEval, LhsEval>
212 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
213 {
214 const auto& pressure = decay<LhsEval>(fluidState.pressure(FluidState::waterPhaseIdx));
215 Scalar pRef = waterReferencePressure_[regionIdx];
216 const LhsEval& X = waterCompressibility_[regionIdx]*(pressure - pRef);
217 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
218 LhsEval bw = (1.0 + X * (1.0 + X / 2.0)) / BwRef;
219 Scalar BwMuwRef = waterViscosity_[regionIdx]*BwRef;
220 const LhsEval& Y =
221 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
222 * (pressure - pRef);
223 LhsEval muw = BwMuwRef * bw / (1 + Y * (1 + Y / 2));
224
225 return { bw, muw };
226 }
227
228 template <class Evaluation>
229 void inverseBAndMu(Evaluation& bw, Evaluation& muW, unsigned regionIdx,
230 const Evaluation& /*temperature*/,
231 const Evaluation& pressure,
232 const Evaluation& /*Rsw*/,
233 const Evaluation& /*saltconcentration*/) const
234 {
235 inverseBAndMu(bw, muW, regionIdx,pressure);
236 }
237
238 template <class Evaluation>
239 void inverseBAndMu(Evaluation& bw, Evaluation& muW, unsigned regionIdx,
240 const Evaluation& pressure) const
241 {
242 Scalar pRef = waterReferencePressure_[regionIdx];
243 const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
244
245 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
246
247 // TODO (?): consider the salt concentration of the brine
248 bw = (1.0 + X * (1.0 + X / 2.0)) / BwRef;
249
250 Scalar BwMuwRef = waterViscosity_[regionIdx]*BwRef;
251
252 const Evaluation& Y =
253 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
254 * (pressure - pRef);
255 muW = BwMuwRef * bw / (1 + Y * (1 + Y / 2));
256 }
257
265 template <class Evaluation>
266 Evaluation saturationPressure(unsigned /*regionIdx*/,
267 const Evaluation& /*temperature*/,
268 const Evaluation& /*Rs*/,
269 const Evaluation& /*saltconcentration*/) const
270 { return 0.0; /* this is dead water, so there isn't any meaningful saturation pressure! */ }
271
272 template <class Evaluation>
273 Evaluation diffusionCoefficient(const Evaluation& /*temperature*/,
274 const Evaluation& /*pressure*/,
275 unsigned /*compIdx*/,
276 unsigned /*regionIdx*/ = 0) const
277 {
278 throw std::runtime_error("Not implemented: The PVT model does not provide "
279 "a diffusionCoefficient()");
280 }
281
285 template <class Evaluation>
286 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
287 const Evaluation& /*temperature*/,
288 const Evaluation& /*pressure*/,
289 const Evaluation& /*saltconcentration*/) const
290 { return 0.0; /* this is dead water! */ }
291
292 Scalar waterReferenceDensity(unsigned regionIdx) const
293 { return waterReferenceDensity_[regionIdx]; }
294
295 const std::vector<Scalar>& waterReferencePressure() const
296 { return waterReferencePressure_; }
297
298 const std::vector<Scalar>& waterReferenceFormationVolumeFactor() const
299 { return waterReferenceFormationVolumeFactor_; }
300
301 const std::vector<Scalar>& waterCompressibility() const
302 { return waterCompressibility_; }
303
304 const std::vector<Scalar>& waterViscosity() const
305 { return waterViscosity_; }
306
307 const std::vector<Scalar>& waterViscosibility() const
308 { return waterViscosibility_; }
309
310private:
311 std::vector<Scalar> waterReferenceDensity_{};
312 std::vector<Scalar> waterReferencePressure_{};
313 std::vector<Scalar> waterReferenceFormationVolumeFactor_{};
314 std::vector<Scalar> waterCompressibility_{};
315 std::vector<Scalar> waterViscosity_{};
316 std::vector<Scalar> waterViscosibility_{};
317};
318
319} // namespace Opm
320
321#endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition ConstantCompressibilityWaterPvt.hpp:47
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
Set the water reference formation volume factor [-].
Definition ConstantCompressibilityWaterPvt.hpp:94
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the water "viscosibility" [1/ (Pa s)].
Definition ConstantCompressibilityWaterPvt.hpp:100
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition ConstantCompressibilityWaterPvt.hpp:212
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the water phase [Pa] depending on its mass fraction of the gas com...
Definition ConstantCompressibilityWaterPvt.hpp:266
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition ConstantCompressibilityWaterPvt.hpp:192
void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
Set the compressibility of the water phase.
Definition ConstantCompressibilityWaterPvt.hpp:88
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar, Scalar rhoRefWater)
Set the water reference density [kg / m^3].
Definition ConstantCompressibilityWaterPvt.hpp:64
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantCompressibilityWaterPvt.hpp:112
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the water reference pressure [Pa].
Definition ConstantCompressibilityWaterPvt.hpp:73
void initEnd()
Finish initializing the water phase PVT properties.
Definition ConstantCompressibilityWaterPvt.hpp:106
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition ConstantCompressibilityWaterPvt.hpp:158
void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility=0.0)
Set the viscosity and "viscosibility" of the water phase.
Definition ConstantCompressibilityWaterPvt.hpp:79
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition ConstantCompressibilityWaterPvt.hpp:178
Evaluation saturatedViscosity(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:139
void initFromState(const EclipseState &eclState, const Schedule &)
Sets the pressure-dependent water viscosity and density using a table stemming from the Eclipse PVTW ...
Definition ConstantCompressibilityWaterPvt.cpp:37
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of water given a set of parameters.
Definition ConstantCompressibilityWaterPvt.hpp:119
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the water phase.
Definition ConstantCompressibilityWaterPvt.hpp:286
Definition EclipseState.hpp:66
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30