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
38#if HAVE_ECL_INPUT
39class EclipseState;
40class Schedule;
41#endif
42
47template <class Scalar>
49{
50public:
51#if HAVE_ECL_INPUT
56 void initFromState(const EclipseState& eclState, const Schedule&);
57#endif
58
59 void setNumRegions(std::size_t numRegions);
60
61 void setVapPars(const Scalar, const Scalar)
62 {
63 }
64
68 void setReferenceDensities(unsigned regionIdx,
69 Scalar /*rhoRefOil*/,
70 Scalar /*rhoRefGas*/,
71 Scalar rhoRefWater)
72 { waterReferenceDensity_[regionIdx] = rhoRefWater; }
73
77 void setReferencePressure(unsigned regionIdx, Scalar p)
78 { waterReferencePressure_[regionIdx] = p; }
79
83 void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility = 0.0)
84 {
85 waterViscosity_[regionIdx] = muw;
86 waterViscosibility_[regionIdx] = waterViscosibility;
87 }
88
92 void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
93 { waterCompressibility_[regionIdx] = waterCompressibility; }
94
98 void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
99 { waterReferenceFormationVolumeFactor_[regionIdx] = BwRef; }
100
104 void setViscosibility(unsigned regionIdx, Scalar muComp)
105 { waterViscosibility_[regionIdx] = muComp; }
106
110 void initEnd()
111 { }
112
116 unsigned numRegions() const
117 { return waterReferenceDensity_.size(); }
118
122 template <class Evaluation>
123 Evaluation internalEnergy(unsigned,
124 const Evaluation&,
125 const Evaluation&,
126 const Evaluation&,
127 const Evaluation&) const
128 {
129 throw std::runtime_error("Requested the enthalpy of water but the thermal "
130 "option is not enabled");
131 }
132
133 Scalar hVap(unsigned) const
134 {
135 throw std::runtime_error("Requested the hvap of oil but the thermal "
136 "option is not enabled");
137 }
138
142 template <class Evaluation>
143 Evaluation saturatedViscosity(unsigned regionIdx,
144 const Evaluation& temperature,
145 const Evaluation& pressure,
146 const Evaluation& saltconcentration) const
147 {
148 Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
149 const Evaluation& bw = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration);
150
151 Scalar pRef = waterReferencePressure_[regionIdx];
152 const Evaluation& Y =
153 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
154 * (pressure - pRef);
155 return BwMuwRef * bw / (1 + Y * (1 + Y / 2));
156 }
157
161 template <class Evaluation>
162 Evaluation viscosity(unsigned regionIdx,
163 const Evaluation& temperature,
164 const Evaluation& pressure,
165 const Evaluation& Rsw,
166 const Evaluation& saltconcentration) const
167 {
168 Scalar BwMuwRef = waterViscosity_[regionIdx]*waterReferenceFormationVolumeFactor_[regionIdx];
169 const Evaluation& bw = inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration);
170
171 Scalar pRef = waterReferencePressure_[regionIdx];
172 const Evaluation& Y =
173 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
174 * (pressure - pRef);
175 return BwMuwRef * bw / (1 + Y * (1 + Y / 2));
176 }
177
181 template <class Evaluation>
182 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
183 const Evaluation& temperature,
184 const Evaluation& pressure,
185 const Evaluation& saltconcentration) const
186 {
187 Evaluation Rsw = 0.0;
188 return inverseFormationVolumeFactor(regionIdx, temperature, pressure,
189 Rsw, saltconcentration);
190 }
191
195 template <class Evaluation>
196 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
197 const Evaluation& /*temperature*/,
198 const Evaluation& pressure,
199 const Evaluation& /*Rsw*/,
200 const Evaluation& /*saltconcentration*/) const
201 {
202 Scalar pRef = waterReferencePressure_[regionIdx];
203 const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
204
205 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
206
207 // TODO (?): consider the salt concentration of the brine
208 return (1.0 + X * (1.0 + X / 2.0)) / BwRef;
209 }
210
214 template <class FluidState, class LhsEval = typename FluidState::Scalar>
215 std::pair<LhsEval, LhsEval>
216 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
217 {
218 const auto& pressure = decay<LhsEval>(fluidState.pressure(FluidState::waterPhaseIdx));
219 Scalar pRef = waterReferencePressure_[regionIdx];
220 const LhsEval& X = waterCompressibility_[regionIdx]*(pressure - pRef);
221 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
222 LhsEval bw = (1.0 + X * (1.0 + X / 2.0)) / BwRef;
223 Scalar BwMuwRef = waterViscosity_[regionIdx]*BwRef;
224 const LhsEval& Y =
225 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
226 * (pressure - pRef);
227 LhsEval muw = BwMuwRef * bw / (1 + Y * (1 + Y / 2));
228
229 return { bw, muw };
230 }
231
232 template <class Evaluation>
233 void inverseBAndMu(Evaluation& bw, Evaluation& muW, unsigned regionIdx,
234 const Evaluation& /*temperature*/,
235 const Evaluation& pressure,
236 const Evaluation& /*Rsw*/,
237 const Evaluation& /*saltconcentration*/) const
238 {
239 inverseBAndMu(bw, muW, regionIdx,pressure);
240 }
241
242 template <class Evaluation>
243 void inverseBAndMu(Evaluation& bw, Evaluation& muW, unsigned regionIdx,
244 const Evaluation& pressure) const
245 {
246 Scalar pRef = waterReferencePressure_[regionIdx];
247 const Evaluation& X = waterCompressibility_[regionIdx]*(pressure - pRef);
248
249 Scalar BwRef = waterReferenceFormationVolumeFactor_[regionIdx];
250
251 // TODO (?): consider the salt concentration of the brine
252 bw = (1.0 + X * (1.0 + X / 2.0)) / BwRef;
253
254 Scalar BwMuwRef = waterViscosity_[regionIdx]*BwRef;
255
256 const Evaluation& Y =
257 (waterCompressibility_[regionIdx] - waterViscosibility_[regionIdx])
258 * (pressure - pRef);
259 muW = BwMuwRef * bw / (1 + Y * (1 + Y / 2));
260 }
261
269 template <class Evaluation>
270 Evaluation saturationPressure(unsigned /*regionIdx*/,
271 const Evaluation& /*temperature*/,
272 const Evaluation& /*Rs*/,
273 const Evaluation& /*saltconcentration*/) const
274 { return 0.0; /* this is dead water, so there isn't any meaningful saturation pressure! */ }
275
276 template <class Evaluation>
277 Evaluation diffusionCoefficient(const Evaluation& /*temperature*/,
278 const Evaluation& /*pressure*/,
279 unsigned /*compIdx*/) const
280 {
281 throw std::runtime_error("Not implemented: The PVT model does not provide "
282 "a diffusionCoefficient()");
283 }
284
288 template <class Evaluation>
289 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
290 const Evaluation& /*temperature*/,
291 const Evaluation& /*pressure*/,
292 const Evaluation& /*saltconcentration*/) const
293 { return 0.0; /* this is dead water! */ }
294
295 Scalar waterReferenceDensity(unsigned regionIdx) const
296 { return waterReferenceDensity_[regionIdx]; }
297
298 const std::vector<Scalar>& waterReferencePressure() const
299 { return waterReferencePressure_; }
300
301 const std::vector<Scalar>& waterReferenceFormationVolumeFactor() const
302 { return waterReferenceFormationVolumeFactor_; }
303
304 const std::vector<Scalar>& waterCompressibility() const
305 { return waterCompressibility_; }
306
307 const std::vector<Scalar>& waterViscosity() const
308 { return waterViscosity_; }
309
310 const std::vector<Scalar>& waterViscosibility() const
311 { return waterViscosibility_; }
312
313private:
314 std::vector<Scalar> waterReferenceDensity_{};
315 std::vector<Scalar> waterReferencePressure_{};
316 std::vector<Scalar> waterReferenceFormationVolumeFactor_{};
317 std::vector<Scalar> waterCompressibility_{};
318 std::vector<Scalar> waterViscosity_{};
319 std::vector<Scalar> waterViscosibility_{};
320};
321
322} // namespace Opm
323
324#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:49
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BwRef)
Set the water reference formation volume factor [-].
Definition ConstantCompressibilityWaterPvt.hpp:98
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the water "viscosibility" [1/ (Pa s)].
Definition ConstantCompressibilityWaterPvt.hpp:104
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:216
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:270
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:196
void setCompressibility(unsigned regionIdx, Scalar waterCompressibility)
Set the compressibility of the water phase.
Definition ConstantCompressibilityWaterPvt.hpp:92
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar, Scalar rhoRefWater)
Set the water reference density [kg / m^3].
Definition ConstantCompressibilityWaterPvt.hpp:68
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantCompressibilityWaterPvt.hpp:116
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the water reference pressure [Pa].
Definition ConstantCompressibilityWaterPvt.hpp:77
void initEnd()
Finish initializing the water phase PVT properties.
Definition ConstantCompressibilityWaterPvt.hpp:110
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:162
void setViscosity(unsigned regionIdx, Scalar muw, Scalar waterViscosibility=0.0)
Set the viscosity and "viscosibility" of the water phase.
Definition ConstantCompressibilityWaterPvt.hpp:83
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:182
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:143
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:123
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:289
Definition EclipseState.hpp:62
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30