Loading...
Searching...
No Matches
BrineDynamic.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_BRINEDYNAMIC_HPP
#define OPM_BRINEDYNAMIC_HPP
#include <opm/material/components/Component.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <string_view>
namespace Opm {
template <class Scalar, class H2O>
class BrineDynamic : public Component<Scalar, BrineDynamic<Scalar, H2O> >
{
public:
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(); }
template <class Evaluation>
static Evaluation molarMass(const Evaluation& salinity)
{
const Scalar M1 = H2O::molarMass();
const Evaluation X2 = salinity; // mass fraction of salt in brine
return M1*mM_salt/(mM_salt + X2*(M1 - mM_salt));
}
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,
const Evaluation& salinity)
{
// 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, const Evaluation& salinity, 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*/, const Evaluation& salinity)
{
Evaluation T_C = temperature - 273.15;
if(temperature <= 275.) // regularization
T_C = 275.0;
Evaluation A = (0.42*Opm::pow((Opm::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...)
}
//Molar mass salt (assumes pure NaCl) [kg/mol]
static constexpr Scalar mM_salt = 58.44e-3;
};
} // 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::BrineDynamic
A class for the brine fluid properties.
Definition BrineDynamic.hpp:48
Opm::BrineDynamic::molarMass
static Evaluation molarMass(const Evaluation &salinity)
The molar mass in of the component.
Definition BrineDynamic.hpp:81
Opm::BrineDynamic::tripleTemperature
static Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition BrineDynamic.hpp:115
Opm::BrineDynamic::gasDensity
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition BrineDynamic.hpp:252
Opm::BrineDynamic::name
static std::string_view name()
A human readable name for the component.
Definition BrineDynamic.hpp:54
Opm::BrineDynamic::gasViscosity
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition BrineDynamic.hpp:328
Opm::BrineDynamic::liquidEnthalpy
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity)
Specific enthalpy of the pure component in liquid.
Definition BrineDynamic.hpp:148
Opm::BrineDynamic::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition BrineDynamic.hpp:97
Opm::BrineDynamic::criticalVolume
static Scalar criticalVolume()
Returns the critical volume of water.
Definition BrineDynamic.hpp:103
Opm::BrineDynamic::liquidDensity
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
Opm::BrineDynamic::liquidPressure
static Evaluation liquidPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of liquid water in at a given density and temperature.
Definition BrineDynamic.hpp:296
Opm::BrineDynamic::liquidViscosity
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &, const Evaluation &salinity)
The dynamic viscosity of pure water.
Definition BrineDynamic.hpp:340
Opm::BrineDynamic::gasIsCompressible
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition BrineDynamic.hpp:66
Opm::BrineDynamic::gasHeatCapacity
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition BrineDynamic.hpp:220
Opm::BrineDynamic::gasEnthalpy
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition BrineDynamic.hpp:135
Opm::BrineDynamic::acentricFactor
static Scalar acentricFactor()
Definition BrineDynamic.hpp:109
Opm::BrineDynamic::liquidHeatCapacity
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition BrineDynamic.hpp:209
Opm::BrineDynamic::liquidIsCompressible
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition BrineDynamic.hpp:72
Opm::BrineDynamic::triplePressure
static Scalar triplePressure()
Returns the pressure at water's triple point.
Definition BrineDynamic.hpp:121
Opm::BrineDynamic::gasIsIdeal
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition BrineDynamic.hpp:60
Opm::BrineDynamic::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition BrineDynamic.hpp:91
Opm::BrineDynamic::liquidInternalEnergy
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition BrineDynamic.hpp:240
Opm::BrineDynamic::gasPressure
static Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition BrineDynamic.hpp:289
Opm::BrineDynamic::vaporPressure
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition BrineDynamic.hpp:128
Opm::BrineDynamic::gasInternalEnergy
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition BrineDynamic.hpp:228
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