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/TimingMacros.hpp>
32
38#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
39
40#include <cstddef>
41#include <vector>
42
43namespace Opm {
44
45class EclipseState;
46class Schedule;
47class Co2StoreConfig;
48
53template <class Scalar>
55{
56 using CO2 = ::Opm::CO2<Scalar>;
59 static constexpr bool extrapolate = true;
60
61public:
64
65 explicit Co2GasPvt() = default;
66
67 explicit Co2GasPvt(const std::vector<Scalar>& salinity,
68 int activityModel = 3,
69 int thermalMixingModel = 1,
70 Scalar T_ref = 288.71, //(273.15 + 15.56)
71 Scalar P_ref = 101325);
72
73#if HAVE_ECL_INPUT
77 void initFromState(const EclipseState& eclState, const Schedule&);
78#endif
79
80 void setNumRegions(std::size_t numRegions);
81
82 void setVapPars(const Scalar, const Scalar)
83 {
84 }
85
89 void setReferenceDensities(unsigned regionIdx,
90 Scalar rhoRefBrine,
91 Scalar rhoRefGas,
92 Scalar /*rhoRefWater*/);
93
101 { enableVaporization_ = yesno; }
102
106 void setActivityModelSalt(int activityModel);
107
111 void setThermalMixingModel(int thermalMixingModel);
112
116 void initEnd()
117 {
118 }
119
123 unsigned numRegions() const
124 { return gasReferenceDensity_.size(); }
125
126 Scalar hVap(unsigned ) const
127 { return 0.0; }
128
132 template <class Evaluation>
133 Evaluation internalEnergy(unsigned regionIdx,
134 const Evaluation& temperature,
135 const Evaluation& pressure,
136 const Evaluation& rv,
137 const Evaluation& rvw) const
138 {
139 OPM_TIMEBLOCK_LOCAL(internalEnergy);
140 if (gastype_ == Co2StoreConfig::GasMixingType::NONE) {
141 // use the gasInternalEnergy of CO2
142 return CO2::gasInternalEnergy(temperature, pressure, extrapolate);
143 }
144
145 assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
146 // account for H2O in the gas phase
147 Evaluation result = 0;
148 // The CO2STORE option both works for GAS/WATER and GAS/OIL systems
149 // Either rv og rvw should be zero
150 assert(rv == 0.0 || rvw == 0.0);
151 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
152 result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
153 result += (1 - xBrine) * CO2::gasInternalEnergy(temperature, pressure, extrapolate);
154 return result;
155 }
156
161 template <class Evaluation>
162 Evaluation viscosity(unsigned regionIdx,
163 const Evaluation& temperature,
164 const Evaluation& pressure,
165 const Evaluation& /*Rv*/,
166 const Evaluation& /*Rvw*/) const
167 { return saturatedViscosity(regionIdx, temperature, pressure); }
168
172 template <class Evaluation>
173 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
174 const Evaluation& temperature,
175 const Evaluation& pressure) const
176 {
177 OPM_TIMEBLOCK_LOCAL(saturatedViscosity);
178 // Neglects impact of vaporized water on the visosity
179 return CO2::gasViscosity(temperature, pressure, extrapolate);
180 }
181
185 template <class Evaluation>
186 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
187 const Evaluation& temperature,
188 const Evaluation& pressure,
189 const Evaluation& rv,
190 const Evaluation& rvw) const
191 {
192 OPM_TIMEFUNCTION_LOCAL();
193 if (!enableVaporization_) {
194 return CO2::gasDensity(temperature, pressure, extrapolate) /
195 gasReferenceDensity_[regionIdx];
196 }
197
198 // Use CO2 density for the gas phase.
199 const auto& rhoCo2 = CO2::gasDensity(temperature, pressure, extrapolate);
200 //const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
201 //The CO2STORE option both works for GAS/WATER and GAS/OIL systems
202 //Either rv og rvw should be zero
203 //assert(rv == 0.0 || rvw == 0.0);
204 //const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
205 //const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoCo2);
206 return rhoCo2 / (gasReferenceDensity_[regionIdx] +
207 max(rvw,rv) * brineReferenceDensity_[regionIdx]);
208 }
209
213 template <class Evaluation>
214 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
215 const Evaluation& temperature,
216 const Evaluation& pressure) const
217 {
218 OPM_TIMEFUNCTION_LOCAL();
219 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
220 Evaluation(salinity_[regionIdx]));
221 return inverseFormationVolumeFactor(regionIdx, temperature,
222 pressure, Evaluation(0.0), rvw);
223 }
224
232 template <class Evaluation>
233 Evaluation saturationPressure(unsigned /*regionIdx*/,
234 const Evaluation& /*temperature*/,
235 const Evaluation& /*Rvw*/) const
236 { return 0.0; /* not implemented */ }
237
241 template <class Evaluation>
242 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
243 const Evaluation& temperature,
244 const Evaluation& pressure) const
245 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
246
250 template <class Evaluation = Scalar>
251 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
252 const Evaluation& temperature,
253 const Evaluation& pressure,
254 const Evaluation& saltConcentration) const
255 {
256 OPM_TIMEFUNCTION_LOCAL();
257 const Evaluation salinity = salinityFromConcentration(temperature, pressure,
258 saltConcentration);
259 return rvwSat_(regionIdx, temperature, pressure, salinity);
260 }
261
265 template <class Evaluation>
266 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
267 const Evaluation& temperature,
268 const Evaluation& pressure,
269 const Evaluation& /*oilSaturation*/,
270 const Evaluation& /*maxOilSaturation*/) const
271 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
272
276 template <class Evaluation>
277 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
278 const Evaluation& temperature,
279 const Evaluation& pressure) const
280 { return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
281
282 template <class Evaluation>
283 Evaluation diffusionCoefficient(const Evaluation& temperature,
284 const Evaluation& pressure,
285 unsigned /*compIdx*/) const
286 {
287 return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure, extrapolate);
288 }
289
290 Scalar gasReferenceDensity(unsigned regionIdx) const
291 { return gasReferenceDensity_[regionIdx]; }
292
293 Scalar oilReferenceDensity(unsigned regionIdx) const
294 { return brineReferenceDensity_[regionIdx]; }
295
296 Scalar waterReferenceDensity(unsigned regionIdx) const
297 { return brineReferenceDensity_[regionIdx]; }
298
299 Scalar salinity(unsigned regionIdx) const
300 { return salinity_[regionIdx]; }
301
302 void setEzrokhiDenCoeff(const std::vector<EzrokhiTable>& denaqa);
303
304private:
305 template <class LhsEval>
306 LhsEval ezrokhiExponent_(const LhsEval& temperature,
307 const std::vector<Scalar>& ezrokhiCoeff) const
308 {
309 const LhsEval& tempC = temperature - 273.15;
310 return ezrokhiCoeff[0] + tempC * (ezrokhiCoeff[1] + ezrokhiCoeff[2] * tempC);
311 }
312
313 template <class LhsEval>
314 LhsEval rvwSat_(unsigned regionIdx,
315 const LhsEval& temperature,
316 const LhsEval& pressure,
317 const LhsEval& salinity) const
318 {
319 OPM_TIMEFUNCTION_LOCAL();
320 if (!enableVaporization_) {
321 return 0.0;
322 }
323
324 // calulate the equilibrium composition for the given
325 // temperature and pressure.
326 LhsEval xgH2O;
327 LhsEval xlCO2;
329 pressure,
330 salinity,
331 /*knownPhaseIdx=*/-1,
332 xlCO2,
333 xgH2O,
334 activityModel_,
335 extrapolate);
336
337 // normalize the phase compositions
338 xgH2O = max(0.0, min(1.0, xgH2O));
339
340 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
341 }
342
347 template <class LhsEval>
348 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
349 {
350 OPM_TIMEFUNCTION_LOCAL();
351 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
352 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
353
354 return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
355 }
356
361 template <class LhsEval>
362 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
363 {
364 OPM_TIMEFUNCTION_LOCAL();
365 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
366 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
367
368 const LhsEval& rho_wG = Rvw * rho_wRef;
369 return rho_wG / (rho_gRef + rho_wG);
370 }
374 template <class LhsEval>
375 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
376 {
377 OPM_TIMEFUNCTION_LOCAL();
378 Scalar M_CO2 = CO2::molarMass();
379 LhsEval M_Brine = Brine::molarMass(salinity);
380
381 return xgW * M_Brine / (xgW * (M_Brine - M_CO2) + M_CO2);
382 }
383
384 template <class LhsEval>
385 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P,
386 const LhsEval& saltConcentration) const
387 { return saltConcentration/H2O::liquidDensity(T, P, true); }
388
389 std::vector<Scalar> brineReferenceDensity_{};
390 std::vector<Scalar> gasReferenceDensity_{};
391 std::vector<Scalar> salinity_{};
392 std::vector<Scalar> ezrokhiDenNaClCoeff_{};
393 bool enableEzrokhiDensity_ = false;
394 bool enableVaporization_ = true;
395 int activityModel_{};
396 Co2StoreConfig::GasMixingType gastype_{};
397};
398
399} // namespace Opm
400
401#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
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:55
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:133
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:214
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:266
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:173
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:242
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.cpp:117
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:277
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.hpp:116
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:251
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:233
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:100
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:123
void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition Co2GasPvt.cpp:141
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:162
void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition Co2GasPvt.cpp: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:186
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
Definition Schedule.hpp:89
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