Use multiple returns in init single well

This commit is contained in:
Joakim Hove committed 2021-11-01 16:02:34 +01:00
1 parent 2527970d11
commit 93218b05c2
1 file changed
+17 -13
+17 -13
View File
@@ -18,6 +18,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fmt/format.h>
#include <config.h>
#include <opm/simulators/wells/WellState.hpp>
@@ -92,6 +93,15 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
ws.status = Well::Status::OPEN;
}
// Thp: assign thp equal to thp target/limit, if such a limit exists,
// otherwise keep it zero.
const bool has_thp = well.isInjector() ? inj_controls.hasControl(Well::InjectorCMode::THP)
: prod_controls.hasControl(Well::ProducerCMode::THP);
const double thp_limit = well.isInjector() ? inj_controls.thp_limit : prod_controls.thp_limit;
if (has_thp) {
ws.thp = thp_limit;
}
if (well.getStatus() == Well::Status::STOP) {
// Stopped well:
// 1. Rates: zero well rates.
@@ -103,7 +113,9 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
} else {
ws.bhp = global_pressure;
}
} else if (is_grup) {
return;
}
if (is_grup) {
// Well under group control.
// 1. Rates: zero well rates.
// 2. Bhp: initialize bhp to be a
@@ -112,7 +124,9 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
// pressure in first perforation cell.
const double safety_factor = well.isInjector() ? 1.01 : 0.99;
ws.bhp = safety_factor * global_pressure;
} else {
return;
}
// Open well, under own control:
// 1. Rates: initialize well rates to match
// controls if type is ORAT/GRAT/WRAT
@@ -161,6 +175,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
break;
}
}
// 2. Bhp: initialize bhp to be target pressure if
// bhp-controlled well, otherwise set to a
// little above or below (depending on if
@@ -174,17 +189,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
}
}
// 3. Thp: assign thp equal to thp target/limit, if such a limit exists,
// otherwise keep it zero.
const bool has_thp = well.isInjector() ? inj_controls.hasControl(Well::InjectorCMode::THP)
: prod_controls.hasControl(Well::ProducerCMode::THP);
const double thp_limit = well.isInjector() ? inj_controls.thp_limit : prod_controls.thp_limit;
if (has_thp) {
ws.thp = thp_limit;
}
}
void WellState::init(const std::vector<double>& cellPressures,
const Schedule& schedule,