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 explicit H2GasPvt(const std::vector<Scalar>& salinity,
63 Scalar T_ref = 288.71, //(273.15 + 15.56)
64 Scalar P_ref = 101325);
65
66#if HAVE_ECL_INPUT
70 void initFromState(const EclipseState& eclState, const Schedule&);
71#endif
72
73 void setNumRegions(size_t numRegions);
74
75 void setVapPars(const Scalar, const Scalar)
76 {
77 }
78
82 void setReferenceDensities(unsigned regionIdx,
83 Scalar rhoRefBrine,
84 Scalar rhoRefGas,
85 Scalar /*rhoRefWater*/);
86
94 { enableVaporization_ = yesno; }
95
99 void initEnd()
100 {
101 }
102
106 unsigned numRegions() const
107 { return gasReferenceDensity_.size(); }
108
109 Scalar hVap(unsigned ) const
110 { return 0.0; }
111
116 template <class Evaluation>
117 Evaluation internalEnergy(unsigned /*regionIdx*/,
118 const Evaluation& temperature,
119 const Evaluation& pressure,
120 const Evaluation& /*rv*/,
121 const Evaluation& /*rvw*/) const
122 {
123 // use the gasInternalEnergy of H2
124 return H2::gasInternalEnergy(temperature, pressure, extrapolate);
125
126 // TODO: account for H2O in the gas phase
127 // Init output
128 //Evaluation result = 0;
129
130 // We have to check that one of RV and RVW is zero since H2STORE works with either GAS/WATER or GAS/OIL system
131 //assert(rv == 0.0 || rvw == 0.0);
132
133 // Calculate each component contribution and return weighted sum
134 //const Evaluation xBrine = convertRvwToXgW_(max(rvw, rv), regionIdx);
135 //result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
136 //result += (1 - xBrine) * H2::gasInternalEnergy(temperature, pressure, extrapolate);
137 //return result;
138 }
139
143 template <class Evaluation>
144 Evaluation viscosity(unsigned regionIdx,
145 const Evaluation& temperature,
146 const Evaluation& pressure,
147 const Evaluation& /*Rv*/,
148 const Evaluation& /*Rvw*/) const
149 {
150 return saturatedViscosity(regionIdx, temperature, pressure);
151 }
152
156 template <class Evaluation>
157 Evaluation saturatedViscosity(unsigned /*regionIdx*/,
158 const Evaluation& temperature,
159 const Evaluation& pressure) const
160 {
161 return H2::gasViscosity(temperature, pressure, extrapolate);
162 }
163
167 template <class Evaluation>
168 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
169 const Evaluation& temperature,
170 const Evaluation& pressure,
171 const Evaluation& rv,
172 const Evaluation& rvw) const
173 {
174 // If vaporization is disabled, return H2 gas volume factor
175 if (!enableVaporization_) {
176 return H2::gasDensity(temperature, pressure, extrapolate) /
177 gasReferenceDensity_[regionIdx];
178 }
179
180 // Use CO2 density for the gas phase.
181 const auto& rhoH2 = H2::gasDensity(temperature, pressure, extrapolate);
182 //const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
183 //The H2STORE option both works for GAS/WATER and GAS/OIL systems
184 //Either rv og rvw should be zero
185 //assert(rv == 0.0 || rvw == 0.0);
186 //const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
187 //const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoH2);
188 return rhoH2 / (gasReferenceDensity_[regionIdx] +
189 max(rvw,rv) * brineReferenceDensity_[regionIdx]);
190 }
191
195 template <class Evaluation>
196 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
197 const Evaluation& temperature,
198 const Evaluation& pressure) const
199 {
200 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
201 Evaluation(salinity_[regionIdx]));
202 return inverseFormationVolumeFactor(regionIdx, temperature, pressure,
203 Evaluation(0.0), rvw);
204 }
205
213 template <class Evaluation>
214 Evaluation saturationPressure(unsigned /*regionIdx*/,
215 const Evaluation& /*temperature*/,
216 const Evaluation& /*Rv*/) const
217 { return 0.0; /* Not implemented! */ }
218
222 template <class Evaluation>
223 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
224 const Evaluation& temperature,
225 const Evaluation& pressure) const
226 {
227 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
228 }
229
233 template <class Evaluation = Scalar>
234 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
235 const Evaluation& temperature,
236 const Evaluation& pressure,
237 const Evaluation& saltConcentration) const
238 {
239 const Evaluation salinity = salinityFromConcentration(temperature, pressure,
240 saltConcentration);
241 return rvwSat_(regionIdx, temperature, pressure, salinity);
242 }
243
247 template <class Evaluation>
248 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
249 const Evaluation& temperature,
250 const Evaluation& pressure,
251 const Evaluation& /*oilSaturation*/,
252 const Evaluation& /*maxOilSaturation*/) const
253 {
254 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
255 }
256
260 template <class Evaluation>
261 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
262 const Evaluation& temperature,
263 const Evaluation& pressure) const
264 {
265 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
266 }
267
268 template <class Evaluation>
269 Evaluation diffusionCoefficient(const Evaluation& temperature,
270 const Evaluation& pressure,
271 unsigned /*compIdx*/) const
272 {
273 return BinaryCoeffBrineH2::gasDiffCoeff(temperature, pressure);
274 }
275
276 Scalar gasReferenceDensity(unsigned regionIdx) const
277 { return gasReferenceDensity_[regionIdx]; }
278
279 Scalar oilReferenceDensity(unsigned regionIdx) const
280 { return brineReferenceDensity_[regionIdx]; }
281
282 Scalar waterReferenceDensity(unsigned regionIdx) const
283 { return brineReferenceDensity_[regionIdx]; }
284
285 Scalar salinity(unsigned regionIdx) const
286 { return salinity_[regionIdx]; }
287
288private:
289 template <class LhsEval>
290 LhsEval rvwSat_(unsigned regionIdx,
291 const LhsEval& temperature,
292 const LhsEval& pressure,
293 const LhsEval& salinity) const
294 {
295 // If water vaporization is disabled, we return zero
296 if (!enableVaporization_) {
297 return 0.0;
298 }
299
300 // From Li et al., Int. J. Hydrogen Energ., 2018, water mole fraction is calculated assuming ideal mixing
301 LhsEval pw_sat = H2O::vaporPressure(temperature);
302 LhsEval yH2O = pw_sat / pressure;
303
304 // normalize the phase compositions
305 yH2O = max(0.0, min(1.0, yH2O));
306 return convertXgWToRvw(convertxgWToXgW(yH2O, salinity), regionIdx);
307 }
308
313 template <class LhsEval>
314 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
315 {
316 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
317 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
318
319 return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
320 }
321
326 template <class LhsEval>
327 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
328 {
329 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
330 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
331
332 const LhsEval& rho_wG = Rvw * rho_wRef;
333 return rho_wG / (rho_gRef + rho_wG);
334 }
335
339 template <class LhsEval>
340 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
341 {
342 Scalar M_H2 = H2::molarMass();
343 LhsEval M_Brine = Brine::molarMass(salinity);
344
345 return xgW * M_Brine / (xgW * (M_Brine - M_H2) + M_H2);
346 }
347
348 template <class LhsEval>
349 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P,
350 const LhsEval& saltConcentration) const
351 {
352 return saltConcentration / H2O::liquidDensity(T, P, true);
353 }
354
355 std::vector<Scalar> gasReferenceDensity_{};
356 std::vector<Scalar> brineReferenceDensity_{};
357 std::vector<Scalar> salinity_{};
358 bool enableVaporization_ = true;
359}; // end class H2GasPvt
360
361} // end namspace Opm
362
363#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:49
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:99
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:223
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: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 H2GasPvt.hpp:261
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition H2GasPvt.hpp:93
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:196
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition H2GasPvt.cpp:93
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition H2GasPvt.hpp:106
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: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 saturated gas.
Definition H2GasPvt.hpp:234
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: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 H2GasPvt.hpp:248
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:168
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:144
Properties of pure molecular hydrogen .
Definition H2.hpp:90
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of H2 [J/kg].
Definition H2.hpp:247
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:281
static constexpr Scalar molarMass()
The molar mass in of molecular hydrogen.
Definition H2.hpp:109
static Evaluation gasDensity(Evaluation temperature, Evaluation pressure, bool extrapolate=false)
The density of at a given pressure and temperature.
Definition H2.hpp:199
Definition Schedule.hpp:101
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
static OPM_HOST_DEVICE Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The density of pure water at a given pressure and temperature .
Definition SimpleHuDuanH2O.hpp:313
static OPM_HOST_DEVICE Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition SimpleHuDuanH2O.hpp:142
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30