cleaning up and updating MultisegmentWells

This commit is contained in:
Kai Bao 2016-11-10 17:49:56 +01:00
parent 6bbc726bc2
commit f85da3768e
4 changed files with 28 additions and 74 deletions

View File

@ -1071,8 +1071,6 @@ namespace detail {
asImpl().wellModel().addWellControlEq(wellSolutionState, well_state, aliveWells, residual_);
converged = getWellConvergence(it);
// When the well targets are just updated or need to be updated, we need at least one more iteration.
if (converged) {
break;
}

View File

@ -150,6 +150,11 @@ namespace Opm {
// get reasonable initial conditions for the wells
wellModel().updateWellControls(well_state);
// enforce VREP control when necessary.
Base::applyVREPGroupControl(reservoir_state, well_state);
asImpl().wellModel().wellCollection()->updateWellTargets(well_state.wellRates());
// Create the primary variables.
SolutionState state = asImpl().variableState(reservoir_state, well_state);

View File

@ -826,17 +826,6 @@ namespace Opm
{
wellhelpers::WellSwitchingLogger logger;
// if we need to update the well targets related to group control,
// we update them then re-run the simulation before updating the well control
if (well_collection_->needUpdateWellTargets() ) {
well_collection_->updateWellTargets(xw.wellRates());
for (size_t i = 0; i < well_collection_->numNode(); ++i) {
well_collection_->getNode(i)->setShouldUpdateWellTargets(false);
}
return;
}
if( msWells().empty() ) return ;
// Find, for each well, if any constraints are broken. If so,
@ -877,38 +866,6 @@ namespace Opm
well_controls_iget_type(wc, ctrl_index));
xw.currentControls()[w] = ctrl_index;
current = xw.currentControls()[w];
WellNode* well_node = well_collection_->findWellNode(std::string(wells().name[w]));
if (well_node == nullptr) {
OPM_THROW(std::runtime_error, "Could not find well " << std::string(wells().name[w]) << " in the well collection!\n");
}
// When the wells swtiching back and forwards between individual control and group control
// The targets of the wells should be updated.
if (well_node->individualControl()) {
if (ctrl_index == well_node->groupControlIndex()) {
well_node->setIndividualControl(false);
}
} else {
if (ctrl_index != well_node->groupControlIndex()) {
well_node->setIndividualControl(true);
}
}
// TODO: double confirming the current strategy
well_node->setShouldUpdateWellTargets(true);
} else {
// no constraints got broken
// the wells running under group control should set to be under group control
// it is based on the fact that we begin with setting all the wells be be under individual control
// The wells switch to be under group control after breaking one of the group target/limit.
// It is the same philosophy with the current srategy of the well control changing.
WellNode* well_node = dynamic_cast<Opm::WellNode *>(well_collection_->findNode(std::string(wells().name[w])));
if (well_node->individualControl()) {
// the wells running under group control, meaning they are not under individual control
if (current == well_node->groupControlIndex()) {
well_node->setIndividualControl(false);
}
}
}
// Get gravity for THP hydrostatic corrrection
@ -947,6 +904,22 @@ namespace Opm
break;
}
// get the pointer to the well node in the well collection
WellNode* well_node = well_collection_->findWellNode(std::string(wells().name[w]));
// maybe should put this if in function findWellNode()
if (well_node == nullptr) {
OPM_THROW(std::runtime_error, "Could not find well " << std::string(wells().name[w]) << " in the well collection!\n");
}
// update whehter the well is under group control or individual control
if (well_node->groupControlIndex() >= 0 && current == well_node->groupControlIndex()) {
// under group control
well_node->setIndividualControl(false);
} else {
// individual control
well_node->setIndividualControl(true);
}
}
}

View File

@ -714,16 +714,6 @@ namespace Opm
if( !localWellsActive() ) return ;
// if we need to update the well targets related to group control,
// we update them then re-run the simulation before updating the well control
/* if (well_collection_->needUpdateWellTargets() ) {
well_collection_->updateWellTargets(xw.wellRates());
for (size_t i = 0; i < well_collection_->numNode(); ++i) {
well_collection_->getNode(i)->setShouldUpdateWellTargets(false);
}
return;
} */
// Find, for each well, if any constraints are broken. If so,
// switch control to first broken constraint.
const int np = wells().number_of_phases;
@ -754,22 +744,6 @@ namespace Opm
break;
}
}
// TODO: when constraints got broken. For a well under group control, we need to change it to individual control
// We need to check the controls in the same group. If there is still some wells under group control,
// we need to update their group share targets. If no well is under group control, it means the group target
// will not be able to meet. We need to give a message there.
// It is better to wait until after the limit check loop. We need to record whose control status changed
// from group control to individual control here.
// Not sure exactly how the well go back from the individual control to group control.
// A guess is that the target is not updated. It works as a limit. When it got broken again, it switch back to
// group control. Then we also need to do something there.
// get the pointer to the well node in the well collection
WellNode* well_node = well_collection_->findWellNode(std::string(wells().name[w]));
// maybe should put this if in function findWellNode()
if (well_node == nullptr) {
OPM_THROW(std::runtime_error, "Could not find well " << std::string(wells().name[w]) << " in the well collection!\n");
}
if (ctrl_index != nwc) {
// Constraint number ctrl_index was broken, switch to it.
@ -781,9 +755,6 @@ namespace Opm
xw.currentControls()[w] = ctrl_index;
current = xw.currentControls()[w];
// TODO: double confirming the current strategy
well_node->setShouldUpdateWellTargets(true);
}
// Updating well state and primary variables.
@ -881,6 +852,13 @@ namespace Opm
break;
}
// get the pointer to the well node in the well collection
WellNode* well_node = well_collection_->findWellNode(std::string(wells().name[w]));
// maybe should put this if in function findWellNode()
if (well_node == nullptr) {
OPM_THROW(std::runtime_error, "Could not find well " << std::string(wells().name[w]) << " in the well collection!\n");
}
// update whehter the well is under group control or individual control
if (well_node->groupControlIndex() >= 0 && current == well_node->groupControlIndex()) {
// under group control