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 /* NOTE: Assume ideal mixing */
140
141 // Init output
142 Evaluation result = 0;
143
144 // We have to check that one of RV and RVW is zero since H2STORE works with either GAS/WATER or GAS/OIL system
145 assert(rv == 0.0 || rvw == 0.0);
146
147 // Calculate each component contribution and return weighted sum
148 const Evaluation xBrine = convertRvwToXgW_(max(rvw, rv), regionIdx);
149 result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
150 result += (1 - xBrine) * H2::gasInternalEnergy(temperature, pressure, extrapolate);
151 return result;
152 }
153
157 template <class Evaluation>
158 Evaluation viscosity(unsigned regionIdx,
159 const Evaluation& temperature,
160 const Evaluation& pressure,
161 const Evaluation& /*Rv*/,
162 const Evaluation& /*Rvw*/) const
163 {
164 return saturatedViscosity(regionIdx, temperature, pressure);
165 }
166
170 template <class Evaluation>
171 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
172 const Evaluation& temperature,
173 const Evaluation& pressure) const
174 {
175 return H2::gasViscosity(temperature, pressure, extrapolate);
176 }
177
181 template <class Evaluation>
182 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
183 const Evaluation& temperature,
184 const Evaluation& pressure,
185 const Evaluation& rv,
186 const Evaluation& rvw) const
187 {
188 // If vaporization is disabled, return H2 gas volume factor
189 if (!enableVaporization_)
190 return H2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
191
192 /* NOTE: Assume ideal mixing! */
193
194 // We have to check that one of RV and RVW is zero since H2STORE works with either GAS/WATER or GAS/OIL system
195 assert(rv == 0.0 || rvw == 0.0);
196
197 // Calculate each component contribution and return weighted sum
198 const Evaluation xBrine = convertRvwToXgW_(max(rvw, rv),regionIdx);
199 const auto& rhoH2 = H2::gasDensity(temperature, pressure, extrapolate);
200 const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
201 return 1.0 / ((xBrine / rhoH2O + (1.0 - xBrine) / rhoH2) * gasReferenceDensity_[regionIdx]);
202 }
203
207 template <class Evaluation>
208 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
209 const Evaluation& temperature,
210 const Evaluation& pressure) const
211 {
212 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
213 return inverseFormationVolumeFactor(regionIdx, temperature, pressure, Evaluation(0.0), rvw);
214 }
215
221 template <class Evaluation>
222 Evaluation saturationPressure(unsigned /*regionIdx*/,
223 const Evaluation& /*temperature*/,
224 const Evaluation& /*Rv*/) const
225 { return 0.0; /* Not implemented! */ }
226
230 template <class Evaluation>
231 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
232 const Evaluation& temperature,
233 const Evaluation& pressure) const
234 {
235 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
236 }
237
241 template <class Evaluation = Scalar>
242 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
243 const Evaluation& temperature,
244 const Evaluation& pressure,
245 const Evaluation& saltConcentration) const
246 {
247 const Evaluation salinity = salinityFromConcentration(temperature, pressure, saltConcentration);
248 return rvwSat_(regionIdx, temperature, pressure, salinity);
249 }
250
254 template <class Evaluation>
255 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
256 const Evaluation& temperature,
257 const Evaluation& pressure,
258 const Evaluation& /*oilSaturation*/,
259 const Evaluation& /*maxOilSaturation*/) const
260 {
261 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
262 }
263
267 template <class Evaluation>
268 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
269 const Evaluation& temperature,
270 const Evaluation& pressure) const
271 {
272 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
273 }
274
275 template <class Evaluation>
276 Evaluation diffusionCoefficient(const Evaluation& temperature,
277 const Evaluation& pressure,
278 unsigned /*compIdx*/) const
279 {
280 return BinaryCoeffBrineH2::gasDiffCoeff(temperature, pressure);
281 }
282
283 const 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 std::vector<Scalar> gasReferenceDensity_;
297 std::vector<Scalar> brineReferenceDensity_;
298 std::vector<Scalar> salinity_;
299 bool enableVaporization_ = true;
300
301 template <class LhsEval>
302 LhsEval rvwSat_(unsigned regionIdx,
303 const LhsEval& temperature,
304 const LhsEval& pressure,
305 const LhsEval& salinity) const
306 {
307 // If water vaporization is disabled, we return zero
308 if (!enableVaporization_)
309 return 0.0;
310
311 // From Li et al., Int. J. Hydrogen Energ., 2018, water mole fraction is calculated assuming ideal mixing
312 LhsEval pw_sat = H2O::vaporPressure(temperature);
313 LhsEval yH2O = pw_sat / pressure;
314
315 // normalize the phase compositions
316 yH2O = max(0.0, min(1.0, yH2O));
317 return convertXgWToRvw(convertxgWToXgW(yH2O, salinity), regionIdx);
318 }
319
324 template <class LhsEval>
325 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
326 {
327 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
328 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
329
330 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
331 }
332
337 template <class LhsEval>
338 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
339 {
340 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
341 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
342
343 const LhsEval& rho_wG = Rvw*rho_wRef;
344 return rho_wG/(rho_gRef + rho_wG);
345 }
346
350 template <class LhsEval>
351 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
352 {
353 Scalar M_H2 = H2::molarMass();
354 LhsEval M_Brine = Brine::molarMass(salinity);
355
356 return xgW*M_Brine / (xgW*(M_Brine - M_H2) + M_H2);
357 }
358
359 template <class LhsEval>
360 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P, const LhsEval& saltConcentration) const
361 {
362 return saltConcentration / H2O::liquidDensity(T, P, true);
363 }
364
365}; // end class H2GasPvt
366
367} // end namspace Opm
368
369#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: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
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:91
Definition EclipseState.hpp:57
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:231
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:268
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:208
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 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 H2GasPvt.hpp:133
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:171
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:242
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:222
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:255
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:182
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:158
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: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 vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition SimpleHuDuanH2O.hpp:138
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