27#ifndef OPM_CO2_GAS_PVT_HPP
28#define OPM_CO2_GAS_PVT_HPP
31#include <opm/common/TimingMacros.hpp>
32#include <opm/common/ErrorMacros.hpp>
33#include <opm/common/utility/gpuDecorators.hpp>
40#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
41#include <opm/material/components/CO2Tables.hpp>
42#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
43#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
55template <
class Scalar,
class ParamsT,
class ContainerT>
60 template <
class ViewType,
class OutputParams,
class InputParams,
class ContainerType,
class Scalar>
61 Co2GasPvt<Scalar, OutputParams, ViewType>
62 make_view(Co2GasPvt<Scalar, InputParams, ContainerType>&);
69template <
class Scalar,
class ParamsT = Opm::CO2Tables<
double, std::vector<
double>>,
class ContainerT = std::vector<Scalar>>
75 using Params = ParamsT;
76 static constexpr bool extrapolate =
true;
84 explicit Co2GasPvt(
const ContainerT& salinity,
85 int activityModel = 3,
86 int thermalMixingModel = 1,
87 Scalar T_ref = 288.71,
88 Scalar P_ref = 101325);
91 const ContainerT& brineReferenceDensity,
92 const ContainerT& gasReferenceDensity,
93 const ContainerT& salinity,
94 bool enableEzrokhiDensity,
95 bool enableVaporization,
97 Co2StoreConfig::GasMixingType gastype)
98 : brineReferenceDensity_(brineReferenceDensity)
99 , gasReferenceDensity_(gasReferenceDensity)
100 , salinity_(salinity)
101 , enableEzrokhiDensity_(enableEzrokhiDensity)
102 , enableVaporization_(enableVaporization)
103 , activityModel_(activityModel)
107 assert(enableEzrokhiDensity ==
false &&
"Ezrokhi density not supported by GPUs");
116 OPM_HOST_DEVICE
void setVapPars(
const Scalar,
const Scalar)
135 { enableVaporization_ = yesno; }
158 {
return gasReferenceDensity_.size(); }
160 OPM_HOST_DEVICE Scalar hVap(
unsigned )
const
166 template <
class Evaluation>
168 const Evaluation& temperature,
169 const Evaluation& pressure,
170 const Evaluation& rv,
171 const Evaluation& rvw)
const
174 if (gastype_ == Co2StoreConfig::GasMixingType::NONE) {
179 assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
181 Evaluation result = 0;
184 assert(rv == 0.0 || rvw == 0.0);
185 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
195 template <
class Evaluation>
196 OPM_HOST_DEVICE Evaluation
viscosity(
unsigned regionIdx,
197 const Evaluation& temperature,
198 const Evaluation& pressure,
200 const Evaluation& )
const
206 template <
class Evaluation>
208 const Evaluation& temperature,
209 const Evaluation& pressure)
const
219 template <
class Evaluation>
221 const Evaluation& temperature,
222 const Evaluation& pressure,
223 const Evaluation& rv,
224 const Evaluation& rvw)
const
226 OPM_TIMEFUNCTION_LOCAL();
227 if (!enableVaporization_) {
228 return CO2::gasDensity(co2Tables, temperature, pressure, extrapolate) /
229 gasReferenceDensity_[regionIdx];
233 const auto& rhoCo2 =
CO2::gasDensity(co2Tables, temperature, pressure, extrapolate);
240 return rhoCo2 / (gasReferenceDensity_[regionIdx] +
241 max(rvw,rv) * brineReferenceDensity_[regionIdx]);
247 template <
class Evaluation>
249 const Evaluation& temperature,
250 const Evaluation& pressure)
const
252 OPM_TIMEFUNCTION_LOCAL();
253 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
254 Evaluation(salinity_[regionIdx]));
256 pressure, Evaluation(0.0), rvw);
266 template <
class Evaluation>
269 const Evaluation& )
const
275 template <
class Evaluation>
277 const Evaluation& temperature,
278 const Evaluation& pressure)
const
279 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
284 template <
class Evaluation = Scalar>
286 const Evaluation& temperature,
287 const Evaluation& pressure,
288 const Evaluation& saltConcentration)
const
290 OPM_TIMEFUNCTION_LOCAL();
291 const Evaluation salinity = salinityFromConcentration(temperature, pressure,
293 return rvwSat_(regionIdx, temperature, pressure, salinity);
299 template <
class Evaluation>
301 const Evaluation& temperature,
302 const Evaluation& pressure,
304 const Evaluation& )
const
305 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
310 template <
class Evaluation>
312 const Evaluation& temperature,
313 const Evaluation& pressure)
const
314 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
316 template <
class Evaluation>
317 OPM_HOST_DEVICE Evaluation diffusionCoefficient(
const Evaluation& temperature,
318 const Evaluation& pressure,
324 OPM_HOST_DEVICE Scalar gasReferenceDensity(
unsigned regionIdx)
const
325 {
return gasReferenceDensity_[regionIdx]; }
327 OPM_HOST_DEVICE Scalar oilReferenceDensity(
unsigned regionIdx)
const
328 {
return brineReferenceDensity_[regionIdx]; }
330 OPM_HOST_DEVICE Scalar waterReferenceDensity(
unsigned regionIdx)
const
331 {
return brineReferenceDensity_[regionIdx]; }
333 OPM_HOST_DEVICE Scalar salinity(
unsigned regionIdx)
const
334 {
return salinity_[regionIdx]; }
336 void setEzrokhiDenCoeff(
const std::vector<EzrokhiTable>& denaqa);
339 OPM_HOST_DEVICE
const ContainerT& getBrineReferenceDensity()
const
340 {
return brineReferenceDensity_; }
342 OPM_HOST_DEVICE
const ContainerT& getGasReferenceDensity()
const
343 {
return gasReferenceDensity_; }
345 OPM_HOST_DEVICE
const ContainerT& getSalinity()
const
346 {
return salinity_; }
348 OPM_HOST_DEVICE
bool getEnableEzrokhiDensity()
const
349 {
return enableEzrokhiDensity_; }
351 OPM_HOST_DEVICE
bool getEnableVaporization()
const
352 {
return enableVaporization_; }
354 OPM_HOST_DEVICE
int getActivityModel()
const
355 {
return activityModel_; }
357 OPM_HOST_DEVICE Co2StoreConfig::GasMixingType getGasType()
const
360 OPM_HOST_DEVICE
const Params& getParams()
const
361 {
return co2Tables; }
364 template <
class LhsEval>
365 LhsEval ezrokhiExponent_(
const LhsEval& temperature,
366 const ContainerT& ezrokhiCoeff)
const
368 const LhsEval& tempC = temperature - 273.15;
369 return ezrokhiCoeff[0] + tempC * (ezrokhiCoeff[1] + ezrokhiCoeff[2] * tempC);
372 template <
class LhsEval>
373 OPM_HOST_DEVICE LhsEval rvwSat_(
unsigned regionIdx,
374 const LhsEval& temperature,
375 const LhsEval& pressure,
376 const LhsEval& salinity)
const
378 OPM_TIMEFUNCTION_LOCAL();
379 if (!enableVaporization_) {
398 xgH2O = max(0.0, min(1.0, xgH2O));
400 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
407 template <
class LhsEval>
408 OPM_HOST_DEVICE LhsEval convertXgWToRvw(
const LhsEval& XgW,
unsigned regionIdx)
const
410 OPM_TIMEFUNCTION_LOCAL();
411 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
412 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
414 return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
421 template <
class LhsEval>
422 OPM_HOST_DEVICE LhsEval convertRvwToXgW_(
const LhsEval& Rvw,
unsigned regionIdx)
const
424 OPM_TIMEFUNCTION_LOCAL();
425 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
426 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
428 const LhsEval& rho_wG = Rvw * rho_wRef;
429 return rho_wG / (rho_gRef + rho_wG);
434 template <
class LhsEval>
435 OPM_HOST_DEVICE LhsEval convertxgWToXgW(
const LhsEval& xgW,
const LhsEval& salinity)
const
437 OPM_TIMEFUNCTION_LOCAL();
441 return xgW * M_Brine / (xgW * (M_Brine - M_CO2) + M_CO2);
444 template <
class ViewType,
class OutputParams,
class InputParams,
class ContainerType,
class ScalarT>
445 friend Co2GasPvt<ScalarT, OutputParams, ViewType>
446 gpuistl::make_view(Co2GasPvt<ScalarT, InputParams, ContainerType>&);
448 template <
class LhsEval>
449 OPM_HOST_DEVICE
const LhsEval salinityFromConcentration(
const LhsEval&T,
const LhsEval& P,
450 const LhsEval& saltConcentration)
const
453 ContainerT brineReferenceDensity_{};
454 ContainerT gasReferenceDensity_{};
455 ContainerT salinity_{};
456 ContainerT ezrokhiDenNaClCoeff_{};
457 bool enableEzrokhiDensity_ =
false;
458 bool enableVaporization_ =
true;
459 int activityModel_{};
460 Co2StoreConfig::GasMixingType gastype_{};
466namespace Opm::gpuistl{
467 template<
class GPUContainer,
class Params,
class ScalarT>
468 Co2GasPvt<ScalarT, Params, GPUContainer>
469 copy_to_gpu(
const Co2GasPvt<ScalarT>& cpuCo2)
471 return Co2GasPvt<ScalarT, Params, GPUContainer>(
472 copy_to_gpu<GPUContainer>(cpuCo2.getParams()),
473 GPUContainer(cpuCo2.getBrineReferenceDensity()),
474 GPUContainer(cpuCo2.getGasReferenceDensity()),
475 GPUContainer(cpuCo2.getSalinity()),
476 cpuCo2.getEnableEzrokhiDensity(),
477 cpuCo2.getEnableVaporization(),
478 cpuCo2.getActivityModel(),
479 cpuCo2.getGasType());
482 template <
class ViewType,
class OutputParams,
class InputParams,
class ContainerType,
class ScalarT>
483 Co2GasPvt<ScalarT, OutputParams, ViewType>
484 make_view(Co2GasPvt<ScalarT, InputParams, ContainerType>& co2GasPvt)
486 using ContainedType =
typename ContainerType::value_type;
488 ViewType newBrineReferenceDensity = make_view<ContainedType>(co2GasPvt.brineReferenceDensity_);
489 ViewType newGasReferenceDensity = make_view<ContainedType>(co2GasPvt.gasReferenceDensity_);
490 ViewType newSalinity = make_view<ContainedType>(co2GasPvt.salinity_);
492 return Co2GasPvt<ScalarT, OutputParams, ViewType>(
493 make_view<ViewType>(co2GasPvt.co2Tables),
494 newBrineReferenceDensity,
495 newGasReferenceDensity,
497 co2GasPvt.getEnableEzrokhiDensity(),
498 co2GasPvt.getEnableVaporization(),
499 co2GasPvt.getActivityModel(),
500 co2GasPvt.getGasType());
A class for the brine fluid properties.
Binary coefficients for brine and CO2.
A class for the CO2 fluid properties.
A simple version of pure water with density from Hu et al.
Binary coefficients for brine and CO2.
Definition Brine_CO2.hpp:46
static OPM_HOST_DEVICE void calculateMoleFractions(const CO2Params ¶ms, const Evaluation &temperature, const Evaluation &pg, const Evaluation &salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O, const int &activityModel, bool extrapolate=false)
Returns the mol (!) fraction of CO2 in the liquid phase and the mol_ (!) fraction of H2O in the gas p...
Definition Brine_CO2.hpp:101
static OPM_HOST_DEVICE Evaluation gasDiffCoeff(const CO2Params ¶ms, const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Binary diffusion coefficent [m^2/s] of water in the CO2 phase.
Definition Brine_CO2.hpp:60
A class for the brine fluid properties.
Definition BrineDynamic.hpp:49
A class for the CO2 fluid properties.
Definition CO2.hpp:58
static OPM_HOST_DEVICE Evaluation gasDensity(const Params ¶ms, const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of CO2 at a given pressure and temperature [kg/m^3].
Definition CO2.hpp:222
static OPM_HOST_DEVICE Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:73
static OPM_HOST_DEVICE Evaluation gasInternalEnergy(const Params ¶ms, const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:195
static OPM_HOST_DEVICE Evaluation gasViscosity(const Params ¶ms, Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:249
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition Co2GasPvt.hpp:71
OPM_HOST_DEVICE void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.hpp:150
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:196
OPM_HOST_DEVICE void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.cpp:124
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:220
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:167
OPM_HOST_DEVICE unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:157
OPM_HOST_DEVICE void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition Co2GasPvt.cpp:135
OPM_HOST_DEVICE Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of water saturated gas at given pressure.
Definition Co2GasPvt.hpp:248
OPM_HOST_DEVICE void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition Co2GasPvt.cpp:152
OPM_HOST_DEVICE void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:134
OPM_HOST_DEVICE Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the brine com...
Definition Co2GasPvt.hpp:267
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:311
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:276
OPM_HOST_DEVICE 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 Co2GasPvt.hpp:300
OPM_HOST_DEVICE 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 phase.
Definition Co2GasPvt.hpp:285
OPM_HOST_DEVICE Evaluation saturatedViscosity(unsigned, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of fluid phase at saturated conditions.
Definition Co2GasPvt.hpp:207
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
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 gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition SimpleHuDuanH2O.hpp:227
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30