opm-common
Loading...
Searching...
No Matches
ConstantRsDeadOilPvt.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_RS_DEAD_OIL_PVT_HPP
28#define OPM_CONSTANT_RS_DEAD_OIL_PVT_HPP
29
33
34#include <cstddef>
35#include <stdexcept>
36#include <vector>
37
38namespace Opm {
39
40class EclipseState;
41class Schedule;
42
50template <class Scalar>
52{
53public:
54 using TabulatedOneDFunction = Tabulated1DFunction<Scalar>;
55
60 void initFromState(const EclipseState& eclState, const Schedule& schedule);
61
62 void setNumRegions(std::size_t numRegions);
63
64 void setVapPars(const Scalar, const Scalar)
65 {
66 // No vaporization parameters for constant Rs
67 }
68
72 void setReferenceDensities(unsigned regionIdx,
73 Scalar rhoRefOil,
74 Scalar rhoRefGas,
75 Scalar /*rhoRefWater*/)
76 {
77 oilReferenceDensity_[regionIdx] = rhoRefOil;
78 gasReferenceDensity_[regionIdx] = rhoRefGas;
79 }
80
84 void setConstantRs(Scalar rsConst)
85 { constantRs_ = rsConst; }
86
90 void setBubblePointPressure(Scalar pbub)
91 { bubblePointPressure_ = pbub; }
92
96 void setInverseOilFormationVolumeFactor(unsigned regionIdx,
97 const TabulatedOneDFunction& invBo)
98 { inverseOilB_[regionIdx] = invBo; }
99
103 void setOilViscosity(unsigned regionIdx, const TabulatedOneDFunction& muo)
104 { oilMu_[regionIdx] = muo; }
105
109 void initEnd();
110
114 unsigned numRegions() const
115 { return inverseOilBMu_.size(); }
116
120 template <class Evaluation>
121 Evaluation internalEnergy(unsigned,
122 const Evaluation&,
123 const Evaluation&,
124 const Evaluation&) const
125 {
126 throw std::runtime_error("Requested the enthalpy of oil but the thermal "
127 "option is not enabled");
128 }
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 }
135
140 template <class Evaluation>
141 Evaluation viscosity(unsigned regionIdx,
142 const Evaluation& temperature,
143 const Evaluation& pressure,
144 const Evaluation& /*Rs*/) const
145 { return saturatedViscosity(regionIdx, temperature, pressure); }
146
151 template <class Evaluation>
152 Evaluation saturatedViscosity(unsigned regionIdx,
153 const Evaluation& /*temperature*/,
154 const Evaluation& pressure) const
155 {
156 const Evaluation& invBo = inverseOilB_[regionIdx].eval(pressure, /*extrapolate=*/true);
157 const Evaluation& invMuoBo = inverseOilBMu_[regionIdx].eval(pressure, /*extrapolate=*/true);
158 return invBo / invMuoBo;
159 }
160
165 template <class Evaluation>
166 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
167 const Evaluation& /*temperature*/,
168 const Evaluation& pressure,
169 const Evaluation& /*Rs*/) const
170 { return inverseOilB_[regionIdx].eval(pressure, /*extrapolate=*/true); }
171
175 template <class FluidState, class LhsEval = typename FluidState::ValueType>
176 std::pair<LhsEval, LhsEval>
177 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
178 {
179 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::oilPhaseIdx));
180 const auto segIdx = this->inverseOilB_[regionIdx].findSegmentIndex(p, /*extrapolate=*/ true);
181 const auto& invBo = this->inverseOilB_[regionIdx].eval(p, SegmentIndex{segIdx});
182 const auto& invMuoBo = this->inverseOilBMu_[regionIdx].eval(p, SegmentIndex{segIdx});
183 return { invBo, invBo / invMuoBo };
184 }
185
190 template <class Evaluation>
191 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
192 const Evaluation& /*temperature*/,
193 const Evaluation& pressure) const
194 { return inverseOilB_[regionIdx].eval(pressure, /*extrapolate=*/true); }
195
201 template <class Evaluation>
202 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
203 const Evaluation& /*temperature*/,
204 const Evaluation& pressure) const
205 {
206 // Enforce bubble point constraint from RSCONST manual:
207 // "The run will terminate if the pressure in any grid block falls below this value."
208 if (pressure < bubblePointPressure_) {
209 throw NumericalProblem(
210 "Pressure is below RSCONST bubble point pressure of " +
211 std::to_string(bubblePointPressure_)
212 );
213 }
214 return constantRs_;
215 }
216
222 template <class Evaluation>
223 Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
224 const Evaluation& /*temperature*/,
225 const Evaluation& pressure,
226 const Evaluation& /*oilSaturation*/,
227 const Evaluation& /*maxOilSaturation*/) const
228 {
229 // Enforce bubble point constraint from RSCONST manual:
230 // "The run will terminate if the pressure in any grid block falls below this value."
231 if (pressure < bubblePointPressure_) {
232 throw NumericalProblem(
233 "Pressure is below RSCONST bubble point pressure of " +
234 std::to_string(bubblePointPressure_)
235 );
236 }
237 return constantRs_;
238 }
239
244 template <class Evaluation>
245 Evaluation saturationPressure(unsigned /*regionIdx*/,
246 const Evaluation& /*temperature*/,
247 const Evaluation& /*Rs*/) const
248 { return bubblePointPressure_; }
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 provide "
256 "a diffusionCoefficient()");
257 }
258
259 Scalar oilReferenceDensity(unsigned regionIdx) const
260 { return oilReferenceDensity_[regionIdx]; }
261
262 Scalar gasReferenceDensity(unsigned regionIdx) const
263 { return gasReferenceDensity_[regionIdx]; }
264
265 Scalar constantRs() const
266 { return constantRs_; }
267
268 Scalar bubblePointPressure() const
269 { return bubblePointPressure_; }
270
271 const std::vector<TabulatedOneDFunction>& inverseOilB() const
272 { return inverseOilB_; }
273
274 const std::vector<TabulatedOneDFunction>& oilMu() const
275 { return oilMu_; }
276
277 const std::vector<TabulatedOneDFunction>& inverseOilBMu() const
278 { return inverseOilBMu_; }
279
280private:
281
282 std::vector<Scalar> oilReferenceDensity_{};
283 std::vector<Scalar> gasReferenceDensity_{};
284 std::vector<TabulatedOneDFunction> inverseOilB_{};
285 std::vector<TabulatedOneDFunction> oilMu_{};
286 std::vector<TabulatedOneDFunction> inverseOilBMu_{};
287
288 // Global constants from RSCONST (same for all regions)
289 Scalar constantRs_ = 0.0; // Constant Rs value from RSCONST
290 Scalar bubblePointPressure_ = 0.0; // Bubble point pressure from RSCONST
291};
292
293} // namespace Opm
294
295#endif
Provides the OPM specific exception classes.
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Implements a linearly interpolated scalar function that depends on one variable.
This class represents the Pressure-Volume-Temperature relations of dead oil with constant dissolved g...
Definition ConstantRsDeadOilPvt.hpp:52
void setInverseOilFormationVolumeFactor(unsigned regionIdx, const TabulatedOneDFunction &invBo)
Initialize the function for the oil formation volume factor.
Definition ConstantRsDeadOilPvt.hpp:96
void initFromState(const EclipseState &eclState, const Schedule &schedule)
Initialize the oil parameters via the data specified by the PVDO ECL keyword with additional constant...
Definition ConstantRsDeadOilPvt.cpp:41
void setOilViscosity(unsigned regionIdx, const TabulatedOneDFunction &muo)
Initialize the viscosity of the oil phase.
Definition ConstantRsDeadOilPvt.hpp:103
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the bubble point pressure [Pa] from RSCONST.
Definition ConstantRsDeadOilPvt.hpp:245
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the constant gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantRsDeadOilPvt.hpp:223
void setConstantRs(Scalar rsConst)
Set the constant Rs value (global for all regions).
Definition ConstantRsDeadOilPvt.hpp:84
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition ConstantRsDeadOilPvt.hpp:72
void initEnd()
Finish initializing the oil phase PVT properties.
Definition ConstantRsDeadOilPvt.cpp:113
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition ConstantRsDeadOilPvt.hpp:177
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &pressure) const
Returns the constant gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantRsDeadOilPvt.hpp:202
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil given a pressure.
Definition ConstantRsDeadOilPvt.hpp:152
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil.
Definition ConstantRsDeadOilPvt.hpp:191
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of oil given a set of parameters.
Definition ConstantRsDeadOilPvt.hpp:121
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition ConstantRsDeadOilPvt.hpp:141
void setBubblePointPressure(Scalar pbub)
Set the bubble point pressure (global for all regions).
Definition ConstantRsDeadOilPvt.hpp:90
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition ConstantRsDeadOilPvt.hpp:166
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantRsDeadOilPvt.hpp:114
Definition EclipseState.hpp:66
Definition Exceptions.hpp:40
Definition Schedule.hpp:101
Implements a linearly interpolated scalar function that depends on one variable.
Definition Tabulated1DFunction.hpp:51
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Tabulated1DFunction.hpp:41