opm-common
Loading...
Searching...
No Matches
ConstantCompressibilityOilPvt.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_OIL_PVT_HPP
28#define OPM_CONSTANT_COMPRESSIBILITY_OIL_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
59 void initFromState(const EclipseState& eclState, const Schedule&);
60#endif
61
62 void setNumRegions(std::size_t numRegions);
63
64 void setVapPars(const Scalar, const Scalar)
65 {
66 }
67
71 void setReferenceDensities(unsigned regionIdx,
72 Scalar rhoRefOil,
73 Scalar /*rhoRefGas*/,
74 Scalar /*rhoRefWater*/)
75 { oilReferenceDensity_[regionIdx] = rhoRefOil; }
76
80 void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility = 0.0)
81 {
82 oilViscosity_[regionIdx] = muo;
83 oilViscosibility_[regionIdx] = oilViscosibility;
84 }
85
89 void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
90 { oilCompressibility_[regionIdx] = oilCompressibility; }
91
95 void setReferencePressure(unsigned regionIdx, Scalar p)
96 { oilReferencePressure_[regionIdx] = p; }
97
101 void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
102 { oilReferenceFormationVolumeFactor_[regionIdx] = BoRef; }
103
107 void setViscosibility(unsigned regionIdx, Scalar muComp)
108 { oilViscosibility_[regionIdx] = muComp; }
109
113 void initEnd()
114 { }
115
119 unsigned numRegions() const
120 { return oilViscosity_.size(); }
121
125 template <class Evaluation>
126 Evaluation internalEnergy(unsigned,
127 const Evaluation&,
128 const Evaluation&,
129 const Evaluation&) const
130 {
131 throw std::runtime_error("Requested the enthalpy of oil but the thermal "
132 "option is not enabled");
133 }
134 Scalar hVap(unsigned) const
135 {
136 throw std::runtime_error("Requested the hvap of oil but the thermal "
137 "option is not enabled");
138 }
143 template <class Evaluation>
144 Evaluation viscosity(unsigned regionIdx,
145 const Evaluation& temperature,
146 const Evaluation& pressure,
147 const Evaluation& /*Rs*/) const
148 { return saturatedViscosity(regionIdx, temperature, pressure); }
149
153 template <class Evaluation>
154 Evaluation saturatedViscosity(unsigned regionIdx,
155 const Evaluation& temperature,
156 const Evaluation& pressure) const
157 {
158 Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
159 const Evaluation& bo = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
160
161 Scalar pRef = oilReferencePressure_[regionIdx];
162 const Evaluation& Y =
163 (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx])
164 * (pressure - pRef);
165 return BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
166 }
167
171 template <class Evaluation>
172 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
173 const Evaluation& temperature,
174 const Evaluation& pressure,
175 const Evaluation& /*Rs*/) const
176 { return saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure); }
177
181 template <class FluidState, class LhsEval = typename FluidState::Scalar>
182 std::pair<LhsEval, LhsEval>
183 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
184 {
185 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::oilPhaseIdx));
186 // Calculate bo(p).
187 Scalar pRef = oilReferencePressure_[regionIdx];
188 const LhsEval X = oilCompressibility_[regionIdx] * (p - pRef);
189 Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
190 const LhsEval bo = (1.0 + X * (1.0 + X / 2.0)) / BoRef;
191 // Calculate mu(p) as (Bo * mu) * bo. Recall bo = 1/Bo.
192 const LhsEval Y = (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx]) * (p - pRef);
193 Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
194 const LhsEval muo = BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
195 return { bo, muo };
196 }
197
204 template <class Evaluation>
205 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
206 const Evaluation& /*temperature*/,
207 const Evaluation& pressure) const
208 {
209 // cf. ECLiPSE 2011 technical description, p. 116
210 Scalar pRef = oilReferencePressure_[regionIdx];
211 const Evaluation& X = oilCompressibility_[regionIdx]*(pressure - pRef);
212
213 Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
214 return (1 + X*(1 + X/2))/BoRef;
215 }
216
220 template <class Evaluation>
221 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
222 const Evaluation& /*temperature*/,
223 const Evaluation& /*pressure*/) const
224 { return 0.0; /* this is dead oil! */ }
225
229 template <class Evaluation>
230 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
231 const Evaluation& /*temperature*/,
232 const Evaluation& /*pressure*/,
233 const Evaluation& /*oilSaturation*/,
234 const Evaluation& /*maxOilSaturation*/) const
235 { return 0.0; /* this is dead oil! */ }
236
244 template <class Evaluation>
245 Evaluation saturationPressure(unsigned /*regionIdx*/,
246 const Evaluation& /*temperature*/,
247 const Evaluation& /*Rs*/) const
248 { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
249
250 template <class Evaluation>
251 Evaluation diffusionCoefficient(const Evaluation& /*temperature*/,
252 const Evaluation& /*pressure*/,
253 unsigned /*compIdx*/) const
254 {
255 throw std::runtime_error("Not implemented: The PVT model does not "
256 "provide a diffusionCoefficient()");
257 }
258
259 Scalar oilReferenceDensity(unsigned regionIdx) const
260 { return oilReferenceDensity_[regionIdx]; }
261
262 const std::vector<Scalar>& oilReferenceFormationVolumeFactor() const
263 { return oilReferenceFormationVolumeFactor_; }
264
265 const std::vector<Scalar>& oilCompressibility() const
266 { return oilCompressibility_; }
267
268 const std::vector<Scalar>& oilViscosity() const
269 { return oilViscosity_; }
270
271 const std::vector<Scalar>& oilViscosibility() const
272 { return oilViscosibility_; }
273
274private:
275 std::vector<Scalar> oilReferenceDensity_{};
276 std::vector<Scalar> oilReferencePressure_{};
277 std::vector<Scalar> oilReferenceFormationVolumeFactor_{};
278 std::vector<Scalar> oilCompressibility_{};
279 std::vector<Scalar> oilViscosity_{};
280 std::vector<Scalar> oilViscosibility_{};
281};
282
283} // namespace Opm
284
285#endif
A number of commonly used algebraic functions for the localized OPM automatic differentiation (AD) fr...
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
Definition ConstantCompressibilityOilPvt.hpp:49
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of oil given a set of parameters.
Definition ConstantCompressibilityOilPvt.hpp:126
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the oil phase [Pa] depending on its mass fraction of the gas compo...
Definition ConstantCompressibilityOilPvt.hpp:245
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility=0.0)
Set the viscosity and "viscosibility" of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:80
void initEnd()
Finish initializing the oil phase PVT properties.
Definition ConstantCompressibilityOilPvt.hpp:113
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:230
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition ConstantCompressibilityOilPvt.hpp:183
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the oil reference pressure [Pa].
Definition ConstantCompressibilityOilPvt.hpp:95
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
Set the compressibility of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:89
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure and a phase composition.
Definition ConstantCompressibilityOilPvt.hpp:144
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition ConstantCompressibilityOilPvt.hpp:71
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the oil "viscosibility" [1/ (Pa s)].
Definition ConstantCompressibilityOilPvt.hpp:107
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition ConstantCompressibilityOilPvt.hpp:172
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas saturated oil.
Definition ConstantCompressibilityOilPvt.hpp:205
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
Set the oil reference formation volume factor [-].
Definition ConstantCompressibilityOilPvt.hpp:101
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:221
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure.
Definition ConstantCompressibilityOilPvt.hpp:154
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantCompressibilityOilPvt.hpp:119
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