27#ifndef OPM_BRINE_CO2_PVT_HPP
28#define OPM_BRINE_CO2_PVT_HPP
31#include <opm/common/TimingMacros.hpp>
32#include <opm/common/ErrorMacros.hpp>
44#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
60template <
class Scalar>
63 static constexpr bool extrapolate =
true;
83 explicit BrineCo2Pvt(
const std::vector<Scalar>& salinity,
84 int activityModel = 3,
85 int thermalMixingModelSalt = 1,
86 int thermalMixingModelLiquid = 2,
87 Scalar T_ref = 288.71,
88 Scalar P_ref = 101325);
100 void setVapPars(
const Scalar,
const Scalar)
126 { enableDissolution_ = yesno; }
135 { enableSaltConcentration_ = yesno; }
147 void setEzrokhiDenCoeff(
const std::vector<EzrokhiTable>& denaqa);
149 void setEzrokhiViscCoeff(
const std::vector<EzrokhiTable>& viscaqa);
155 {
return brineReferenceDensity_.size(); }
157 Scalar hVap(
unsigned )
const{
164 template <
class Evaluation>
166 const Evaluation& temperature,
167 const Evaluation& pressure,
168 const Evaluation& Rs,
169 const Evaluation& saltConcentration)
const
171 OPM_TIMEFUNCTION_LOCAL();
172 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature, pressure, saltConcentration);
173 const Evaluation xlCO2 = convertRsToXoG_(Rs,regionIdx);
174 return (liquidEnthalpyBrineCO2_(temperature,
178 - pressure / density(regionIdx, temperature, pressure, Rs, salinity ));
183 template <
class Evaluation>
185 const Evaluation& temperature,
186 const Evaluation& pressure,
187 const Evaluation& Rs)
const
189 OPM_TIMEFUNCTION_LOCAL();
190 const Evaluation xlCO2 = convertRsToXoG_(Rs,regionIdx);
191 return (liquidEnthalpyBrineCO2_(temperature,
193 Evaluation(salinity_[regionIdx]),
195 - pressure / density(regionIdx, temperature, pressure, Rs, Evaluation(salinity_[regionIdx])));
201 template <
class Evaluation>
203 const Evaluation& temperature,
204 const Evaluation& pressure,
205 const Evaluation& )
const
214 template <
class Evaluation>
216 const Evaluation& temperature,
217 const Evaluation& pressure,
218 const Evaluation& saltConcentration)
const
220 OPM_TIMEFUNCTION_LOCAL();
221 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature, pressure, saltConcentration);
222 if (enableEzrokhiViscosity_) {
224 const Evaluation& nacl_exponent = ezrokhiExponent_(temperature, ezrokhiViscNaClCoeff_);
225 return mu_pure * pow(10.0, nacl_exponent * salinity);
235 template <
class Evaluation>
237 const Evaluation& temperature,
238 const Evaluation& pressure,
240 const Evaluation& saltConcentration)
const
242 OPM_TIMEFUNCTION_LOCAL();
250 template <
class Evaluation>
252 const Evaluation& temperature,
253 const Evaluation& pressure)
const
255 OPM_TIMEFUNCTION_LOCAL();
256 if (enableEzrokhiViscosity_) {
258 const Evaluation& nacl_exponent = ezrokhiExponent_(temperature, ezrokhiViscNaClCoeff_);
259 return mu_pure * pow(10.0, nacl_exponent * Evaluation(salinity_[regionIdx]));
271 template <
class Evaluation>
273 const Evaluation& temperature,
274 const Evaluation& pressure,
275 const Evaluation& saltconcentration)
const
277 OPM_TIMEFUNCTION_LOCAL();
278 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
279 pressure, saltconcentration);
280 Evaluation rs_sat = rsSat(regionIdx, temperature, pressure, salinity);
281 return (1.0 - convertRsToXoG_(rs_sat,regionIdx)) * density(regionIdx, temperature,
282 pressure, rs_sat, salinity)
283 / brineReferenceDensity_[regionIdx];
288 template <
class Evaluation>
290 const Evaluation& temperature,
291 const Evaluation& pressure,
292 const Evaluation& Rs,
293 const Evaluation& saltConcentration)
const
295 OPM_TIMEFUNCTION_LOCAL();
296 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
297 pressure, saltConcentration);
298 return (1.0 - convertRsToXoG_(Rs,regionIdx)) * density(regionIdx, temperature,
299 pressure, Rs, salinity)
300 / brineReferenceDensity_[regionIdx];
305 template <
class Evaluation>
307 const Evaluation& temperature,
308 const Evaluation& pressure,
309 const Evaluation& Rs)
const
311 return (1.0 - convertRsToXoG_(Rs,regionIdx)) * density(regionIdx, temperature, pressure,
312 Rs, Evaluation(salinity_[regionIdx]))
313 / brineReferenceDensity_[regionIdx];
319 template <
class Evaluation>
321 const Evaluation& temperature,
322 const Evaluation& pressure)
const
324 OPM_TIMEFUNCTION_LOCAL();
325 Evaluation rs_sat = rsSat(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
326 return (1.0 - convertRsToXoG_(rs_sat,regionIdx)) * density(regionIdx, temperature, pressure,
327 rs_sat, Evaluation(salinity_[regionIdx]))
328 / brineReferenceDensity_[regionIdx];
337 template <
class Evaluation>
340 const Evaluation& )
const
342 throw std::runtime_error(
"Requested the saturation pressure for the brine-co2 pvt module. "
343 "Not yet implemented.");
352 template <
class Evaluation>
356 const Evaluation& )
const
358 throw std::runtime_error(
"Requested the saturation pressure for the brine-co2 pvt module. "
359 "Not yet implemented.");
365 template <
class Evaluation>
367 const Evaluation& temperature,
368 const Evaluation& pressure,
370 const Evaluation& )
const
373 return rsSat(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
379 template <
class Evaluation>
381 const Evaluation& temperature,
382 const Evaluation& pressure,
383 const Evaluation& saltConcentration)
const
385 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
386 pressure, saltConcentration);
387 return rsSat(regionIdx, temperature, pressure, salinity);
393 template <
class Evaluation>
395 const Evaluation& temperature,
396 const Evaluation& pressure)
const
398 return rsSat(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
401 Scalar oilReferenceDensity(
unsigned regionIdx)
const
402 {
return brineReferenceDensity_[regionIdx]; }
404 Scalar waterReferenceDensity(
unsigned regionIdx)
const
405 {
return brineReferenceDensity_[regionIdx]; }
407 Scalar gasReferenceDensity(
unsigned regionIdx)
const
408 {
return co2ReferenceDensity_[regionIdx]; }
410 Scalar salinity(
unsigned regionIdx)
const
411 {
return salinity_[regionIdx]; }
413 template <
class Evaluation>
414 Evaluation diffusionCoefficient(
const Evaluation& temperature,
415 const Evaluation& pressure,
418 OPM_TIMEFUNCTION_LOCAL();
421 const Evaluation log_D_H20 = -4.1764 + 712.52 / temperature
422 -2.5907e5 / (temperature * temperature);
430 if (enableEzrokhiViscosity_) {
431 const Evaluation& nacl_exponent = ezrokhiExponent_(temperature,
432 ezrokhiViscNaClCoeff_);
433 mu_Brine = mu_H20 * pow(10.0, nacl_exponent * Evaluation(salinity_[0]));
439 const Evaluation log_D_Brine = log_D_H20 - 0.87*log10(mu_Brine / mu_H20);
441 return pow(Evaluation(10), log_D_Brine) * 1e-4;
444 template <
class Evaluation>
445 Evaluation density(
unsigned regionIdx,
446 const Evaluation& temperature,
447 const Evaluation& pressure,
448 const Evaluation& Rs,
449 const Evaluation& salinity)
const
451 OPM_TIMEFUNCTION_LOCAL();
452 Evaluation xlCO2 = convertXoGToxoG_(convertRsToXoG_(Rs,regionIdx), salinity);
453 Evaluation result = liquidDensity_(temperature,
458 Valgrind::CheckDefined(result);
462 template <
class Evaluation>
463 Evaluation rsSat(
unsigned regionIdx,
464 const Evaluation& temperature,
465 const Evaluation& pressure,
466 const Evaluation& salinity)
const
468 OPM_TIMEFUNCTION_LOCAL();
469 if (!enableDissolution_) {
487 xlCO2 = max(0.0, min(1.0, xlCO2));
489 return convertXoGToRs(convertxoGToXoG(xlCO2, salinity), regionIdx);
493 template <
class LhsEval>
494 LhsEval ezrokhiExponent_(
const LhsEval& temperature,
495 const std::vector<Scalar>& ezrokhiCoeff)
const
497 const LhsEval& tempC = temperature - 273.15;
498 return ezrokhiCoeff[0] + tempC * (ezrokhiCoeff[1] + ezrokhiCoeff[2] * tempC);
501 template <
class LhsEval>
502 LhsEval liquidDensity_(
const LhsEval& T,
504 const LhsEval& xlCO2,
505 const LhsEval& salinity)
const
507 OPM_TIMEFUNCTION_LOCAL();
508 Valgrind::CheckDefined(T);
509 Valgrind::CheckDefined(pl);
510 Valgrind::CheckDefined(xlCO2);
512 if (!extrapolate && T < 273.15) {
513 const std::string msg =
514 "Liquid density for Brine and CO2 is only "
515 "defined above 273.15K (is " +
516 std::to_string(getValue(T)) +
"K)";
517 throw NumericalProblem(msg);
519 if (!extrapolate && pl >= 2.5e8) {
520 const std::string msg =
521 "Liquid density for Brine and CO2 is only "
522 "defined below 250MPa (is " +
523 std::to_string(getValue(pl)) +
"Pa)";
524 throw NumericalProblem(msg);
528 if (enableEzrokhiDensity_) {
529 const LhsEval& nacl_exponent = ezrokhiExponent_(T, ezrokhiDenNaClCoeff_);
530 const LhsEval& co2_exponent = ezrokhiExponent_(T, ezrokhiDenCo2Coeff_);
531 const LhsEval& XCO2 = convertxoGToXoG(xlCO2, salinity);
532 return rho_pure * pow(10.0, nacl_exponent * salinity + co2_exponent * XCO2);
536 const LhsEval& rho_lCO2 = liquidDensityWaterCO2_(T, pl, xlCO2);
537 const LhsEval& contribCO2 = rho_lCO2 - rho_pure;
538 return rho_brine + contribCO2;
542 template <
class LhsEval>
543 LhsEval liquidDensityWaterCO2_(
const LhsEval& temperature,
545 const LhsEval& xlCO2)
const
547 OPM_TIMEFUNCTION_LOCAL();
551 const LhsEval& tempC = temperature - 273.15;
556 const LhsEval xlH2O = 1.0 - xlCO2;
557 const LhsEval& M_T = M_H2O * xlH2O + M_CO2 * xlCO2;
558 const LhsEval& V_phi =
562 tempC*5.044e-7))) / 1.0e6;
563 return 1 / (xlCO2 * V_phi/M_T + M_H2O * xlH2O / (rho_pure * M_T));
570 template <
class LhsEval>
571 LhsEval convertRsToXoG_(
const LhsEval& Rs,
unsigned regionIdx)
const
573 OPM_TIMEFUNCTION_LOCAL();
574 Scalar rho_oRef = brineReferenceDensity_[regionIdx];
575 Scalar rho_gRef = co2ReferenceDensity_[regionIdx];
577 const LhsEval& rho_oG = Rs*rho_gRef;
578 return rho_oG/(rho_oRef + rho_oG);
584 template <
class LhsEval>
585 LhsEval convertXoGToxoG_(
const LhsEval& XoG,
const LhsEval& salinity)
const
587 OPM_TIMEFUNCTION_LOCAL();
590 return XoG*M_Brine / (M_CO2*(1 - XoG) + XoG*M_Brine);
596 template <
class LhsEval>
597 LhsEval convertxoGToXoG(
const LhsEval& xoG,
const LhsEval& salinity)
const
599 OPM_TIMEBLOCK_LOCAL(convertxoGToXoG);
603 return xoG*M_CO2 / (xoG*(M_CO2 - M_Brine) + M_Brine);
610 template <
class LhsEval>
611 LhsEval convertXoGToRs(
const LhsEval& XoG,
unsigned regionIdx)
const
613 Scalar rho_oRef = brineReferenceDensity_[regionIdx];
614 Scalar rho_gRef = co2ReferenceDensity_[regionIdx];
616 return XoG/(1.0 - XoG)*(rho_oRef/rho_gRef);
619 template <
class LhsEval>
620 LhsEval liquidEnthalpyBrineCO2_(
const LhsEval& T,
622 const LhsEval& salinity,
623 const LhsEval& X_CO2_w)
const
625 if (liquidMixType_ == Co2StoreConfig::LiquidMixingType::NONE
626 && saltMixType_ == Co2StoreConfig::SaltMixingType::NONE)
634 if (saltMixType_ == Co2StoreConfig::SaltMixingType::MICHAELIDES) {
641 static constexpr Scalar f[] = {
642 2.63500E-1, 7.48368E-6, 1.44611E-6, -3.80860E-10
646 static constexpr Scalar a[4][3] = {
647 { 9633.6, -4080.0, +286.49 },
648 { +166.58, +68.577, -4.6856 },
649 { -0.90963, -0.36524, +0.249667E-1 },
650 { +0.17965E-2, +0.71924E-3, -0.4900E-4 }
653 LhsEval theta, h_NaCl;
654 LhsEval d_h, delta_h;
659 Scalar scalarTheta = scalarValue(theta);
660 Scalar S_lSAT = f[0] + scalarTheta*(f[1] + scalarTheta*(f[2] + scalarTheta*f[3]));
662 LhsEval S = salinity;
667 h_NaCl = (3.6710E4*T + 0.5*(6.2770E1)*T*T - ((6.6670E-2)/3)*T*T*T
668 +((2.8000E-5)/4)*(T*T*T*T))/(58.44E3)- 2.045698e+02;
670 LhsEval m = 1E3 / 58.44 * S / (1 - S);
673 for (
int i = 0; i <=3; ++i) {
674 for (
int j = 0; j <= 2; ++j) {
675 d_h += a[i][j] * pow(theta,
static_cast<Scalar
>(i)) * pow(m, j);
679 delta_h = (4.184/(1E3 + (58.44 * m)))*d_h;
682 h_ls1 =(1-S)*hw + S*h_NaCl + S*delta_h;
685 if (liquidMixType_ == Co2StoreConfig::LiquidMixingType::NONE) {
690 LhsEval delta_hCO2, hg;
694 if (liquidMixType_ == Co2StoreConfig::LiquidMixingType::DUANSUN) {
695 delta_hCO2 = (-57.4375 + T * 0.1325) * 1000/44;
705 return (h_ls1 - X_CO2_w*hw + hg*X_CO2_w)*1E3;
708 template <
class LhsEval>
709 const LhsEval salinityFromConcentration(
unsigned regionIdx,
712 const LhsEval& saltConcentration)
const
714 if (enableSaltConcentration_) {
718 return salinity(regionIdx);
721 std::vector<Scalar> brineReferenceDensity_{};
722 std::vector<Scalar> co2ReferenceDensity_{};
723 std::vector<Scalar> salinity_{};
724 std::vector<Scalar> ezrokhiDenNaClCoeff_{};
725 std::vector<Scalar> ezrokhiDenCo2Coeff_{};
726 std::vector<Scalar> ezrokhiViscNaClCoeff_{};
727 bool enableEzrokhiDensity_ =
false;
728 bool enableEzrokhiViscosity_ =
false;
729 bool enableDissolution_ =
true;
730 bool enableSaltConcentration_ =
false;
731 int activityModel_{};
732 Co2StoreConfig::LiquidMixingType liquidMixType_{};
733 Co2StoreConfig::SaltMixingType saltMixType_{};
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.
Provides the OPM specific exception classes.
Binary coefficients for water and CO2.
A simple version of pure water with density from Hu et al.
A generic class which tabulates all thermodynamic properties of a given component.
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
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
Definition BrineCo2Pvt.hpp:62
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition BrineCo2Pvt.hpp:184
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &saltConcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition BrineCo2Pvt.hpp:236
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs, const Evaluation &saltConcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition BrineCo2Pvt.hpp:289
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs, const Evaluation &saltConcentration) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition BrineCo2Pvt.hpp:165
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the gas dissoluiton factor [m^3/m^3] of the liquid phase.
Definition BrineCo2Pvt.hpp:366
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the gas dissoluiton factor [m^3/m^3] of the liquid phase.
Definition BrineCo2Pvt.hpp:380
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas at given pressure.
Definition BrineCo2Pvt.hpp:251
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition BrineCo2Pvt.hpp:306
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition BrineCo2Pvt.hpp:154
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition BrineCo2Pvt.hpp:272
void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition BrineCo2Pvt.cpp:172
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the brine phase [Pa] depending on its mass fraction of the gas com...
Definition BrineCo2Pvt.hpp:338
void initEnd()
Finish initializing the oil phase PVT properties.
Definition BrineCo2Pvt.hpp:115
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of brine saturated with CO2 at a given pressure.
Definition BrineCo2Pvt.hpp:320
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the brine phase [Pa] depending on its mass fraction of the gas com...
Definition BrineCo2Pvt.hpp:353
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition BrineCo2Pvt.hpp:215
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefCO2, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition BrineCo2Pvt.cpp:161
void setEnableSaltConcentration(bool yesno)
Specify whether the PVT model should consider salt concentration from the fluidstate or a fixed salin...
Definition BrineCo2Pvt.hpp:134
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition BrineCo2Pvt.hpp:202
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns thegas dissoluiton factor [m^3/m^3] of the liquid phase.
Definition BrineCo2Pvt.hpp:394
void setThermalMixingModel(int thermalMixingModelSalt, int thermalMixingModelLiquid)
Set thermal mixing model for co2 in brine.
Definition BrineCo2Pvt.cpp:184
void setEnableDissolvedGas(bool yesno)
Specify whether the PVT model should consider that the CO2 component can dissolve in the brine phase.
Definition BrineCo2Pvt.hpp:125
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
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &, const Evaluation &salinity)
The dynamic viscosity of pure water.
Definition BrineDynamic.hpp:340
A class for the CO2 fluid properties.
Definition CO2.hpp:54
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition CO2.hpp:169
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:71
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Definition EclipseState.hpp:63
Definition Schedule.hpp:89
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of liquid water .
Definition SimpleHuDuanH2O.hpp:198
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The dynamic viscosity of pure water.
Definition SimpleHuDuanH2O.hpp:351
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 Scalar molarMass()
The molar mass in of water.
Definition SimpleHuDuanH2O.hpp:99
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30