opm-common
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>
49class H2GasPvt
50{
51 using H2O = SimpleHuDuanH2O<Scalar>;
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
58 using BinaryCoeffBrineH2 = BinaryCoeff::Brine_H2<Scalar, H2O, H2>;
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 FluidState, class LhsEval = typename FluidState::Scalar>
196 std::pair<LhsEval, LhsEval>
197 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
198 {
199 const LhsEval& T = decay<LhsEval>(fluidState.temperature(FluidState::gasPhaseIdx));
200 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::gasPhaseIdx));
201 const LhsEval& Rv = decay<LhsEval>(fluidState.Rv());
202 const LhsEval& Rvw = decay<LhsEval>(fluidState.Rvw());
203 return { this->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw),
204 this->viscosity(regionIdx, T, p, Rv, Rvw) };
205 }
206
210 template <class Evaluation>
211 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
212 const Evaluation& temperature,
213 const Evaluation& pressure) const
214 {
215 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
216 Evaluation(salinity_[regionIdx]));
217 return inverseFormationVolumeFactor(regionIdx, temperature, pressure,
218 Evaluation(0.0), rvw);
219 }
220
228 template <class Evaluation>
229 Evaluation saturationPressure(unsigned /*regionIdx*/,
230 const Evaluation& /*temperature*/,
231 const Evaluation& /*Rv*/) const
232 { return 0.0; /* Not implemented! */ }
233
237 template <class Evaluation>
238 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
239 const Evaluation& temperature,
240 const Evaluation& pressure) const
241 {
242 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
243 }
244
248 template <class Evaluation = Scalar>
249 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
250 const Evaluation& temperature,
251 const Evaluation& pressure,
252 const Evaluation& saltConcentration) const
253 {
254 const Evaluation salinity = salinityFromConcentration(temperature, pressure,
255 saltConcentration);
256 return rvwSat_(regionIdx, temperature, pressure, salinity);
257 }
258
262 template <class Evaluation>
263 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
264 const Evaluation& temperature,
265 const Evaluation& pressure,
266 const Evaluation& /*oilSaturation*/,
267 const Evaluation& /*maxOilSaturation*/) const
268 {
269 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
270 }
271
275 template <class Evaluation>
276 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
277 const Evaluation& temperature,
278 const Evaluation& pressure) const
279 {
280 return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
281 }
282
283 template <class Evaluation>
284 Evaluation diffusionCoefficient(const Evaluation& temperature,
285 const Evaluation& pressure,
286 unsigned /*compIdx*/) const
287 {
288 return BinaryCoeffBrineH2::gasDiffCoeff(temperature, pressure);
289 }
290
291 Scalar gasReferenceDensity(unsigned regionIdx) const
292 { return gasReferenceDensity_[regionIdx]; }
293
294 Scalar oilReferenceDensity(unsigned regionIdx) const
295 { return brineReferenceDensity_[regionIdx]; }
296
297 Scalar waterReferenceDensity(unsigned regionIdx) const
298 { return brineReferenceDensity_[regionIdx]; }
299
300 Scalar salinity(unsigned regionIdx) const
301 { return salinity_[regionIdx]; }
302
303private:
304 template <class LhsEval>
305 LhsEval rvwSat_(unsigned regionIdx,
306 const LhsEval& temperature,
307 const LhsEval& pressure,
308 const LhsEval& salinity) const
309 {
310 // If water vaporization is disabled, we return zero
311 if (!enableVaporization_) {
312 return 0.0;
313 }
314
315 // From Li et al., Int. J. Hydrogen Energ., 2018, water mole fraction is calculated assuming ideal mixing
316 LhsEval pw_sat = H2O::vaporPressure(temperature);
317 LhsEval yH2O = pw_sat / pressure;
318
319 // normalize the phase compositions
320 yH2O = max(0.0, min(1.0, yH2O));
321 return convertXgWToRvw(convertxgWToXgW(yH2O, salinity), regionIdx);
322 }
323
328 template <class LhsEval>
329 LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
330 {
331 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
332 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
333
334 return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
335 }
336
341 template <class LhsEval>
342 LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
343 {
344 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
345 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
346
347 const LhsEval& rho_wG = Rvw * rho_wRef;
348 return rho_wG / (rho_gRef + rho_wG);
349 }
350
354 template <class LhsEval>
355 LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
356 {
357 Scalar M_H2 = H2::molarMass();
358 LhsEval M_Brine = Brine::molarMass(salinity);
359
360 return xgW * M_Brine / (xgW * (M_Brine - M_H2) + M_H2);
361 }
362
363 template <class LhsEval>
364 const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P,
365 const LhsEval& saltConcentration) const
366 {
367 return saltConcentration / H2O::liquidDensity(T, P, true);
368 }
369
370 std::vector<Scalar> gasReferenceDensity_{};
371 std::vector<Scalar> brineReferenceDensity_{};
372 std::vector<Scalar> salinity_{};
373 bool enableVaporization_ = true;
374}; // end class H2GasPvt
375
376} // end namspace Opm
377
378#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:187
A class for the brine fluid properties.
Definition BrineDynamic.hpp:49
static Scalar molarMass()
Definition Component.hpp:93
Definition EclipseState.hpp:62
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:238
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:276
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:211
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:249
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition H2GasPvt.hpp:197
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:229
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:263
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:249
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:285
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:200
Definition Schedule.hpp:101
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:66
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:316
static OPM_HOST_DEVICE Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition SimpleHuDuanH2O.hpp:143
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Scalar Brine< Scalar, H2O >::salinity
Default value for the salinity of the brine (dimensionless).
Definition Brine.hpp:391