40 enum { numComponents = FluidSystem::numComponents };
44 using EOSType = CompositionalConfig::EOSType;
51 void setEOSType(
const EOSType eos_type)
56 void updatePure(Scalar temperature, Scalar pressure)
58 Valgrind::CheckDefined(temperature);
59 Valgrind::CheckDefined(pressure);
62 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
63 Scalar pr = pressure / FluidSystem::criticalPressure(compIdx);
64 Scalar Tr = temperature / FluidSystem::criticalTemperature(compIdx);
65 Scalar OmegaA = OmegaA_(temperature, compIdx);
66 Scalar OmegaB = OmegaB_();
68 Scalar newA = OmegaA * pr / (Tr * Tr);
69 Scalar newB = OmegaB * pr / Tr;
70 assert(std::isfinite(scalarValue(newA)));
71 assert(std::isfinite(scalarValue(newB)));
75 Valgrind::CheckDefined(Ai(compIdx));
76 Valgrind::CheckDefined(Bi(compIdx));
84 template <
class Flu
idState>
85 void updateMix(
const FluidState& fs)
87 using FlashEval =
typename FluidState::Scalar;
91 for (
unsigned compIIdx = 0; compIIdx < numComponents; ++compIIdx) {
92 const FlashEval moleFracI = fs.moleFraction(phaseIdx, compIIdx);
93 FlashEval xi = max(0.0, min(1.0, moleFracI));
94 Valgrind::CheckDefined(xi);
96 for (
unsigned compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
97 const FlashEval moleFracJ = fs.moleFraction(phaseIdx, compJIdx );
98 FlashEval xj = max(0.0, min(1.0, moleFracJ));
99 Valgrind::CheckDefined(xj);
102 newA += xi * xj * aCache_[compIIdx][compJIdx];
103 assert(std::isfinite(scalarValue(newA)));
107 newB += max(0.0, xi) * Bi(compIIdx);
108 assert(std::isfinite(scalarValue(newB)));
112 setA(decay<Scalar>(newA));
113 setB(decay<Scalar>(newB));
114 Valgrind::CheckDefined(A());
115 Valgrind::CheckDefined(B());
118 template <
class Flu
idState>
119 void updateSingleMoleFraction(
const FluidState& fs,
125 Scalar aCache(
unsigned compIIdx,
unsigned compJIdx )
const
127 return aCache_[compIIdx][compJIdx];
130 void setAi(Scalar value,
unsigned compIdx)
132 Ai_[compIdx] = value;
135 void setBi(Scalar value,
unsigned compIdx)
137 Bi_[compIdx] = value;
140 Scalar Ai(
unsigned compIdx)
const
145 Scalar Bi(
unsigned compIdx)
const
150 void setA(Scalar value)
155 void setB(Scalar value)
173 case EOSType::PRCORR:
179 return SRK::calcm1();
181 throw std::runtime_error(
"EOS type not implemented!");
188 case EOSType::PRCORR:
194 return SRK::calcm2();
196 throw std::runtime_error(
"EOS type not implemented!");
201 std::array<Scalar, numComponents> Ai_;
202 std::array<Scalar, numComponents> Bi_;
205 std::array<std::array<Scalar, numComponents>, numComponents> aCache_;
212 for (
unsigned compIIdx = 0; compIIdx < numComponents; ++ compIIdx) {
213 for (
unsigned compJIdx = 0; compJIdx < numComponents; ++ compJIdx) {
215 Scalar Psi = FluidSystem::interactionCoefficient(compIIdx, compJIdx);
217 aCache_[compIIdx][compJIdx] = sqrt(Ai(compIIdx) * Ai(compJIdx)) * (1 - Psi);
222 Scalar OmegaA_(Scalar temperature,
unsigned compIdx)
225 case EOSType::PRCORR:
226 return PR::calcOmegaA(temperature, compIdx,
true);
228 return PR::calcOmegaA(temperature, compIdx,
false);
230 return RK::calcOmegaA(temperature, compIdx);
232 return SRK::calcOmegaA(temperature, compIdx);
234 throw std::runtime_error(
"EOS type not implemented!");
241 case EOSType::PRCORR:
243 return PR::calcOmegaB();
245 return RK::calcOmegaB();
247 return SRK::calcOmegaB();
249 throw std::runtime_error(
"EOS type not implemented!");