recovering group control for legacy_flow.

This commit is contained in:
Kai Bao 2017-04-07 10:05:35 +02:00
parent 8fa3c4b324
commit 181112491b
2 changed files with 81 additions and 0 deletions

View File

@ -558,6 +558,11 @@ namespace Opm {
std::vector<double>& maxNormWell,
int nc) const;
/// Set up the group control related at the beginning of each time step
void
setupGroupControl(const ReservoirState& reservoir_state,
WellState& well_state);
double dpMaxRel() const { return param_.dp_max_rel_; }
double dbhpMaxRel() const {return param_.dbhp_max_rel_; }
double dsMax() const { return param_.ds_max_; }

View File

@ -764,6 +764,11 @@ typedef Eigen::Array<double,
asImpl().wellModel().computeWellConnectionPressures(state0, well_state);
}
// set up the guide rate and group control
if (asImpl().wellModel().wellCollection()->groupControlActive() && initial_assembly) {
setupGroupControl(reservoir_state, well_state);
}
// Possibly switch well controls and updating well state to
// get reasonable initial conditions for the wells
asImpl().wellModel().updateWellControls(well_state);
@ -2545,6 +2550,77 @@ typedef Eigen::Array<double,
}
}
template <class Grid, class WellModel, class Implementation>
void
BlackoilModelBase<Grid, WellModel, Implementation>::
setupGroupControl(const ReservoirState& reservoir_state,
WellState& well_state)
{
if (param_.compute_well_potentials_) {
SolutionState state = asImpl().variableState(reservoir_state, well_state);
asImpl().makeConstantState(state);
asImpl().wellModel().computeWellConnectionPressures(state, well_state);
const int np = numPhases();
std::vector<ADB> b(np, ADB::null());
std::vector<ADB> mob(np, ADB::null());
const ADB& press = state.pressure;
const ADB& temp = state.temperature;
const ADB& rs = state.rs;
const ADB& rv = state.rv;
const std::vector<PhasePresence> cond = phaseCondition();
const ADB pv_mult = poroMult(press);
const ADB tr_mult = transMult(press);
const std::vector<ADB> kr = asImpl().computeRelPerm(state);
std::vector<ADB> mob_perfcells(np, ADB::null());
std::vector<ADB> b_perfcells(np, ADB::null());
for (int phase = 0; phase < np; ++phase) {
if (active_[phase]) {
const std::vector<int>& well_cells = asImpl().wellModel().wellOps().well_cells;
const ADB mu = asImpl().fluidViscosity(canph_[phase], state.canonical_phase_pressures[canph_[phase]],
temp, rs, rv, cond);
mob[phase] = tr_mult * kr[canph_[phase]] / mu;
mob_perfcells[phase] = subset(mob[phase], well_cells);
b[phase] = asImpl().fluidReciprocFVF(phase, state.canonical_phase_pressures[phase], temp, rs, rv, cond);
b_perfcells[phase] = subset(b[phase], well_cells);
}
}
// well potentials for each well
std::vector<double> well_potentials;
asImpl().wellModel().computeWellPotentials(mob_perfcells, b_perfcells, well_state, state, well_potentials);
asImpl().wellModel().wellCollection()->setGuideRatesWithPotentials(asImpl().wellModel().wellsPointer(),
fluid_.phaseUsage(), well_potentials);
applyVREPGroupControl(reservoir_state, well_state);
if (asImpl().wellModel().wellCollection()->groupControlApplied()) {
asImpl().wellModel().wellCollection()->updateWellTargets(well_state.wellRates());
} else {
asImpl().wellModel().wellCollection()->applyGroupControls();
// the well collections do not have access to Well State, so the currentControls() of Well State need to
// be updated based on the group control setup
const int nw = wells().number_of_wells;
for (int w = 0; w < nw; ++w) {
const WellNode& well_node = asImpl().wellModel().wellCollection()->findWellNode(wells().name[w]);
if (!well_node.individualControl()) {
well_state.currentControls()[w] = well_node.groupControlIndex();
}
}
} // end of else
} // end of if (param_.compute_well_potentials_)
}
} // namespace Opm
#endif // OPM_BLACKOILMODELBASE_IMPL_HEADER_INCLUDED