From 3d943770a5467b6738ee22936cb174e1e0aa4224 Mon Sep 17 00:00:00 2001 From: Trine Mykkeltvedt Date: Wed, 12 Jun 2024 12:23:26 +0200 Subject: [PATCH] adressed minor comments by reviewer, added enableConvectiveMixing flag to drsdtcon --- .../blackoilconvectivemixingmodule.hh | 69 +++++++++++++++++-- .../blackoil/blackoilintensivequantities.hh | 7 +- opm/models/blackoil/blackoillocalresidual.hh | 3 +- .../blackoil/blackoillocalresidualtpfa.hh | 23 ++++--- opm/models/blackoil/blackoilmodel.hh | 2 + opm/models/common/multiphasebaseproperties.hh | 3 + 6 files changed, 88 insertions(+), 19 deletions(-) diff --git a/opm/models/blackoil/blackoilconvectivemixingmodule.hh b/opm/models/blackoil/blackoilconvectivemixingmodule.hh index ce4dc8248..38108242c 100644 --- a/opm/models/blackoil/blackoilconvectivemixingmodule.hh +++ b/opm/models/blackoil/blackoilconvectivemixingmodule.hh @@ -23,7 +23,7 @@ /*! * \file * - * \brief Classes required for molecular diffusion. + * \brief Classes required for dynamic convective mixing. */ #ifndef EWOMS_CONVECTIVEMIXING_MODULE_HH #define EWOMS_CONVECTIVEMIXING_MODULE_HH @@ -42,10 +42,70 @@ namespace Opm { /*! * \copydoc Opm::BlackOilConvectiveMixingModule - * \brief Provides the requiered methods for dynamic convective mixing. + * \brief Provides the convective term in the transport flux for the brine + * when convective mixing (enhanced dissolution of CO2 in brine) occurs. + * Controlled by the regimes for a controlvolume: + * i) initial phase (CO2 dissolves in brine due to diffusion) + * ii) linear phase (Convective fingers of CO2-rich brine propagate downwards) + * iii) steady-state-phase (fingers have passed through the bottom of a control + * -volume but the larger scale convective process is still active) + * iv) decline phase (Convection ceases at the large-scale when the CO2 + * has been completely dissolved) */ + +template +class BlackOilConvectiveMixingModule; + +/*! + * \copydoc Opm::BlackOilConvectiveMixingModule + */ + template -class BlackOilConvectiveMixingModule +class BlackOilConvectiveMixingModule +{ + using Scalar = GetPropType; + using FluidSystem = GetPropType; + using RateVector = GetPropType; + using Evaluation = GetPropType; + using Indices = GetPropType; + using IntensiveQuantities = GetPropType; + using GridView = GetPropType; + + enum { conti0EqIdx = Indices::conti0EqIdx }; + enum { dimWorld = GridView::dimensionworld }; + +public: + struct ConvectiveMixingModuleParam + {}; + + #if HAVE_ECL_INPUT + static void beginEpisode(const EclipseState& eclState, const Schedule& schedule, const int episodeIdx, ConvectiveMixingModuleParam& info) + {} + #endif + + template + static void addConvectiveMixingFlux(RateVector& flux, + const Context& elemCtx, + unsigned scvfIdx, + unsigned timeIdx) + {} + /*! + * \brief Adds the convective mixing mass flux flux to the flux vector over a flux + * integration point. + */ + static void addConvectiveMixingFlux(RateVector& flux, + const IntensiveQuantities& intQuantsIn, + const IntensiveQuantities& intQuantsEx, + const unsigned globalIndexIn, + const unsigned globalIndexEx, + const Scalar distZg, + const Scalar trans, + const Scalar faceArea, + const ConvectiveMixingModuleParam& info) + {} +}; +template +class BlackOilConvectiveMixingModule { using Scalar = GetPropType; using FluidSystem = GetPropType; @@ -73,6 +133,7 @@ public: // check that Xhi and Psi didn't change std::size_t numRegions = eclState.runspec().tabdims().getNumPVTTables(); const auto& control = schedule[episodeIdx].oilvap(); + info.active_ = control.drsdtConvective(); if (!info.active_) { return; } @@ -129,7 +190,7 @@ public: /*! - * \brief Adds the diffusive mass flux flux to the flux vector over a flux + * \brief Adds the convective mixing mass flux flux to the flux vector over a flux * integration point. */ static void addConvectiveMixingFlux(RateVector& flux, diff --git a/opm/models/blackoil/blackoilintensivequantities.hh b/opm/models/blackoil/blackoilintensivequantities.hh index 75fd19362..e0542addb 100644 --- a/opm/models/blackoil/blackoilintensivequantities.hh +++ b/opm/models/blackoil/blackoilintensivequantities.hh @@ -106,6 +106,7 @@ class BlackOilIntensiveQuantities enum { enableEnergy = getPropValue() }; enum { enableDiffusion = getPropValue() }; enum { enableDispersion = getPropValue() }; + enum { enableConvectiveMixing = getPropValue() }; enum { enableMICP = getPropValue() }; enum { numPhases = getPropValue() }; enum { numComponents = getPropValue() }; @@ -405,8 +406,7 @@ public: rho = fluidState_.invB(waterPhaseIdx); rho *= FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx); if (FluidSystem::enableDissolvedGasInWater()) { - const auto& oilVaporizationControl = problem.simulator().vanguard().schedule()[problem.episodeIndex()].oilvap(); - if(!oilVaporizationControl.drsdtConvective()) { + if(!enableConvectiveMixing) { rho += fluidState_.invB(waterPhaseIdx) * fluidState_.Rsw() * @@ -438,8 +438,7 @@ public: rho = fluidState_.invB(oilPhaseIdx); rho *= FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx); if (FluidSystem::enableDissolvedGas()) { - const auto& oilVaporizationControl = problem.simulator().vanguard().schedule()[problem.episodeIndex()].oilvap(); - if(!oilVaporizationControl.drsdtConvective()) { + if(!enableConvectiveMixing) { rho += fluidState_.invB(oilPhaseIdx) * fluidState_.Rs() * diff --git a/opm/models/blackoil/blackoillocalresidual.hh b/opm/models/blackoil/blackoillocalresidual.hh index dc8efb8ff..f69bc4979 100644 --- a/opm/models/blackoil/blackoillocalresidual.hh +++ b/opm/models/blackoil/blackoillocalresidual.hh @@ -81,6 +81,7 @@ class BlackOilLocalResidual : public GetPropType(); static constexpr bool enableEnergy = getPropValue(); static constexpr bool enableDiffusion = getPropValue(); + static constexpr bool enableConvectiveMixing = getPropValue(); using Toolbox = MathToolbox; using SolventModule = BlackOilSolventModule; @@ -91,7 +92,7 @@ class BlackOilLocalResidual : public GetPropType; using DiffusionModule = BlackOilDiffusionModule; using MICPModule = BlackOilMICPModule; - using ConvectiveMixingModule = BlackOilConvectiveMixingModule; + using ConvectiveMixingModule = BlackOilConvectiveMixingModule; public: diff --git a/opm/models/blackoil/blackoillocalresidualtpfa.hh b/opm/models/blackoil/blackoillocalresidualtpfa.hh index dc216e9b6..015d0adee 100644 --- a/opm/models/blackoil/blackoillocalresidualtpfa.hh +++ b/opm/models/blackoil/blackoillocalresidualtpfa.hh @@ -95,6 +95,7 @@ class BlackOilLocalResidualTPFA : public GetPropType(); static constexpr bool enableDiffusion = getPropValue(); static constexpr bool enableDispersion = getPropValue(); + static constexpr bool enableConvectiveMixing = getPropValue(); static constexpr bool enableMICP = getPropValue(); using SolventModule = BlackOilSolventModule; @@ -104,7 +105,7 @@ class BlackOilLocalResidualTPFA : public GetPropType; using BrineModule = BlackOilBrineModule; using DiffusionModule = BlackOilDiffusionModule; - using ConvectiveMixingModule = BlackOilConvectiveMixingModule; + using ConvectiveMixingModule = BlackOilConvectiveMixingModule; using ConvectiveMixingModuleParam = typename ConvectiveMixingModule::ConvectiveMixingModuleParam; using DispersionModule = BlackOilDispersionModule; @@ -457,15 +458,17 @@ public: // BrineModule::computeFlux(flux, elemCtx, scvfIdx, timeIdx); // deal with convective mixing - ConvectiveMixingModule::addConvectiveMixingFlux(flux, - intQuantsIn, - intQuantsEx, - globalIndexIn, - globalIndexEx, - nbInfo.dZg, - nbInfo.trans, - nbInfo.faceArea, - moduleParams.convectiveMixingModuleParam); + if constexpr(enableConvectiveMixing){ + ConvectiveMixingModule::addConvectiveMixingFlux(flux, + intQuantsIn, + intQuantsEx, + globalIndexIn, + globalIndexEx, + nbInfo.dZg, + nbInfo.trans, + nbInfo.faceArea, + moduleParams.convectiveMixingModuleParam); + } // deal with diffusion (if present). opm-models expects per area flux (added in the tmpdiffusivity). diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index d7f7a9ddc..7ffc65d07 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -181,6 +181,8 @@ struct EnableDiffusion { static constexpr bool val //! disable disperison by default template struct EnableDispersion { static constexpr bool value = false; }; +template +struct EnableConvectiveMixing { static constexpr bool value = false; }; //! by default, scale the energy equation by the inverse of the energy required to heat //! up one kg of water by 30 Kelvin. If we conserve surface volumes, this must be divided diff --git a/opm/models/common/multiphasebaseproperties.hh b/opm/models/common/multiphasebaseproperties.hh index d79165c3b..f067612f9 100644 --- a/opm/models/common/multiphasebaseproperties.hh +++ b/opm/models/common/multiphasebaseproperties.hh @@ -80,6 +80,9 @@ struct EnableDiffusion { using type = UndefinedProperty; }; //! Enable dispersive fluxes? template struct EnableDispersion { using type = UndefinedProperty; }; +//! Enable convective mixing? +template +struct EnableConvectiveMixing { using type = UndefinedProperty; }; } // namespace Opm::Properties