My Project
Co2GasPvt.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_CO2_GAS_PVT_HPP
28#define OPM_CO2_GAS_PVT_HPP
29
31
37
38#include <vector>
39
40namespace Opm {
41
42#if HAVE_ECL_INPUT
43class EclipseState;
44class Schedule;
45#endif
46
51template <class Scalar>
53{
54 using CO2 = ::Opm::CO2<Scalar>;
57 static constexpr bool extrapolate = true;
58
59public:
62
63 explicit Co2GasPvt() = default;
64
65 Co2GasPvt(const std::vector<Scalar>& salinity,
66 Scalar T_ref = 288.71, //(273.15 + 15.56)
67 Scalar P_ref = 101325)
68 : salinity_(salinity)
69 {
70 int num_regions = salinity_.size();
71 setNumRegions(num_regions);
72 Brine::salinity = salinity[0];
73 for (int i = 0; i < num_regions; ++i) {
74 gasReferenceDensity_[i] = CO2::gasDensity(T_ref, P_ref, extrapolate);
75 brineReferenceDensity_[i] = Brine::liquidDensity(T_ref, P_ref, extrapolate);
76 }
77 }
78#if HAVE_ECL_INPUT
82 void initFromState(const EclipseState& eclState, const Schedule&);
83#endif
84
85 void setNumRegions(size_t numRegions)
86 {
87 gasReferenceDensity_.resize(numRegions);
88 brineReferenceDensity_.resize(numRegions);
89 salinity_.resize(numRegions);
90 }
91
92
96 void setReferenceDensities(unsigned regionIdx,
97 Scalar rhoRefBrine,
98 Scalar rhoRefGas,
99 Scalar /*rhoRefWater*/)
100 {
101 gasReferenceDensity_[regionIdx] = rhoRefGas;
102 brineReferenceDensity_[regionIdx] = rhoRefBrine;;
103 }
104
112 { enableVaporization_ = yesno; }
113
117 void initEnd()
118 {
119
120 }
121
125 unsigned numRegions() const
126 { return gasReferenceDensity_.size(); }
127
131 template <class Evaluation>
132 Evaluation internalEnergy(unsigned regionIdx,
133 const Evaluation& temperature,
134 const Evaluation& pressure,
135 const Evaluation& rv,
136 const Evaluation& rvw) const
137 {
138 // assume ideal mixture
139 Evaluation result = 0;
140
141 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
142 // Either rv og rvw should be zero
143 assert(rv == 0.0 || rvw == 0.0);
144 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
145 result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
146 result += (1 - xBrine) * CO2::gasInternalEnergy(temperature, pressure, extrapolate);
147 return result;
148 }
149
153 template <class Evaluation>
154 Evaluation viscosity(unsigned regionIdx,
155 const Evaluation& temperature,
156 const Evaluation& pressure,
157 const Evaluation& /*Rv*/,
158 const Evaluation& /*Rvw*/) const
159 { return saturatedViscosity(regionIdx, temperature, pressure); }
160
164 template <class Evaluation>
165 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
166 const Evaluation& temperature,
167 const Evaluation& pressure) const
168 {
169 // Neglects impact of vaporized water on the visosity
170 return CO2::gasViscosity(temperature, pressure, extrapolate);
171 }
172
176 template <class Evaluation>
177 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
178 const Evaluation& temperature,
179 const Evaluation& pressure,
180 const Evaluation& rv,
181 const Evaluation& rvw) const
182 {
183
184 if (!enableVaporization_)
185 return CO2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
186
187 // assume ideal mixture
188 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
189 // Either rv og rvw should be zero
190 assert(rv == 0.0 || rvw == 0.0);
191 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
192 const auto& rhoCo2 = CO2::gasDensity(temperature, pressure, extrapolate);
193 const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
194 return 1.0 / ( ( xBrine/rhoH2O + (1.0 - xBrine)/rhoCo2) * gasReferenceDensity_[regionIdx]);
195 }
196
200 template <class Evaluation>
201 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
202 const Evaluation& temperature,
203 const Evaluation& pressure) const
204 {
205 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure);
206 return inverseFormationVolumeFactor(regionIdx,temperature,pressure, Evaluation(0.0), rvw);
207 }
208
215 template <class Evaluation>
216 Evaluation saturationPressure(unsigned /*regionIdx*/,
217 const Evaluation& /*temperature*/,
218 const Evaluation& /*Rvw*/) const
219 { return 0.0; /* not implemented */ }
220
224 template <class Evaluation>
225 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
226 const Evaluation& temperature,
227 const Evaluation& pressure) const
228 { return rvwSat_(regionIdx, temperature, pressure); }
229
233 template <class Evaluation = Scalar>
234 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
235 const Evaluation& temperature,
236 const Evaluation& pressure,
237 const Evaluation& /*saltConcentration*/) const
238 { return rvwSat_(regionIdx, temperature, pressure); }
239
243 template <class Evaluation>
244 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
245 const Evaluation& temperature,
246 const Evaluation& pressure,
247 const Evaluation& /*oilSaturation*/,
248 const Evaluation& /*maxOilSaturation*/) const
249 { return rvwSat_(regionIdx, temperature, pressure); }
250
254 template <class Evaluation>
255 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
256 const Evaluation& temperature,
257 const Evaluation& pressure) const
258 { return rvwSat_(regionIdx, temperature, pressure); }
259
260 template <class Evaluation>
261 Evaluation diffusionCoefficient(const Evaluation& temperature,
262 const Evaluation& pressure,
263 unsigned /*compIdx*/) const
264 {
265 return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure, extrapolate);
266 }
267
268 Scalar gasReferenceDensity(unsigned regionIdx) const
269 { return gasReferenceDensity_[regionIdx]; }
270
271 Scalar oilReferenceDensity(unsigned regionIdx) const
272 { return brineReferenceDensity_[regionIdx]; }
273
274 Scalar waterReferenceDensity(unsigned regionIdx) const
275 { return brineReferenceDensity_[regionIdx]; }
276
277 Scalar salinity(unsigned regionIdx) const
278 { return salinity_[regionIdx]; }
279
280private:
281
282 template <class LhsEval>
283 LhsEval rvwSat_(unsigned regionIdx,
284 const LhsEval& temperature,
285 const LhsEval& pressure) const
286 {
287 if (!enableVaporization_)
288 return 0.0;
289
290 // calulate the equilibrium composition for the given
291 // temperature and pressure.
292 LhsEval xgH2O;
293 LhsEval xlCO2;
295 pressure,
296 salinity_[regionIdx],
297 /*knownPhaseIdx=*/-1,
298 xlCO2,
299 xgH2O,
300 extrapolate);
301
302 // normalize the phase compositions
303 xgH2O = max(0.0, min(1.0, xgH2O));
304
305 return convertXgWToRvw(convertxgWToXgW(xgH2O), regionIdx);
306 }
307
312 template <class LhsEval>
313 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
314 {
315 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
316 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
317
318 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
319 }
320
325 template <class LhsEval>
326 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
327 {
328 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
329 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
330
331 const LhsEval& rho_wG = Rvw*rho_wRef;
332 return rho_wG/(rho_gRef + rho_wG);
333 }
337 template <class LhsEval>
338 LhsEval convertxgWToXgW(const LhsEval& xgW) const
339 {
340 Scalar M_CO2 = CO2::molarMass();
341 Scalar M_Brine = Brine::molarMass();
342
343 return xgW*M_Brine / (xgW*(M_Brine - M_CO2) + M_CO2);
344 }
345
346 std::vector<Scalar> brineReferenceDensity_;
347 std::vector<Scalar> gasReferenceDensity_;
348 std::vector<Scalar> salinity_;
349 bool enableVaporization_ = true;
350};
351
352} // namespace Opm
353
354#endif
A class for the brine fluid properties.
Binary coefficients for brine and CO2.
A class for the CO2 fluid properties.
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
Binary coefficients for brine and CO2.
Definition: Brine_CO2.hpp:42
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, Scalar salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O, bool extrapolate=false)
Returns the mol (!) fraction of CO2 in the liquid phase and the mol_ (!) fraction of H2O in the gas p...
Definition: Brine_CO2.hpp:97
static Evaluation gasDiffCoeff(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Binary diffusion coefficent [m^2/s] of water in the CO2 phase.
Definition: Brine_CO2.hpp:56
A class for the brine fluid properties.
Definition: Brine.hpp:46
static Scalar molarMass()
The molar mass in of the component.
Definition: Brine.hpp:80
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in .
Definition: Brine.hpp:262
static Scalar salinity
The mass fraction of salt assumed to be in the brine.
Definition: Brine.hpp:49
A class for the CO2 fluid properties.
Definition: CO2.hpp:53
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition: CO2.hpp:207
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:70
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition: CO2.hpp:179
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of CO2 at a given pressure and temperature [kg/m^3].
Definition: CO2.hpp:193
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition: Co2GasPvt.hpp:53
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &rv, const Evaluation &rvw) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: Co2GasPvt.hpp:132
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of water saturated gas at given pressure.
Definition: Co2GasPvt.hpp:201
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition: Co2GasPvt.hpp:244
Evaluation saturatedViscosity(unsigned, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of fluid phase at saturated conditions.
Definition: Co2GasPvt.hpp:165
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition: Co2GasPvt.hpp:225
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: Co2GasPvt.hpp:96
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition: Co2GasPvt.hpp:255
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition: Co2GasPvt.hpp:117
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the brine com...
Definition: Co2GasPvt.hpp:216
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of water phase.
Definition: Co2GasPvt.hpp:234
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition: Co2GasPvt.hpp:111
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: Co2GasPvt.hpp:125
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: Co2GasPvt.hpp:154
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &rv, const Evaluation &rvw) const
Returns the formation volume factor [-] of the fluid phase.
Definition: Co2GasPvt.hpp:177
Definition: EclipseState.hpp:55
Definition: Schedule.hpp:130
A simple version of pure water with density from Hu et al.
Definition: SimpleHuDuanH2O.hpp:63
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam at a given pressure and temperature.
Definition: SimpleHuDuanH2O.hpp:274
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition: SimpleHuDuanH2O.hpp:217
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30