Merge pull request #5627 from vkip/fc_clean

Handle cleaning of filter cake in a more intuitive way
This commit is contained in:
Kai Bao
2024-10-08 13:54:14 +02:00
committed by GitHub
5 changed files with 200 additions and 112 deletions

View File

@@ -1821,20 +1821,21 @@ void BlackoilWellModelGeneric<Scalar>::initInjMult()
template<class Scalar>
void BlackoilWellModelGeneric<Scalar>::
updateFiltrationParticleVolume(const double dt,
const std::size_t water_index)
updateFiltrationModelsPostStep(const double dt,
const std::size_t water_index,
DeferredLogger& deferred_logger)
{
for (auto& well : this->well_container_generic_) {
if (well->isInjector()) {
const Scalar conc = well->wellEcl().evalFilterConc(this->summaryState_);
if (conc > 0.) {
auto fc = this->filter_cake_
// Update filter cake build-ups (external to the wellbore)
auto retval = this->filter_cake_
.emplace(std::piecewise_construct,
std::forward_as_tuple(well->name()),
std::tuple{});
fc.first->second.updateFiltrationParticleVolume(*well, dt, conc, water_index,
this->wellState());
auto& fc = retval.first->second;
fc.updatePostStep(*well, this->wellState(), dt, conc, water_index, deferred_logger);
}
}
}
@@ -1853,19 +1854,20 @@ updateInjMult(DeferredLogger& deferred_logger)
template<class Scalar>
void BlackoilWellModelGeneric<Scalar>::
updateInjFCMult(DeferredLogger& deferred_logger)
updateFiltrationModelsPreStep(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, this->wellState(), deferred_logger);
it->second.updatePreStep(*well, deferred_logger);
well->updateFilterCakeMultipliers(it->second.multipliers());
}
}
}
}
template class BlackoilWellModelGeneric<double>;
#if FLOW_INSTANTIATE_FLOAT

View File

@@ -411,8 +411,11 @@ protected:
void updateInjMult(DeferredLogger& deferred_logger);
void updateInjFCMult(DeferredLogger& deferred_logger);
void updateFiltrationParticleVolume(const double dt,
const std::size_t water_index);
void updateFiltrationModelsPostStep(const double dt,
const std::size_t water_index,
DeferredLogger& deferred_logger);
void updateFiltrationModelsPreStep(DeferredLogger& deferred_logger);
// create the well container
virtual void createWellContainer(const int time_step) = 0;

View File

@@ -497,7 +497,7 @@ namespace Opm {
well->setGuideRate(&this->guideRate_);
}
this->updateInjFCMult(local_deferredLogger);
this->updateFiltrationModelsPreStep(local_deferredLogger);
// Close completions due to economic reasons
for (auto& well : well_container_) {
@@ -708,10 +708,10 @@ namespace Opm {
}
if (Indices::waterEnabled) {
this->updateFiltrationParticleVolume(dt, FluidSystem::waterPhaseIdx);
this->updateFiltrationModelsPostStep(dt, FluidSystem::waterPhaseIdx, local_deferredLogger);
}
// at the end of the time step, updating the inj_multiplier saved in WellState for later use
// WINJMULT: At the end of the time step, update the inj_multiplier saved in WellState for later use
this->updateInjMult(local_deferredLogger);
// report well switching

View File

@@ -37,109 +37,178 @@ namespace Opm {
template<class Scalar>
void WellFilterCake<Scalar>::
updateFiltrationParticleVolume(const WellInterfaceGeneric<Scalar>& well,
const double dt,
const Scalar conc,
const std::size_t water_index,
WellState<Scalar>& well_state)
updatePostStep(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
const double dt,
const Scalar conc,
const std::size_t water_index,
DeferredLogger& deferred_logger)
{
if (!well.isInjector()) {
if (! well.isInjector() || well.wellEcl().injectorType() != InjectorType::WATER)
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;
}
assert (conc > 0.);
auto& ws = well_state.well(well.indexOfWell());
const auto nperf = ws.perf_data.size();
if (skin_factor_.empty()) {
skin_factor_.assign(nperf, 0.);
thickness_.assign(nperf, 0.);
}
ws.filtrate_conc = conc;
if (conc == 0.) {
return;
}
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 Scalar water_rates = std::max(Scalar{0.}, connection_rates[perf * np + water_index]);
const Scalar filtrate_rate = water_rates * conc;
filtration_particle_volume_[perf] += filtrate_rate * dt;
ws.perf_data.filtrate_data.rates[perf] = filtrate_rate;
ws.perf_data.filtrate_data.total[perf] = filtration_particle_volume_[perf];
}
updateSkinFactorsAndMultipliers(well, well_state, dt, water_index, deferred_logger);
}
template<class Scalar>
void WellFilterCake<Scalar>::
updateInjFCMult(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
DeferredLogger& deferred_logger)
updatePreStep(const WellInterfaceGeneric<Scalar>& well, DeferredLogger& deferred_logger)
{
if (inj_fc_multiplier_.empty()) {
inj_fc_multiplier_.resize(well.numPerfs(), 1.0);
}
auto& ws = well_state.well(well.indexOfWell());
auto& perf_data = ws.perf_data;
// Apply cleaning and reset any filter cake cleaning multipliers (even if the well is producing at this time)
applyCleaning(well, deferred_logger);
}
for (int perf = 0; perf < well.numPerfs(); ++perf) {
template<class Scalar>
void WellFilterCake<Scalar>::
applyCleaning(const WellInterfaceGeneric<Scalar>& well,
DeferredLogger& deferred_logger)
{
const auto& connections = well.wellEcl().getConnections();
const auto nperf = well.numPerfs();
for (int perf = 0; perf < nperf; ++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 Scalar area = connection.getFilterCakeArea();
const Scalar poro = filter_cake.poro;
const Scalar perm = filter_cake.perm;
const Scalar rw = connection.getFilterCakeRadius();
const Scalar K = connection.Kh() / connection.connectionLength();
const Scalar factor = filter_cake.sf_multiplier;
// the thickness of the filtration cake
const Scalar thickness = filtration_particle_volume_[perf] / (area * (1. - poro));
auto& filtrate_data = perf_data.filtrate_data;
filtrate_data.thickness[perf] = thickness;
filtrate_data.poro[perf] = poro;
filtrate_data.perm[perf] = perm;
filtrate_data.radius[perf] = connection.getFilterCakeRadius();
filtrate_data.area_of_flow[perf] = connection.getFilterCakeArea();
if (!connection.filterCakeActive())
continue;
Scalar skin_factor = 0.;
switch (filter_cake.geometry) {
case FilterCake::FilterCakeGeometry::LINEAR: {
skin_factor = thickness / rw * K / perm * factor;
break;
}
case FilterCake::FilterCakeGeometry::RADIAL: {
const Scalar 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);
const auto& filter_cake = connection.getFilterCake();
const Scalar factor = filter_cake.sf_multiplier;
if (factor == 1.0)
continue;
filter_cake.sf_multiplier = 1.0;
skin_factor_[perf] *= factor;
updateMultiplier(connection, perf);
const Scalar rw = connection.getFilterCakeRadius();
switch (filter_cake.geometry) {
case FilterCake::FilterCakeGeometry::LINEAR: {
// Previous thickness adjusted to give correct cleaning multiplier at start of time step
thickness_[perf] *= factor;
break;
}
filtrate_data.skin_factor[perf] = skin_factor;
const auto denom = connection.ctfProperties().peaceman_denom;
const auto denom2 = denom + skin_factor;
inj_fc_multiplier_[perf] = denom / denom2;
} else {
inj_fc_multiplier_[perf] = 1.0;
case FilterCake::FilterCakeGeometry::RADIAL: {
Scalar rc_prev = std::sqrt(rw * rw + 2. * rw * thickness_[perf]);
// Previous thickness and rc adjusted to give correct cleaning multiplier at start of time step
rc_prev = rw*std::exp(factor*std::log(rc_prev/rw));
thickness_[perf] = (rc_prev * rc_prev - rw * rw) / (2. * rw);
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);
}
}
}
template<class Scalar>
void WellFilterCake<Scalar>::
updateSkinFactorsAndMultipliers(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
const double dt,
const std::size_t water_index,
DeferredLogger& deferred_logger)
{
const auto nperf = well.numPerfs();
inj_fc_multiplier_.assign(nperf, 1.0);
assert(well.isInjector());
const auto& connections = well.wellEcl().getConnections();
auto& ws = well_state.well(well.indexOfWell());
auto& perf_data = ws.perf_data;
assert (nperf == static_cast<int>(perf_data.size()));
const auto& connection_rates = perf_data.phase_rates;
const auto conc = ws.filtrate_conc;
const std::size_t np = well_state.numPhases();
for (int perf = 0; perf < nperf; ++perf) {
const auto perf_ecl_index = well.perforationData()[perf].ecl_index;
const auto& connection = connections[perf_ecl_index];
if (!connection.filterCakeActive())
continue;
// not considering the production water
const Scalar water_rates = std::max(Scalar{0.}, connection_rates[perf * np + water_index]);
const Scalar filtrate_rate = water_rates * conc;
const Scalar filtrate_particle_volume = filtrate_rate * dt;
auto& filtrate_data = perf_data.filtrate_data;
filtrate_data.rates[perf] = filtrate_rate;
filtrate_data.total[perf] += filtrate_particle_volume;
const auto& filter_cake = connection.getFilterCake();
const Scalar area = connection.getFilterCakeArea();
const Scalar poro = filter_cake.poro;
const Scalar perm = filter_cake.perm;
const Scalar rw = connection.getFilterCakeRadius();
const Scalar K = connection.Kh() / connection.connectionLength();
// The thickness of the filtration cake due to particle deposition at current time step
const Scalar delta_thickness = filtrate_particle_volume / (area * (1. - poro));
filtrate_data.poro[perf] = poro;
filtrate_data.perm[perf] = perm;
filtrate_data.radius[perf] = connection.getFilterCakeRadius();
filtrate_data.area_of_flow[perf] = connection.getFilterCakeArea();
Scalar delta_skin_factor = 0.;
Scalar thickness = 0.;
switch (filter_cake.geometry) {
case FilterCake::FilterCakeGeometry::LINEAR: {
thickness = thickness_[perf] + delta_thickness;
filtrate_data.thickness[perf] = thickness;
delta_skin_factor = delta_thickness / rw * K / perm;
break;
}
case FilterCake::FilterCakeGeometry::RADIAL: {
const auto prev_thickness = thickness_[perf];
Scalar rc_prev = std::sqrt(rw * rw + 2. * rw * prev_thickness);
thickness = prev_thickness + delta_thickness;
const Scalar rc = std::sqrt(rw * rw + 2. * rw * thickness);
filtrate_data.thickness[perf] = rc - rw;
delta_skin_factor = K / perm * std::log(rc / rc_prev);
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);
}
skin_factor_[perf] += delta_skin_factor;
filtrate_data.skin_factor[perf] = skin_factor_[perf];
thickness_[perf] = thickness;
updateMultiplier(connection, perf);
}
}
template<class Scalar> template <class Conn>
void WellFilterCake<Scalar>::
updateMultiplier(const Conn& connection, const int perf)
{
const auto denom = connection.ctfProperties().peaceman_denom;
const auto denom2 = denom + skin_factor_[perf];
inj_fc_multiplier_[perf] = denom / denom2;
}
template class WellFilterCake<double>;
#if FLOW_INSTANTIATE_FLOAT

View File

@@ -33,28 +33,42 @@ template<class Scalar> class WellState;
template<class Scalar>
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<Scalar>& well,
const double dt,
const Scalar conc,
const std::size_t water_index,
WellState<Scalar>& well_state);
//! \brief Post-step filtration model updates
//! \details Calculates the filtrate deposition volumes and associated skin factors / injectivity multipliers
void updatePostStep(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
const double dt,
const Scalar conc,
const std::size_t water_index,
DeferredLogger& deferred_logger);
//! \brief Update the multiplier for well transmissbility due to cake filtration.
void updateInjFCMult(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
DeferredLogger& deferred_logger);
//! \brief Pre-step filtration model updates
//! \details Applies filter cake cleaning
void updatePreStep(const WellInterfaceGeneric<Scalar>& well,
DeferredLogger& deferred_logger);
//! \brief Returns a const-ref to multipliers.
const std::vector<Scalar>& multipliers() const
{
return inj_fc_multiplier_;
}
const std::vector<Scalar>& multipliers() const { return inj_fc_multiplier_; }
private:
std::vector<Scalar> filtration_particle_volume_; //!<// Volume of filtration particles during water injection
//! \brief Update the multiplier for well transmissbility due to cake filtration.
void updateSkinFactorsAndMultipliers(const WellInterfaceGeneric<Scalar>& well,
WellState<Scalar>& well_state,
const double dt,
const std::size_t water_index,
DeferredLogger& deferred_logger);
template<class Conn>
void updateMultiplier(const Conn& conn, const int perf);
//! \brief Apply cleaning multipliers to skin factors and reduce cake thickness accordingly
//! \details The cake thickness is re-computed to give the new (reduced) skin factor with current cake properties
void applyCleaning(const WellInterfaceGeneric<Scalar>& well,
DeferredLogger& deferred_logger);
std::vector<Scalar> inj_fc_multiplier_; //!< Multiplier due to injection filtration cake
std::vector<Scalar> skin_factor_;
std::vector<Scalar> thickness_;
};
}