update gpmain before not after timestep

This commit is contained in:
Tor Harald Sandve 2021-09-21 14:03:35 +02:00
parent b2ac3eaa59
commit eb4997a011
3 changed files with 14 additions and 12 deletions

View File

@ -452,7 +452,7 @@ checkGroupInjectionConstraints(const Group& group,
const auto& controls = group.injectionControls(phase, this->summaryState_);
double target = controls.surface_max_rate;
if (group.has_gpmaint_control(phase, Group::InjectionCMode::RATE) && this->groupState().has_gpmaint_target(group.name()))
if (group.has_gpmaint_control(phase, Group::InjectionCMode::RATE))
target = this->groupState().gpmaint_target(group.name());
if (target < current_rate) {
@ -475,7 +475,7 @@ checkGroupInjectionConstraints(const Group& group,
const auto& controls = group.injectionControls(phase, this->summaryState_);
double target = controls.resv_max_rate;
if (group.has_gpmaint_control(phase, Group::InjectionCMode::RESV) && this->groupState().has_gpmaint_target(group.name()))
if (group.has_gpmaint_control(phase, Group::InjectionCMode::RESV))
target = this->groupState().gpmaint_target(group.name());
if (target < current_rate) {
@ -648,7 +648,7 @@ checkGroupProductionConstraints(const Group& group,
current_rate = comm_.sum(current_rate);
double target = controls.resv_target;
if (group.has_gpmaint_control(Group::ProductionCMode::RESV) && this->groupState().has_gpmaint_target(group.name()))
if (group.has_gpmaint_control(Group::ProductionCMode::RESV))
target = this->groupState().gpmaint_target(group.name());
if ( target < current_rate ) {

View File

@ -221,7 +221,6 @@ namespace Opm {
const auto& fp = this->eclState_.fieldProps();
const auto& fipnum = fp.get_int("FIPNUM");
regionalAveragePressureCalculator_.reset(new AverageRegionalPressureType (phase_usage_,fipnum));
regionalAveragePressureCalculator_->template defineState<ElementContext>(ebosSimulator_);
}
{
@ -359,6 +358,15 @@ namespace Opm {
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
WellGroupHelpers::updateGuideRates(fieldGroup, schedule(), summaryState, this->phase_usage_, reportStepIdx, simulationTime,
this->wellState(), this->groupState(), comm, &this->guideRate_, pot, local_deferredLogger);
// update gpmaint targets
if (schedule_[reportStepIdx].has_gpmaint()) {
regionalAveragePressureCalculator_->template defineState<ElementContext>(ebosSimulator_);
const double dt = ebosSimulator_.timeStepSize();
WellGroupHelpers::updateGpMaintTargetForGroups(fieldGroup,
schedule_, *regionalAveragePressureCalculator_, reportStepIdx, dt, this->wellState(), this->groupState());
}
try {
// Compute initial well solution for new wells and injectors that change injection type i.e. WAG.
for (auto& well : well_container_) {
@ -496,13 +504,6 @@ namespace Opm {
// update the rate converter with current averages pressures etc in
rateConverter_->template defineState<ElementContext>(ebosSimulator_);
const Group& fieldGroup = schedule_.getGroup("FIELD", reportStepIdx);
if (schedule_[reportStepIdx].has_gpmaint()) {
regionalAveragePressureCalculator_->template defineState<ElementContext>(ebosSimulator_);
WellGroupHelpers::updateGpMaintTargetForGroups(fieldGroup,
schedule_, *regionalAveragePressureCalculator_, reportStepIdx, dt, this->wellState(), this->groupState());
}
// calculate the well potentials
try {
updateWellPotentials(reportStepIdx,
@ -517,6 +518,7 @@ namespace Opm {
updateWellTestState(simulationTime, wellTestState());
// check group sales limits at the end of the timestep
const Group& fieldGroup = schedule_.getGroup("FIELD", reportStepIdx);
checkGconsaleLimits(fieldGroup, this->wellState(),
ebosSimulator_.episodeIndex(), local_deferredLogger);

View File

@ -114,7 +114,7 @@ double TargetCalculator::groupTarget(const Group::ProductionControls ctrl) const
return ctrl.liquid_target;
case Group::ProductionCMode::RESV:
{
if(use_gpmaint_ && this->group_state_.has_gpmaint_target(this->group_name_))
if(use_gpmaint_)
return this->group_state_.gpmaint_target(this->group_name_);
return ctrl.resv_target;