本文整理汇总了C++中FluidState::averageMolarMass方法的典型用法代码示例。如果您正苦于以下问题:C++ FluidState::averageMolarMass方法的具体用法?C++ FluidState::averageMolarMass怎么用?C++ FluidState::averageMolarMass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluidState
的用法示例。
在下文中一共展示了FluidState::averageMolarMass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: density
static Scalar density(const FluidState &fluidState,
const ParameterCache ¶mCache,
unsigned phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
static_assert(std::is_same<Evaluation, Scalar>::value,
"The SPE-5 fluid system is currently only implemented for the scalar case.");
return fluidState.averageMolarMass(phaseIdx)/paramCache.molarVolume(phaseIdx);
}
示例2: density
static Scalar density(const FluidState &fluidState,
const ParameterCache ¶mCache,
int phaseIdx)
{
assert(0 <= phaseIdx && phaseIdx < numPhases);
Scalar T = fluidState.temperature(phaseIdx);
Scalar p;
if (isCompressible(phaseIdx))
p = fluidState.pressure(phaseIdx);
else {
// random value which will hopefully cause things to blow
// up if it is used in a calculation!
p = - 1e100;
Valgrind::SetUndefined(p);
}
Scalar sumMoleFrac = 0;
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
sumMoleFrac += fluidState.moleFraction(phaseIdx, compIdx);
if (phaseIdx == lPhaseIdx)
{
if (!useComplexRelations)
// assume pure water
return H2O::liquidDensity(T, p);
else
{
// See: Ochs 2008 (2.6)
Scalar rholH2O = H2O::liquidDensity(T, p);
Scalar clH2O = rholH2O/H2O::molarMass();
return
clH2O
* (H2O::molarMass()*fluidState.moleFraction(lPhaseIdx, H2OIdx)
+
Air::molarMass()*fluidState.moleFraction(lPhaseIdx, AirIdx))
/ sumMoleFrac;
}
}
else if (phaseIdx == gPhaseIdx)
{
if (!useComplexRelations)
// for the gas phase assume an ideal gas
return
IdealGas::molarDensity(T, p)
* fluidState.averageMolarMass(gPhaseIdx)
/ std::max(1e-5, sumMoleFrac);
Scalar partialPressureH2O =
fluidState.moleFraction(gPhaseIdx, H2OIdx) *
fluidState.pressure(gPhaseIdx);
Scalar partialPressureAir =
fluidState.moleFraction(gPhaseIdx, AirIdx) *
fluidState.pressure(gPhaseIdx);
return
H2O::gasDensity(T, partialPressureH2O) +
Air::gasDensity(T, partialPressureAir);
}
OPM_THROW(std::logic_error, "Invalid phase index " << phaseIdx);
}
示例3: density
static LhsEval density(const FluidState &fluidState,
const ParameterCache &/*paramCache*/,
unsigned phaseIdx)
{
typedef Opm::MathToolbox<typename FluidState::Scalar> FsToolbox;
typedef Opm::MathToolbox<LhsEval> LhsToolbox;
assert(0 <= phaseIdx && phaseIdx < numPhases);
const auto& T = FsToolbox::template toLhs<LhsEval>(fluidState.temperature(phaseIdx));
LhsEval p;
if (isCompressible(phaseIdx))
p = FsToolbox::template toLhs<LhsEval>(fluidState.pressure(phaseIdx));
else {
// random value which will hopefully cause things to blow
// up if it is used in a calculation!
p = - 1e100;
Valgrind::SetUndefined(p);
}
LhsEval sumMoleFrac = 0;
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
sumMoleFrac += FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
if (phaseIdx == liquidPhaseIdx)
{
if (!useComplexRelations)
// assume pure water
return H2O::liquidDensity(T, p);
else
{
// See: Ochs 2008 (2.6)
const LhsEval& rholH2O = H2O::liquidDensity(T, p);
const LhsEval& clH2O = rholH2O/H2O::molarMass();
const auto& xlH2O = FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(liquidPhaseIdx, H2OIdx));
const auto& xlAir = FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(liquidPhaseIdx, AirIdx));
return clH2O*(H2O::molarMass()*xlH2O + Air::molarMass()*xlAir)/sumMoleFrac;
}
}
else if (phaseIdx == gasPhaseIdx)
{
if (!useComplexRelations)
// for the gas phase assume an ideal gas
return
IdealGas::molarDensity(T, p)
* FsToolbox::template toLhs<LhsEval>(fluidState.averageMolarMass(gasPhaseIdx))
/ LhsToolbox::max(1e-5, sumMoleFrac);
LhsEval partialPressureH2O =
FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(gasPhaseIdx, H2OIdx))
*FsToolbox::template toLhs<LhsEval>(fluidState.pressure(gasPhaseIdx));
LhsEval partialPressureAir =
FsToolbox::template toLhs<LhsEval>(fluidState.moleFraction(gasPhaseIdx, AirIdx))
*FsToolbox::template toLhs<LhsEval>(fluidState.pressure(gasPhaseIdx));
return H2O::gasDensity(T, partialPressureH2O) + Air::gasDensity(T, partialPressureAir);
}
OPM_THROW(std::logic_error, "Invalid phase index " << phaseIdx);
}