@@ -209,11 +209,17 @@ namespace Opm
209
209
} else {
210
210
from = WellProducerCMode2String (ws.production_cmode );
211
211
}
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
213
214
const int episodeIdx = simulator.episodeIndex ();
214
215
const int iterationIdx = simulator.model ().newtonMethod ().numIterations ();
215
216
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) {
217
223
// only output frist time
218
224
bool output = std::count (this ->well_control_log_ .begin (), this ->well_control_log_ .end (), from) == this ->param_ .max_number_of_well_switches_ ;
219
225
if (output) {
@@ -222,7 +228,7 @@ namespace Opm
222
228
<< " is oscillating\n "
223
229
<< " We don't allow for more than "
224
230
<< 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;
226
232
deferred_logger.info (ss.str ());
227
233
// add one more to avoid outputting the same info again
228
234
this ->well_control_log_ .push_back (from);
@@ -287,11 +293,16 @@ namespace Opm
287
293
} else {
288
294
from = WellProducerCMode2String (ws.production_cmode );
289
295
}
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
292
298
const int episodeIdx = simulator.episodeIndex ();
299
+ const int iterationIdx = simulator.model ().newtonMethod ().numIterations ();
293
300
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)) {
295
306
return false ;
296
307
}
297
308
0 commit comments