27#ifndef OPM_BRINE_H2_PVT_HPP
28#define OPM_BRINE_H2_PVT_HPP
51template <
class Scalar>
54 static const bool extrapolate =
true;
63 explicit BrineH2Pvt() =
default;
65 explicit BrineH2Pvt(
const std::vector<Scalar>& salinity,
66 Scalar T_ref = 288.71,
67 Scalar P_ref = 101325);
77 void setVapPars(
const Scalar,
const Scalar)
103 { enableDissolution_ = yesno; }
112 { enableSaltConcentration_ = yesno; }
118 {
return brineReferenceDensity_.size(); }
126 template <
class Evaluation>
127 Evaluation internalEnergy(
unsigned regionIdx,
128 const Evaluation& temperature,
129 const Evaluation& pressure,
130 const Evaluation& Rs,
131 const Evaluation& saltConcentration)
const
133 const Evaluation
salinity = salinityFromConcentration(regionIdx, temperature,
134 pressure, saltConcentration);
135 const Evaluation xlH2 = convertRsToXoG_(Rs,regionIdx);
136 return liquidEnthalpyBrineH2_(temperature,
140 - pressure / density_(regionIdx, temperature, pressure, Rs,
salinity);
146 template <
class Evaluation>
148 const Evaluation& temperature,
149 const Evaluation& pressure,
150 const Evaluation& Rs)
const
152 const Evaluation xlH2 = convertRsToXoG_(Rs,regionIdx);
153 return liquidEnthalpyBrineH2_(temperature,
155 Evaluation(salinity_[regionIdx]),
157 - pressure / density_(regionIdx, temperature, pressure,
158 Rs, Evaluation(salinity_[regionIdx]));
164 template <
class Evaluation>
166 const Evaluation& temperature,
167 const Evaluation& pressure,
168 const Evaluation& )
const
177 template <
class Evaluation>
179 const Evaluation& temperature,
180 const Evaluation& pressure,
181 const Evaluation& saltConcentration)
const
183 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
184 pressure, saltConcentration);
191 template <
class Evaluation>
193 const Evaluation& temperature,
194 const Evaluation& pressure,
196 const Evaluation& saltConcentration)
const
205 template <
class Evaluation>
207 const Evaluation& temperature,
208 const Evaluation& pressure)
const
216 template <
class Evaluation>
218 const Evaluation& temperature,
219 const Evaluation& pressure,
220 const Evaluation& saltconcentration)
const
222 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
223 pressure, saltconcentration);
224 Evaluation rsSat = rsSat_(regionIdx, temperature, pressure, salinity);
225 return (1.0 - convertRsToXoG_(rsSat,regionIdx))
226 * density_(regionIdx, temperature, pressure, rsSat, salinity)
227 / brineReferenceDensity_[regionIdx];
233 template <
class Evaluation>
235 const Evaluation& temperature,
236 const Evaluation& pressure,
237 const Evaluation& Rs,
238 const Evaluation& saltConcentration)
const
240 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
241 pressure, saltConcentration);
242 return (1.0 - convertRsToXoG_(Rs,regionIdx))
243 * density_(regionIdx, temperature, pressure, Rs, salinity)
244 / brineReferenceDensity_[regionIdx];
250 template <
class Evaluation>
252 const Evaluation& temperature,
253 const Evaluation& pressure,
254 const Evaluation& Rs)
const
256 return (1.0 - convertRsToXoG_(Rs, regionIdx))
257 * density_(regionIdx, temperature, pressure, Rs, Evaluation(salinity_[regionIdx]))
258 / brineReferenceDensity_[regionIdx];
264 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
265 std::pair<LhsEval, LhsEval>
269 const bool waterIsActive = fluidState.phaseIsActive(FluidState::waterPhaseIdx);
270 const int myPhaseIdx = waterIsActive ? FluidState::waterPhaseIdx : FluidState::oilPhaseIdx;
271 const LhsEval& Rsw = waterIsActive ? decay<LhsEval>(fluidState.Rsw()) : decay<LhsEval>(fluidState.Rs());
273 const LhsEval& T = decay<LhsEval>(fluidState.temperature(myPhaseIdx));
274 const LhsEval& p = decay<LhsEval>(fluidState.pressure(myPhaseIdx));
275 const LhsEval& saltConcentration
276 = BlackOil::template getSaltConcentration_<FluidState, LhsEval>(fluidState, regionIdx);
286 template <
class Evaluation>
288 const Evaluation& temperature,
289 const Evaluation& pressure)
const
291 Evaluation rsSat = rsSat_(regionIdx, temperature,
292 pressure, Evaluation(salinity_[regionIdx]));
293 return (1.0 - convertRsToXoG_(rsSat, regionIdx))
294 * density_(regionIdx, temperature, pressure, rsSat,
295 Evaluation(salinity_[regionIdx]))
296 / brineReferenceDensity_[regionIdx];
305 template <
class Evaluation>
308 const Evaluation& )
const
310 throw std::runtime_error(
"Saturation pressure for the Brine-H2 PVT module "
311 "has not been implemented yet!");
320 template <
class Evaluation>
324 const Evaluation& )
const
326 throw std::runtime_error(
"Saturation pressure for the Brine-H2 PVT module "
327 "has not been implemented yet!");
333 template <
class Evaluation>
335 const Evaluation& temperature,
336 const Evaluation& pressure,
338 const Evaluation& )
const
341 return rsSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
347 template <
class Evaluation>
349 const Evaluation& temperature,
350 const Evaluation& pressure,
351 const Evaluation& saltConcentration)
const
353 const Evaluation salinity = salinityFromConcentration(regionIdx, temperature,
354 pressure, saltConcentration);
355 return rsSat_(regionIdx, temperature, pressure, salinity);
361 template <
class Evaluation>
363 const Evaluation& temperature,
364 const Evaluation& pressure)
const
366 return rsSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx]));
369 Scalar oilReferenceDensity(
unsigned regionIdx)
const
370 {
return brineReferenceDensity_[regionIdx]; }
372 Scalar waterReferenceDensity(
unsigned regionIdx)
const
373 {
return brineReferenceDensity_[regionIdx]; }
375 Scalar gasReferenceDensity(
unsigned regionIdx)
const
376 {
return h2ReferenceDensity_[regionIdx]; }
378 Scalar
salinity(
unsigned regionIdx)
const
379 {
return salinity_[regionIdx]; }
384 template <
class Evaluation>
386 const Evaluation& pressure,
388 unsigned regionIdx = 0)
const
395 const Scalar vm = 28.45;
396 const Scalar sigma = 2.96 * 1e-8;
397 const Scalar avogadro = 6.022e23;
398 const Scalar alpha = sigma / pow((vm / avogadro), 1 / 3);
399 const Scalar lambda = 1.729;
402 Evaluation(salinity_[regionIdx])) * 1e3;
405 const Evaluation D_pure = ((4.8e-7 * temperature) / pow(mu_pure, alpha)) *
406 pow((1 + pow(lambda, 2)) / vm, 0.6);
412 const Evaluation log_D_brine = log10(D_pure) - 0.637 * log10(mu_brine / mu_pure);
414 return pow(Evaluation(10), log_D_brine) * 1e-4;
425 template <
class LhsEval>
426 LhsEval density_(
unsigned regionIdx,
427 const LhsEval& temperature,
428 const LhsEval& pressure,
433 LhsEval xlH2 = convertXoGToxoG_(convertRsToXoG_(Rs,regionIdx),
salinity);
436 LhsEval result = liquidDensity_(temperature,
453 template <
class LhsEval>
454 LhsEval liquidDensity_(
const LhsEval& T,
460 Valgrind::CheckDefined(T);
461 Valgrind::CheckDefined(pl);
462 Valgrind::CheckDefined(xlH2);
465 if (!extrapolate && T < 273.15) {
466 const std::string msg =
467 "Liquid density for Brine and H2 is only "
468 "defined above 273.15K (is " +
469 std::to_string(getValue(T)) +
"K)";
470 throw NumericalProblem(msg);
472 if (!extrapolate && pl >= 2.5e8) {
473 const std::string msg =
474 "Liquid density for Brine and H2 is only "
475 "defined below 250MPa (is " +
476 std::to_string(getValue(pl)) +
"Pa)";
477 throw NumericalProblem(msg);
483 const LhsEval& rho_lH2 = liquidDensityWaterH2_(T, pl, xlH2);
484 const LhsEval& contribH2 = rho_lH2 - rho_pure;
486 return rho_brine + contribH2;
498 template <
class LhsEval>
499 LhsEval liquidDensityWaterH2_(
const LhsEval& temperature,
501 const LhsEval& xlH2)
const
511 const LhsEval& A1 = 51.1904 - 0.208062 * temperature +
512 3.4427e-4 * temperature * temperature;
513 const LhsEval& A2 = -0.022;
515 const LhsEval& V_phi = (A1 + A2 * (pl / 1e6)) / 1e6;
518 const LhsEval xlH2O = 1.0 - xlH2;
519 const LhsEval& M_T = M_H2O * xlH2O + M_H2 * xlH2;
520 const LhsEval& rho_aq = 1 / (xlH2 * V_phi/M_T + M_H2O * xlH2O / (rho_pure * M_T));
532 template <
class LhsEval>
533 LhsEval convertRsToXoG_(
const LhsEval& Rs,
unsigned regionIdx)
const
535 Scalar rho_oRef = brineReferenceDensity_[regionIdx];
536 Scalar rho_gRef = h2ReferenceDensity_[regionIdx];
538 const LhsEval& rho_oG = Rs*rho_gRef;
539 return rho_oG/(rho_oRef + rho_oG);
548 template <
class LhsEval>
549 LhsEval convertXoGToxoG_(
const LhsEval& XoG,
const LhsEval& salinity)
const
553 return XoG*M_Brine / (M_H2*(1 - XoG) + XoG*M_Brine);
562 template <
class LhsEval>
563 LhsEval convertxoGToXoG(
const LhsEval& xoG,
const LhsEval& salinity)
const
568 return xoG*M_H2 / (xoG*(M_H2 - M_Brine) + M_Brine);
578 template <
class LhsEval>
579 LhsEval convertXoGToRs(
const LhsEval& XoG,
unsigned regionIdx)
const
581 Scalar rho_oRef = brineReferenceDensity_[regionIdx];
582 Scalar rho_gRef = h2ReferenceDensity_[regionIdx];
584 return XoG/(1.0 - XoG)*(rho_oRef/rho_gRef);
594 template <
class LhsEval>
595 LhsEval rsSat_(
unsigned regionIdx,
596 const LhsEval& temperature,
597 const LhsEval& pressure,
598 const LhsEval& salinity)
const
601 if (!enableDissolution_)
606 salinity, extrapolate);
609 xlH2 = max(0.0, min(1.0, xlH2));
611 return convertXoGToRs(convertxoGToXoG(xlH2, salinity), regionIdx);
614 template <
class LhsEval>
615 static LhsEval liquidEnthalpyBrineH2_(
const LhsEval& T,
617 const LhsEval& salinity,
618 const LhsEval& X_H2_w)
624 static constexpr Scalar f[] = {
625 2.63500E-1, 7.48368E-6, 1.44611E-6, -3.80860E-10
629 static constexpr Scalar a[4][3] = {
630 { 9633.6, -4080.0, +286.49 },
631 { +166.58, +68.577, -4.6856 },
632 { -0.90963, -0.36524, +0.249667E-1 },
633 { +0.17965E-2, +0.71924E-3, -0.4900E-4 }
636 LhsEval theta, h_NaCl;
645 Scalar scalarTheta = scalarValue(theta);
646 Scalar S_lSAT = f[0] + scalarTheta*(f[1] + scalarTheta*(f[2] + scalarTheta*f[3]));
648 LhsEval S = salinity;
656 h_NaCl = (3.6710E4*T + 0.5*(6.2770E1)*T*T - ((6.6670E-2)/3)*T*T*T
657 +((2.8000E-5)/4)*(T*T*T*T))/(58.44E3)- 2.045698e+02;
659 LhsEval m = 1E3/58.44 * S/(1-S);
662 for (
int i = 0; i <=3 ; ++i) {
663 for (
int j = 0; j <= 2; ++j) {
664 d_h = d_h + a[i][j] * pow(theta,
static_cast<Scalar
>(i)) * pow(m, j);
668 delta_h = (4.184/(1E3 + (58.44 * m)))*d_h;
671 h_ls1 =(1-S)*hw + S*h_NaCl + S*delta_h;
677 return (h_ls1 - X_H2_w*hw + hg*X_H2_w)*1E3;
680 template <
class LhsEval>
681 const LhsEval salinityFromConcentration(
unsigned regionIdx,
684 const LhsEval& saltConcentration)
const
686 if (enableSaltConcentration_) {
690 const LhsEval S_approx = saltConcentration / rho_w;
693 return saltConcentration / rho_brine;
699 std::vector<Scalar> brineReferenceDensity_{};
700 std::vector<Scalar> h2ReferenceDensity_{};
701 std::vector<Scalar> salinity_{};
702 bool enableDissolution_ =
true;
703 bool enableSaltConcentration_ =
false;
A class for the brine fluid properties.
Binary coefficients for brine and H2.
Provides the OPM specific exception classes.
Properties of pure molecular hydrogen .
A simple version of pure water with density from Hu et al.
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
Binary coefficients for brine and H2.
Definition Brine_H2.hpp:41
static Evaluation calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, const Evaluation &salinity, bool extrapolate=false)
Returns the mol (!) fraction of H2 in the liquid phase for a given temperature, pressure,...
Definition Brine_H2.hpp:57
A class for the brine fluid properties.
Definition BrineDynamic.hpp:49
static OPM_HOST_DEVICE Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &, const Evaluation &salinity)
The dynamic liquid viscosity of the pure component.
Definition BrineDynamic.hpp:385
static OPM_HOST_DEVICE 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:283
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 BrineH2Pvt.hpp:206
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition BrineH2Pvt.hpp:251
void setEnableSaltConcentration(bool yesno)
Specify whether the PVT model should consider salt concentration from the fluidstate or a fixed salin...
Definition BrineH2Pvt.hpp:111
void initEnd()
Finish initializing the oil phase PVT properties.
Definition BrineH2Pvt.hpp:92
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 BrineH2Pvt.hpp:321
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned, unsigned regionIdx=0) const
Diffusion coefficient of H2 in water.
Definition BrineH2Pvt.hpp:385
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 BrineH2Pvt.hpp:234
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 BrineH2Pvt.hpp:147
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 BrineH2Pvt.hpp:178
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the liquid phase.
Definition BrineH2Pvt.hpp:334
void setEnableDissolvedGas(bool yesno)
Specify whether the PVT model should consider that the H2 component can dissolve in the brine phase.
Definition BrineH2Pvt.hpp:102
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 BrineH2Pvt.hpp:165
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition BrineH2Pvt.hpp:266
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition BrineH2Pvt.hpp:117
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of brine saturated with H2 at a given pressure.
Definition BrineH2Pvt.hpp:287
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns thegas dissoluiton factor [m^3/m^3] of the liquid phase.
Definition BrineH2Pvt.hpp:362
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefH2, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition BrineH2Pvt.cpp:126
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition BrineH2Pvt.hpp:217
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 BrineH2Pvt.hpp:306
Scalar hVap(unsigned) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition BrineH2Pvt.hpp:123
void initFromState(const EclipseState &eclState, const Schedule &)
Initialize the parameters for Brine-H2 system using an ECL deck.
Definition BrineH2Pvt.cpp:55
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 BrineH2Pvt.hpp:192
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 BrineH2Pvt.hpp:348
static Scalar molarMass()
Definition Component.hpp:93
Definition EclipseState.hpp:66
Properties of pure molecular hydrogen .
Definition H2.hpp:90
static constexpr Scalar molarMass()
The molar mass in of molecular hydrogen.
Definition H2.hpp:109
static const Evaluation gasEnthalpy(Evaluation temperature, Evaluation pressure, bool extrapolate=false)
Specific enthalpy of pure hydrogen gas.
Definition H2.hpp:267
Definition Schedule.hpp:101
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:66
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
static OPM_HOST_DEVICE Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The dynamic viscosity of pure water.
Definition SimpleHuDuanH2O.hpp:361
static OPM_HOST_DEVICE Scalar molarMass()
The molar mass in of water.
Definition SimpleHuDuanH2O.hpp:103
static OPM_HOST_DEVICE Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of liquid water .
Definition SimpleHuDuanH2O.hpp:202
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Scalar Brine< Scalar, H2O >::salinity
Default value for the salinity of the brine (dimensionless).
Definition Brine.hpp:391