Skip to content

Commit

Permalink
Merge pull request #5900 from totto82/improve_well_shutting
Browse files Browse the repository at this point in the history
Improve well shutting logic
  • Loading branch information
atgeirr authored Jan 28, 2025
2 parents 536ad41 + cfc2b03 commit 270018c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions opm/simulators/timestepping/AdaptiveTimeStepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void logTimer(const AdaptiveSimulatorTimer& substepTimer)
}

std::set<std::string>
consistentlyFailingWells(const std::vector<StepReport>& sr)
consistentlyFailingWells(const std::vector<StepReport>& sr, bool requireRepeatedFailures)
{
// If there are wells that cause repeated failures, we
// close them, and restart the un-chopped timestep.
Expand All @@ -60,10 +60,10 @@ consistentlyFailingWells(const std::vector<StepReport>& sr)
const int rep_step = sr.back().report_step;
const int sub_step = sr.back().current_step;
const int sr_size = sr.size();
if (sr_size >= num_steps) {
for (const auto& wf : wfs) {
failing_wells.insert(wf.wellName());
}
for (const auto& wf : wfs) {
failing_wells.insert(wf.wellName());
}
if (requireRepeatedFailures && sr_size >= num_steps) {
for (int s = 1; s < num_steps; ++s) {
const auto& srep = sr[sr_size - 1 - s];
// Report must be from same report step and substep, otherwise we have
Expand Down
2 changes: 1 addition & 1 deletion opm/simulators/timestepping/AdaptiveTimeStepping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct StepReport;
namespace detail {
void logTimer(const AdaptiveSimulatorTimer& substep_timer);

std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr);
std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr, bool requireRepeatedFailures);
void registerAdaptiveParameters();

std::tuple<TimeStepControlType, std::unique_ptr<TimeStepControlInterface>, bool>
Expand Down
13 changes: 9 additions & 4 deletions opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,15 @@ AdaptiveTimeStepping<TypeTag>::SubStepIteration<Solver>::
chopTimeStepOrCloseFailingWells_(const int new_time_step)
{
bool wells_shut = false;
// We are below the threshold, and will check if there are any wells we should close
// rather than chopping again.
std::set<std::string> failing_wells = detail::consistentlyFailingWells(
solver_().model().stepReports());
// We are below the threshold, and will check if there are any
// wells that fails repeatedly (that means that it fails in the last three steps)
// we should close rather than chopping again.
// If we already have chopped the timestep two times that is
// new_time_step < minTimeStepBeforeClosingWells_()*restartFactor_()*restartFactor_()
// We also shut wells that fails only on this step.
bool requireRepeatedFailures = new_time_step > ( minTimeStepBeforeClosingWells_()*restartFactor_()*restartFactor_());
std::set<std::string> failing_wells = detail::consistentlyFailingWells(solver_().model().stepReports(), requireRepeatedFailures);

if (failing_wells.empty()) {
// Found no wells to close, chop the timestep
chopTimeStep_(new_time_step);
Expand Down

0 comments on commit 270018c

Please sign in to comment.