27 #ifndef OPM_CO2_GAS_PVT_HPP 28 #define OPM_CO2_GAS_PVT_HPP 30 #include <opm/common/utility/VectorWithDefaultAllocator.hpp> 33 #include <opm/common/TimingMacros.hpp> 34 #include <opm/common/ErrorMacros.hpp> 35 #include <opm/common/utility/gpuDecorators.hpp> 43 #include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp> 44 #include <opm/material/components/CO2Tables.hpp> 45 #include <opm/input/eclipse/EclipseState/EclipseState.hpp> 46 #include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp> 58 template <
class Scalar,
template<
class>
class Storage>
64 template <
class Scalar>
73 template <
class Scalar,
template<
class>
class Storage = VectorWithDefaultAllocator>
80 using ContainerT = Storage<Scalar>;
81 static constexpr
bool extrapolate =
true;
89 explicit Co2GasPvt(
const ContainerT& salinity,
90 int activityModel = 3,
91 int thermalMixingModel = 1,
92 Scalar T_ref = 288.71,
93 Scalar P_ref = 101325);
96 const ContainerT& brineReferenceDensity,
97 const ContainerT& gasReferenceDensity,
98 const ContainerT& salinity,
99 bool enableEzrokhiDensity,
100 bool enableVaporization,
102 Co2StoreConfig::GasMixingType gastype)
103 : brineReferenceDensity_(brineReferenceDensity)
104 , gasReferenceDensity_(gasReferenceDensity)
105 , salinity_(salinity)
106 , enableEzrokhiDensity_(enableEzrokhiDensity)
107 , enableVaporization_(enableVaporization)
108 , activityModel_(activityModel)
112 assert(enableEzrokhiDensity ==
false &&
"Ezrokhi density not supported by GPUs");
119 OPM_HOST_DEVICE
void setVapPars(
const Scalar,
const Scalar)
124 OPM_HOST_DEVICE
static constexpr
bool isActive()
144 { enableVaporization_ = yesno; }
167 {
return gasReferenceDensity_.size(); }
169 OPM_HOST_DEVICE Scalar hVap(
unsigned )
const 181 template <
class Evaluation>
183 const Evaluation& temperature,
184 const Evaluation& pressure,
185 const Evaluation& rv,
186 const Evaluation& rvw)
const 189 if (gastype_ == Co2StoreConfig::GasMixingType::NONE) {
194 assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
196 Evaluation result = 0;
199 assert(rv == 0.0 || rvw == 0.0);
200 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
210 template <
class Evaluation>
211 OPM_HOST_DEVICE Evaluation
viscosity(
unsigned regionIdx,
212 const Evaluation& temperature,
213 const Evaluation& pressure,
215 const Evaluation& )
const 221 template <
class Evaluation>
223 const Evaluation& temperature,
224 const Evaluation& pressure)
const 234 template <
class Evaluation>
236 const Evaluation& temperature,
237 const Evaluation& pressure,
238 const Evaluation& rv,
239 const Evaluation& rvw)
const 241 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
242 if (!enableVaporization_) {
243 return CO2::gasDensity(co2Tables, temperature, pressure, extrapolate) /
244 gasReferenceDensity_[regionIdx];
248 const auto& rhoCo2 =
CO2::gasDensity(co2Tables, temperature, pressure, extrapolate);
255 return rhoCo2 / (gasReferenceDensity_[regionIdx] +
256 max(rvw,rv) * brineReferenceDensity_[regionIdx]);
262 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
263 OPM_HOST_DEVICE std::pair<LhsEval, LhsEval>
266 const LhsEval& T = decay<LhsEval>(fluidState.temperature(FluidState::gasPhaseIdx));
267 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::gasPhaseIdx));
268 const LhsEval& Rv = decay<LhsEval>(fluidState.Rv());
269 const LhsEval& Rvw = decay<LhsEval>(fluidState.Rvw());
271 this->
viscosity(regionIdx, T, p, Rv, Rvw) };
277 template <
class Evaluation>
279 const Evaluation& temperature,
280 const Evaluation& pressure)
const 282 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
283 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
284 Evaluation(salinity_[regionIdx]));
286 pressure, Evaluation(0.0), rvw);
296 template <
class Evaluation>
299 const Evaluation& )
const 305 template <
class Evaluation>
307 const Evaluation& temperature,
308 const Evaluation& pressure)
const 309 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
314 template <
class Evaluation = Scalar>
316 const Evaluation& temperature,
317 const Evaluation& pressure,
318 const Evaluation& saltConcentration)
const 320 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
321 const Evaluation salinity = salinityFromConcentration(temperature, pressure,
323 return rvwSat_(regionIdx, temperature, pressure, salinity);
329 template <
class Evaluation>
331 const Evaluation& temperature,
332 const Evaluation& pressure,
334 const Evaluation& )
const 335 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
340 template <
class Evaluation>
342 const Evaluation& temperature,
343 const Evaluation& pressure)
const 344 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
346 template <
class Evaluation>
347 OPM_HOST_DEVICE Evaluation diffusionCoefficient(
const Evaluation& temperature,
348 const Evaluation& pressure,
354 OPM_HOST_DEVICE Scalar gasReferenceDensity(
unsigned regionIdx)
const 356 return gasReferenceDensity_[regionIdx];
359 OPM_HOST_DEVICE Scalar oilReferenceDensity(
unsigned regionIdx)
const 360 {
return brineReferenceDensity_[regionIdx]; }
362 OPM_HOST_DEVICE Scalar waterReferenceDensity(
unsigned regionIdx)
const 363 {
return brineReferenceDensity_[regionIdx]; }
365 OPM_HOST_DEVICE Scalar salinity(
unsigned regionIdx)
const 366 {
return salinity_[regionIdx]; }
368 void setEzrokhiDenCoeff(
const std::vector<EzrokhiTable>& denaqa);
371 OPM_HOST_DEVICE
const ContainerT& getBrineReferenceDensity()
const 372 {
return brineReferenceDensity_; }
374 OPM_HOST_DEVICE
const ContainerT& getGasReferenceDensity()
const 375 {
return gasReferenceDensity_; }
377 OPM_HOST_DEVICE
const ContainerT& getSalinity()
const 378 {
return salinity_; }
380 OPM_HOST_DEVICE
bool getEnableEzrokhiDensity()
const 381 {
return enableEzrokhiDensity_; }
383 OPM_HOST_DEVICE
bool getEnableVaporization()
const 384 {
return enableVaporization_; }
386 OPM_HOST_DEVICE
int getActivityModel()
const 387 {
return activityModel_; }
389 OPM_HOST_DEVICE Co2StoreConfig::GasMixingType getGasType()
const 392 OPM_HOST_DEVICE
const Params& getParams()
const 393 {
return co2Tables; }
396 template <
class LhsEval>
397 LhsEval ezrokhiExponent_(
const LhsEval& temperature,
398 const ContainerT& ezrokhiCoeff)
const 400 const LhsEval& tempC = temperature - 273.15;
401 return ezrokhiCoeff[0] + tempC * (ezrokhiCoeff[1] + ezrokhiCoeff[2] * tempC);
404 template <
class LhsEval>
405 OPM_HOST_DEVICE LhsEval rvwSat_(
unsigned regionIdx,
406 const LhsEval& temperature,
407 const LhsEval& pressure,
408 const LhsEval& salinity)
const 410 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
411 if (!enableVaporization_) {
430 xgH2O = max(0.0, min(1.0, xgH2O));
432 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
439 template <
class LhsEval>
440 OPM_HOST_DEVICE LhsEval convertXgWToRvw(
const LhsEval& XgW,
unsigned regionIdx)
const 442 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
443 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
444 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
446 return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
453 template <
class LhsEval>
454 OPM_HOST_DEVICE LhsEval convertRvwToXgW_(
const LhsEval& Rvw,
unsigned regionIdx)
const 456 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
457 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
458 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
460 const LhsEval& rho_wG = Rvw * rho_wRef;
461 return rho_wG / (rho_gRef + rho_wG);
466 template <
class LhsEval>
467 OPM_HOST_DEVICE LhsEval convertxgWToXgW(
const LhsEval& xgW,
const LhsEval& salinity)
const 469 OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
473 return xgW * M_Brine / (xgW * (M_Brine - M_CO2) + M_CO2);
477 template <
class ScalarT>
478 friend Co2GasPvt<ScalarT, gpuistl::GpuView>
479 gpuistl::make_view(Co2GasPvt<ScalarT, gpuistl::GpuBuffer>&);
482 template <
class LhsEval>
483 OPM_HOST_DEVICE
const LhsEval salinityFromConcentration(
const LhsEval&T,
const LhsEval& P,
484 const LhsEval& saltConcentration)
const 487 ContainerT brineReferenceDensity_{};
488 ContainerT gasReferenceDensity_{};
489 ContainerT salinity_{};
490 ContainerT ezrokhiDenNaClCoeff_{};
491 bool enableEzrokhiDensity_ =
false;
492 bool enableVaporization_ =
true;
493 int activityModel_{};
494 Co2StoreConfig::GasMixingType gastype_{};
502 template<
class ScalarT>
503 Co2GasPvt<ScalarT, GpuBuffer>
506 return Co2GasPvt<ScalarT, GpuBuffer>(
508 GpuBuffer<ScalarT>(cpuCo2.getBrineReferenceDensity()),
509 GpuBuffer<ScalarT>(cpuCo2.getGasReferenceDensity()),
510 GpuBuffer<ScalarT>(cpuCo2.getSalinity()),
511 cpuCo2.getEnableEzrokhiDensity(),
512 cpuCo2.getEnableVaporization(),
513 cpuCo2.getActivityModel(),
514 cpuCo2.getGasType());
517 template <
class ScalarT>
518 Co2GasPvt<ScalarT, GpuView>
519 make_view(Co2GasPvt<ScalarT, GpuBuffer>& co2GasPvt)
521 using ContainedType = ScalarT;
523 auto newBrineReferenceDensity = make_view<ContainedType>(co2GasPvt.brineReferenceDensity_);
524 auto newGasReferenceDensity = make_view<ContainedType>(co2GasPvt.gasReferenceDensity_);
525 auto newSalinity = make_view<ContainedType>(co2GasPvt.salinity_);
527 return Co2GasPvt<ScalarT, GpuView>(
529 newBrineReferenceDensity,
530 newGasReferenceDensity,
532 co2GasPvt.getEnableEzrokhiDensity(),
533 co2GasPvt.getEnableVaporization(),
534 co2GasPvt.getActivityModel(),
535 co2GasPvt.getGasType());
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:65
Material properties of pure water .
Definition: H2O.hpp:64
static OPM_HOST_DEVICE Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:73
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
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:330
A class for the brine fluid properties.
Definition: BrineDynamic.hpp:48
A class for the CO2 fluid properties.
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:122
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
OPM_HOST_DEVICE void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition: Co2GasPvt.cpp:150
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:306
Definition: Schedule.hpp:102
OPM_HOST_DEVICE std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx) const
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition: Co2GasPvt.hpp:264
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:341
OPM_HOST_DEVICE unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: Co2GasPvt.hpp:166
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
PiecewiseLinearTwoPhaseMaterialParams< TraitsT, ViewType > make_view(PiecewiseLinearTwoPhaseMaterialParams< TraitsT, ContainerType > ¶ms)
this function is intented to make a GPU friendly view of the PiecewiseLinearTwoPhaseMaterialParams ...
Definition: PiecewiseLinearTwoPhaseMaterialParams.hpp:312
A class for the brine fluid properties.
Definition: Brine.hpp:47
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Convience header to include the gpuistl headers if HAVE_CUDA is defined.
Binary coefficients for brine and CO2.
Definition: Brine_CO2.hpp:48
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
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:143
Definition: EclipseState.hpp:66
A class for the CO2 fluid properties.
Definition: CO2.hpp:57
OPM_HOST_DEVICE void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition: Co2GasPvt.cpp:133
A simple version of pure water with density from Hu et al.
static OPM_HOST_DEVICE constexpr bool mixingEnergy()
Indicates whether this PVT object computes the gas internal energy via a thermal mixing model...
Definition: Co2GasPvt.hpp:175
static OPM_HOST_DEVICE Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition: SimpleHuDuanH2O.hpp:228
A simple version of pure water with density from Hu et al.
Definition: SimpleHuDuanH2O.hpp:65
A class for the brine fluid properties.
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2...
Definition: Co2GasPvt.hpp:59
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:182
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:113
PiecewiseLinearTwoPhaseMaterialParams< TraitsT, GPUContainerType > copy_to_gpu(const PiecewiseLinearTwoPhaseMaterialParams< TraitsT > ¶ms)
Move a PiecewiseLinearTwoPhaseMaterialParams-object to the GPU.
Definition: PiecewiseLinearTwoPhaseMaterialParams.hpp:285
Definition: PiecewiseLinearTwoPhaseMaterialParams.hpp:47
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:297
Binary coefficients for brine and CO2.
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:278
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:235
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:315
static Scalar molarMass()
The molar mass in of the component.
Definition: Component.hpp:93
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:211
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:222
OPM_HOST_DEVICE void initEnd()
Finish initializing the co2 phase PVT properties.
Definition: Co2GasPvt.hpp:159