本文整理汇总了C++中Params::a方法的典型用法代码示例。如果您正苦于以下问题:C++ Params::a方法的具体用法?C++ Params::a怎么用?C++ Params::a使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Params
的用法示例。
在下文中一共展示了Params::a方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeFugacityCoefficient
static Scalar computeFugacityCoefficient(const FluidState &fs,
const Params ¶ms,
int phaseIdx,
int compIdx)
{
// note that we normalize the component mole fractions, so
// that their sum is 100%. This increases numerical stability
// considerably if the fluid state is not physical.
Scalar Vm = params.molarVolume(phaseIdx);
// Calculate b_i / b
Scalar bi_b = params.bPure(phaseIdx, compIdx) / params.b(phaseIdx);
// Calculate the compressibility factor
Scalar RT = R*fs.temperature(phaseIdx);
Scalar p = fs.pressure(phaseIdx); // molar volume in [bar]
Scalar Z = p*Vm/RT; // compressibility factor
// Calculate A^* and B^* (see: Reid, p. 42)
Scalar Astar = params.a(phaseIdx)*p/(RT*RT);
Scalar Bstar = params.b(phaseIdx)*p/(RT);
// calculate delta_i (see: Reid, p. 145)
Scalar sumMoleFractions = 0.0;
for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx)
sumMoleFractions += fs.moleFraction(phaseIdx, compJIdx);
Scalar deltai = 2*std::sqrt(params.aPure(phaseIdx, compIdx))/params.a(phaseIdx);
Scalar tmp = 0;
for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
tmp +=
fs.moleFraction(phaseIdx, compJIdx)
/ sumMoleFractions
* std::sqrt(params.aPure(phaseIdx, compJIdx))
* (1.0 - StaticParameters::interactionCoefficient(compIdx, compJIdx));
};
deltai *= tmp;
Scalar base =
(2*Z + Bstar*(u + std::sqrt(u*u - 4*w))) /
(2*Z + Bstar*(u - std::sqrt(u*u - 4*w)));
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::pow(base, expo);
////////
// limit the fugacity coefficient to a reasonable range:
//
// 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);
//
// 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);
///////////
return fugCoeff;
}