mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
adapt to the recent blackoil API changes of opm-material
This commit is contained in:
parent
8272ec5528
commit
0cbc6839f2
@ -105,11 +105,6 @@ public:
|
||||
simulator.problem().gravity()[dimWorld - 1],
|
||||
opmBlackoilState);
|
||||
|
||||
const Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, /*regionIdx=*/0);
|
||||
const Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, /*regionIdx=*/0);
|
||||
const Scalar MG = FluidSystem::molarMass(gasCompIdx);
|
||||
const Scalar MO = FluidSystem::molarMass(oilCompIdx);
|
||||
|
||||
// copy the result into the array of initial fluid states
|
||||
initialFluidStates_.resize(numElems);
|
||||
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
|
||||
@ -140,7 +135,6 @@ public:
|
||||
Scalar po = opmBlackoilState.pressure()[elemIdx];
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
fluidState.setPressure(phaseIdx, po + (pC[phaseIdx] - pC[oilPhaseIdx]));
|
||||
Scalar pg = fluidState.pressure(gasPhaseIdx);
|
||||
|
||||
// reset the phase compositions
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
@ -155,15 +149,14 @@ public:
|
||||
// for gas and oil we have to translate surface volumes to mole fractions
|
||||
// before we can set the composition in the fluid state
|
||||
Scalar Rs = opmBlackoilState.gasoilratio()[elemIdx];
|
||||
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(fluidState, oilPhaseIdx, regionIdx);
|
||||
|
||||
// dissolved gas surface volume to mass fraction
|
||||
Scalar XoG = Rs/(rhooRef/rhogRef + Rs);
|
||||
// mass fraction to mole fraction
|
||||
Scalar xoG = XoG*MO / (MG*(1 - XoG) + XoG*MO);
|
||||
if (Rs > RsSat)
|
||||
Rs = RsSat;
|
||||
|
||||
Scalar xoGMax = FluidSystem::saturatedOilGasMoleFraction(T, pg, regionIdx);
|
||||
if (fluidState.saturation(gasPhaseIdx) > 0.0 || xoG > xoGMax)
|
||||
xoG = xoGMax;
|
||||
// convert the Rs factor to mole fraction dissolved gas in oil
|
||||
Scalar XoG = FluidSystem::convertRsToXoG(Rs, regionIdx);
|
||||
Scalar xoG = FluidSystem::convertXoGToxoG(XoG, regionIdx);
|
||||
|
||||
fluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, 1 - xoG);
|
||||
fluidState.setMoleFraction(oilPhaseIdx, gasCompIdx, xoG);
|
||||
@ -172,15 +165,14 @@ public:
|
||||
// retrieve the surface volume of vaporized gas
|
||||
if (gridManager.deck()->hasKeyword("VAPOIL")) {
|
||||
Scalar Rv = opmBlackoilState.rv()[elemIdx];
|
||||
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(fluidState, gasPhaseIdx, regionIdx);
|
||||
|
||||
// vaporized oil surface volume to mass fraction
|
||||
Scalar XgO = Rv/(rhogRef/rhooRef + Rv);
|
||||
// mass fraction to mole fraction
|
||||
Scalar xgO = XgO*MG / (MO*(1 - XgO) + XgO*MG);
|
||||
if (Rv > RvSat)
|
||||
Rv = RvSat;
|
||||
|
||||
Scalar xgOMax = FluidSystem::saturatedGasOilMoleFraction(T, pg, regionIdx);
|
||||
if (fluidState.saturation(oilPhaseIdx) > 0.0 || xgO > xgOMax)
|
||||
xgO = xgOMax;
|
||||
// convert the Rs factor to mole fraction dissolved gas in oil
|
||||
Scalar XgO = FluidSystem::convertRvToXgO(Rv, regionIdx);
|
||||
Scalar xgO = FluidSystem::convertXgOToxgO(XgO, regionIdx);
|
||||
|
||||
fluidState.setMoleFraction(gasPhaseIdx, oilCompIdx, xgO);
|
||||
fluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, 1 - xgO);
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
|
||||
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
|
||||
const auto &fs = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState();
|
||||
typedef typename std::remove_const<typename std::remove_reference<decltype(fs)>::type>::type FluidState;
|
||||
unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
|
||||
unsigned regionIdx = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0).pvtRegionIndex();
|
||||
Scalar po = Toolbox::value(fs.pressure(oilPhaseIdx));
|
||||
@ -186,22 +187,22 @@ public:
|
||||
}
|
||||
if (gasDissolutionFactorOutput_()) {
|
||||
gasDissolutionFactor_[globalDofIdx] =
|
||||
FluidSystem::gasDissolutionFactor(To, po, regionIdx);
|
||||
FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(fs, gasPhaseIdx, regionIdx);
|
||||
Valgrind::CheckDefined(gasDissolutionFactor_[globalDofIdx]);
|
||||
}
|
||||
if (gasFormationVolumeFactorOutput_()) {
|
||||
gasFormationVolumeFactor_[globalDofIdx] =
|
||||
FluidSystem::gasFormationVolumeFactor(To, po, XgO, regionIdx);
|
||||
FluidSystem::template formationVolumeFactor<FluidState, Scalar>(fs, gasPhaseIdx, regionIdx);
|
||||
Valgrind::CheckDefined(gasFormationVolumeFactor_[globalDofIdx]);
|
||||
}
|
||||
if (saturatedOilFormationVolumeFactorOutput_()) {
|
||||
saturatedOilFormationVolumeFactor_[globalDofIdx] =
|
||||
FluidSystem::saturatedOilFormationVolumeFactor(To, po, regionIdx);
|
||||
FluidSystem::template saturatedFormationVolumeFactor<FluidState, Scalar>(fs, oilPhaseIdx, regionIdx);
|
||||
Valgrind::CheckDefined(saturatedOilFormationVolumeFactor_[globalDofIdx]);
|
||||
}
|
||||
if (oilSaturationPressureOutput_()) {
|
||||
oilSaturationPressure_[globalDofIdx] =
|
||||
FluidSystem::oilSaturationPressure(To, XoG, regionIdx);
|
||||
FluidSystem::template saturationPressure<FluidState, Scalar>(fs, oilPhaseIdx, regionIdx);
|
||||
Valgrind::CheckDefined(oilSaturationPressure_[globalDofIdx]);
|
||||
}
|
||||
}
|
||||
|
@ -948,6 +948,7 @@ private:
|
||||
for (size_t dofIdx = 0; dofIdx < numDof; ++dofIdx) {
|
||||
auto &dofFluidState = initialFluidStates_[dofIdx];
|
||||
|
||||
int pvtRegionIdx = pvtRegionIndex(dofIdx);
|
||||
size_t cartesianDofIdx = gridManager.cartesianIndex(dofIdx);
|
||||
assert(0 <= cartesianDofIdx);
|
||||
assert(cartesianDofIdx <= numCartesianCells);
|
||||
@ -968,7 +969,7 @@ private:
|
||||
dofFluidState.setSaturation(FluidSystem::gasPhaseIdx,
|
||||
gasSaturationData[cartesianDofIdx]);
|
||||
dofFluidState.setSaturation(FluidSystem::oilPhaseIdx,
|
||||
1
|
||||
1.0
|
||||
- waterSaturationData[cartesianDofIdx]
|
||||
- gasSaturationData[cartesianDofIdx]);
|
||||
|
||||
@ -986,7 +987,6 @@ private:
|
||||
Valgrind::CheckDefined(pc);
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
dofFluidState.setPressure(phaseIdx, oilPressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
|
||||
Scalar gasPressure = dofFluidState.pressure(gasPhaseIdx);
|
||||
|
||||
//////
|
||||
// set compositions
|
||||
@ -1003,17 +1003,7 @@ private:
|
||||
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, 1.0);
|
||||
|
||||
if (enableDisgas) {
|
||||
// set the composition of the oil phase:
|
||||
//
|
||||
// first, retrieve the relevant black-oil parameters from
|
||||
// the fluid system.
|
||||
//
|
||||
// note that we use the gas pressure here. this is because the primary
|
||||
// varibles and the intensive quantities of the black oil model also do
|
||||
// this...
|
||||
Scalar RsSat = FluidSystem::gasDissolutionFactor(temperature,
|
||||
gasPressure,
|
||||
/*regionIdx=*/0);
|
||||
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(dofFluidState, oilPhaseIdx, pvtRegionIdx);
|
||||
Scalar RsReal = (*rsData)[cartesianDofIdx];
|
||||
|
||||
if (RsReal > RsSat) {
|
||||
@ -1024,36 +1014,21 @@ private:
|
||||
<< " amount which can be dissolved in oil"
|
||||
<< " (R_s,max=" << RsSat << ")"
|
||||
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
||||
<< " Ignoring.\n";
|
||||
<< " Using maximimum.\n";
|
||||
RsReal = RsSat;
|
||||
}
|
||||
|
||||
// calculate composition of the real and the saturated oil phase in terms of
|
||||
// mass fractions.
|
||||
Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, /*regionIdx=*/0);
|
||||
Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, /*regionIdx=*/0);
|
||||
Scalar XoGReal = RsReal/(RsReal + rhooRef/rhogRef);
|
||||
|
||||
// convert mass to mole fractions
|
||||
Scalar MG = FluidSystem::molarMass(gasCompIdx);
|
||||
Scalar MO = FluidSystem::molarMass(oilCompIdx);
|
||||
|
||||
Scalar xoGReal = XoGReal * MO / ((MO - MG) * XoGReal + MG);
|
||||
Scalar xoOReal = 1 - xoGReal;
|
||||
// calculate the initial oil phase composition in terms of mole fractions
|
||||
Scalar XoGReal = FluidSystem::convertRsToXoG(RsReal, pvtRegionIdx);
|
||||
Scalar xoGReal = FluidSystem::convertXoGToxoG(XoGReal, pvtRegionIdx);
|
||||
|
||||
// finally, set the oil-phase composition
|
||||
dofFluidState.setMoleFraction(oilPhaseIdx, gasCompIdx, xoGReal);
|
||||
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, xoOReal);
|
||||
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, 1.0 - xoGReal);
|
||||
}
|
||||
|
||||
if (enableVapoil) {
|
||||
// set the composition of the gas phase:
|
||||
//
|
||||
// first, retrieve the relevant black-gas parameters from
|
||||
// the fluid system.
|
||||
Scalar RvSat = FluidSystem::oilVaporizationFactor(temperature,
|
||||
gasPressure,
|
||||
/*regionIdx=*/0);
|
||||
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(dofFluidState, gasPhaseIdx, pvtRegionIdx);
|
||||
Scalar RvReal = (*rvData)[cartesianDofIdx];
|
||||
|
||||
if (RvReal > RvSat) {
|
||||
@ -1064,26 +1039,17 @@ private:
|
||||
<< " amount which can be dissolved in gas"
|
||||
<< " (R_v,max=" << RvSat << ")"
|
||||
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
||||
<< " Ignoring.\n";
|
||||
<< " Using maximimum.\n";
|
||||
RvReal = RvSat;
|
||||
}
|
||||
|
||||
// calculate composition of the real and the saturated gas phase in terms of
|
||||
// mass fractions.
|
||||
Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, /*regionIdx=*/0);
|
||||
Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, /*regionIdx=*/0);
|
||||
Scalar XgOReal = RvReal/(RvReal + rhogRef/rhooRef);
|
||||
|
||||
// convert mass to mole fractions
|
||||
Scalar MG = FluidSystem::molarMass(gasCompIdx);
|
||||
Scalar MO = FluidSystem::molarMass(oilCompIdx);
|
||||
|
||||
Scalar xgOReal = XgOReal * MG / ((MG - MO) * XgOReal + MO);
|
||||
Scalar xgGReal = 1 - xgOReal;
|
||||
// calculate the initial gas phase composition in terms of mole fractions
|
||||
Scalar XgOReal = FluidSystem::convertRvToXgO(RvReal, pvtRegionIdx);
|
||||
Scalar xgOReal = FluidSystem::convertXgOToxgO(XgOReal, pvtRegionIdx);
|
||||
|
||||
// finally, set the gas-phase composition
|
||||
dofFluidState.setMoleFraction(gasPhaseIdx, oilCompIdx, xgOReal);
|
||||
dofFluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, xgGReal);
|
||||
dofFluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, 1.0 - xgOReal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user