30 #ifndef OPM_VISCOSITY_MODELS_HPP 31 #define OPM_VISCOSITY_MODELS_HPP 41 template <
class Scalar,
class Flu
idSystem>
49 static constexpr std::array<Scalar, 5> defaultLBCCoefficients()
51 return {Scalar(0.10230),
60 template <
class Flu
idState,
class Params,
class LhsEval =
typename Flu
idState::ValueType>
61 static LhsEval LBC(
const FluidState& fluidState,
65 const Scalar MPa_atm = 0.101325;
67 const auto& T = Opm::decay<LhsEval>(fluidState.temperature(phaseIdx));
68 const auto& P = Opm::decay<LhsEval>(fluidState.pressure(phaseIdx));
69 const auto& Z = Opm::decay<LhsEval>(fluidState.compressFactor(phaseIdx));
71 LhsEval sumVolume = 0.0;
72 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
73 const auto& x = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
74 const Scalar v_c = FluidSystem::criticalVolume(compIdx) / 1000;
78 LhsEval rho_pc = 1.0 / sumVolume;
79 LhsEval V = (R * T * Z)/P;
80 LhsEval rho = 1.0 / V;
81 LhsEval rho_r = rho / rho_pc;
83 LhsEval xsum_T_c = 0.0;
84 LhsEval xsum_Mm = 0.0;
85 LhsEval xsum_p_ca = 0.0;
86 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
87 const Scalar& p_c = FluidSystem::criticalPressure(compIdx) / 1e6;
88 const Scalar& T_c = FluidSystem::criticalTemperature(compIdx);
89 const Scalar Mm = FluidSystem::molarMass(compIdx) * 1000;
90 const auto& x = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
91 Scalar p_ca = p_c / MPa_atm;
94 xsum_p_ca += x * p_ca;
96 LhsEval zeta_tot = Opm::pow(xsum_T_c / (Opm::pow(xsum_Mm,3.0) * Opm::pow(xsum_p_ca,4.0)),1./6);
100 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
101 const Scalar& p_c = FluidSystem::criticalPressure(compIdx) / 1e6;
102 const Scalar& T_c = FluidSystem::criticalTemperature(compIdx);
103 const Scalar Mm = FluidSystem::molarMass(compIdx) * 1000;
104 const auto& x = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
105 Scalar p_ca = p_c / MPa_atm;
106 Scalar zeta = std::pow(T_c / (std::pow(Mm,3.0) * std::pow(p_ca,4.0)),1./6);
108 LhsEval xrM = x * std::pow(Mm,0.5);
111 mys = 34.0e-5*Opm::pow(T_r,0.94)/zeta;
113 mys = 17.78e-5*Opm::pow(4.58*T_r - 1.67, 0.625)/zeta;
121 const auto& LBC = []() -> decltype(
auto) {
122 if constexpr (requires { FluidSystem::lbcCoefficients(); }) {
123 return FluidSystem::lbcCoefficients();
125 static constexpr std::array<Scalar, 5> default_lbc = defaultLBCCoefficients();
126 return (default_lbc);
130 LhsEval sumLBC = 0.0;
131 for (
int i = 0; i < 5; ++i) {
132 sumLBC += Opm::pow(rho_r,i)*LBC[i];
135 const LhsEval mu = (my0 + (Opm::pow(sumLBC,4.0) - 1e-4)/zeta_tot)/1e3;
138 throw NumericalProblem(
"LBC correlation produced a non-positive viscosity; " 139 "check the LBC coefficients");
146 template <
class Flu
idState,
class Params,
class LhsEval =
typename Flu
idState::ValueType>
147 static LhsEval LBCco2rich(
const FluidState& fluidState,
151 const Scalar MPa_atm = 0.101325;
152 const auto& T = Opm::decay<LhsEval>(fluidState.temperature(phaseIdx));
153 const auto& rho = Opm::decay<LhsEval>(fluidState.density(phaseIdx));
156 LhsEval sumVolume = 0.0;
157 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
158 const Scalar Mm = FluidSystem::molarMass(compIdx) * 1000;
159 const auto& x = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
160 const Scalar v_c = FluidSystem::criticalVolume(compIdx);
165 LhsEval rho_pc = sumMm/sumVolume;
166 LhsEval rho_r = rho/rho_pc;
169 LhsEval xxT2_p = 0.0;
170 for (
unsigned i_compIdx = 0; i_compIdx < FluidSystem::numComponents; ++i_compIdx) {
171 const Scalar& T_c_i = FluidSystem::criticalTemperature(i_compIdx);
172 const Scalar& p_c_i = FluidSystem::criticalPressure(i_compIdx)/1e6;
173 const auto& x_i = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, i_compIdx));
174 for (
unsigned j_compIdx = 0; j_compIdx < FluidSystem::numComponents; ++j_compIdx) {
175 const Scalar& T_c_j = FluidSystem::criticalTemperature(j_compIdx);
176 const Scalar& p_c_j = FluidSystem::criticalPressure(j_compIdx)/1e6;
177 const auto& x_j = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, j_compIdx));
179 const Scalar T_c_ij = std::sqrt(T_c_i*T_c_j);
180 const Scalar p_c_ij = 8.0*T_c_ij / Opm::pow(Opm::pow(T_c_i/p_c_i,1.0/3)+Opm::pow(T_c_j/p_c_j,1.0/3),3);
182 xxT_p += x_i*x_j*T_c_ij/p_c_ij;
183 xxT2_p += x_i*x_j*T_c_ij*T_c_ij/p_c_ij;
187 const LhsEval T_pc = xxT2_p/xxT_p;
188 const LhsEval p_pc = T_pc/xxT_p;
190 LhsEval p_pca = p_pc / MPa_atm;
191 LhsEval zeta_tot = Opm::pow(T_pc / (Opm::pow(sumMm,3.0) * Opm::pow(p_pca,4.0)),1./6);
194 LhsEval sumxrM = 0.0;
195 for (
unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) {
196 const Scalar& p_c = FluidSystem::criticalPressure(compIdx)/1e6;
197 const Scalar& T_c = FluidSystem::criticalTemperature(compIdx);
198 const Scalar Mm = FluidSystem::molarMass(compIdx) * 1000;
199 const auto& x = Opm::decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
200 Scalar p_ca = p_c / MPa_atm;
201 Scalar zeta = std::pow(T_c / (std::pow(Mm,3.0) * std::pow(p_ca,4.0)),1./6);
203 LhsEval xrM = x * std::pow(Mm,0.5);
206 mys = 34.0e-5*Opm::pow(T_r,0.94)/zeta;
208 mys = 17.78e-5*Opm::pow(4.58*T_r - 1.67, 0.625)/zeta;
216 const auto& LBC = []() -> decltype(
auto) {
217 if constexpr (requires { FluidSystem::lbcCoefficients(); }) {
218 return FluidSystem::lbcCoefficients();
220 static constexpr std::array<Scalar, 5> default_lbc = defaultLBCCoefficients();
221 return (default_lbc);
225 LhsEval sumLBC = 0.0;
226 for (
int i = 0; i < 5; ++i) {
227 sumLBC += Opm::pow(rho_r,i)*LBC[i];
230 return (my0 + (Opm::pow(sumLBC,4.0) - 1e-4)/zeta_tot - 1.8366e-8*Opm::pow(rho_r,13.992))/1e3;
237 #endif // OPM_VISCOSITY_MODELS_HPP Definition: Exceptions.hpp:39
Definition: ViscosityModels.hpp:42
Provides the OPM specific exception classes.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Constants.hpp:41