本文整理汇总了C++中FluidState::setPressure方法的典型用法代码示例。如果您正苦于以下问题:C++ FluidState::setPressure方法的具体用法?C++ FluidState::setPressure怎么用?C++ FluidState::setPressure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluidState
的用法示例。
在下文中一共展示了FluidState::setPressure方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: completeReferenceFluidState
void completeReferenceFluidState(FluidState &fs,
typename MaterialLaw::Params &matParams,
int refPhaseIdx)
{
enum { numPhases = FluidSystem::numPhases };
typedef Dune::FieldVector<Scalar, numPhases> PhaseVector;
int otherPhaseIdx = 1 - refPhaseIdx;
// calculate the other saturation
fs.setSaturation(otherPhaseIdx, 1.0 - fs.saturation(refPhaseIdx));
// calulate the capillary pressure
PhaseVector pC;
MaterialLaw::capillaryPressures(pC, matParams, fs);
fs.setPressure(otherPhaseIdx,
fs.pressure(refPhaseIdx)
+ (pC[otherPhaseIdx] - pC[refPhaseIdx]));
// set all phase densities
typename FluidSystem::ParameterCache paramCache;
paramCache.updateAll(fs);
for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx);
fs.setDensity(phaseIdx, rho);
}
}
示例2: completeReferenceFluidState
void completeReferenceFluidState(FluidState &fs,
typename MaterialLaw::Params &matParams,
int refPhaseIdx)
{
enum { numPhases = FluidSystem::numPhases };
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> ComputeFromReferencePhase;
typedef Dune::FieldVector<Scalar, numPhases> PhaseVector;
int otherPhaseIdx = 1 - refPhaseIdx;
// calculate the other saturation
fs.setSaturation(otherPhaseIdx, 1.0 - fs.saturation(refPhaseIdx));
// calulate the capillary pressure
PhaseVector pC;
MaterialLaw::capillaryPressures(pC, matParams, fs);
fs.setPressure(otherPhaseIdx,
fs.pressure(refPhaseIdx)
+ (pC[otherPhaseIdx] - pC[refPhaseIdx]));
// make the fluid state consistent with local thermodynamic
// equilibrium
typename FluidSystem::ParameterCache paramCache;
ComputeFromReferencePhase::solve(fs,
paramCache,
refPhaseIdx,
/*setViscosity=*/false,
/*setEnthalpy=*/false);
}
示例3: createSurfaceGasFluidSystem
void createSurfaceGasFluidSystem(FluidState& gasFluidState)
{
static const int gasPhaseIdx = FluidSystem::gasPhaseIdx;
// temperature
gasFluidState.setTemperature(273.15 + 20);
// gas pressure
gasFluidState.setPressure(gasPhaseIdx, 1e5);
// gas saturation
gasFluidState.setSaturation(gasPhaseIdx, 1.0);
// gas composition: mostly methane, a bit of propane
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::H2OIdx, 0.0);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C1Idx, 0.94);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C3Idx, 0.06);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C6Idx, 0.00);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C10Idx, 0.00);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C15Idx, 0.00);
gasFluidState.setMoleFraction(gasPhaseIdx, FluidSystem::C20Idx, 0.00);
// gas density
typename FluidSystem::template ParameterCache<typename FluidState::Scalar> paramCache;
paramCache.updatePhase(gasFluidState, gasPhaseIdx);
gasFluidState.setDensity(gasPhaseIdx,
FluidSystem::density(gasFluidState, paramCache, gasPhaseIdx));
}
示例4: guessInitial
static void guessInitial(FluidState &fluidState,
const Dune::FieldVector<Evaluation, numComponents>& /*globalMolarities*/)
{
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
// pressure. use 1 bar as initial guess
fluidState.setPressure(phaseIdx, 1e5);
// saturation. assume all fluids to be equally distributed
fluidState.setSaturation(phaseIdx, 1.0/numPhases);
}
}
示例5: testAll
inline void testAll()
{
typedef Opm::FluidSystems::Spe5<Scalar> FluidSystem;
enum {
numPhases = FluidSystem::numPhases,
waterPhaseIdx = FluidSystem::waterPhaseIdx,
gasPhaseIdx = FluidSystem::gasPhaseIdx,
oilPhaseIdx = FluidSystem::oilPhaseIdx,
numComponents = FluidSystem::numComponents,
H2OIdx = FluidSystem::H2OIdx,
C1Idx = FluidSystem::C1Idx,
C3Idx = FluidSystem::C3Idx,
C6Idx = FluidSystem::C6Idx,
C10Idx = FluidSystem::C10Idx,
C15Idx = FluidSystem::C15Idx,
C20Idx = FluidSystem::C20Idx
};
typedef Opm::NcpFlash<Scalar, FluidSystem> Flash;
typedef Dune::FieldVector<Scalar, numComponents> ComponentVector;
typedef Opm::CompositionalFluidState<Scalar, FluidSystem> FluidState;
typedef Opm::ThreePhaseMaterialTraits<Scalar, waterPhaseIdx, oilPhaseIdx, gasPhaseIdx> MaterialTraits;
typedef Opm::LinearMaterial<MaterialTraits> MaterialLaw;
typedef typename MaterialLaw::Params MaterialLawParams;
typedef typename FluidSystem::template ParameterCache<Scalar> ParameterCache;
////////////
// Initialize the fluid system and create the capillary pressure
// parameters
////////////
Scalar T = 273.15 + 20; // 20 deg Celsius
FluidSystem::init(/*minTemperature=*/T - 1,
/*maxTemperature=*/T + 1,
/*minPressure=*/1.0e4,
/*maxTemperature=*/40.0e6);
// 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();
////////////
// Create a fluid state
////////////
FluidState gasFluidState;
createSurfaceGasFluidSystem<FluidSystem>(gasFluidState);
FluidState fluidState;
ParameterCache paramCache;
// temperature
fluidState.setTemperature(T);
// oil pressure
fluidState.setPressure(oilPhaseIdx, 4000 * 6894.7573); // 4000 PSI
// oil saturation
fluidState.setSaturation(oilPhaseIdx, 1.0);
fluidState.setSaturation(gasPhaseIdx, 1.0 - fluidState.saturation(oilPhaseIdx));
// oil composition: SPE-5 reservoir oil
fluidState.setMoleFraction(oilPhaseIdx, H2OIdx, 0.0);
fluidState.setMoleFraction(oilPhaseIdx, C1Idx, 0.50);
fluidState.setMoleFraction(oilPhaseIdx, C3Idx, 0.03);
fluidState.setMoleFraction(oilPhaseIdx, C6Idx, 0.07);
fluidState.setMoleFraction(oilPhaseIdx, C10Idx, 0.20);
fluidState.setMoleFraction(oilPhaseIdx, C15Idx, 0.15);
fluidState.setMoleFraction(oilPhaseIdx, C20Idx, 0.05);
//makeOilSaturated<Scalar, FluidSystem>(fluidState, gasFluidState);
// set the saturations and pressures of the other phases
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (phaseIdx != oilPhaseIdx) {
fluidState.setSaturation(phaseIdx, 0.0);
fluidState.setPressure(phaseIdx, fluidState.pressure(oilPhaseIdx));
}
// initial guess for the composition (needed by the ComputeFromReferencePhase
// constraint solver. TODO: bug in ComputeFromReferencePhase?)
guessInitial<FluidSystem>(fluidState, phaseIdx);
}
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
CFRP::solve(fluidState,
paramCache,
/*refPhaseIdx=*/oilPhaseIdx,
/*setViscosity=*/false,
/*setEnthalpy=*/false);
////////////
// Calculate the total molarities of the components
////////////
//.........这里部分代码省略.........
示例6: 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;
}