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#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
39
40#include <vector>
41
42namespace Opm {
43
44class EclipseState;
45class Schedule;
46class Co2StoreConfig;
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 int activityModel = 3,
68 int thermalMixingModel = 1,
69 Scalar T_ref = 288.71, //(273.15 + 15.56)
70 Scalar P_ref = 101325)
71 : salinity_(salinity)
72 {
73 // Throw an error if reference state is not (T, p) = (15.56 C, 1 atm) = (288.71 K, 1.01325e5 Pa)
74 if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
75 OPM_THROW(std::runtime_error,
76 "BrineCo2Pvt class can only be used with default reference state (T, P) = (288.71 K, 1.01325e5 Pa)!");
77 }
78 setActivityModelSalt(activityModel);
79 setThermalMixingModel(thermalMixingModel);
80
81 int num_regions = salinity_.size();
82 setNumRegions(num_regions);
83 for (int i = 0; i < num_regions; ++i) {
84 gasReferenceDensity_[i] = CO2::gasDensity(T_ref, P_ref, extrapolate);
85 brineReferenceDensity_[i] = Brine::liquidDensity(T_ref, P_ref, salinity_[i], extrapolate);
86 }
87 }
91 void initFromState(const EclipseState& eclState, const Schedule&);
92
93 void setNumRegions(size_t numRegions)
94 {
95 gasReferenceDensity_.resize(numRegions);
96 brineReferenceDensity_.resize(numRegions);
97 salinity_.resize(numRegions);
98 }
99
100 void setVapPars(const Scalar, const Scalar)
101 {
102 }
103
107 void setReferenceDensities(unsigned regionIdx,
108 Scalar rhoRefBrine,
109 Scalar rhoRefGas,
110 Scalar /*rhoRefWater*/)
111 {
112 gasReferenceDensity_[regionIdx] = rhoRefGas;
113 brineReferenceDensity_[regionIdx] = rhoRefBrine;;
114 }
115
123 { enableVaporization_ = yesno; }
124
128 void setActivityModelSalt(int activityModel)
129 {
130 // Only 1, 2, and 3 are allowed
131 if (activityModel > 3 || activityModel < 1) {
132 OPM_THROW(std::runtime_error, "The salt activity model options are 1, 2 or 3");
133 }
134 activityModel_ = activityModel;
135 }
136
140 void setThermalMixingModel(int thermalMixingModel)
141 {
142 // Only 0 and 1 are allowed
143 // 0 = Use pure CO2 entalpy
144 // 1 = Account for vapporized water in gas phase (Mass fraction)
145 if (thermalMixingModel == 0)
146 gastype_ = Co2StoreConfig::GasMixingType::NONE;
147
148 else if (thermalMixingModel == 1)
149 gastype_ = Co2StoreConfig::GasMixingType::IDEAL;
150 else
151 OPM_THROW(std::runtime_error, "The thermal mixing model options are 0 and 1");
152 }
153
157 void initEnd()
158 {
159
160 }
161
165 unsigned numRegions() const
166 { return gasReferenceDensity_.size(); }
167
171 template <class Evaluation>
172 Evaluation internalEnergy(unsigned regionIdx,
173 const Evaluation& temperature,
174 const Evaluation& pressure,
175 const Evaluation& rv,
176 const Evaluation& rvw) const
177 {
178 OPM_TIMEBLOCK_LOCAL(internalEnergy);
179
180 if (gastype_ == Co2StoreConfig::GasMixingType::NONE)
181 // use the gasInternalEnergy of CO2
182 return CO2::gasInternalEnergy(temperature, pressure, extrapolate);
183
184 assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
185 // account for H2O in the gas phase
186 Evaluation result = 0;
187 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
188 // Either rv og rvw should be zero
189 assert(rv == 0.0 || rvw == 0.0);
190 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
191 result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
192 result += (1 - xBrine) * CO2::gasInternalEnergy(temperature, pressure, extrapolate);
193 return result;
194 }
195
199 template <class Evaluation>
200 Evaluation viscosity(unsigned regionIdx,
201 const Evaluation& temperature,
202 const Evaluation& pressure,
203 const Evaluation& /*Rv*/,
204 const Evaluation& /*Rvw*/) const
205 { return saturatedViscosity(regionIdx, temperature, pressure); }
206
210 template <class Evaluation>
211 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
212 const Evaluation& temperature,
213 const Evaluation& pressure) const
214 {
215 OPM_TIMEBLOCK_LOCAL(saturatedViscosity);
216 // Neglects impact of vaporized water on the visosity
217 return CO2::gasViscosity(temperature, pressure, extrapolate);
218 }
219
223 template <class Evaluation>
224 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
225 const Evaluation& temperature,
226 const Evaluation& pressure,
227 const Evaluation& rv,
228 const Evaluation& rvw) const
229 {
230 OPM_TIMEFUNCTION_LOCAL();
231 if (!enableVaporization_)
232 return CO2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
233
234 // Use CO2 density for the gas phase.
235 const auto& rhoCo2 = CO2::gasDensity(temperature, pressure, extrapolate);
236 //const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
237 //The CO2STORE option both works for GAS/WATER and GAS/OIL systems
238 //Either rv og rvw should be zero
239 //assert(rv == 0.0 || rvw == 0.0);
240 //const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
241 //const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoCo2);
242 return rhoCo2/(gasReferenceDensity_[regionIdx] + max(rvw,rv)*brineReferenceDensity_[regionIdx]);
243 }
244
248 template <class Evaluation>
249 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
250 const Evaluation& temperature,
251 const Evaluation& pressure) const
252 {
253 OPM_TIMEFUNCTION_LOCAL();
254 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
255 return inverseFormationVolumeFactor(regionIdx,temperature,pressure, Evaluation(0.0), rvw);
256 }
257
264 template <class Evaluation>
265 Evaluation saturationPressure(unsigned /*regionIdx*/,
266 const Evaluation& /*temperature*/,
267 const Evaluation& /*Rvw*/) const
268 { return 0.0; /* not implemented */ }
269
273 template <class Evaluation>
274 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
275 const Evaluation& temperature,
276 const Evaluation& pressure) const
277 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
278
282 template <class Evaluation = Scalar>
283 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
284 const Evaluation& temperature,
285 const Evaluation& pressure,
286 const Evaluation& saltConcentration) const
287 {
288 OPM_TIMEFUNCTION_LOCAL();
289 const Evaluation salinity = salinityFromConcentration(temperature, pressure, saltConcentration);
290 return rvwSat_(regionIdx, temperature, pressure, salinity);
291 }
292
296 template <class Evaluation>
297 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
298 const Evaluation& temperature,
299 const Evaluation& pressure,
300 const Evaluation& /*oilSaturation*/,
301 const Evaluation& /*maxOilSaturation*/) const
302 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
303
307 template <class Evaluation>
308 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
309 const Evaluation& temperature,
310 const Evaluation& pressure) const
311 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
312
313 template <class Evaluation>
314 Evaluation diffusionCoefficient(const Evaluation& temperature,
315 const Evaluation& pressure,
316 unsigned /*compIdx*/) const
317 {
318 return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure, extrapolate);
319 }
320
321 Scalar gasReferenceDensity(unsigned regionIdx) const
322 { return gasReferenceDensity_[regionIdx]; }
323
324 Scalar oilReferenceDensity(unsigned regionIdx) const
325 { return brineReferenceDensity_[regionIdx]; }
326
327 Scalar waterReferenceDensity(unsigned regionIdx) const
328 { return brineReferenceDensity_[regionIdx]; }
329
330 Scalar salinity(unsigned regionIdx) const
331 { return salinity_[regionIdx]; }
332
333private:
334
335 template <class LhsEval>
336 LhsEval rvwSat_(unsigned regionIdx,
337 const LhsEval& temperature,
338 const LhsEval& pressure,
339 const LhsEval& salinity) const
340 {
341 OPM_TIMEFUNCTION_LOCAL();
342 if (!enableVaporization_)
343 return 0.0;
344
345 // calulate the equilibrium composition for the given
346 // temperature and pressure.
347 LhsEval xgH2O;
348 LhsEval xlCO2;
350 pressure,
351 salinity,
352 /*knownPhaseIdx=*/-1,
353 xlCO2,
354 xgH2O,
355 activityModel_,
356 extrapolate);
357
358 // normalize the phase compositions
359 xgH2O = max(0.0, min(1.0, xgH2O));
360
361 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
362 }
363
368 template <class LhsEval>
369 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
370 {
371 OPM_TIMEFUNCTION_LOCAL();
372 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
373 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
374
375 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
376 }
377
382 template <class LhsEval>
383 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
384 {
385 OPM_TIMEFUNCTION_LOCAL();
386 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
387 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
388
389 const LhsEval& rho_wG = Rvw*rho_wRef;
390 return rho_wG/(rho_gRef + rho_wG);
391 }
395 template <class LhsEval>
396 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
397 {
398 OPM_TIMEFUNCTION_LOCAL();
399 Scalar M_CO2 = CO2::molarMass();
400 LhsEval M_Brine = Brine::molarMass(salinity);
401
402 return xgW*M_Brine / (xgW*(M_Brine - M_CO2) + M_CO2);
403 }
404
405 template <class LhsEval>
406 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P, const LhsEval& saltConcentration) const
407 { return saltConcentration/H2O::liquidDensity(T, P, true); }
408
409 std::vector<Scalar> brineReferenceDensity_;
410 std::vector<Scalar> gasReferenceDensity_;
411 std::vector<Scalar> salinity_;
412 bool enableVaporization_ = true;
413 int activityModel_;
414 Co2StoreConfig::GasMixingType gastype_;
415};
416
417} // namespace Opm
418
419#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:45
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, const Evaluation &salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O, const int &activityModel, 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:100
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:59
A class for the brine fluid properties.
Definition BrineDynamic.hpp:48
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:263
A class for the CO2 fluid properties.
Definition CO2.hpp:54
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:208
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:71
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:180
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:194
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:172
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:249
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:297
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:211
void initFromState(const EclipseState &eclState, const Schedule &)
Initialize the parameters for CO2 gas using an ECL deck.
Definition Co2GasPvt.cpp:37
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:274
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.hpp:107
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:308
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.hpp:157
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:283
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:265
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:122
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:165
void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition Co2GasPvt.hpp:140
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:200
void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition Co2GasPvt.hpp:128
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:224
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
Definition Schedule.hpp:88
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
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:310
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition SimpleHuDuanH2O.hpp:224
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30