adressed minor comments by reviewer, added enableConvectiveMixing flag to drsdtcon, fixed indentation and bug in lastRs for gas/water

This commit is contained in:
Trine Mykkeltvedt
2024-06-24 12:51:43 +02:00
committed by Tor Harald Sandve
parent ab2bd924db
commit f10c44279f
6 changed files with 25 additions and 31 deletions

View File

@@ -127,8 +127,11 @@ struct EnableMICP<TypeTag, TTag::FlowProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
template<class TypeTag> template<class TypeTag>
struct EnableDispersion<TypeTag, TTag::FlowProblem> struct EnableDispersion<TypeTag, TTag::FlowProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
template<class TypeTag>
struct EnableConvectiveMixing<TypeTag, TTag::FlowProblem>
{ static constexpr bool value = true; };
template<class TypeTag> template<class TypeTag>
struct WellModel<TypeTag, TTag::FlowProblem> struct WellModel<TypeTag, TTag::FlowProblem>

View File

@@ -174,7 +174,6 @@ public:
const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, regionIdx); const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, regionIdx);
fluidState.setEnthalpy(phaseIdx, h); fluidState.setEnthalpy(phaseIdx, h);
} }
} }
// set the salt concentration // set the salt concentration

View File

@@ -145,6 +145,7 @@ class FlowProblem : public GetPropType<TypeTag, Properties::BaseProblem>
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() }; enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() }; enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>() }; enum { enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>() };
enum { enableConvectiveMixing = getPropValue<TypeTag, Properties::EnableConvectiveMixing>() };
enum { enableThermalFluxBoundaries = getPropValue<TypeTag, Properties::EnableThermalFluxBoundaries>() }; enum { enableThermalFluxBoundaries = getPropValue<TypeTag, Properties::EnableThermalFluxBoundaries>() };
enum { enableApiTracking = getPropValue<TypeTag, Properties::EnableApiTracking>() }; enum { enableApiTracking = getPropValue<TypeTag, Properties::EnableApiTracking>() };
enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() }; enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() };
@@ -182,7 +183,7 @@ class FlowProblem : public GetPropType<TypeTag, Properties::BaseProblem>
using MICPModule = BlackOilMICPModule<TypeTag>; using MICPModule = BlackOilMICPModule<TypeTag>;
using DispersionModule = BlackOilDispersionModule<TypeTag, enableDispersion>; using DispersionModule = BlackOilDispersionModule<TypeTag, enableDispersion>;
using DiffusionModule = BlackOilDiffusionModule<TypeTag, enableDiffusion>; using DiffusionModule = BlackOilDiffusionModule<TypeTag, enableDiffusion>;
using ConvectiveMixingModule = BlackOilConvectiveMixingModule<TypeTag>; using ConvectiveMixingModule = BlackOilConvectiveMixingModule<TypeTag, enableConvectiveMixing>;
using ModuleParams = typename BlackOilLocalResidualTPFA<TypeTag>::ModuleParams; using ModuleParams = typename BlackOilLocalResidualTPFA<TypeTag>::ModuleParams;
using InitialFluidState = typename EquilInitializer<TypeTag>::ScalarFluidState; using InitialFluidState = typename EquilInitializer<TypeTag>::ScalarFluidState;
@@ -538,8 +539,6 @@ public:
const auto& schedule = simulator.vanguard().schedule(); const auto& schedule = simulator.vanguard().schedule();
const auto& events = schedule[episodeIdx].events(); const auto& events = schedule[episodeIdx].events();
if (episodeIdx >= 0 && events.hasEvent(ScheduleEvents::GEO_MODIFIER)) { if (episodeIdx >= 0 && events.hasEvent(ScheduleEvents::GEO_MODIFIER)) {
// bring the contents of the keywords to the current state of the SCHEDULE // bring the contents of the keywords to the current state of the SCHEDULE
// section. // section.

View File

@@ -198,7 +198,12 @@ template<class TypeTag>
struct EnableDispersion<TypeTag, TTag::FlowBaseProblem> struct EnableDispersion<TypeTag, TTag::FlowBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// disable API tracking // Enable Convective Mixing
template<class TypeTag>
struct EnableConvectiveMixing<TypeTag, TTag::FlowBaseProblem>
{ static constexpr bool value = true; };
// only write the solutions for the report steps to disk
template<class TypeTag> template<class TypeTag>
struct EnableApiTracking<TypeTag, TTag::FlowBaseProblem> struct EnableApiTracking<TypeTag, TTag::FlowBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };

View File

@@ -108,7 +108,6 @@ init(std::size_t numDof, int episodeIdx, const unsigned ntpvt)
dRsDtOnlyFreeGas_.resize(ntpvt, false); dRsDtOnlyFreeGas_.resize(ntpvt, false);
lastRs_.resize(numDof, 0.0); lastRs_.resize(numDof, 0.0);
maxDRv_.resize(ntpvt, 1e30); maxDRv_.resize(ntpvt, 1e30);
lastRv_.resize(numDof, 0.0);
if (this->drsdtConvective(episodeIdx)) { if (this->drsdtConvective(episodeIdx)) {
convectiveDrs_.resize(numDof, 1.0); convectiveDrs_.resize(numDof, 1.0);
} }
@@ -119,8 +118,6 @@ bool MixingRateControls<FluidSystem>::
drsdtActive(int episodeIdx) const drsdtActive(int episodeIdx) const
{ {
const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap(); const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
const bool bothOilGasActive = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) &&
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
return (oilVaporizationControl.drsdtActive()); return (oilVaporizationControl.drsdtActive());
} }
@@ -129,8 +126,6 @@ bool MixingRateControls<FluidSystem>::
drvdtActive(int episodeIdx) const drvdtActive(int episodeIdx) const
{ {
const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap(); const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
const bool bothOilGasActive = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) &&
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
return (oilVaporizationControl.drvdtActive()); return (oilVaporizationControl.drvdtActive());
} }
@@ -139,8 +134,6 @@ bool MixingRateControls<FluidSystem>::
drsdtConvective(int episodeIdx) const drsdtConvective(int episodeIdx) const
{ {
const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap(); const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
const bool bothOilGasActive = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) &&
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
return (oilVaporizationControl.drsdtConvective()); return (oilVaporizationControl.drsdtConvective());
} }
@@ -269,8 +262,8 @@ void MixingRateControls<FluidSystem>::
updateConvectiveDRsDt_(const unsigned compressedDofIdx, updateConvectiveDRsDt_(const unsigned compressedDofIdx,
const Scalar t, const Scalar t,
const Scalar p, const Scalar p,
const Scalar pg,
const Scalar rs, const Scalar rs,
const Scalar so,
const Scalar sg, const Scalar sg,
const Scalar poro, const Scalar poro,
const Scalar permz, const Scalar permz,
@@ -283,7 +276,7 @@ updateConvectiveDRsDt_(const unsigned compressedDofIdx,
const int pvtRegionIndex) const int pvtRegionIndex)
{ {
const Scalar rssat = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ? const Scalar rssat = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIndex, t, p, salt) : FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIndex, t, p, salt) :
FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIndex, t, p); FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIndex, t, p);
const Scalar saturatedInvB = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ? const Scalar saturatedInvB = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
FluidSystem::waterPvt().saturatedInverseFormationVolumeFactor(pvtRegionIndex, t, p, salt) : FluidSystem::waterPvt().saturatedInverseFormationVolumeFactor(pvtRegionIndex, t, p, salt) :
@@ -305,7 +298,7 @@ updateConvectiveDRsDt_(const unsigned compressedDofIdx,
FluidSystem::waterPvt().viscosity(pvtRegionIndex, t, p, rs, salt) : FluidSystem::waterPvt().viscosity(pvtRegionIndex, t, p, rs, salt) :
FluidSystem::oilPvt().viscosity(pvtRegionIndex, t, p, rs); FluidSystem::oilPvt().viscosity(pvtRegionIndex, t, p, rs);
// Note that for so = 0 this gives no limits (inf) for the dissolution rate // Note that for sLiquid = 0 this gives no limits (inf) for the dissolution rate
// Also we restrict the effect of convective mixing to positive density differences // Also we restrict the effect of convective mixing to positive density differences
// i.e. we only allow for fingers moving downward // i.e. we only allow for fingers moving downward
@@ -314,18 +307,19 @@ updateConvectiveDRsDt_(const unsigned compressedDofIdx,
Scalar factor = 1.0; Scalar factor = 1.0;
Scalar X = (rs - rssat * sg) / (rssat * ( 1.0 - sg)); Scalar X = (rs - rssat * sg) / (rssat * ( 1.0 - sg));
Scalar omega = 0.0; Scalar omega = 0.0;
if ((rs >= (rssat * sg))){ const Scalar pCap = Opm::abs(pg - p);
if ((rs >= (rssat * sg)) || (pCap < 1e-12)){
if(X > Psi){ if(X > Psi){
factor = 0.0; factor = 0.0;
omega = omegainn; omega = omegainn;
} }
} else { } else {
factor /= Xhi; factor /= Xhi;
deltaDensity = (saturatedDensity - co2Density); deltaDensity = (saturatedDensity - co2Density);
} }
convectiveDrs_[compressedDofIdx] convectiveDrs_[compressedDofIdx]
= factor * permz * rssat * max(0.0, deltaDensity) * gravity / ( std::max(sg_max - sg, 0.0) * visc * distZ * poro) + (omega/Xhi); = factor * permz * rssat * max(0.0, deltaDensity) * gravity / ( std::max(sg_max - sg, 0.0) * visc * distZ * poro) + (omega/Xhi);
} }
template class MixingRateControls<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>>; template class MixingRateControls<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>>;

View File

@@ -118,7 +118,6 @@ public:
const std::array<bool,3>& active) const std::array<bool,3>& active)
{ {
const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap(); const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
if (active[0]) { if (active[0]) {
// This implements the convective DRSDT as described in // This implements the convective DRSDT as described in
// Sandve et al. "Convective dissolution in field scale CO2 storage simulations using the OPM Flow // Sandve et al. "Convective dissolution in field scale CO2 storage simulations using the OPM Flow
@@ -132,11 +131,7 @@ public:
const auto& pressure = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ? const auto& pressure = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
getValue(fs.pressure(FluidSystem::waterPhaseIdx)) : getValue(fs.pressure(FluidSystem::waterPhaseIdx)) :
getValue(fs.pressure(FluidSystem::oilPhaseIdx)); getValue(fs.pressure(FluidSystem::oilPhaseIdx));
const auto& pressuregas = getValue(fs.pressure(FluidSystem::gasPhaseIdx));
const auto& sLiquid = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
getValue(fs.saturation(FluidSystem::waterPhaseIdx)) :
getValue(fs.saturation(FluidSystem::oilPhaseIdx));
const auto& rs = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ? const auto& rs = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
getValue(fs.Rsw()) : getValue(fs.Rsw()) :
getValue(fs.Rs()); getValue(fs.Rs());
@@ -146,8 +141,8 @@ public:
this->updateConvectiveDRsDt_(compressedDofIdx, this->updateConvectiveDRsDt_(compressedDofIdx,
temperature, temperature,
pressure, pressure,
pressuregas,
rs, rs,
sLiquid,
getValue(fs.saturation(FluidSystem::gasPhaseIdx)), getValue(fs.saturation(FluidSystem::gasPhaseIdx)),
getValue(iq.porosity()), getValue(iq.porosity()),
permZ, permZ,
@@ -164,12 +159,11 @@ public:
const auto& fs = iq.fluidState(); const auto& fs = iq.fluidState();
using FluidState = typename std::decay<decltype(fs)>::type; using FluidState = typename std::decay<decltype(fs)>::type;
const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
constexpr Scalar freeGasMinSaturation_ = 1e-7; constexpr Scalar freeGasMinSaturation_ = 1e-7;
if (oilVaporizationControl.getOption(pvtRegionIdx) || if (oilVaporizationControl.getOption(pvtRegionIdx) ||
fs.saturation(FluidSystem::gasPhaseIdx) > freeGasMinSaturation_) { fs.saturation(FluidSystem::gasPhaseIdx) > freeGasMinSaturation_) {
lastRs_[compressedDofIdx] lastRs_[compressedDofIdx]
= (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ? = ((FluidSystem::enableDissolvedGasInWater())) ?
BlackOil::template getRsw_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex()) : BlackOil::template getRsw_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex()) :
BlackOil::template getRs_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex()); BlackOil::template getRs_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex());
} }
@@ -189,8 +183,8 @@ private:
void updateConvectiveDRsDt_(const unsigned compressedDofIdx, void updateConvectiveDRsDt_(const unsigned compressedDofIdx,
const Scalar t, const Scalar t,
const Scalar p, const Scalar p,
const Scalar pg,
const Scalar rs, const Scalar rs,
const Scalar so,
const Scalar sg, const Scalar sg,
const Scalar poro, const Scalar poro,
const Scalar permz, const Scalar permz,