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
38class EclipseState;
39class Schedule;
40
45template <class Scalar>
47{
48public:
56 void initFromState(const EclipseState& eclState, const Schedule&);
57
58 void setNumRegions(std::size_t numRegions);
59
60 void setVapPars(const Scalar, const Scalar)
61 {
62 }
63
67 void setReferenceDensities(unsigned regionIdx,
68 Scalar rhoRefOil,
69 Scalar /*rhoRefGas*/,
70 Scalar /*rhoRefWater*/)
71 { oilReferenceDensity_[regionIdx] = rhoRefOil; }
72
76 void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility = 0.0)
77 {
78 oilViscosity_[regionIdx] = muo;
79 oilViscosibility_[regionIdx] = oilViscosibility;
80 }
81
85 void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
86 { oilCompressibility_[regionIdx] = oilCompressibility; }
87
91 void setReferencePressure(unsigned regionIdx, Scalar p)
92 { oilReferencePressure_[regionIdx] = p; }
93
97 void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
98 { oilReferenceFormationVolumeFactor_[regionIdx] = BoRef; }
99
103 void setViscosibility(unsigned regionIdx, Scalar muComp)
104 { oilViscosibility_[regionIdx] = muComp; }
105
109 void initEnd()
110 { }
111
115 unsigned numRegions() const
116 { return oilViscosity_.size(); }
117
121 template <class Evaluation>
122 Evaluation internalEnergy(unsigned,
123 const Evaluation&,
124 const Evaluation&,
125 const Evaluation&) const
126 {
127 throw std::runtime_error("Requested the enthalpy of oil but the thermal "
128 "option is not enabled");
129 }
130 Scalar hVap(unsigned) const
131 {
132 throw std::runtime_error("Requested the hvap of oil but the thermal "
133 "option is not enabled");
134 }
139 template <class Evaluation>
140 Evaluation viscosity(unsigned regionIdx,
141 const Evaluation& temperature,
142 const Evaluation& pressure,
143 const Evaluation& /*Rs*/) const
144 { return saturatedViscosity(regionIdx, temperature, pressure); }
145
149 template <class Evaluation>
150 Evaluation saturatedViscosity(unsigned regionIdx,
151 const Evaluation& temperature,
152 const Evaluation& pressure) const
153 {
154 Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
155 const Evaluation& bo = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
156
157 Scalar pRef = oilReferencePressure_[regionIdx];
158 const Evaluation& Y =
159 (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx])
160 * (pressure - pRef);
161 return BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
162 }
163
167 template <class Evaluation>
168 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
169 const Evaluation& temperature,
170 const Evaluation& pressure,
171 const Evaluation& /*Rs*/) const
172 { return saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure); }
173
177 template <class FluidState, class LhsEval = typename FluidState::ValueType>
178 std::pair<LhsEval, LhsEval>
179 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
180 {
181 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::oilPhaseIdx));
182 // Calculate bo(p).
183 Scalar pRef = oilReferencePressure_[regionIdx];
184 const LhsEval X = oilCompressibility_[regionIdx] * (p - pRef);
185 Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
186 const LhsEval bo = (1.0 + X * (1.0 + X / 2.0)) / BoRef;
187 // Calculate mu(p) as (Bo * mu) * bo. Recall bo = 1/Bo.
188 const LhsEval Y = (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx]) * (p - pRef);
189 Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
190 const LhsEval muo = BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
191 return { bo, muo };
192 }
193
200 template <class Evaluation>
201 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
202 const Evaluation& /*temperature*/,
203 const Evaluation& pressure) const
204 {
205 // cf. ECLiPSE 2011 technical description, p. 116
206 Scalar pRef = oilReferencePressure_[regionIdx];
207 const Evaluation& X = oilCompressibility_[regionIdx]*(pressure - pRef);
208
209 Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
210 return (1 + X*(1 + X/2))/BoRef;
211 }
212
216 template <class Evaluation>
217 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
218 const Evaluation& /*temperature*/,
219 const Evaluation& /*pressure*/) const
220 { return 0.0; /* this is dead oil! */ }
221
225 template <class Evaluation>
226 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
227 const Evaluation& /*temperature*/,
228 const Evaluation& /*pressure*/,
229 const Evaluation& /*oilSaturation*/,
230 const Evaluation& /*maxOilSaturation*/) const
231 { return 0.0; /* this is dead oil! */ }
232
240 template <class Evaluation>
241 Evaluation saturationPressure(unsigned /*regionIdx*/,
242 const Evaluation& /*temperature*/,
243 const Evaluation& /*Rs*/) const
244 { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
245
246 template <class Evaluation>
247 Evaluation diffusionCoefficient(const Evaluation& /*temperature*/,
248 const Evaluation& /*pressure*/,
249 unsigned /*compIdx*/) const
250 {
251 throw std::runtime_error("Not implemented: The PVT model does not "
252 "provide a diffusionCoefficient()");
253 }
254
255 Scalar oilReferenceDensity(unsigned regionIdx) const
256 { return oilReferenceDensity_[regionIdx]; }
257
258 const std::vector<Scalar>& oilReferenceFormationVolumeFactor() const
259 { return oilReferenceFormationVolumeFactor_; }
260
261 const std::vector<Scalar>& oilCompressibility() const
262 { return oilCompressibility_; }
263
264 const std::vector<Scalar>& oilViscosity() const
265 { return oilViscosity_; }
266
267 const std::vector<Scalar>& oilViscosibility() const
268 { return oilViscosibility_; }
269
270private:
271 std::vector<Scalar> oilReferenceDensity_{};
272 std::vector<Scalar> oilReferencePressure_{};
273 std::vector<Scalar> oilReferenceFormationVolumeFactor_{};
274 std::vector<Scalar> oilCompressibility_{};
275 std::vector<Scalar> oilViscosity_{};
276 std::vector<Scalar> oilViscosibility_{};
277};
278
279} // namespace Opm
280
281#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:47
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:122
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:241
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility=0.0)
Set the viscosity and "viscosibility" of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:76
void initEnd()
Finish initializing the oil phase PVT properties.
Definition ConstantCompressibilityOilPvt.hpp:109
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:226
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:179
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the oil reference pressure [Pa].
Definition ConstantCompressibilityOilPvt.hpp:91
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
Set the compressibility of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:85
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:140
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition ConstantCompressibilityOilPvt.hpp:67
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the oil "viscosibility" [1/ (Pa s)].
Definition ConstantCompressibilityOilPvt.hpp:103
void initFromState(const EclipseState &eclState, const Schedule &)
Sets the pressure-dependent oil viscosity and density using the Eclipse PVCDO keyword.
Definition ConstantCompressibilityOilPvt.cpp:37
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:168
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas saturated oil.
Definition ConstantCompressibilityOilPvt.hpp:201
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
Set the oil reference formation volume factor [-].
Definition ConstantCompressibilityOilPvt.hpp:97
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:217
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:150
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantCompressibilityOilPvt.hpp:115
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