Merge pull request #621 from totto82/fix_lrat

Bugfix. Fix setting initial rates in updateWellControls
This commit is contained in:
Atgeirr Flø Rasmussen 2016-03-31 14:33:33 +02:00
commit b5c216f4f3

View File

@ -1611,11 +1611,37 @@ namespace detail {
break; break;
case SURFACE_RATE: case SURFACE_RATE:
for (int phase = 0; phase < np; ++phase) { // assign target value as initial guess for injectors and
if (distr[phase] > 0.0) { // single phase producers (orat, grat, wrat)
xw.wellRates()[np*w + phase] = target * distr[phase]; const WellType& well_type = wells().type[w];
if (well_type == INJECTOR) {
for (int phase = 0; phase < np; ++phase) {
const double& compi = wells().comp_frac[np * w + phase];
if (compi > 0.0) {
xw.wellRates()[np*w + phase] = target * compi;
}
} }
} else if (well_type == PRODUCER) {
// only set target as initial rates for single phase
// producers. (orat, grat and wrat, and not lrat)
// lrat will result in numPhasesWithTargetsUnderThisControl == 2
int numPhasesWithTargetsUnderThisControl = 0;
for (int phase = 0; phase < np; ++phase) {
if (distr[phase] > 0.0) {
numPhasesWithTargetsUnderThisControl += 1;
}
}
for (int phase = 0; phase < np; ++phase) {
if (distr[phase] > 0.0 && numPhasesWithTargetsUnderThisControl < 2 ) {
xw.wellRates()[np*w + phase] = target * distr[phase];
}
}
} else {
OPM_THROW(std::logic_error, "Expected PRODUCER or INJECTOR type of well");
} }
break; break;
} }