Merge pull request #722 from akva2/micp_module_params

blackoilmicpmodules: put parameters in separate class
This commit is contained in:
Markus Blatt 2022-09-20 11:42:23 +02:00 committed by GitHub
commit 453261d6ad
3 changed files with 158 additions and 180 deletions

View File

@ -29,8 +29,9 @@
#define EWOMS_BLACK_OIL_MICP_MODULE_HH #define EWOMS_BLACK_OIL_MICP_MODULE_HH
#include "blackoilproperties.hh" #include "blackoilproperties.hh"
#include <opm/models/blackoil/blackoilmicpparams.hh>
#include <opm/models/io/vtkblackoilmicpmodule.hh> #include <opm/models/io/vtkblackoilmicpmodule.hh>
#include <opm/models/common/quantitycallbacks.hh>
#if HAVE_ECL_INPUT #if HAVE_ECL_INPUT
#include <opm/input/eclipse/EclipseState/EclipseState.hpp> #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
@ -39,6 +40,9 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <cmath>
#include <cstddef>
#include <stdexcept>
#include <string> #include <string>
namespace Opm { namespace Opm {
@ -123,7 +127,7 @@ public:
MICPpara.getMaximumUreaConcentration(), MICPpara.getMaximumUreaConcentration(),
MICPpara.getToleranceBeforeClogging()); MICPpara.getToleranceBeforeClogging());
// obtain the porosity for the clamp in the blackoilnewtonmethod // obtain the porosity for the clamp in the blackoilnewtonmethod
phi_ = eclState.fieldProps().get_double("PORO"); params_.phi_ = eclState.fieldProps().get_double("PORO");
} }
#endif #endif
@ -137,7 +141,7 @@ public:
static void checkCloggingMICP(const Model& model, const Scalar phi, unsigned dofIdx) static void checkCloggingMICP(const Model& model, const Scalar phi, unsigned dofIdx)
{ {
const PrimaryVariables& priVars = model.solution(/*timeIdx=*/1)[dofIdx]; const PrimaryVariables& priVars = model.solution(/*timeIdx=*/1)[dofIdx];
if (phi - priVars[biofilmConcentrationIdx] - priVars[calciteConcentrationIdx] < MICPparaToleranceBeforeClogging()) if (phi - priVars[biofilmConcentrationIdx] - priVars[calciteConcentrationIdx] < toleranceBeforeClogging())
throw std::logic_error("Clogging has been (almost) reached in at least one cell\n"); throw std::logic_error("Clogging has been (almost) reached in at least one cell\n");
} }
@ -146,41 +150,41 @@ public:
* *
* The index of specified here must be in range [0, numSatRegions) * The index of specified here must be in range [0, numSatRegions)
*/ */
static void setMICPpara(const Scalar& MICPparaDensityBiofilm, static void setMICPpara(const Scalar& densityBiofilm,
const Scalar& MICPparaDensityCalcite, const Scalar& densityCalcite,
const Scalar& MICPparaDetachmentRate, const Scalar& detachmentRate,
const Scalar& MICPparaCriticalPorosity, const Scalar& criticalPorosity,
const Scalar& MICPparaFittingFactor, const Scalar& fittingFactor,
const Scalar& MICPparaHalfVelocityOxygen, const Scalar& halfVelocityOxygen,
const Scalar& MICPparaHalfVelocityUrea, const Scalar& halfVelocityUrea,
const Scalar& MICPparaMaximumGrowthRate, const Scalar& maximumGrowthRate,
const Scalar& MICPparaMaximumUreaUtilization, const Scalar& maximumUreaUtilization,
const Scalar& MICPparaMicrobialAttachmentRate, const Scalar& microbialAttachmentRate,
const Scalar& MICPparaMicrobialDeathRate, const Scalar& microbialDeathRate,
const Scalar& MICPparaMinimumPermeability, const Scalar& minimumPermeability,
const Scalar& MICPparaOxygenConsumptionFactor, const Scalar& oxygenConsumptionFactor,
const Scalar& MICPparaYieldGrowthCoefficient, const Scalar& yieldGrowthCoefficient,
const Scalar& MICPparaMaximumOxygenConcentration, const Scalar& maximumOxygenConcentration,
const Scalar& MICPparaMaximumUreaConcentration, const Scalar& maximumUreaConcentration,
const Scalar& MICPparaToleranceBeforeClogging) const Scalar& toleranceBeforeClogging)
{ {
MICPparaDensityBiofilm_ = MICPparaDensityBiofilm; params_.densityBiofilm_ = densityBiofilm;
MICPparaDensityCalcite_ = MICPparaDensityCalcite; params_.densityCalcite_ = densityCalcite;
MICPparaDetachmentRate_ = MICPparaDetachmentRate; params_.detachmentRate_ = detachmentRate;
MICPparaCriticalPorosity_ = MICPparaCriticalPorosity; params_.criticalPorosity_ = criticalPorosity;
MICPparaFittingFactor_ = MICPparaFittingFactor; params_.fittingFactor_ = fittingFactor;
MICPparaHalfVelocityOxygen_ = MICPparaHalfVelocityOxygen; params_.halfVelocityOxygen_ = halfVelocityOxygen;
MICPparaHalfVelocityUrea_ = MICPparaHalfVelocityUrea; params_.halfVelocityUrea_ = halfVelocityUrea;
MICPparaMaximumGrowthRate_ = MICPparaMaximumGrowthRate; params_.maximumGrowthRate_ = maximumGrowthRate;
MICPparaMaximumUreaUtilization_ = MICPparaMaximumUreaUtilization; params_.maximumUreaUtilization_ = maximumUreaUtilization;
MICPparaMicrobialAttachmentRate_ = MICPparaMicrobialAttachmentRate; params_.microbialAttachmentRate_ = microbialAttachmentRate;
MICPparaMicrobialDeathRate_ = MICPparaMicrobialDeathRate; params_.microbialDeathRate_ = microbialDeathRate;
MICPparaMinimumPermeability_ = MICPparaMinimumPermeability; params_.minimumPermeability_ = minimumPermeability;
MICPparaOxygenConsumptionFactor_ = MICPparaOxygenConsumptionFactor; params_.oxygenConsumptionFactor_ = oxygenConsumptionFactor;
MICPparaYieldGrowthCoefficient_ = MICPparaYieldGrowthCoefficient; params_.yieldGrowthCoefficient_ = yieldGrowthCoefficient;
MICPparaMaximumOxygenConcentration_ = MICPparaMaximumOxygenConcentration; params_.maximumOxygenConcentration_ = maximumOxygenConcentration;
MICPparaMaximumUreaConcentration_ = MICPparaMaximumUreaConcentration; params_.maximumUreaConcentration_ = maximumUreaConcentration;
MICPparaToleranceBeforeClogging_ = MICPparaToleranceBeforeClogging; params_.toleranceBeforeClogging_ = toleranceBeforeClogging;
} }
/*! /*!
@ -313,17 +317,17 @@ public:
} }
// get the model parameters // get the model parameters
Scalar k_a = MICPparaMicrobialAttachmentRate(); Scalar k_a = microbialAttachmentRate();
Scalar k_d = MICPparaMicrobialDeathRate(); Scalar k_d = microbialDeathRate();
Scalar rho_b = MICPparaDensityBiofilm(); Scalar rho_b = densityBiofilm();
Scalar rho_c = MICPparaDensityCalcite(); Scalar rho_c = densityCalcite();
Scalar k_str = MICPparaDetachmentRate(); Scalar k_str = detachmentRate();
Scalar k_o = MICPparaHalfVelocityOxygen(); Scalar k_o = halfVelocityOxygen();
Scalar k_u = MICPparaHalfVelocityUrea() / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp) Scalar k_u = halfVelocityUrea() / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp)
Scalar mu = MICPparaMaximumGrowthRate(); Scalar mu = maximumGrowthRate();
Scalar mu_u = MICPparaMaximumUreaUtilization() / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp) Scalar mu_u = maximumUreaUtilization() / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp)
Scalar Y_sb = MICPparaYieldGrowthCoefficient(); Scalar Y_sb = yieldGrowthCoefficient();
Scalar F = MICPparaOxygenConsumptionFactor(); Scalar F = oxygenConsumptionFactor();
Scalar Y_uc = 1.67 * 10; //Multiplying by scaling factor 10 (see WellInterface_impl.hpp) Scalar Y_uc = 1.67 * 10; //Multiplying by scaling factor 10 (see WellInterface_impl.hpp)
// compute the processes // compute the processes
@ -344,190 +348,104 @@ public:
source[Indices::contiCalciteEqIdx] += (rho_b / rho_c) * intQuants.biofilmConcentration() * Y_uc * mu_u * intQuants.ureaConcentration() / (k_u + intQuants.ureaConcentration()); source[Indices::contiCalciteEqIdx] += (rho_b / rho_c) * intQuants.biofilmConcentration() * Y_uc * mu_u * intQuants.ureaConcentration() / (k_u + intQuants.ureaConcentration());
} }
static const Scalar MICPparaDensityBiofilm() static const Scalar densityBiofilm()
{ {
return MICPparaDensityBiofilm_; return params_.densityBiofilm_;
} }
static const Scalar MICPparaDensityCalcite() static const Scalar densityCalcite()
{ {
return MICPparaDensityCalcite_; return params_.densityCalcite_;
} }
static const Scalar MICPparaDetachmentRate() static const Scalar detachmentRate()
{ {
return MICPparaDetachmentRate_; return params_.detachmentRate_;
} }
static const Scalar MICPparaCriticalPorosity() static const Scalar criticalPorosity()
{ {
return MICPparaCriticalPorosity_; return params_.criticalPorosity_;
} }
static const Scalar MICPparaFittingFactor() static const Scalar fittingFactor()
{ {
return MICPparaFittingFactor_; return params_.fittingFactor_;
} }
static const Scalar MICPparaHalfVelocityOxygen() static const Scalar halfVelocityOxygen()
{ {
return MICPparaHalfVelocityOxygen_; return params_.halfVelocityOxygen_;
} }
static const Scalar MICPparaHalfVelocityUrea() static const Scalar halfVelocityUrea()
{ {
return MICPparaHalfVelocityUrea_; return params_.halfVelocityUrea_;
} }
static const Scalar MICPparaMaximumGrowthRate() static const Scalar maximumGrowthRate()
{ {
return MICPparaMaximumGrowthRate_; return params_.maximumGrowthRate_;
} }
static const Scalar MICPparaMaximumOxygenConcentration() static const Scalar maximumOxygenConcentration()
{ {
return MICPparaMaximumOxygenConcentration_; return params_.maximumOxygenConcentration_;
} }
static const Scalar MICPparaMaximumUreaConcentration() static const Scalar maximumUreaConcentration()
{ {
return MICPparaMaximumUreaConcentration_ / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp); return params_.maximumUreaConcentration_ / 10.0;//Dividing by scaling factor 10 (see WellInterface_impl.hpp);
} }
static const Scalar MICPparaMaximumUreaUtilization() static const Scalar maximumUreaUtilization()
{ {
return MICPparaMaximumUreaUtilization_; return params_.maximumUreaUtilization_;
} }
static const Scalar MICPparaMicrobialAttachmentRate() static const Scalar microbialAttachmentRate()
{ {
return MICPparaMicrobialAttachmentRate_; return params_.microbialAttachmentRate_;
} }
static const Scalar MICPparaMicrobialDeathRate() static const Scalar microbialDeathRate()
{ {
return MICPparaMicrobialDeathRate_; return params_.microbialDeathRate_;
} }
static const Scalar MICPparaMinimumPermeability() static const Scalar minimumPermeability()
{ {
return MICPparaMinimumPermeability_; return params_.minimumPermeability_;
} }
static const Scalar MICPparaOxygenConsumptionFactor() static const Scalar oxygenConsumptionFactor()
{ {
return MICPparaOxygenConsumptionFactor_; return params_.oxygenConsumptionFactor_;
} }
static const Scalar MICPparaToleranceBeforeClogging() static const Scalar toleranceBeforeClogging()
{ {
return MICPparaToleranceBeforeClogging_; return params_.toleranceBeforeClogging_;
} }
static const Scalar MICPparaYieldGrowthCoefficient() static const Scalar yieldGrowthCoefficient()
{ {
return MICPparaYieldGrowthCoefficient_; return params_.yieldGrowthCoefficient_;
} }
static const std::vector<Scalar> phi() static const std::vector<Scalar> phi()
{ {
return phi_; return params_.phi_;
} }
private: private:
static Scalar MICPparaDensityBiofilm_; static BlackOilMICPParams<Scalar> params_;
static Scalar MICPparaDensityCalcite_;
static Scalar MICPparaDetachmentRate_;
static Scalar MICPparaCriticalPorosity_;
static Scalar MICPparaFittingFactor_;
static Scalar MICPparaHalfVelocityOxygen_;
static Scalar MICPparaHalfVelocityUrea_;
static Scalar MICPparaMaximumGrowthRate_;
static Scalar MICPparaMaximumUreaUtilization_;
static Scalar MICPparaMicrobialAttachmentRate_;
static Scalar MICPparaMicrobialDeathRate_;
static Scalar MICPparaMinimumPermeability_;
static Scalar MICPparaOxygenConsumptionFactor_;
static Scalar MICPparaYieldGrowthCoefficient_;
static Scalar MICPparaMaximumOxygenConcentration_;
static Scalar MICPparaMaximumUreaConcentration_;
static Scalar MICPparaToleranceBeforeClogging_;
static std::vector<Scalar> phi_;
}; };
template <class TypeTag, bool enableMICPV> template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar BlackOilMICPParams<typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar>
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaDensityBiofilm_; BlackOilMICPModule<TypeTag, enableMICPV>::params_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaDensityCalcite_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaDetachmentRate_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaCriticalPorosity_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaFittingFactor_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaHalfVelocityOxygen_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaHalfVelocityUrea_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMaximumGrowthRate_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMaximumUreaUtilization_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMicrobialAttachmentRate_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMicrobialDeathRate_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMinimumPermeability_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaOxygenConsumptionFactor_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaYieldGrowthCoefficient_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMaximumOxygenConcentration_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaMaximumUreaConcentration_;
template <class TypeTag, bool enableMICPV>
typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar
BlackOilMICPModule<TypeTag, enableMICPV>::MICPparaToleranceBeforeClogging_;
template <class TypeTag, bool enableMICPV>
std::vector<typename BlackOilMICPModule<TypeTag, enableMICPV>::Scalar>
BlackOilMICPModule<TypeTag, enableMICPV>::phi_;
/*! /*!
* \ingroup BlackOil * \ingroup BlackOil
@ -574,9 +492,9 @@ public:
const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx); const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
const auto& K = elemCtx.problem().intrinsicPermeability(elemCtx, dofIdx, timeIdx); const auto& K = elemCtx.problem().intrinsicPermeability(elemCtx, dofIdx, timeIdx);
Scalar referencePorosity_ = elemCtx.problem().porosity(elemCtx, dofIdx, timeIdx); Scalar referencePorosity_ = elemCtx.problem().porosity(elemCtx, dofIdx, timeIdx);
Scalar eta = MICPModule::MICPparaFittingFactor(); Scalar eta = MICPModule::fittingFactor();
Scalar k_min = MICPModule::MICPparaMinimumPermeability(); Scalar k_min = MICPModule::minimumPermeability();
Scalar phi_crit = MICPModule::MICPparaCriticalPorosity(); Scalar phi_crit = MICPModule::criticalPorosity();
microbialConcentration_ = priVars.makeEvaluation(microbialConcentrationIdx, timeIdx, linearizationType); microbialConcentration_ = priVars.makeEvaluation(microbialConcentrationIdx, timeIdx, linearizationType);
oxygenConcentration_ = priVars.makeEvaluation(oxygenConcentrationIdx, timeIdx, linearizationType); oxygenConcentration_ = priVars.makeEvaluation(oxygenConcentrationIdx, timeIdx, linearizationType);

View File

@ -0,0 +1,60 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
*
* \brief Contains the parameters required to extend the black-oil model by MICP.
*/
#ifndef EWOMS_BLACK_OIL_MICP_PARAMS_HH
#define EWOMS_BLACK_OIL_MICP_PARAMS_HH
#include <vector>
namespace Opm {
//! \brief Struct holding the parameters for the BlackOilMICPModule class.
template<class Scalar>
struct BlackOilMICPParams {
Scalar densityBiofilm_;
Scalar densityCalcite_;
Scalar detachmentRate_;
Scalar criticalPorosity_;
Scalar fittingFactor_;
Scalar halfVelocityOxygen_;
Scalar halfVelocityUrea_;
Scalar maximumGrowthRate_;
Scalar maximumUreaUtilization_;
Scalar microbialAttachmentRate_;
Scalar microbialDeathRate_;
Scalar minimumPermeability_;
Scalar oxygenConsumptionFactor_;
Scalar yieldGrowthCoefficient_;
Scalar maximumOxygenConcentration_;
Scalar maximumUreaConcentration_;
Scalar toleranceBeforeClogging_;
std::vector<Scalar> phi_;
};
} // namespace Opm
#endif

View File

@ -404,15 +404,15 @@ protected:
// concentration (the urea concentration has been scaled by 10). For // concentration (the urea concentration has been scaled by 10). For
// the biofilm and calcite, we set this value equal to the porosity minus the clogging tolerance. // the biofilm and calcite, we set this value equal to the porosity minus the clogging tolerance.
if (enableMICP && pvIdx == Indices::microbialConcentrationIdx) if (enableMICP && pvIdx == Indices::microbialConcentrationIdx)
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::MICPparaDensityBiofilm()); nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::densityBiofilm());
if (enableMICP && pvIdx == Indices::oxygenConcentrationIdx) if (enableMICP && pvIdx == Indices::oxygenConcentrationIdx)
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::MICPparaMaximumOxygenConcentration()); nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::maximumOxygenConcentration());
if (enableMICP && pvIdx == Indices::ureaConcentrationIdx) if (enableMICP && pvIdx == Indices::ureaConcentrationIdx)
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::MICPparaMaximumUreaConcentration()); nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::maximumUreaConcentration());
if (enableMICP && pvIdx == Indices::biofilmConcentrationIdx) if (enableMICP && pvIdx == Indices::biofilmConcentrationIdx)
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::MICPparaToleranceBeforeClogging()); nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
if (enableMICP && pvIdx == Indices::calciteConcentrationIdx) if (enableMICP && pvIdx == Indices::calciteConcentrationIdx)
nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::MICPparaToleranceBeforeClogging()); nextValue[pvIdx] = std::clamp(nextValue[pvIdx], 0.0, MICPModule::phi()[globalDofIdx] - MICPModule::toleranceBeforeClogging());
} }
// switch the new primary variables to something which is physically meaningful. // switch the new primary variables to something which is physically meaningful.