本文整理汇总了C++中FluidState::density方法的典型用法代码示例。如果您正苦于以下问题:C++ FluidState::density方法的具体用法?C++ FluidState::density怎么用?C++ FluidState::density使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluidState
的用法示例。
在下文中一共展示了FluidState::density方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assign
void assign(const FluidState& fs)
{
typedef typename FluidState::Scalar FsScalar;
typedef Opm::MathToolbox<FsScalar> FsToolbox;
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
density_[phaseIdx] = FsToolbox::template toLhs<Scalar>(fs.density(phaseIdx));
}
}
示例2: assign
void assign(const FluidState& fs)
{
if (enableTemperature || enableEnergy)
setTemperature(fs.temperature(/*phaseIdx=*/0));
unsigned pvtRegionIdx = getPvtRegionIndex_<FluidState>(fs);
setPvtRegionIndex(pvtRegionIdx);
setRs(Opm::BlackOil::getRs_<FluidSystem, FluidState, Scalar>(fs, pvtRegionIdx));
setRv(Opm::BlackOil::getRv_<FluidSystem, FluidState, Scalar>(fs, pvtRegionIdx));
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
setSaturation(phaseIdx, fs.saturation(phaseIdx));
setPressure(phaseIdx, fs.pressure(phaseIdx));
setDensity(phaseIdx, fs.density(phaseIdx));
if (enableEnergy)
setEnthalpy(phaseIdx, fs.enthalpy(phaseIdx));
setInvB(phaseIdx, getInvB_<FluidSystem, FluidState, Scalar>(fs, phaseIdx, pvtRegionIdx));
}
}
示例3: bringOilToSurface
Scalar bringOilToSurface(FluidState& surfaceFluidState, Scalar alpha, const FluidState& reservoirFluidState, bool guessInitial)
{
enum {
numPhases = FluidSystem::numPhases,
waterPhaseIdx = FluidSystem::waterPhaseIdx,
gasPhaseIdx = FluidSystem::gasPhaseIdx,
oilPhaseIdx = FluidSystem::oilPhaseIdx,
numComponents = FluidSystem::numComponents
};
typedef Opm::NcpFlash<Scalar, FluidSystem> Flash;
typedef Opm::ThreePhaseMaterialTraits<Scalar, waterPhaseIdx, oilPhaseIdx, gasPhaseIdx> MaterialTraits;
typedef Opm::LinearMaterial<MaterialTraits> MaterialLaw;
typedef typename MaterialLaw::Params MaterialLawParams;
typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
const Scalar refPressure = 1.0135e5; // [Pa]
// set the parameters for the capillary pressure law
MaterialLawParams matParams;
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
matParams.setPcMinSat(phaseIdx, 0.0);
matParams.setPcMaxSat(phaseIdx, 0.0);
}
matParams.finalize();
// retieve the global volumetric component molarities
surfaceFluidState.setTemperature(273.15 + 20);
ComponentVector molarities;
for (unsigned compIdx = 0; compIdx < numComponents; ++ compIdx)
molarities[compIdx] = reservoirFluidState.molarity(oilPhaseIdx, compIdx);
if (guessInitial) {
// we start at a fluid state with reservoir oil.
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
for (unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
surfaceFluidState.setMoleFraction(phaseIdx,
compIdx,
reservoirFluidState.moleFraction(phaseIdx, compIdx));
}
surfaceFluidState.setDensity(phaseIdx, reservoirFluidState.density(phaseIdx));
surfaceFluidState.setPressure(phaseIdx, reservoirFluidState.pressure(phaseIdx));
surfaceFluidState.setSaturation(phaseIdx, 0.0);
}
surfaceFluidState.setSaturation(oilPhaseIdx, 1.0);
surfaceFluidState.setSaturation(gasPhaseIdx, 1.0 - surfaceFluidState.saturation(oilPhaseIdx));
}
typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updateAll(surfaceFluidState);
// increase volume until we are at surface pressure. use the
// newton method for this
ComponentVector tmpMolarities;
for (int i = 0;; ++i) {
if (i >= 20)
throw Opm::NumericalIssue("Newton method did not converge after 20 iterations");
// calculate the deviation from the standard pressure
tmpMolarities = molarities;
tmpMolarities /= alpha;
Flash::template solve<MaterialLaw>(surfaceFluidState, matParams, paramCache, tmpMolarities);
Scalar f = surfaceFluidState.pressure(gasPhaseIdx) - refPressure;
// calculate the derivative of the deviation from the standard
// pressure
Scalar eps = alpha*1e-10;
tmpMolarities = molarities;
tmpMolarities /= alpha + eps;
Flash::template solve<MaterialLaw>(surfaceFluidState, matParams, paramCache, tmpMolarities);
Scalar fStar = surfaceFluidState.pressure(gasPhaseIdx) - refPressure;
Scalar fPrime = (fStar - f)/eps;
// newton update
Scalar delta = f/fPrime;
alpha -= delta;
if (std::abs(delta) < std::abs(alpha)*1e-9) {
break;
}
}
// calculate the final result
tmpMolarities = molarities;
tmpMolarities /= alpha;
Flash::template solve<MaterialLaw>(surfaceFluidState, matParams, paramCache, tmpMolarities);
return alpha;
}