My Project
Loading...
Searching...
No Matches
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#include <opm/common/ErrorMacros.hpp>
32
38
39#include <vector>
40
41namespace Opm {
42
43#if HAVE_ECL_INPUT
44class EclipseState;
45class Schedule;
46#endif
47
52template <class Scalar>
54{
55 using CO2 = ::Opm::CO2<Scalar>;
58 static constexpr bool extrapolate = true;
59
60public:
63
64 explicit Co2GasPvt() = default;
65
66 Co2GasPvt(const std::vector<Scalar>& salinity,
67 Scalar T_ref = 288.71, //(273.15 + 15.56)
68 Scalar P_ref = 101325)
69 : salinity_(salinity)
70 {
71 // Throw an error if reference state is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
72 if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
73 OPM_THROW(std::runtime_error,
74 "BrineCo2Pvt class can only be used with default reference state (T, P) = (288.71 K, 1.01325e5 Pa)!");
75 }
76 int num_regions = salinity_.size();
77 setNumRegions(num_regions);
78 for (int i = 0; i < num_regions; ++i) {
79 gasReferenceDensity_[i] = CO2::gasDensity(T_ref, P_ref, extrapolate);
80 brineReferenceDensity_[i] = Brine::liquidDensity(T_ref, P_ref, salinity_[i], extrapolate);
81 }
82 }
83#if HAVE_ECL_INPUT
87 void initFromState(const EclipseState& eclState, const Schedule&);
88#endif
89
90 void setNumRegions(size_t numRegions)
91 {
92 gasReferenceDensity_.resize(numRegions);
93 brineReferenceDensity_.resize(numRegions);
94 salinity_.resize(numRegions);
95 }
96
97 void setVapPars(const Scalar, const Scalar)
98 {
99 }
100
104 void setReferenceDensities(unsigned regionIdx,
105 Scalar rhoRefBrine,
106 Scalar rhoRefGas,
107 Scalar /*rhoRefWater*/)
108 {
109 gasReferenceDensity_[regionIdx] = rhoRefGas;
110 brineReferenceDensity_[regionIdx] = rhoRefBrine;;
111 }
112
120 { enableVaporization_ = yesno; }
121
125 void initEnd()
126 {
127
128 }
129
133 unsigned numRegions() const
134 { return gasReferenceDensity_.size(); }
135
139 template <class Evaluation>
140 Evaluation internalEnergy(unsigned regionIdx,
141 const Evaluation& temperature,
142 const Evaluation& pressure,
143 const Evaluation& rv,
144 const Evaluation& rvw) const
145 {
146 OPM_TIMEBLOCK_LOCAL(internalEnergy);
147 // assume ideal mixture
148 Evaluation result = 0;
149
150 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
151 // Either rv og rvw should be zero
152 assert(rv == 0.0 || rvw == 0.0);
153 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
154 result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
155 result += (1 - xBrine) * CO2::gasInternalEnergy(temperature, pressure, extrapolate);
156 return result;
157 }
158
162 template <class Evaluation>
163 Evaluation viscosity(unsigned regionIdx,
164 const Evaluation& temperature,
165 const Evaluation& pressure,
166 const Evaluation& /*Rv*/,
167 const Evaluation& /*Rvw*/) const
168 { return saturatedViscosity(regionIdx, temperature, pressure); }
169
173 template <class Evaluation>
174 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
175 const Evaluation& temperature,
176 const Evaluation& pressure) const
177 {
178 OPM_TIMEBLOCK_LOCAL(saturatedViscosity);
179 // Neglects impact of vaporized water on the visosity
180 return CO2::gasViscosity(temperature, pressure, extrapolate);
181 }
182
186 template <class Evaluation>
187 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
188 const Evaluation& temperature,
189 const Evaluation& pressure,
190 const Evaluation& rv,
191 const Evaluation& rvw) const
192 {
193 OPM_TIMEFUNCTION_LOCAL();
194 if (!enableVaporization_)
195 return CO2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
196
197 // assume ideal mixture
198 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
199 // Either rv og rvw should be zero
200 assert(rv == 0.0 || rvw == 0.0);
201 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
202 const auto& rhoCo2 = CO2::gasDensity(temperature, pressure, extrapolate);
203 const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
204 return 1.0 / ( ( xBrine/rhoH2O + (1.0 - xBrine)/rhoCo2) * gasReferenceDensity_[regionIdx]);
205 }
206
210 template <class Evaluation>
211 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
212 const Evaluation& temperature,
213 const Evaluation& pressure) const
214 {
215 OPM_TIMEFUNCTION_LOCAL();
216 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
217 return inverseFormationVolumeFactor(regionIdx,temperature,pressure, Evaluation(0.0), rvw);
218 }
219
226 template <class Evaluation>
227 Evaluation saturationPressure(unsigned /*regionIdx*/,
228 const Evaluation& /*temperature*/,
229 const Evaluation& /*Rvw*/) const
230 { return 0.0; /* not implemented */ }
231
235 template <class Evaluation>
236 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
237 const Evaluation& temperature,
238 const Evaluation& pressure) const
239 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
240
244 template <class Evaluation = Scalar>
245 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
246 const Evaluation& temperature,
247 const Evaluation& pressure,
248 const Evaluation& saltConcentration) const
249 {
250 OPM_TIMEFUNCTION_LOCAL();
251 const Evaluation salinity = salinityFromConcentration(temperature, pressure, saltConcentration);
252 return rvwSat_(regionIdx, temperature, pressure, salinity);
253 }
254
258 template <class Evaluation>
259 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
260 const Evaluation& temperature,
261 const Evaluation& pressure,
262 const Evaluation& /*oilSaturation*/,
263 const Evaluation& /*maxOilSaturation*/) const
264 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
265
269 template <class Evaluation>
270 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
271 const Evaluation& temperature,
272 const Evaluation& pressure) const
273 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
274
275 template <class Evaluation>
276 Evaluation diffusionCoefficient(const Evaluation& temperature,
277 const Evaluation& pressure,
278 unsigned /*compIdx*/) const
279 {
280 return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure, extrapolate);
281 }
282
283 Scalar gasReferenceDensity(unsigned regionIdx) const
284 { return gasReferenceDensity_[regionIdx]; }
285
286 Scalar oilReferenceDensity(unsigned regionIdx) const
287 { return brineReferenceDensity_[regionIdx]; }
288
289 Scalar waterReferenceDensity(unsigned regionIdx) const
290 { return brineReferenceDensity_[regionIdx]; }
291
292 Scalar salinity(unsigned regionIdx) const
293 { return salinity_[regionIdx]; }
294
295private:
296
297 template <class LhsEval>
298 LhsEval rvwSat_(unsigned regionIdx,
299 const LhsEval& temperature,
300 const LhsEval& pressure,
301 const LhsEval& salinity) const
302 {
303 OPM_TIMEFUNCTION_LOCAL();
304 if (!enableVaporization_)
305 return 0.0;
306
307 // calulate the equilibrium composition for the given
308 // temperature and pressure.
309 LhsEval xgH2O;
310 LhsEval xlCO2;
312 pressure,
313 salinity,
314 /*knownPhaseIdx=*/-1,
315 xlCO2,
316 xgH2O,
317 extrapolate);
318
319 // normalize the phase compositions
320 xgH2O = max(0.0, min(1.0, xgH2O));
321
322 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
323 }
324
329 template <class LhsEval>
330 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
331 {
332 OPM_TIMEFUNCTION_LOCAL();
333 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
334 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
335
336 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
337 }
338
343 template <class LhsEval>
344 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
345 {
346 OPM_TIMEFUNCTION_LOCAL();
347 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
348 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
349
350 const LhsEval& rho_wG = Rvw*rho_wRef;
351 return rho_wG/(rho_gRef + rho_wG);
352 }
356 template <class LhsEval>
357 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
358 {
359 OPM_TIMEFUNCTION_LOCAL();
360 Scalar M_CO2 = CO2::molarMass();
361 LhsEval M_Brine = Brine::molarMass(salinity);
362
363 return xgW*M_Brine / (xgW*(M_Brine - M_CO2) + M_CO2);
364 }
365
366 template <class LhsEval>
367 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P, const LhsEval& saltConcentration) const
368 { return saltConcentration/H2O::liquidDensity(T, P, true); }
369
370 std::vector<Scalar> brineReferenceDensity_;
371 std::vector<Scalar> gasReferenceDensity_;
372 std::vector<Scalar> salinity_;
373 bool enableVaporization_ = true;
374};
375
376} // namespace Opm
377
378#endif
A class for the brine fluid properties.
Binary coefficients for brine and CO2.
A class for the CO2 fluid properties.
A central place for various physical constants occuring in some equations.
A simple version of pure water with density from Hu et al.
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 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
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, const Evaluation &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
A class for the brine fluid properties.
Definition BrineDynamic.hpp:46
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in .
Definition BrineDynamic.hpp:261
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:54
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:140
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:211
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:259
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:174
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:236
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.hpp:104
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:270
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.hpp:125
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the water vaporization factor [m^3/m^3] of water phase.
Definition Co2GasPvt.hpp:245
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:227
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:119
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:133
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:163
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:187
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:91
Definition EclipseState.hpp:57
Definition Schedule.hpp:133
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:64
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam at a given pressure and temperature.
Definition SimpleHuDuanH2O.hpp:281
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The density of pure water at a given pressure and temperature .
Definition SimpleHuDuanH2O.hpp:309
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition SimpleHuDuanH2O.hpp:223
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30