Skip to content

Commit 34075be

Browse files
author
Tor Harald Sandve
committed
only count osc after NUPCOL
1 parent 443d9e7 commit 34075be

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

opm/simulators/wells/WellInterface_impl.hpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,17 @@ namespace Opm
209209
} else {
210210
from = WellProducerCMode2String(ws.production_cmode);
211211
}
212-
bool oscillating = std::count(this->well_control_log_.begin(), this->well_control_log_.end(), from) >= this->param_.max_number_of_well_switches_;
212+
// Only keep first and last control until iterationIdx >= nupcol (These are used for output)
213+
// After iteration >= nupcol we log all switches to check if the well controls oscillates
213214
const int episodeIdx = simulator.episodeIndex();
214215
const int iterationIdx = simulator.model().newtonMethod().numIterations();
215216
const int nupcol = schedule[episodeIdx].nupcol();
216-
if (oscillating && iterationIdx >= nupcol) {
217+
if (iterationIdx < nupcol && this->well_control_log_.size() > 2) {
218+
this->well_control_log_.erase (this->well_control_log_.begin()+1,this->well_control_log_.end()-1);
219+
}
220+
221+
const bool oscillating = std::count(this->well_control_log_.begin(), this->well_control_log_.end(), from) >= this->param_.max_number_of_well_switches_;
222+
if (oscillating) {
217223
// only output frist time
218224
bool output = std::count(this->well_control_log_.begin(), this->well_control_log_.end(), from) == this->param_.max_number_of_well_switches_;
219225
if (output) {
@@ -222,7 +228,7 @@ namespace Opm
222228
<< " is oscillating\n"
223229
<< " We don't allow for more than "
224230
<< this->param_.max_number_of_well_switches_
225-
<< " switches. The control is kept at " << from;
231+
<< " switches after NUPCOL. The control is kept at " << from;
226232
deferred_logger.info(ss.str());
227233
// add one more to avoid outputting the same info again
228234
this->well_control_log_.push_back(from);
@@ -287,11 +293,16 @@ namespace Opm
287293
} else {
288294
from = WellProducerCMode2String(ws.production_cmode);
289295
}
290-
const bool oscillating = std::count(this->well_control_log_.begin(), this->well_control_log_.end(), from) >= this->param_.max_number_of_well_switches_;
291-
const int iterationIdx = simulator.model().newtonMethod().numIterations();
296+
// Only keep first and last control until iterationIdx >= nupcol (These are used for output)
297+
// After iteration >= nupcol we log all switches to check if the well controls oscillates
292298
const int episodeIdx = simulator.episodeIndex();
299+
const int iterationIdx = simulator.model().newtonMethod().numIterations();
293300
const int nupcol = schedule[episodeIdx].nupcol();
294-
if ( (oscillating && iterationIdx >= nupcol)|| this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) || !(this->well_ecl_.getStatus() == WellStatus::OPEN)) {
301+
if (iterationIdx < nupcol && this->well_control_log_.size() > 2) {
302+
this->well_control_log_.erase (this->well_control_log_.begin()+1,this->well_control_log_.end()-1);
303+
}
304+
const bool oscillating = std::count(this->well_control_log_.begin(), this->well_control_log_.end(), from) >= this->param_.max_number_of_well_switches_;
305+
if (oscillating || this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) || !(this->well_ecl_.getStatus() == WellStatus::OPEN)) {
295306
return false;
296307
}
297308

0 commit comments

Comments
 (0)