mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-01 12:06:54 -06:00
Merge pull request #4745 from akva2/filtercake_separate_class
FilterCake: put code in separate class
This commit is contained in:
commit
ff9e6ca18a
@ -127,6 +127,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/simulators/wells/WellConnectionAuxiliaryModule.cpp
|
||||
opm/simulators/wells/WellConstraints.cpp
|
||||
opm/simulators/wells/WellConvergence.cpp
|
||||
opm/simulators/wells/WellFilterCake.cpp
|
||||
opm/simulators/wells/WellGroupConstraints.cpp
|
||||
opm/simulators/wells/WellGroupControls.cpp
|
||||
opm/simulators/wells/WellGroupHelpers.cpp
|
||||
@ -512,6 +513,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/simulators/wells/WellConnectionAuxiliaryModule.hpp
|
||||
opm/simulators/wells/WellConstraints.hpp
|
||||
opm/simulators/wells/WellConvergence.hpp
|
||||
opm/simulators/wells/WellFilterCake.hpp
|
||||
opm/simulators/wells/WellGroupConstraints.hpp
|
||||
opm/simulators/wells/WellGroupControls.hpp
|
||||
opm/simulators/wells/WellGroupHelpers.hpp
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <opm/simulators/wells/BlackoilWellModelRestart.hpp>
|
||||
#include <opm/simulators/wells/GasLiftStage2.hpp>
|
||||
#include <opm/simulators/wells/VFPProperties.hpp>
|
||||
#include <opm/simulators/wells/WellFilterCake.hpp>
|
||||
#include <opm/simulators/wells/WellGroupHelpers.hpp>
|
||||
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
@ -1422,21 +1423,24 @@ void BlackoilWellModelGeneric::initInjMult() {
|
||||
}
|
||||
|
||||
|
||||
void BlackoilWellModelGeneric::updateFiltrationParticleVolume(const double dt, const size_t water_index) {
|
||||
void BlackoilWellModelGeneric::updateFiltrationParticleVolume(const double dt,
|
||||
const size_t water_index)
|
||||
{
|
||||
for (auto& well : this->well_container_generic_) {
|
||||
if (well->isInjector() && well->wellEcl().getFilterConc() > 0.) {
|
||||
auto &values = this->filtration_particle_volume_[well->name()];
|
||||
const auto& ws = this->wellState().well(well->indexOfWell());
|
||||
if (values.empty()) {
|
||||
values.assign(ws.perf_data.size(), 0.); // initializing to be zero
|
||||
}
|
||||
well->updateFiltrationParticleVolume(dt, water_index, this->wellState(), values);
|
||||
auto fc = this->filter_cake_
|
||||
.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(well->name()),
|
||||
std::tuple{});
|
||||
|
||||
fc.first->second.updateFiltrationParticleVolume(*well, dt, water_index,
|
||||
this->wellState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BlackoilWellModelGeneric::updateInjMult(DeferredLogger& deferred_logger) {
|
||||
void BlackoilWellModelGeneric::updateInjMult(DeferredLogger& deferred_logger)
|
||||
{
|
||||
for (const auto& well : this->well_container_generic_) {
|
||||
if (well->isInjector() && well->wellEcl().getInjMultMode() != Well::InjMultMode::NONE) {
|
||||
well->updateInjMult(this->prev_inj_multipliers_[well->name()], deferred_logger);
|
||||
@ -1444,4 +1448,17 @@ void BlackoilWellModelGeneric::updateInjMult(DeferredLogger& deferred_logger) {
|
||||
}
|
||||
}
|
||||
|
||||
void BlackoilWellModelGeneric::updateInjFCMult(DeferredLogger& deferred_logger)
|
||||
{
|
||||
for (auto& well : this->well_container_generic_) {
|
||||
if (well->isInjector()) {
|
||||
const auto it = filter_cake_.find(well->name());
|
||||
if (it != filter_cake_.end()) {
|
||||
it->second.updateInjFCMult(*well, deferred_logger);
|
||||
well->updateFilterCakeMultipliers(it->second.multipliers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
|
||||
#include <opm/simulators/wells/PerforationData.hpp>
|
||||
#include <opm/simulators/wells/WellFilterCake.hpp>
|
||||
#include <opm/simulators/wells/WellProdIndexCalculator.hpp>
|
||||
#include <opm/simulators/wells/WGState.hpp>
|
||||
|
||||
@ -375,6 +376,7 @@ protected:
|
||||
|
||||
|
||||
void updateInjMult(DeferredLogger& deferred_logger);
|
||||
void updateInjFCMult(DeferredLogger& deferred_logger);
|
||||
|
||||
void updateFiltrationParticleVolume(const double dt, const size_t water_index);
|
||||
|
||||
@ -440,8 +442,8 @@ protected:
|
||||
// previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
|
||||
std::unordered_map<std::string, std::vector<double>> prev_inj_multipliers_;
|
||||
|
||||
// the volume of the filtration particles during water injection
|
||||
std::unordered_map<std::string, std::vector<double>> filtration_particle_volume_;
|
||||
// Handling for filter cake injection multipliers
|
||||
std::unordered_map<std::string, WellFilterCake> filter_cake_;
|
||||
|
||||
/*
|
||||
The various wellState members should be accessed and modified
|
||||
@ -460,7 +462,6 @@ protected:
|
||||
std::map<std::string, std::string> switched_prod_groups_;
|
||||
std::map<std::pair<std::string, Opm::Phase>, std::string> switched_inj_groups_;
|
||||
|
||||
|
||||
private:
|
||||
WellInterfaceGeneric* getGenWell(const std::string& well_name);
|
||||
};
|
||||
|
@ -205,7 +205,6 @@ namespace Opm {
|
||||
// playing it safe by extending the scope a bit.
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
{
|
||||
|
||||
// The well state initialize bhp with the cell pressure in the top cell.
|
||||
// We must therefore provide it with updated cell pressures
|
||||
this->initializeWellPerfData();
|
||||
@ -310,15 +309,7 @@ namespace Opm {
|
||||
well->setGuideRate(&guideRate_);
|
||||
}
|
||||
|
||||
for (auto& well : well_container_) {
|
||||
if (well->isInjector()) {
|
||||
const auto it = this->filtration_particle_volume_.find(well->name());
|
||||
if (it != this->filtration_particle_volume_.end()) {
|
||||
const auto& filtration_particle_volume = it->second;
|
||||
well->updateInjFCMult(filtration_particle_volume, local_deferredLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->updateInjFCMult(local_deferredLogger);
|
||||
|
||||
// Close completions due to economic reasons
|
||||
for (auto& well : well_container_) {
|
||||
|
131
opm/simulators/wells/WellFilterCake.cpp
Normal file
131
opm/simulators/wells/WellFilterCake.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
Copyright 2023 Equinor
|
||||
|
||||
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 3 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/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/WellFilterCake.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
|
||||
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
|
||||
#include <opm/simulators/wells/PerforationData.hpp>
|
||||
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
void WellFilterCake::
|
||||
updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
|
||||
const double dt,
|
||||
const std::size_t water_index,
|
||||
const WellState& well_state)
|
||||
{
|
||||
if (!well.isInjector()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (filtration_particle_volume_.empty()) {
|
||||
const auto& ws = well_state.well(well.indexOfWell());
|
||||
filtration_particle_volume_.assign(ws.perf_data.size(), 0.); // initializing to be zero
|
||||
}
|
||||
|
||||
const auto injectorType = well.wellEcl().injectorType();
|
||||
if (injectorType != InjectorType::WATER) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double conc = well.wellEcl().getFilterConc();
|
||||
if (conc == 0.) {
|
||||
return;
|
||||
}
|
||||
|
||||
// it is currently used for the filter cake modeling related to formation damage study
|
||||
auto& ws = well_state.well(well.indexOfWell());
|
||||
const auto& connection_rates = ws.perf_data.phase_rates;
|
||||
|
||||
const std::size_t np = well_state.numPhases();
|
||||
for (int perf = 0; perf < well.numPerfs(); ++perf) {
|
||||
// not considering the production water
|
||||
const double water_rates = std::max(0., connection_rates[perf * np + water_index]);
|
||||
filtration_particle_volume_[perf] += water_rates * conc * dt;
|
||||
}
|
||||
}
|
||||
|
||||
void WellFilterCake::
|
||||
updateInjFCMult(const WellInterfaceGeneric& well,
|
||||
DeferredLogger& deferred_logger)
|
||||
{
|
||||
if (inj_fc_multiplier_.empty()) {
|
||||
inj_fc_multiplier_.resize(well.numPerfs(), 1.0);
|
||||
}
|
||||
|
||||
for (int perf = 0; perf < well.numPerfs(); ++perf) {
|
||||
const auto perf_ecl_index = well.perforationData()[perf].ecl_index;
|
||||
const auto& connections = well.wellEcl().getConnections();
|
||||
const auto& connection = connections[perf_ecl_index];
|
||||
if (well.isInjector() && connection.filterCakeActive()) {
|
||||
const auto& filter_cake = connection.getFilterCake();
|
||||
const double area = connection.getFilterCakeArea();
|
||||
const double poro = filter_cake.poro;
|
||||
const double perm = filter_cake.perm;
|
||||
const double rw = connection.getFilterCakeRadius();
|
||||
const auto cr0 = connection.r0();
|
||||
const auto crw = connection.rw();
|
||||
const double K = connection.Kh() / connection.connectionLength();
|
||||
const double factor = filter_cake.sf_multiplier;
|
||||
// the thickness of the filtration cake
|
||||
const double thickness = filtration_particle_volume_[perf] / (area * (1. - poro));
|
||||
|
||||
double skin_factor = 0.;
|
||||
switch (filter_cake.geometry) {
|
||||
case FilterCake::FilterCakeGeometry::LINEAR: {
|
||||
skin_factor = thickness / rw * K / perm * factor;
|
||||
break;
|
||||
}
|
||||
case FilterCake::FilterCakeGeometry::RADIAL: {
|
||||
const double rc = std::sqrt(rw * rw + 2. * rw * thickness);
|
||||
skin_factor = K / perm * std::log(rc / rw) * factor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
const auto geometry =
|
||||
FilterCake::filterCakeGeometryToString(filter_cake.geometry);
|
||||
OPM_DEFLOG_THROW(std::runtime_error,
|
||||
fmt::format(" Invalid filtration cake geometry type ({}) for well {}",
|
||||
geometry, well.name()),
|
||||
deferred_logger);
|
||||
}
|
||||
// the original skin factor for the connection
|
||||
const auto cskinfactor = connection.skinFactor();
|
||||
// compute a multiplier for the well connection transmissibility
|
||||
const auto denom = std::log(cr0 / std::min(crw, cr0)) + cskinfactor;
|
||||
const auto denom2 = denom + skin_factor;
|
||||
inj_fc_multiplier_[perf] = denom / denom2;
|
||||
} else {
|
||||
inj_fc_multiplier_[perf] = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Opm
|
59
opm/simulators/wells/WellFilterCake.hpp
Normal file
59
opm/simulators/wells/WellFilterCake.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2023 Equinor
|
||||
|
||||
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 3 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/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_WELL_FILTER_CAKE_HEADER_INCLUDED
|
||||
#define OPM_WELL_FILTER_CAKE_HEADER_INCLUDED
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class DeferredLogger;
|
||||
class WellInterfaceGeneric;
|
||||
class WellState;
|
||||
|
||||
//! \brief Class for well calculations related to filter cakes.
|
||||
class WellFilterCake {
|
||||
public:
|
||||
//! \brief Update the water injection volume.
|
||||
//! \details Used for calculation related to cake filtration due to injection activity.
|
||||
void updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
|
||||
const double dt,
|
||||
const std::size_t water_index,
|
||||
const WellState& well_state);
|
||||
|
||||
//! \brief Update the multiplier for well transmissbility due to cake filtration.
|
||||
void updateInjFCMult(const WellInterfaceGeneric& well,
|
||||
DeferredLogger& deferred_logger);
|
||||
|
||||
//! \brief Returns a const-ref to multipliers.
|
||||
const std::vector<double>& multipliers() const
|
||||
{
|
||||
return inj_fc_multiplier_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<double> filtration_particle_volume_; //!<// Volume of filtration particles during water injection
|
||||
std::vector<double> inj_fc_multiplier_; //!< Multiplier due to injection filtration cake
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OPM_WELL_FILTER_CAKE_HEADER_INCLUDED
|
@ -98,9 +98,6 @@ WellInterfaceGeneric::WellInterfaceGeneric(const Well& well,
|
||||
saturation_table_number_[perf] = pd.satnum_id;
|
||||
++perf;
|
||||
}
|
||||
if (this->isInjector()) {
|
||||
inj_fc_multiplier_.resize(number_of_perforations_, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
// initialization of the completions mapping
|
||||
@ -729,82 +726,4 @@ checkNegativeWellPotentials(std::vector<double>& well_potentials,
|
||||
}
|
||||
}
|
||||
|
||||
void WellInterfaceGeneric::
|
||||
updateFiltrationParticleVolume(const double dt, const size_t water_index,
|
||||
const WellState& well_state, std::vector<double>& filtration_particle_volume) const
|
||||
{
|
||||
if (!this->isInjector()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto injectorType = this->well_ecl_.injectorType();
|
||||
if (injectorType != InjectorType::WATER) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double conc = this->well_ecl_.getFilterConc();
|
||||
if (conc == 0.) {
|
||||
return;
|
||||
}
|
||||
|
||||
// it is currently used for the filter cake modeling related to formation damage study
|
||||
auto& ws = well_state.well(this->index_of_well_);
|
||||
const auto& connection_rates = ws.perf_data.phase_rates;
|
||||
|
||||
const std::size_t np = well_state.numPhases();
|
||||
for (int perf = 0; perf < this->number_of_perforations_; ++perf) {
|
||||
// not considering the production water
|
||||
const double water_rates = std::max(0., connection_rates[perf * np + water_index]);
|
||||
filtration_particle_volume[perf] += water_rates * conc * dt;
|
||||
}
|
||||
}
|
||||
|
||||
void WellInterfaceGeneric::
|
||||
updateInjFCMult(const std::vector<double>& filtration_particle_volume, DeferredLogger& deferred_logger) {
|
||||
for (int perf = 0; perf < this->number_of_perforations_; ++perf) {
|
||||
const auto perf_ecl_index = this->perforationData()[perf].ecl_index;
|
||||
const auto& connections = this->well_ecl_.getConnections();
|
||||
const auto& connection = connections[perf_ecl_index];
|
||||
if (this->isInjector() && connection.filterCakeActive()) {
|
||||
const auto& filter_cake = connection.getFilterCake();
|
||||
const double area = connection.getFilterCakeArea();
|
||||
const double poro = filter_cake.poro;
|
||||
const double perm = filter_cake.perm;
|
||||
const double rw = connection.getFilterCakeRadius();
|
||||
const auto cr0 = connection.r0();
|
||||
const auto crw = connection.rw();
|
||||
const double K = connection.Kh() / connection.connectionLength();
|
||||
const double factor = filter_cake.sf_multiplier;
|
||||
// the thickness of the filtration cake
|
||||
const double thickness = filtration_particle_volume[perf] / (area * (1. - poro));
|
||||
|
||||
double skin_factor = 0.;
|
||||
switch (filter_cake.geometry) {
|
||||
case FilterCake::FilterCakeGeometry::LINEAR: {
|
||||
skin_factor = thickness / rw * K / perm * factor;
|
||||
break;
|
||||
}
|
||||
case FilterCake::FilterCakeGeometry::RADIAL: {
|
||||
const double rc = std::sqrt(rw * rw + 2. * rw * thickness);
|
||||
skin_factor = K / perm * std::log(rc / rw) * factor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
OPM_DEFLOG_THROW(std::runtime_error,
|
||||
fmt::format(" Invalid filtration cake geometry type ({}) for well {}",
|
||||
FilterCake::filterCakeGeometryToString(filter_cake.geometry), name()),
|
||||
deferred_logger);
|
||||
}
|
||||
// the original skin factor for the connection
|
||||
const auto cskinfactor = connection.skinFactor();
|
||||
// compute a multiplier for the well connection transmissibility
|
||||
const auto denom = std::log(cr0 / std::min(crw, cr0)) + cskinfactor;
|
||||
const auto denom2 = denom + skin_factor;
|
||||
this->inj_fc_multiplier_[perf] = denom / denom2;
|
||||
} else {
|
||||
this->inj_fc_multiplier_[perf] = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -189,13 +189,6 @@ public:
|
||||
// it might change in the future
|
||||
double getInjMult(const int perf, const double bhp, const double perf_pres) const;
|
||||
|
||||
// update the water injection volume, it will be used for calculation related to cake filtration due to injection activity
|
||||
void updateFiltrationParticleVolume(const double dt, const size_t water_index,
|
||||
const WellState& well_state, std::vector<double>& filtration_particle_volume) const;
|
||||
|
||||
// update the multiplier for well transmissbility due to cake filteration
|
||||
void updateInjFCMult(const std::vector<double>& filtration_particle_volume, DeferredLogger& deferred_logger);
|
||||
|
||||
// whether a well is specified with a non-zero and valid VFP table number
|
||||
bool isVFPActive(DeferredLogger& deferred_logger) const;
|
||||
|
||||
@ -219,6 +212,12 @@ public:
|
||||
double wellEfficiencyFactor() const
|
||||
{ return well_efficiency_factor_; }
|
||||
|
||||
//! \brief Update filter cake multipliers.
|
||||
void updateFilterCakeMultipliers(const std::vector<double>& inj_fc_multiplier)
|
||||
{
|
||||
inj_fc_multiplier_ = inj_fc_multiplier;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool getAllowCrossFlow() const;
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
if (this->isInjector()) {
|
||||
if (this->isInjector() && !this->inj_fc_multiplier_.empty()) {
|
||||
const auto perf_ecl_index = this->perforationData()[perf].ecl_index;
|
||||
const auto& connections = this->well_ecl_.getConnections();
|
||||
const auto& connection = connections[perf_ecl_index];
|
||||
|
Loading…
Reference in New Issue
Block a user