Loading...
Searching...
No Matches
Brine.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_BRINE_HPP
#define OPM_BRINE_HPP
#include <opm/material/components/Component.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <string_view>
namespace Opm {
template <class Scalar, class H2O>
class Brine : public Component<Scalar, Brine<Scalar, H2O> >
{
public:
static Scalar salinity;
static std::string_view name()
{ return "Brine"; }
static bool gasIsIdeal()
{ return H2O::gasIsIdeal(); }
static bool gasIsCompressible()
{ return H2O::gasIsCompressible(); }
static bool liquidIsCompressible()
{ return H2O::liquidIsCompressible(); }
static Scalar molarMass()
{
const Scalar M1 = H2O::molarMass();
constexpr Scalar M2 = 58e-3; // molar mass of NaCl [kg/mol]
const Scalar X2 = salinity; // mass fraction of salt in brine
return M1*M2/(M2 + X2*(M1 - M2));
}
static Scalar criticalTemperature()
{ return H2O::criticalTemperature(); /* [K] */ }
static Scalar criticalPressure()
{ return H2O::criticalPressure(); /* [N/m^2] */ }
static Scalar criticalVolume()
{ return H2O::criticalVolume(); /* [m3/kmol] */ }
static Scalar acentricFactor()
{ return H2O::acentricFactor(); }
static Scalar tripleTemperature()
{ return H2O::tripleTemperature(); /* [K] */ }
static Scalar triplePressure()
{ return H2O::triplePressure(); /* [N/m^2] */ }
template <class Evaluation>
static Evaluation vaporPressure(const Evaluation& T)
{ return H2O::vaporPressure(T); /* [N/m^2] */ }
template <class Evaluation>
static Evaluation gasEnthalpy(const Evaluation& temperature,
const Evaluation& pressure)
{ return H2O::gasEnthalpy(temperature, pressure); /* [J/kg] */ }
template <class Evaluation>
static Evaluation liquidEnthalpy(const Evaluation& temperature,
const Evaluation& pressure)
{
// Numerical coefficents from Palliser and McKibbin
static constexpr Scalar f[] = {
2.63500e-1, 7.48368e-6, 1.44611e-6, -3.80860e-10
};
// Numerical coefficents from Michaelides for the enthalpy of brine
static constexpr Scalar a[4][3] = {
{ -9633.6, -4080.0, +286.49 },
{ +166.58, +68.577, -4.6856 },
{ -0.90963, -0.36524, +0.249667e-1 },
{ +0.17965e-2, +0.71924e-3, -0.4900e-4 }
};
const Evaluation theta = temperature - 273.15;
Evaluation S = salinity;
const Evaluation S_lSAT =
f[0]
+ f[1]*theta
+ f[2]*pow(theta, 2)
+ f[3]*pow(theta, 3);
// Regularization
if (S > S_lSAT)
S = S_lSAT;
const Evaluation hw = H2O::liquidEnthalpy(temperature, pressure)/1e3; // [kJ/kg]
// From Daubert and Danner
const Evaluation h_NaCl =
(3.6710e4*temperature
+ (6.2770e1/2)*temperature*temperature
- (6.6670e-2/3)*temperature*temperature*temperature
+ (2.8000e-5/4)*pow(temperature, 4.0))/58.44e3
- 2.045698e+02; // [kJ/kg]
const Evaluation m = S/(1-S)/58.44e-3;
Evaluation d_h = 0;
for (int i = 0; i<=3; ++i) {
for (int j = 0; j <= 2; ++j) {
d_h += a[i][j] * pow(theta, i) * pow(m, j);
}
}
const Evaluation delta_h = 4.184/(1e3 + (58.44 * m))*d_h;
// Enthalpy of brine
const Evaluation h_ls = (1-S)*hw + S*h_NaCl + S*delta_h; // [kJ/kg]
return h_ls*1e3; // convert to [J/kg]
}
template <class Evaluation>
static Evaluation liquidHeatCapacity(const Evaluation& temperature,
const Evaluation& pressure)
{
Scalar eps = scalarValue(temperature)*1e-8;
return (liquidEnthalpy(temperature + eps, pressure) - liquidEnthalpy(temperature, pressure))/eps;
}
template <class Evaluation>
static Evaluation gasHeatCapacity(const Evaluation& temperature,
const Evaluation& pressure)
{ return H2O::gasHeatCapacity(temperature, pressure); }
template <class Evaluation>
static Evaluation gasInternalEnergy(const Evaluation& temperature,
const Evaluation& pressure)
{
return
gasEnthalpy(temperature, pressure) -
pressure/gasDensity(temperature, pressure);
}
template <class Evaluation>
static Evaluation liquidInternalEnergy(const Evaluation& temperature,
const Evaluation& pressure)
{
return
liquidEnthalpy(temperature, pressure) -
pressure/liquidDensity(temperature, pressure);
}
template <class Evaluation>
static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
{ return H2O::gasDensity(temperature, pressure); }
template <class Evaluation>
static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure, bool extrapolate = false)
{
Evaluation tempC = temperature - 273.15;
Evaluation pMPa = pressure/1.0E6;
const Evaluation rhow = H2O::liquidDensity(temperature, pressure, extrapolate);
return
rhow +
1000*salinity*(
0.668 +
0.44*salinity +
1.0E-6*(
300*pMPa -
2400*pMPa*salinity +
tempC*(
80.0 +
3*tempC -
3300*salinity -
13*pMPa +
47*pMPa*salinity)));
}
template <class Evaluation>
static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
{ return H2O::gasPressure(temperature, density); }
template <class Evaluation>
static Evaluation liquidPressure(const Evaluation& temperature, const Evaluation& density)
{
// We use the newton method for this. For the initial value we
// assume the pressure to be 10% higher than the vapor
// pressure
Evaluation pressure = 1.1*vaporPressure(temperature);
Scalar eps = scalarValue(pressure)*1e-7;
Evaluation deltaP = pressure*2;
for (int i = 0;
i < 5
&& std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP));
++i)
{
const Evaluation f = liquidDensity(temperature, pressure) - density;
Evaluation df_dp = liquidDensity(temperature, pressure + eps);
df_dp -= liquidDensity(temperature, pressure - eps);
df_dp /= 2*eps;
deltaP = - f/df_dp;
pressure += deltaP;
}
return pressure;
}
template <class Evaluation>
static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
{ return H2O::gasViscosity(temperature, pressure); }
template <class Evaluation>
static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& /*pressure*/)
{
Evaluation T_C = temperature - 273.15;
if(temperature <= 275.) // regularization
T_C = 275.0;
Evaluation A = (0.42*std::pow((std::pow(salinity, 0.8)-0.17), 2) + 0.045)*pow(T_C, 0.8);
Evaluation mu_brine = 0.1 + 0.333*salinity + (1.65+91.9*salinity*salinity*salinity)*exp(-A);
return mu_brine/1000.0; // convert to [Pa s] (todo: check if correct cP->Pa s is times 10...)
}
};
template <class Scalar, class H2O>
Scalar Brine<Scalar, H2O>::salinity = 0.1; // also needs to be adapted in CO2 solubility table!
} // namespace Opm
#endif
Component.hpp
Abstract base class of a pure chemical species.
MathToolbox.hpp
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Opm::Brine
A class for the brine fluid properties.
Definition Brine.hpp:48
Opm::Brine::molarMass
static Scalar molarMass()
The molar mass in of the component.
Definition Brine.hpp:82
Opm::Brine::gasPressure
static Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition Brine.hpp:290
Opm::Brine::criticalVolume
static Scalar criticalVolume()
Returns the critical volume of water.
Definition Brine.hpp:105
Opm::Brine::tripleTemperature
static Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition Brine.hpp:117
Opm::Brine::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition Brine.hpp:99
Opm::Brine::gasInternalEnergy
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition Brine.hpp:229
Opm::Brine::vaporPressure
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition Brine.hpp:130
Opm::Brine::liquidEnthalpy
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in liquid.
Definition Brine.hpp:150
Opm::Brine::name
static std::string_view name()
A human readable name for the component.
Definition Brine.hpp:56
Opm::Brine::gasIsCompressible
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition Brine.hpp:68
Opm::Brine::liquidDensity
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in .
Definition Brine.hpp:264
Opm::Brine::gasViscosity
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition Brine.hpp:329
Opm::Brine::gasDensity
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition Brine.hpp:253
Opm::Brine::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition Brine.hpp:93
Opm::Brine::triplePressure
static Scalar triplePressure()
Returns the pressure at water's triple point.
Definition Brine.hpp:123
Opm::Brine::gasHeatCapacity
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition Brine.hpp:221
Opm::Brine::liquidViscosity
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &)
The dynamic viscosity of pure water.
Definition Brine.hpp:341
Opm::Brine::liquidInternalEnergy
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition Brine.hpp:241
Opm::Brine::liquidPressure
static Evaluation liquidPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of liquid water in at a given density and temperature.
Definition Brine.hpp:297
Opm::Brine::liquidIsCompressible
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition Brine.hpp:74
Opm::Brine::gasIsIdeal
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition Brine.hpp:62
Opm::Brine::gasEnthalpy
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition Brine.hpp:137
Opm::Brine::salinity
static Scalar salinity
The mass fraction of salt assumed to be in the brine.
Definition Brine.hpp:51
Opm::Brine::acentricFactor
static Scalar acentricFactor()
Definition Brine.hpp:111
Opm::Brine::liquidHeatCapacity
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition Brine.hpp:210
Opm::Component
Abstract base class of a pure chemical species.
Definition Component.hpp:44
Opm::H2O::liquidDensity
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of pure water in at a given pressure and temperature.
Definition H2O.hpp:689
Opm::H2O::criticalTemperature
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition H2O.hpp:97
Opm::H2O::gasDensity
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition H2O.hpp:564
Opm::H2O::gasIsCompressible
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition H2O.hpp:542
Opm::H2O::gasPressure
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition H2O.hpp:645
Opm::H2O::vaporPressure
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition H2O.hpp:143
Opm::H2O::gasViscosity
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition H2O.hpp:792
Opm::H2O::gasHeatCapacity
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition H2O.hpp:281
Opm::H2O::liquidEnthalpy
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition H2O.hpp:239
Opm::H2O::acentricFactor
static const Scalar acentricFactor()
The acentric factor of water.
Definition H2O.hpp:91
Opm::H2O::gasIsIdeal
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition H2O.hpp:629
Opm::H2O::criticalPressure
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition H2O.hpp:103
Opm::H2O::molarMass
static const Scalar molarMass()
The molar mass in of water.
Definition H2O.hpp:85
Opm::H2O::liquidIsCompressible
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition H2O.hpp:548
Opm::H2O::gasEnthalpy
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition H2O.hpp:188
Opm::H2O::tripleTemperature
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition H2O.hpp:121
Opm::H2O::triplePressure
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition H2O.hpp:127
Opm::H2O::criticalVolume
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition H2O.hpp:109
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30