Merge pull request #5350 from totto82/gpmain_reset

Reset gpmain state when rate is zero
This commit is contained in:
Atgeirr Flø Rasmussen 2024-05-15 08:12:16 +02:00 committed by GitHub
commit 48eb73fa80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -796,7 +796,12 @@ updateGpMaintTargetForGroups(const Group& group,
// we only activate gpmaint if pressure is lower than the target regional pressure for injectors
// (i.e. error > 0) and higher for producers.
bool activate = (injection && error > 0) || (!injection && error < 0);
const Scalar rate = activate? gpm->rate(gpmaint_state, current_rate, error, dt) : 0.0;
Scalar rate = 0.0;
if (activate) {
rate = gpm->rate(gpmaint_state, current_rate, error, dt);
} else {
gpm->resetState(gpmaint_state);
}
group_state.update_gpmaint_target(group.name(), std::max(0.0, sign * rate));
}