opm-common
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 
38 namespace Opm {
39 
40 class EclipseState;
41 class Schedule;
42 
46 template <class Scalar>
47 class H2GasPvt
48 {
51  using H2 = ::Opm::H2<Scalar>;
52  static const bool extrapolate = true;
53 
54 public:
55  // The binary coefficients for brine and H2 used by this fluid system
57 
58  explicit H2GasPvt() = default;
59 
60  explicit H2GasPvt(const std::vector<Scalar>& salinity,
61  Scalar T_ref = 288.71, //(273.15 + 15.56)
62  Scalar P_ref = 101325);
63 
67  void initFromState(const EclipseState& eclState, const Schedule&);
68 
69  void setNumRegions(size_t numRegions);
70 
71  void setVapPars(const Scalar, const Scalar)
72  {
73  }
74 
78  void setReferenceDensities(unsigned regionIdx,
79  Scalar rhoRefBrine,
80  Scalar rhoRefGas,
81  Scalar /*rhoRefWater*/);
82 
89  void setEnableVaporizationWater(bool yesno)
90  { enableVaporization_ = yesno; }
91 
95  void initEnd()
96  {
97  }
98 
102  unsigned numRegions() const
103  { return gasReferenceDensity_.size(); }
104 
105  Scalar hVap(unsigned ) const
106  { return 0.0; }
107 
112  template <class Evaluation>
113  Evaluation internalEnergy(unsigned /*regionIdx*/,
114  const Evaluation& temperature,
115  const Evaluation& pressure,
116  const Evaluation& /*rv*/,
117  const Evaluation& /*rvw*/) const
118  {
119  // use the gasInternalEnergy of H2
120  return H2::gasInternalEnergy(temperature, pressure, extrapolate);
121 
122  // TODO: account for H2O in the gas phase
123  // Init output
124  //Evaluation result = 0;
125 
126  // We have to check that one of RV and RVW is zero since H2STORE works with either GAS/WATER or GAS/OIL system
127  //assert(rv == 0.0 || rvw == 0.0);
128 
129  // Calculate each component contribution and return weighted sum
130  //const Evaluation xBrine = convertRvwToXgW_(max(rvw, rv), regionIdx);
131  //result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
132  //result += (1 - xBrine) * H2::gasInternalEnergy(temperature, pressure, extrapolate);
133  //return result;
134  }
135 
139  template <class Evaluation>
140  Evaluation viscosity(unsigned regionIdx,
141  const Evaluation& temperature,
142  const Evaluation& pressure,
143  const Evaluation& /*Rv*/,
144  const Evaluation& /*Rvw*/) const
145  {
146  return saturatedViscosity(regionIdx, temperature, pressure);
147  }
148 
152  template <class Evaluation>
153  Evaluation saturatedViscosity(unsigned /*regionIdx*/,
154  const Evaluation& temperature,
155  const Evaluation& pressure) const
156  {
157  return H2::gasViscosity(temperature, pressure, extrapolate);
158  }
159 
163  template <class Evaluation>
164  Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
165  const Evaluation& temperature,
166  const Evaluation& pressure,
167  const Evaluation& rv,
168  const Evaluation& rvw) const
169  {
170  // If vaporization is disabled, return H2 gas volume factor
171  if (!enableVaporization_) {
172  return H2::gasDensity(temperature, pressure, extrapolate) /
173  gasReferenceDensity_[regionIdx];
174  }
175 
176  // Use CO2 density for the gas phase.
177  const auto& rhoH2 = H2::gasDensity(temperature, pressure, extrapolate);
178  //const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
179  //The H2STORE option both works for GAS/WATER and GAS/OIL systems
180  //Either rv og rvw should be zero
181  //assert(rv == 0.0 || rvw == 0.0);
182  //const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
183  //const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoH2);
184  return rhoH2 / (gasReferenceDensity_[regionIdx] +
185  max(rvw,rv) * brineReferenceDensity_[regionIdx]);
186  }
187 
191  template <class FluidState, class LhsEval = typename FluidState::ValueType>
192  std::pair<LhsEval, LhsEval>
193  inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
194  {
195  const LhsEval& T = decay<LhsEval>(fluidState.temperature(FluidState::gasPhaseIdx));
196  const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::gasPhaseIdx));
197  const LhsEval& Rv = decay<LhsEval>(fluidState.Rv());
198  const LhsEval& Rvw = decay<LhsEval>(fluidState.Rvw());
199  return { this->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw),
200  this->viscosity(regionIdx, T, p, Rv, Rvw) };
201  }
202 
206  template <class Evaluation>
207  Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
208  const Evaluation& temperature,
209  const Evaluation& pressure) const
210  {
211  const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
212  Evaluation(salinity_[regionIdx]));
213  return inverseFormationVolumeFactor(regionIdx, temperature, pressure,
214  Evaluation(0.0), rvw);
215  }
216 
224  template <class Evaluation>
225  Evaluation saturationPressure(unsigned /*regionIdx*/,
226  const Evaluation& /*temperature*/,
227  const Evaluation& /*Rv*/) const
228  { return 0.0; /* Not implemented! */ }
229 
233  template <class Evaluation>
234  Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
235  const Evaluation& temperature,
236  const Evaluation& pressure) const
237  {
238  return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
239  }
240 
244  template <class Evaluation = Scalar>
245  Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
246  const Evaluation& temperature,
247  const Evaluation& pressure,
248  const Evaluation& saltConcentration) const
249  {
250  const Evaluation salinity = salinityFromConcentration(temperature, pressure,
251  saltConcentration);
252  return rvwSat_(regionIdx, temperature, pressure, salinity);
253  }
254 
258  template <class Evaluation>
259  Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
260  const Evaluation& temperature,
261  const Evaluation& pressure,
262  const Evaluation& /*oilSaturation*/,
263  const Evaluation& /*maxOilSaturation*/) const
264  {
265  return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
266  }
267 
271  template <class Evaluation>
272  Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
273  const Evaluation& temperature,
274  const Evaluation& pressure) const
275  {
276  return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
277  }
278 
279  template <class Evaluation>
280  Evaluation diffusionCoefficient(const Evaluation& temperature,
281  const Evaluation& pressure,
282  unsigned /*compIdx*/) const
283  {
284  return BinaryCoeffBrineH2::gasDiffCoeff(temperature, pressure);
285  }
286 
287  Scalar gasReferenceDensity(unsigned regionIdx) const
288  { return gasReferenceDensity_[regionIdx]; }
289 
290  Scalar oilReferenceDensity(unsigned regionIdx) const
291  { return brineReferenceDensity_[regionIdx]; }
292 
293  Scalar waterReferenceDensity(unsigned regionIdx) const
294  { return brineReferenceDensity_[regionIdx]; }
295 
296  Scalar salinity(unsigned regionIdx) const
297  { return salinity_[regionIdx]; }
298 
299 private:
300  template <class LhsEval>
301  LhsEval rvwSat_(unsigned regionIdx,
302  const LhsEval& temperature,
303  const LhsEval& pressure,
304  const LhsEval& salinity) const
305  {
306  // If water vaporization is disabled, we return zero
307  if (!enableVaporization_) {
308  return 0.0;
309  }
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,
361  const LhsEval& saltConcentration) const
362  {
363  return saltConcentration / H2O::liquidDensity(T, P, true);
364  }
365 
366  std::vector<Scalar> gasReferenceDensity_{};
367  std::vector<Scalar> brineReferenceDensity_{};
368  std::vector<Scalar> salinity_{};
369  bool enableVaporization_ = true;
370 }; // end class H2GasPvt
371 
372 } // end namspace Opm
373 
374 #endif
Properties of pure molecular hydrogen .
A class for the brine fluid properties.
Definition: BrineDynamic.hpp:48
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:259
void initFromState(const EclipseState &eclState, const Schedule &)
Initialize the parameters for H2 gas using an ECL deck.
Definition: H2GasPvt.cpp:51
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:234
static OPM_HOST_DEVICE Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition: SimpleHuDuanH2O.hpp:143
static constexpr Scalar molarMass()
The molar mass in of molecular hydrogen.
Definition: H2.hpp:109
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:193
Definition: Schedule.hpp:100
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:164
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:207
This class represents the Pressure-Volume-Temperature relations of the gas phase for H2...
Definition: H2GasPvt.hpp:47
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
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase...
Definition: H2GasPvt.hpp:89
void initEnd()
Finish initializing the oil phase PVT properties.
Definition: H2GasPvt.hpp:95
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
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition: H2GasPvt.cpp:91
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: H2GasPvt.hpp:102
Definition: EclipseState.hpp:66
Binary coefficients for brine and H2.
Definition: Brine_H2.hpp:41
A simple version of pure water with density from Hu et al.
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
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:245
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:225
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
A simple version of pure water with density from Hu et al.
Definition: SimpleHuDuanH2O.hpp:65
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:140
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:113
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:153
A class for the brine fluid properties.
Binary coefficients for brine and H2.
static Evaluation gasDensity(Evaluation temperature, Evaluation pressure, bool extrapolate=false)
The density of at a given pressure and temperature.
Definition: H2.hpp:200
static Scalar molarMass()
The molar mass in of the component.
Definition: Component.hpp:93
Properties of pure molecular hydrogen .
Definition: H2.hpp:89
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:272
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of H2 [J/kg].
Definition: H2.hpp:249