My Project
Loading...
Searching...
No Matches
H2GasPvt.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_H2_GAS_PVT_HPP
28#define OPM_H2_GAS_PVT_HPP
29
35
36#include <vector>
37
38namespace Opm {
39
40#if HAVE_ECL_INPUT
41class EclipseState;
42class Schedule;
43#endif
44
48template <class Scalar>
50{
53 using H2 = ::Opm::H2<Scalar>;
54 static const bool extrapolate = true;
55
56public:
57 // The binary coefficients for brine and H2 used by this fluid system
59
60 explicit H2GasPvt() = default;
61
62 H2GasPvt(const std::vector<Scalar>& salinity,
63 Scalar T_ref = 288.71, //(273.15 + 15.56)
64 Scalar P_ref = 101325)
65 : salinity_(salinity)
66 {
67 int numRegions = salinity_.size();
68 setNumRegions(numRegions);
69 for (int i = 0; i < numRegions; ++i) {
70 gasReferenceDensity_[i] = H2::gasDensity(T_ref, P_ref, extrapolate);
71 brineReferenceDensity_[i] = Brine::liquidDensity(T_ref, P_ref, salinity_[i], extrapolate);
72 }
73 }
74
75#if HAVE_ECL_INPUT
79 void initFromState(const EclipseState& eclState, const Schedule&);
80#endif
81
82 void setNumRegions(size_t numRegions)
83 {
84 gasReferenceDensity_.resize(numRegions);
85 brineReferenceDensity_.resize(numRegions);
86 salinity_.resize(numRegions);
87 }
88
89 void setVapPars(const Scalar, const Scalar)
90 {
91 }
92
93
97 void setReferenceDensities(unsigned regionIdx,
98 Scalar rhoRefBrine,
99 Scalar rhoRefGas,
100 Scalar /*rhoRefWater*/)
101 {
102 gasReferenceDensity_[regionIdx] = rhoRefGas;
103 brineReferenceDensity_[regionIdx] = rhoRefBrine;
104 }
105
113 { enableVaporization_ = yesno; }
114
118 void initEnd()
119 {
120 }
121
125 unsigned numRegions() const
126 { return gasReferenceDensity_.size(); }
127
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 // use the gasInternalEnergy of H2
140 return H2::gasInternalEnergy(temperature, pressure, extrapolate);
141
142 // TODO: account for H2O in the gas phase
143 // Init output
144 //Evaluation result = 0;
145
146 // We have to check that one of RV and RVW is zero since H2STORE works with either GAS/WATER or GAS/OIL system
147 //assert(rv == 0.0 || rvw == 0.0);
148
149 // Calculate each component contribution and return weighted sum
150 //const Evaluation xBrine = convertRvwToXgW_(max(rvw, rv), regionIdx);
151 //result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
152 //result += (1 - xBrine) * H2::gasInternalEnergy(temperature, pressure, extrapolate);
153 //return result;
154 }
155
159 template <class Evaluation>
160 Evaluation viscosity(unsigned regionIdx,
161 const Evaluation& temperature,
162 const Evaluation& pressure,
163 const Evaluation& /*Rv*/,
164 const Evaluation& /*Rvw*/) const
165 {
166 return saturatedViscosity(regionIdx, temperature, pressure);
167 }
168
172 template <class Evaluation>
173 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
174 const Evaluation& temperature,
175 const Evaluation& pressure) const
176 {
177 return H2::gasViscosity(temperature, pressure, extrapolate);
178 }
179
183 template <class Evaluation>
184 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
185 const Evaluation& temperature,
186 const Evaluation& pressure,
187 const Evaluation& rv,
188 const Evaluation& rvw) const
189 {
190 // If vaporization is disabled, return H2 gas volume factor
191 if (!enableVaporization_)
192 return H2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
193
194 // Use CO2 density for the gas phase.
195 const auto& rhoH2 = H2::gasDensity(temperature, pressure, extrapolate);
196 //const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
197 //The H2STORE option both works for GAS/WATER and GAS/OIL systems
198 //Either rv og rvw should be zero
199 //assert(rv == 0.0 || rvw == 0.0);
200 //const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
201 //const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoH2);
202 return rhoH2/(gasReferenceDensity_[regionIdx] + max(rvw,rv)*brineReferenceDensity_[regionIdx]);
203 }
204
208 template <class Evaluation>
209 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
210 const Evaluation& temperature,
211 const Evaluation& pressure) const
212 {
213 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
214 return inverseFormationVolumeFactor(regionIdx, temperature, pressure, Evaluation(0.0), rvw);
215 }
216
222 template <class Evaluation>
223 Evaluation saturationPressure(unsigned /*regionIdx*/,
224 const Evaluation& /*temperature*/,
225 const Evaluation& /*Rv*/) const
226 { return 0.0; /* Not implemented! */ }
227
231 template <class Evaluation>
232 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
233 const Evaluation& temperature,
234 const Evaluation& pressure) const
235 {
236 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
237 }
238
242 template <class Evaluation = Scalar>
243 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
244 const Evaluation& temperature,
245 const Evaluation& pressure,
246 const Evaluation& saltConcentration) const
247 {
248 const Evaluation salinity = salinityFromConcentration(temperature, pressure, saltConcentration);
249 return rvwSat_(regionIdx, temperature, pressure, salinity);
250 }
251
255 template <class Evaluation>
256 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
257 const Evaluation& temperature,
258 const Evaluation& pressure,
259 const Evaluation& /*oilSaturation*/,
260 const Evaluation& /*maxOilSaturation*/) const
261 {
262 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
263 }
264
268 template <class Evaluation>
269 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
270 const Evaluation& temperature,
271 const Evaluation& pressure) const
272 {
273 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
274 }
275
276 template <class Evaluation>
277 Evaluation diffusionCoefficient(const Evaluation& temperature,
278 const Evaluation& pressure,
279 unsigned /*compIdx*/) const
280 {
281 return BinaryCoeffBrineH2::gasDiffCoeff(temperature, pressure);
282 }
283
284 const Scalar gasReferenceDensity(unsigned regionIdx) const
285 { return gasReferenceDensity_[regionIdx]; }
286
287 Scalar oilReferenceDensity(unsigned regionIdx) const
288 { return brineReferenceDensity_[regionIdx]; }
289
290 Scalar waterReferenceDensity(unsigned regionIdx) const
291 { return brineReferenceDensity_[regionIdx]; }
292
293 Scalar salinity(unsigned regionIdx) const
294 { return salinity_[regionIdx]; }
295
296private:
297 std::vector<Scalar> gasReferenceDensity_;
298 std::vector<Scalar> brineReferenceDensity_;
299 std::vector<Scalar> salinity_;
300 bool enableVaporization_ = true;
301
302 template <class LhsEval>
303 LhsEval rvwSat_(unsigned regionIdx,
304 const LhsEval& temperature,
305 const LhsEval& pressure,
306 const LhsEval& salinity) const
307 {
308 // If water vaporization is disabled, we return zero
309 if (!enableVaporization_)
310 return 0.0;
311
312 // From Li et al., Int. J. Hydrogen Energ., 2018, water mole fraction is calculated assuming ideal mixing
313 LhsEval pw_sat = H2O::vaporPressure(temperature);
314 LhsEval yH2O = pw_sat / pressure;
315
316 // normalize the phase compositions
317 yH2O = max(0.0, min(1.0, yH2O));
318 return convertXgWToRvw(convertxgWToXgW(yH2O, salinity), regionIdx);
319 }
320
325 template <class LhsEval>
326 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
327 {
328 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
329 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
330
331 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
332 }
333
338 template <class LhsEval>
339 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
340 {
341 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
342 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
343
344 const LhsEval& rho_wG = Rvw*rho_wRef;
345 return rho_wG/(rho_gRef + rho_wG);
346 }
347
351 template <class LhsEval>
352 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
353 {
354 Scalar M_H2 = H2::molarMass();
355 LhsEval M_Brine = Brine::molarMass(salinity);
356
357 return xgW*M_Brine / (xgW*(M_Brine - M_H2) + M_H2);
358 }
359
360 template <class LhsEval>
361 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P, const LhsEval& saltConcentration) const
362 {
363 return saltConcentration / H2O::liquidDensity(T, P, true);
364 }
365
366}; // end class H2GasPvt
367
368} // end namspace Opm
369
370#endif
A class for the brine fluid properties.
Binary coefficients for brine and H2.
Properties of pure molecular hydrogen .
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 H2.
Definition Brine_H2.hpp:41
static Evaluation gasDiffCoeff(const Evaluation &temperature, const Evaluation &pressure)
Binary diffusion coefficent [m^2/s] for molecular water and H2 as an approximation for brine-H2 diffu...
Definition Brine_H2.hpp:186
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
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
This class represents the Pressure-Volume-Temperature relations of the gas phase for H2.
Definition H2GasPvt.hpp:50
void initEnd()
Finish initializing the oil phase PVT properties.
Definition H2GasPvt.hpp:118
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 H2GasPvt.hpp:232
Evaluation internalEnergy(unsigned, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition H2GasPvt.hpp:133
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 H2GasPvt.hpp:269
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition H2GasPvt.hpp:112
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil saturated gas at given pressure.
Definition H2GasPvt.hpp:209
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition H2GasPvt.hpp:97
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition H2GasPvt.hpp:125
Evaluation saturatedViscosity(unsigned, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas at given pressure.
Definition H2GasPvt.hpp:173
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 saturated gas.
Definition H2GasPvt.hpp:243
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the oil compo...
Definition H2GasPvt.hpp:223
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 H2GasPvt.hpp:256
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 H2GasPvt.hpp:184
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 H2GasPvt.hpp:160
Properties of pure molecular hydrogen .
Definition H2.hpp:58
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of H2 [J/kg].
Definition H2.hpp:215
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity of at a given pressure and temperature.
Definition H2.hpp:249
static constexpr Scalar molarMass()
The molar mass in of molecular hydrogen.
Definition H2.hpp:77
static Evaluation gasDensity(Evaluation temperature, Evaluation pressure, bool extrapolate=false)
The density of at a given pressure and temperature.
Definition H2.hpp:167
Definition Schedule.hpp:88
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition SimpleHuDuanH2O.hpp:139
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
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30