Merge pull request #1143 from GitPaean/fixing_thp_initialization

Fixing thp initialization
This commit is contained in:
Atgeirr Flø Rasmussen 2017-03-02 15:51:38 +01:00 committed by GitHub
commit 03e005bb76

View File

@ -84,8 +84,8 @@ namespace Opm
for (int p = 0; p < np; ++p) {
wellrates_[np*w + p] = 0.0;
}
bhp_[w] = 0;
thp_[w] = 0;
bhp_[w] = 0.;
thp_[w] = 0.;
continue;
}
@ -104,13 +104,6 @@ namespace Opm
const int first_cell = wells->well_cells[wells->well_connpos[w]];
bhp_[w] = state.pressure()[first_cell];
}
// 3. Thp: assign thp equal to thp control, if applicable,
// otherwise assign equal to bhp value.
if (well_controls_get_current_type(ctrl) == THP) {
thp_[w] = well_controls_get_current_target( ctrl );
} else {
thp_[w] = bhp_[w];
}
} else {
// Open well:
// 1. Rates: initialize well rates to match controls
@ -138,20 +131,23 @@ namespace Opm
// little above or below (depending on if
// the well is an injector or producer)
// pressure in first perforation cell.
if (well_controls_get_current_type(ctrl) == BHP) {
bhp_[w] = well_controls_get_current_target( ctrl );
} else {
const int first_cell = wells->well_cells[wells->well_connpos[w]];
const double safety_factor = (wells->type[w] == INJECTOR) ? 1.01 : 0.99;
bhp_[w] = safety_factor*state.pressure()[first_cell];
if (well_controls_get_current_type(ctrl) == BHP) {
bhp_[w] = well_controls_get_current_target( ctrl );
} else {
const int first_cell = wells->well_cells[wells->well_connpos[w]];
const double safety_factor = (wells->type[w] == INJECTOR) ? 1.01 : 0.99;
bhp_[w] = safety_factor*state.pressure()[first_cell];
}
}
// 3. Thp: assign thp equal to thp control, if applicable,
// otherwise assign equal to bhp value.
if (well_controls_get_current_type(ctrl) == THP) {
thp_[w] = well_controls_get_current_target( ctrl );
} else {
thp_[w] = bhp_[w];
// 3. Thp: assign thp equal to thp target/limit, if applicable,
// otherwise keep it zero. Basically, the value should not be used
// in the simulation at all.
const int nwc = well_controls_get_num(ctrl);
for (int ctrl_index = 0; ctrl_index < nwc; ++ctrl_index) {
if (well_controls_iget_type(ctrl, ctrl_index) == THP) {
thp_[w] = well_controls_iget_target(ctrl, ctrl_index);
break;
}
}
}