From 4129928be456cc70284d9ebd1e4fa726c663fb9c Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 17 Feb 2017 17:12:52 +0100 Subject: [PATCH] when no THP control/limit, thp value will be set to zero. It provides a strategy to reset the zero thp value when no thp control is involved anymore. --- opm/autodiff/WellStateFullyImplicitBlackoil.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp index 9daf543ad..84a54ebff 100644 --- a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp +++ b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp @@ -171,6 +171,22 @@ namespace Opm currentControls()[ newIndex ] = 0; } } + + + // If in the new step, there is no THP related target/limit anymore, its thp value should be + // set to zero. + const WellControls* ctrl = wells->ctrls[w]; + const int nwc = well_controls_get_num(ctrl); + int ctrl_index = 0; + for (; ctrl_index < nwc; ++ctrl_index) { + if (well_controls_iget_type(ctrl, ctrl_index) == THP) { + break; + } + } + // not finding any thp related control/limits + if (ctrl_index == nwc) { + thp()[w] = 0.; + } } } }