27#ifndef OPM_CO2_GAS_PVT_HPP
28#define OPM_CO2_GAS_PVT_HPP
31#include <opm/common/ErrorMacros.hpp>
38#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
52template <
class Scalar>
58 static constexpr bool extrapolate =
true;
66 Co2GasPvt(
const std::vector<Scalar>& salinity,
67 int activityModel = 3,
68 int thermalMixingModel = 1,
69 Scalar T_ref = 288.71,
70 Scalar P_ref = 101325)
74 if (T_ref != Scalar(288.71) || P_ref != Scalar(1.01325e5)) {
75 OPM_THROW(std::runtime_error,
76 "BrineCo2Pvt class can only be used with default reference state (T, P) = (288.71 K, 1.01325e5 Pa)!");
81 int num_regions = salinity_.size();
82 setNumRegions(num_regions);
83 for (
int i = 0; i < num_regions; ++i) {
100 void setVapPars(
const Scalar,
const Scalar)
112 gasReferenceDensity_[regionIdx] = rhoRefGas;
113 brineReferenceDensity_[regionIdx] = rhoRefBrine;;
123 { enableVaporization_ = yesno; }
131 if (activityModel > 3 || activityModel < 1) {
132 OPM_THROW(std::runtime_error,
"The salt activity model options are 1, 2 or 3");
134 activityModel_ = activityModel;
145 if (thermalMixingModel == 0)
146 gastype_ = Co2StoreConfig::GasMixingType::NONE;
148 else if (thermalMixingModel == 1)
149 gastype_ = Co2StoreConfig::GasMixingType::IDEAL;
151 OPM_THROW(std::runtime_error,
"The thermal mixing model options are 0 and 1");
166 {
return gasReferenceDensity_.size(); }
171 template <
class Evaluation>
173 const Evaluation& temperature,
174 const Evaluation& pressure,
175 const Evaluation& rv,
176 const Evaluation& rvw)
const
180 if (gastype_ == Co2StoreConfig::GasMixingType::NONE)
184 assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
186 Evaluation result = 0;
189 assert(rv == 0.0 || rvw == 0.0);
190 const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
199 template <
class Evaluation>
201 const Evaluation& temperature,
202 const Evaluation& pressure,
204 const Evaluation& )
const
210 template <
class Evaluation>
212 const Evaluation& temperature,
213 const Evaluation& pressure)
const
223 template <
class Evaluation>
225 const Evaluation& temperature,
226 const Evaluation& pressure,
227 const Evaluation& rv,
228 const Evaluation& rvw)
const
230 OPM_TIMEFUNCTION_LOCAL();
231 if (!enableVaporization_)
232 return CO2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
235 const auto& rhoCo2 =
CO2::gasDensity(temperature, pressure, extrapolate);
242 return rhoCo2/(gasReferenceDensity_[regionIdx] + max(rvw,rv)*brineReferenceDensity_[regionIdx]);
248 template <
class Evaluation>
250 const Evaluation& temperature,
251 const Evaluation& pressure)
const
253 OPM_TIMEFUNCTION_LOCAL();
254 const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
264 template <
class Evaluation>
267 const Evaluation& )
const
273 template <
class Evaluation>
275 const Evaluation& temperature,
276 const Evaluation& pressure)
const
277 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
282 template <
class Evaluation = Scalar>
284 const Evaluation& temperature,
285 const Evaluation& pressure,
286 const Evaluation& saltConcentration)
const
288 OPM_TIMEFUNCTION_LOCAL();
289 const Evaluation salinity = salinityFromConcentration(temperature, pressure, saltConcentration);
290 return rvwSat_(regionIdx, temperature, pressure, salinity);
296 template <
class Evaluation>
298 const Evaluation& temperature,
299 const Evaluation& pressure,
301 const Evaluation& )
const
302 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
307 template <
class Evaluation>
309 const Evaluation& temperature,
310 const Evaluation& pressure)
const
311 {
return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
313 template <
class Evaluation>
314 Evaluation diffusionCoefficient(
const Evaluation& temperature,
315 const Evaluation& pressure,
321 Scalar gasReferenceDensity(
unsigned regionIdx)
const
322 {
return gasReferenceDensity_[regionIdx]; }
324 Scalar oilReferenceDensity(
unsigned regionIdx)
const
325 {
return brineReferenceDensity_[regionIdx]; }
327 Scalar waterReferenceDensity(
unsigned regionIdx)
const
328 {
return brineReferenceDensity_[regionIdx]; }
330 Scalar salinity(
unsigned regionIdx)
const
331 {
return salinity_[regionIdx]; }
335 template <
class LhsEval>
336 LhsEval rvwSat_(
unsigned regionIdx,
337 const LhsEval& temperature,
338 const LhsEval& pressure,
339 const LhsEval& salinity)
const
341 OPM_TIMEFUNCTION_LOCAL();
342 if (!enableVaporization_)
359 xgH2O = max(0.0, min(1.0, xgH2O));
361 return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
368 template <
class LhsEval>
369 LhsEval convertXgWToRvw(
const LhsEval& XgW,
unsigned regionIdx)
const
371 OPM_TIMEFUNCTION_LOCAL();
372 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
373 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
375 return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
382 template <
class LhsEval>
383 LhsEval convertRvwToXgW_(
const LhsEval& Rvw,
unsigned regionIdx)
const
385 OPM_TIMEFUNCTION_LOCAL();
386 Scalar rho_wRef = brineReferenceDensity_[regionIdx];
387 Scalar rho_gRef = gasReferenceDensity_[regionIdx];
389 const LhsEval& rho_wG = Rvw*rho_wRef;
390 return rho_wG/(rho_gRef + rho_wG);
395 template <
class LhsEval>
396 LhsEval convertxgWToXgW(
const LhsEval& xgW,
const LhsEval& salinity)
const
398 OPM_TIMEFUNCTION_LOCAL();
402 return xgW*M_Brine / (xgW*(M_Brine - M_CO2) + M_CO2);
405 template <
class LhsEval>
406 const LhsEval salinityFromConcentration(
const LhsEval&T,
const LhsEval& P,
const LhsEval& saltConcentration)
const
409 std::vector<Scalar> brineReferenceDensity_;
410 std::vector<Scalar> gasReferenceDensity_;
411 std::vector<Scalar> salinity_;
412 bool enableVaporization_ =
true;
414 Co2StoreConfig::GasMixingType gastype_;
A class for the brine fluid properties.
Binary coefficients for brine and CO2.
A class for the CO2 fluid properties.
A central place for various physical constants occuring in some equations.
A simple version of pure water with density from Hu et al.
Binary coefficients for brine and CO2.
Definition Brine_CO2.hpp:45
static void calculateMoleFractions(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:100
static Evaluation gasDiffCoeff(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:59
A class for the brine fluid properties.
Definition BrineDynamic.hpp:48
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in .
Definition BrineDynamic.hpp:263
A class for the CO2 fluid properties.
Definition CO2.hpp:54
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:208
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:71
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:180
static Evaluation gasDensity(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:194
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition Co2GasPvt.hpp:54
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:172
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:249
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:297
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:211
void initFromState(const EclipseState &eclState, const Schedule &)
Initialize the parameters for CO2 gas using an ECL deck.
Definition Co2GasPvt.cpp:37
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:274
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.hpp:107
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:308
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.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 phase.
Definition Co2GasPvt.hpp:283
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:265
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:122
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:165
void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition Co2GasPvt.hpp:140
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:200
void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition Co2GasPvt.hpp:128
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:224
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
Definition Schedule.hpp:88
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The density of pure water at a given pressure and temperature .
Definition SimpleHuDuanH2O.hpp:310
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition SimpleHuDuanH2O.hpp:224
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30