mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-27 17:50:59 -06:00
Start using the BlackoilFluidState
This commit is contained in:
parent
ab72522e6c
commit
321af5ff4d
@ -30,7 +30,7 @@
|
||||
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
|
||||
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
|
||||
#include <opm/material/fluidstates/BlackOilFluidState.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
|
||||
|
||||
// the ordering of these includes matters. do not touch it if you're not prepared to deal
|
||||
@ -69,7 +69,9 @@ class EclEquilInitializer
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
|
||||
|
||||
typedef Opm::CompositionalFluidState<Scalar, FluidSystem> ScalarFluidState;
|
||||
typedef Opm::BlackOilFluidState<Scalar,
|
||||
FluidSystem,
|
||||
/*enableTemperature=*/true> ScalarFluidState;
|
||||
|
||||
enum { numPhases = FluidSystem::numPhases };
|
||||
enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
|
||||
@ -108,19 +110,29 @@ public:
|
||||
|
||||
// get the PVT region index of the current element
|
||||
unsigned regionIdx = simulator_.problem().pvtRegionIndex(elemIdx);
|
||||
fluidState.setPvtRegionIndex(regionIdx);
|
||||
|
||||
// set the phase saturations
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
||||
Scalar S;
|
||||
if (!FluidSystem::phaseIsActive(phaseIdx))
|
||||
S = 0.0;
|
||||
else {
|
||||
S = initialState.saturation()[phaseIdx][elemIdx];
|
||||
}
|
||||
fluidState.setSaturation(phaseIdx, S);
|
||||
if (FluidSystem::phaseIsActive(phaseIdx))
|
||||
fluidState.setSaturation(phaseIdx, initialState.saturation()[phaseIdx][elemIdx]);
|
||||
else
|
||||
fluidState.setSaturation(phaseIdx, 0.0);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
fluidState.setRs(initialState.rs()[elemIdx]);
|
||||
else
|
||||
fluidState.setRs(0.0);
|
||||
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
fluidState.setRv(initialState.rv()[elemIdx]);
|
||||
else
|
||||
fluidState.setRv(0.0);
|
||||
|
||||
|
||||
// set the temperature
|
||||
// TODO Get the temperature from the initialState
|
||||
Scalar T = FluidSystem::surfaceTemperature;
|
||||
fluidState.setTemperature(T);
|
||||
|
||||
@ -128,47 +140,6 @@ public:
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
fluidState.setPressure(phaseIdx, initialState.press()[phaseIdx][elemIdx]);
|
||||
|
||||
// reset the phase compositions
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
|
||||
fluidState.setMoleFraction(phaseIdx, compIdx, 0.0);
|
||||
|
||||
// the composition of the water phase is simple: it only consists of the
|
||||
// water component.
|
||||
fluidState.setMoleFraction(waterPhaseIdx, waterCompIdx, 1.0);
|
||||
|
||||
if (FluidSystem::enableDissolvedGas()) {
|
||||
// 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 = initialState.rs()[elemIdx];
|
||||
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(fluidState, oilPhaseIdx, regionIdx);
|
||||
|
||||
if (Rs > RsSat)
|
||||
Rs = RsSat;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// retrieve the surface volume of vaporized gas
|
||||
if (FluidSystem::enableVaporizedOil()) {
|
||||
Scalar Rv = initialState.rv()[elemIdx];
|
||||
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(fluidState, gasPhaseIdx, regionIdx);
|
||||
|
||||
if (Rv > RvSat)
|
||||
Rv = RvSat;
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,10 @@ class EclProblem : public GET_PROP_TYPE(TypeTag, BaseProblem)
|
||||
typedef BlackOilSolventModule<TypeTag> SolventModule;
|
||||
typedef BlackOilPolymerModule<TypeTag> PolymerModule;
|
||||
|
||||
typedef Opm::CompositionalFluidState<Scalar, FluidSystem> ScalarFluidState;
|
||||
typedef Opm::BlackOilFluidState<Scalar,
|
||||
FluidSystem,
|
||||
/*enableTemperature=*/true> InitialFluidState;
|
||||
|
||||
typedef Opm::MathToolbox<Evaluation> Toolbox;
|
||||
typedef Ewoms::EclSummaryWriter<TypeTag> EclSummaryWriter;
|
||||
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
|
||||
@ -1008,7 +1011,7 @@ public:
|
||||
{ return wellManager_; }
|
||||
|
||||
// temporary solution to facilitate output of initial state from flow
|
||||
const ScalarFluidState& initialFluidState(unsigned globalDofIdx ) const {
|
||||
const InitialFluidState& initialFluidState(unsigned globalDofIdx ) const {
|
||||
return initialFluidStates_[globalDofIdx];
|
||||
}
|
||||
|
||||
@ -1314,7 +1317,7 @@ private:
|
||||
for (size_t dofIdx = 0; dofIdx < numDof; ++dofIdx) {
|
||||
auto& dofFluidState = initialFluidStates_[dofIdx];
|
||||
|
||||
int pvtRegionIdx = pvtRegionIndex(dofIdx);
|
||||
dofFluidState.setPvtRegionIndex(pvtRegionIndex(dofIdx));
|
||||
size_t cartesianDofIdx = gridManager.cartesianIndex(dofIdx);
|
||||
assert(0 <= cartesianDofIdx);
|
||||
assert(cartesianDofIdx <= numCartesianCells);
|
||||
@ -1354,69 +1357,16 @@ private:
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
dofFluidState.setPressure(phaseIdx, oilPressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
|
||||
|
||||
//////
|
||||
// set compositions
|
||||
//////
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
dofFluidState.setRs(rsData[cartesianDofIdx]);
|
||||
else
|
||||
dofFluidState.setRs(0.0);
|
||||
|
||||
// reset all mole fractions to 0
|
||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
|
||||
dofFluidState.setMoleFraction(phaseIdx, compIdx, 0.0);
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
dofFluidState.setRv(rvData[cartesianDofIdx]);
|
||||
else
|
||||
dofFluidState.setRv(0.0);
|
||||
|
||||
// by default, assume immiscibility for all phases
|
||||
dofFluidState.setMoleFraction(waterPhaseIdx, waterCompIdx, 1.0);
|
||||
dofFluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, 1.0);
|
||||
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, 1.0);
|
||||
|
||||
if (FluidSystem::enableDissolvedGas()) {
|
||||
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(dofFluidState, oilPhaseIdx, pvtRegionIdx);
|
||||
Scalar RsReal = rsData[cartesianDofIdx];
|
||||
|
||||
if (RsReal > RsSat) {
|
||||
std::array<int, 3> ijk;
|
||||
gridManager.cartesianCoordinate(dofIdx, ijk);
|
||||
std::cerr << "Warning: The specified amount gas (R_s = " << RsReal << ") is more"
|
||||
<< " than the maximium\n"
|
||||
<< " amount which can be dissolved in oil"
|
||||
<< " (R_s,max=" << RsSat << ")"
|
||||
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
||||
<< " Using maximimum.\n";
|
||||
RsReal = RsSat;
|
||||
}
|
||||
|
||||
// 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, 1.0 - xoGReal);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableVaporizedOil()) {
|
||||
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(dofFluidState, gasPhaseIdx, pvtRegionIdx);
|
||||
Scalar RvReal = rvData[cartesianDofIdx];
|
||||
|
||||
if (RvReal > RvSat) {
|
||||
std::array<int, 3> ijk;
|
||||
gridManager.cartesianCoordinate(dofIdx, ijk);
|
||||
std::cerr << "Warning: The specified amount oil (R_v = " << RvReal << ") is more"
|
||||
<< " than the maximium\n"
|
||||
<< " amount which can be dissolved in gas"
|
||||
<< " (R_v,max=" << RvSat << ")"
|
||||
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
||||
<< " Using maximimum.\n";
|
||||
RvReal = RvSat;
|
||||
}
|
||||
|
||||
// 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, 1.0 - xgOReal);
|
||||
}
|
||||
}
|
||||
}
|
||||
void readBlackoilExtentionsInitialConditions_()
|
||||
@ -1616,7 +1566,7 @@ private:
|
||||
std::vector<Scalar> maxPolymerAdsorption_;
|
||||
|
||||
bool useMassConservativeInitialCondition_;
|
||||
std::vector<ScalarFluidState> initialFluidStates_;
|
||||
std::vector<InitialFluidState> initialFluidStates_;
|
||||
|
||||
std::vector<Scalar> polymerConcentration_;
|
||||
std::vector<Scalar> solventSaturation_;
|
||||
|
Loading…
Reference in New Issue
Block a user