PengRobinson: make compile when Scalar is not double.
This commit is contained in:
parent
c6c44acb4c
commit
92062f009c
@ -130,7 +130,7 @@ public:
|
||||
Scalar expo = Astar/(Bstar*std::sqrt(u*u - 4*w))*(bi_b - deltai);
|
||||
|
||||
Scalar fugCoeff =
|
||||
std::exp(bi_b*(Z - 1))/std::max(1e-9, Z - Bstar) *
|
||||
std::exp(bi_b*(Z - 1))/std::max(Scalar(1e-9), Z - Bstar) *
|
||||
std::pow(base, expo);
|
||||
|
||||
////////
|
||||
@ -139,12 +139,12 @@ public:
|
||||
// on one side, we want the mole fraction to be at
|
||||
// least 10^-3 if the fugacity is at the current pressure
|
||||
//
|
||||
fugCoeff = std::min(1e10, fugCoeff);
|
||||
fugCoeff = std::min(Scalar(1e10), fugCoeff);
|
||||
//
|
||||
// on the other hand, if the mole fraction of the component is 100%, we want the
|
||||
// fugacity to be at least 10^-3 Pa
|
||||
//
|
||||
fugCoeff = std::max(1e-10, fugCoeff);
|
||||
fugCoeff = std::max(Scalar(1e-10), fugCoeff);
|
||||
///////////
|
||||
|
||||
return fugCoeff;
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
Scalar sumx = 0.0;
|
||||
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
|
||||
sumx += fs.moleFraction(phaseIdx, compIdx);
|
||||
sumx = std::max(1e-10, sumx);
|
||||
sumx = std::max(Scalar(1e-10), sumx);
|
||||
|
||||
// Calculate the Peng-Robinson parameters of the mixture
|
||||
//
|
||||
@ -144,11 +144,13 @@ public:
|
||||
Scalar newA = 0;
|
||||
Scalar newB = 0;
|
||||
for (unsigned compIIdx = 0; compIIdx < numComponents; ++compIIdx) {
|
||||
Scalar xi = std::max(0.0, std::min(1.0, fs.moleFraction(phaseIdx, compIIdx)));
|
||||
const Scalar moleFracJ = fs.moleFraction(phaseIdx, compIIdx);
|
||||
Scalar xi = std::max(Scalar(0), std::min(Scalar(1), moleFracJ));
|
||||
Valgrind::CheckDefined(xi);
|
||||
|
||||
for (unsigned compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
|
||||
Scalar xj = std::max(0.0, std::min(1.0, fs.moleFraction(phaseIdx, compJIdx)));
|
||||
const Scalar moleFracJ = fs.moleFraction(phaseIdx, compJIdx );
|
||||
Scalar xj = std::max(Scalar(0), std::min(Scalar(1), moleFracJ));
|
||||
Valgrind::CheckDefined(xj);
|
||||
|
||||
// mixing rule from Reid, page 82
|
||||
@ -158,7 +160,7 @@ public:
|
||||
}
|
||||
|
||||
// mixing rule from Reid, page 82
|
||||
newB += std::max(0.0, xi) * this->pureParams_[compIIdx].b();
|
||||
newB += std::max(Scalar(0), xi) * this->pureParams_[compIIdx].b();
|
||||
assert(std::isfinite(newB));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user