28#ifndef OPM_BRINE_CO2_SYSTEM_HPP
29#define OPM_BRINE_CO2_SYSTEM_HPP
53const float CO2<float>::brineSalinity;
55const double CO2<double>::brineSalinity;
64template <
class Scalar>
69 typedef ::Opm::Brine<Scalar, H2O_IAPWS>
Brine_IAPWS;
76 template <
class Evaluation>
83 typedef ::Opm::CO2<Scalar>
CO2;
105 static const char* name[] = {
111 return name[phaseIdx];
172 static const char* name[] = {
178 return name[compIdx];
201 init(273.15, 623.15, 50,
219 if (H2O::isTabulated) {
221 pressMin, pressMax, nPress);
227 if (Brine::isTabulated) {
229 pressMin, pressMax, nPress);
236 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
237 static LhsEval
density(
const FluidState& fluidState,
243 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
244 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
251 LhsEval xlCO2 = min(1.0, max(0.0, decay<LhsEval>(fluidState.moleFraction(
liquidPhaseIdx,
CO2Idx))));
252 LhsEval sumx = xlBrine + xlCO2;
256 LhsEval result = liquidDensity_(temperature,
261 Valgrind::CheckDefined(result);
270 LhsEval xgBrine = min(1.0, max(0.0, decay<LhsEval>(fluidState.moleFraction(
gasPhaseIdx,
BrineIdx))));
271 LhsEval xgCO2 = min(1.0, max(0.0, decay<LhsEval>(fluidState.moleFraction(
gasPhaseIdx,
CO2Idx))));
272 LhsEval sumx = xgBrine + xgCO2;
276 LhsEval result = gasDensity_(temperature,
280 Valgrind::CheckDefined(result);
287 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
294 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
295 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
301 Valgrind::CheckDefined(result);
307 Valgrind::CheckDefined(result);
314 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
329 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
330 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
331 assert(temperature > 0);
332 assert(pressure > 0);
337 LhsEval xlH2O, xgH2O;
338 LhsEval xlCO2, xgCO2;
347 xlCO2 = max(0.0, min(1.0, xlCO2));
348 xgH2O = max(0.0, min(1.0, xgH2O));
355 return phigH2O * xgH2O / xlH2O;
358 assert(compIdx ==
CO2Idx);
361 return phigCO2 * xgCO2 / xlCO2;
368 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
374 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
375 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
386 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
387 static LhsEval
enthalpy(
const FluidState& fluidState,
393 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
394 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
397 const LhsEval& XlCO2 = decay<LhsEval>(fluidState.massFraction(phaseIdx,
CO2Idx));
398 const LhsEval& result = liquidEnthalpyBrineCO2_(temperature,
402 Valgrind::CheckDefined(result);
406 const LhsEval& XCO2 = decay<LhsEval>(fluidState.massFraction(
gasPhaseIdx,
CO2Idx));
412 Valgrind::CheckDefined(result);
420 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
445 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar,
class ParamCacheEval = LhsEval>
452 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
453 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
462 template <
class LhsEval>
463 static LhsEval gasDensity_(
const LhsEval& T,
465 const LhsEval& xgH2O,
466 const LhsEval& xgCO2)
468 Valgrind::CheckDefined(T);
469 Valgrind::CheckDefined(pg);
470 Valgrind::CheckDefined(xgH2O);
471 Valgrind::CheckDefined(xgCO2);
482 template <
class LhsEval>
483 static LhsEval liquidDensity_(
const LhsEval& T,
485 const LhsEval& xlH2O,
486 const LhsEval& xlCO2)
488 Valgrind::CheckDefined(T);
489 Valgrind::CheckDefined(pl);
490 Valgrind::CheckDefined(xlH2O);
491 Valgrind::CheckDefined(xlCO2);
493 auto cast = [](
const auto d)
496 if constexpr (std::is_same_v<
decltype(d),
const quad>)
497 return static_cast<double>(d);
503 auto tostring = [cast](
const auto& val) -> std::string
505 if constexpr (DenseAd::is_evaluation<LhsEval>::value) {
506 return std::to_string(cast(getValue(val.value())));
508 return std::to_string(cast(val));
513 const std::string msg =
514 "Liquid density for Brine and CO2 is only "
515 "defined above 273.15K (is +"
517 throw NumericalProblem(msg);
520 const std::string msg =
521 "Liquid density for Brine and CO2 is only "
522 "defined below 250MPa (is "
523 + tostring(pl) +
"Pa)";
524 throw NumericalProblem(msg);
529 const LhsEval& rho_lCO2 = liquidDensityWaterCO2_(T, pl, xlH2O, xlCO2);
530 const LhsEval& contribCO2 = rho_lCO2 - rho_pure;
532 return rho_brine + contribCO2;
535 template <
class LhsEval>
536 static LhsEval liquidDensityWaterCO2_(
const LhsEval& temperature,
539 const LhsEval& xlCO2)
544 const LhsEval& tempC = temperature - 273.15;
549 const LhsEval xlH2O = 1.0 - xlCO2;
550 const LhsEval& M_T = M_H2O * xlH2O + M_CO2 * xlCO2;
551 const LhsEval& V_phi =
555 tempC*5.044e-7))) / 1.0e6;
556 return 1/ (xlCO2 * V_phi/M_T + M_H2O * xlH2O / (rho_pure * M_T));
559 template <
class LhsEval>
560 static LhsEval liquidEnthalpyBrineCO2_(
const LhsEval& T,
563 const LhsEval& X_CO2_w)
571 2.63500E-1, 7.48368E-6, 1.44611E-6, -3.80860E-10
576 { 9633.6, -4080.0, +286.49 },
577 { +166.58, +68.577, -4.6856 },
578 { -0.90963, -0.36524, +0.249667E-1 },
579 { +0.17965E-2, +0.71924E-3, -0.4900E-4 }
582 LhsEval theta, h_NaCl;
585 LhsEval delta_hCO2, hg, hw;
590 Scalar scalarTheta = scalarValue(theta);
591 Scalar S_lSAT = f[0] + scalarTheta*(f[1] + scalarTheta*(f[2] + scalarTheta*f[3]));
598 h_NaCl = (3.6710E4*T + 0.5*(6.2770E1)*T*T - ((6.6670E-2)/3)*T*T*T
599 +((2.8000E-5)/4)*(T*T*T*T))/(58.44E3)- 2.045698e+02;
601 Scalar m = 1E3/58.44 * S/(1-S);
606 for (i = 0; i<=3; i++) {
607 for (j=0; j<=2; j++) {
608 d_h = d_h + a[i][j] * pow(theta,
static_cast<Scalar>(i)) * std::pow(m, j);
612 delta_h = (4.184/(1E3 + (58.44 * m)))*d_h;
615 h_ls1 =(1-S)*hw + S*h_NaCl + S*delta_h;
620 delta_hCO2 = (-57.4375 + T * 0.1325) * 1000/44;
626 return (h_ls1 - X_CO2_w*hw + hg*X_CO2_w)*1E3;
The base class for all fluid systems.
A class for the brine fluid properties.
Binary coefficients for brine and CO2.
A class for the CO2 fluid properties.
Provides the OPM specific exception classes.
Binary coefficients for water and CO2.
Binary coefficients for water and nitrogen.
Relations valid for an ideal gas.
A parameter cache which does nothing.
A simplistic class representing the fluid properties.
A simple version of pure water.
A generic class which tabulates all thermodynamic properties of a given component.
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:46
Scalar Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:51
Binary coefficients for brine and CO2.
Definition Brine_CO2.hpp:42
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:56
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, const Evaluation &salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O, 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:97
static Evaluation liquidDiffCoeff(const Evaluation &, const Evaluation &)
Binary diffusion coefficent [m^2/s] of CO2 in the brine phase.
Definition Brine_CO2.hpp:73
A two-phase fluid system with water and CO2.
Definition BrineCO2FluidSystem.hpp:67
static const int CO2Idx
The index of the CO2 component.
Definition BrineCO2FluidSystem.hpp:165
static const int BrineIdx
The index of the brine component.
Definition BrineCO2FluidSystem.hpp:163
Brine_Tabulated Brine
The type of the component for brine used by the fluid system.
Definition BrineCO2FluidSystem.hpp:81
static void init()
Initialize the fluid system's static parameters.
Definition BrineCO2FluidSystem.hpp:199
static LhsEval heatCapacity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition BrineCO2FluidSystem.hpp:446
static const char * componentName(unsigned compIdx)
Return the human readable name of a component.
Definition BrineCO2FluidSystem.hpp:170
static const int gasPhaseIdx
The index of the gas phase.
Definition BrineCO2FluidSystem.hpp:98
static LhsEval thermalConductivity(const FluidState &, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Thermal conductivity of a fluid phase [W/(m K)].
Definition BrineCO2FluidSystem.hpp:421
static const char * phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition BrineCO2FluidSystem.hpp:103
static const int numPhases
The number of phases considered by the fluid system.
Definition BrineCO2FluidSystem.hpp:93
BinaryCoeff::Brine_CO2< Scalar, H2O, CO2 > BinaryCoeffBrineCO2
The binary coefficients for brine and CO2 used by this fluid system.
Definition BrineCO2FluidSystem.hpp:86
::Opm::CO2< Scalar > CO2
The type of the component for pure CO2 used by the fluid system.
Definition BrineCO2FluidSystem.hpp:83
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition BrineCO2FluidSystem.hpp:184
static bool isIdealMixture(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition BrineCO2FluidSystem.hpp:139
static bool isCompressible(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition BrineCO2FluidSystem.hpp:149
static const int numComponents
Number of chemical species in the fluid system.
Definition BrineCO2FluidSystem.hpp:160
static const int liquidPhaseIdx
The index of the liquid phase.
Definition BrineCO2FluidSystem.hpp:96
static LhsEval enthalpy(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition BrineCO2FluidSystem.hpp:387
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the fluid system's static parameters using problem specific temperature and pressure range...
Definition BrineCO2FluidSystem.hpp:216
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition BrineCO2FluidSystem.hpp:288
static bool isIdealGas(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition BrineCO2FluidSystem.hpp:127
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition BrineCO2FluidSystem.hpp:237
static LhsEval diffusionCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition BrineCO2FluidSystem.hpp:369
static bool isLiquid(unsigned phaseIdx)
Return whether a phase is liquid.
Definition BrineCO2FluidSystem.hpp:117
static LhsEval fugacityCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx, unsigned compIdx)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition BrineCO2FluidSystem.hpp:315
A class for the brine fluid properties.
Definition Brine.hpp:46
static Scalar salinity
The mass fraction of salt assumed to be in the brine.
Definition Brine.hpp:49
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition CO2.hpp:260
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:207
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition CO2.hpp:168
static const char * name()
A human readable name for the CO2.
Definition CO2.hpp:64
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition CO2.hpp:161
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:70
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:193
Material properties of pure water .
Definition H2O.hpp:65
A parameter cache which does nothing.
Definition NullParameterCache.hpp:40
A generic class which tabulates all thermodynamic properties of a given component.
Definition TabulatedComponent.hpp:56
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the gas .
Definition TabulatedComponent.hpp:282
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the liquid .
Definition TabulatedComponent.hpp:333
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the tables.
Definition TabulatedComponent.hpp:72
static Scalar molarMass()
The molar mass in of the component.
Definition TabulatedComponent.hpp:221
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of liquid.
Definition TabulatedComponent.hpp:478
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of liquid at a given pressure and temperature .
Definition TabulatedComponent.hpp:444
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the liquid .
Definition TabulatedComponent.hpp:299
static const char * name()
A human readable name for the component.
Definition TabulatedComponent.hpp:215
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition BrineCO2FluidSystem.hpp:78