add well_test_state to WGState to be able to access last valid wellTestState

This commit is contained in:
Tor Harald Sandve 2021-09-21 09:30:02 +02:00
parent 7b833b7706
commit 6fa9c05985
5 changed files with 22 additions and 15 deletions

View File

@ -1312,7 +1312,7 @@ assignShutConnections(data::Wells& wsrpt,
return wellIsOpen && (conn.state() != Connection::State::SHUT);
};
if (this->wellTestState_.hasWellClosed(well.name()) &&
if (this->wellTestState().hasWellClosed(well.name()) &&
!this->wasDynamicallyShutThisTimeStep(wellID))
{
xwel.dynamicStatus = well.getAutomaticShutIn()
@ -1581,7 +1581,7 @@ forceShutWellByNameIfPredictionMode(const std::string& wellname,
for (const auto& well : well_container_generic_) {
if (well->name() == wellname && !well->wellIsStopped()) {
if (well->underPredictionMode()) {
wellTestState_.closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time);
wellTestState().closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time);
well_was_shut = 1;
}
break;

View File

@ -116,6 +116,10 @@ public:
GroupState& groupState() { return this->active_wgstate_.group_state; }
WellTestState& wellTestState() { return this->active_wgstate_.well_test_state; }
const WellTestState& wellTestState() const { return this->active_wgstate_.well_test_state; }
double wellPI(const int well_index) const;
double wellPI(const std::string& well_name) const;
@ -405,7 +409,6 @@ protected:
mutable std::unordered_set<std::string> closed_this_step_;
WellTestState wellTestState_{};
GuideRate guideRate_;
std::unique_ptr<VFPProperties> vfp_properties_{};
std::map<std::string, double> node_pressures_; // Storing network pressures for output.

View File

@ -326,7 +326,7 @@ namespace Opm {
// Close completions due to economical reasons
for (auto& well : well_container_) {
well->closeCompletions(wellTestState_);
well->closeCompletions(wellTestState());
}
// calculate the well potentials
@ -412,7 +412,7 @@ namespace Opm {
{
const auto& wtest_config = schedule()[timeStepIdx].wtest_config();
if (wtest_config.size() != 0) { // there is a WTEST request
const auto wellsForTesting = wellTestState_
const auto wellsForTesting = wellTestState()
.updateWells(wtest_config, wells_ecl_, simulationTime);
for (const auto& testWell : wellsForTesting) {
@ -435,7 +435,7 @@ namespace Opm {
const WellTestConfig::Reason testing_reason = testWell.second;
well->wellTesting(ebosSimulator_, simulationTime, timeStepIdx,
testing_reason, this->wellState(), this->groupState(), wellTestState_, deferred_logger);
testing_reason, this->wellState(), this->groupState(), wellTestState(), deferred_logger);
}
}
}
@ -511,7 +511,7 @@ namespace Opm {
local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg);
}
updateWellTestState(simulationTime, wellTestState_);
updateWellTestState(simulationTime, wellTestState());
// check group sales limits at the end of the timestep
checkGconsaleLimits(fieldGroup, this->wellState(),
@ -634,28 +634,28 @@ namespace Opm {
}
// A new WCON keywords can re-open a well that was closed/shut due to Physical limit
if (this->wellTestState_.hasWellClosed(well_name)) {
if (this->wellTestState().hasWellClosed(well_name)) {
// TODO: more checking here, to make sure this standard more specific and complete
// maybe there is some WCON keywords will not open the well
auto& events = this->wellState().well(w).events;
if (events.hasEvent(WellState::event_mask)) {
if (wellTestState_.lastTestTime(well_name) == ebosSimulator_.time()) {
if (wellTestState().lastTestTime(well_name) == ebosSimulator_.time()) {
// The well was shut this timestep, we are most likely retrying
// a timestep without the well in question, after it caused
// repeated timestep cuts. It should therefore not be opened,
// even if it was new or received new targets this report step.
events.clearEvent(WellState::event_mask);
} else {
wellTestState_.openWell(well_name);
wellTestState().openWell(well_name);
}
}
}
// TODO: should we do this for all kinds of closing reasons?
// something like wellTestState_.hasWell(well_name)?
// something like wellTestState().hasWell(well_name)?
bool wellIsStopped = false;
if (wellTestState_.hasWellClosed(well_name, WellTestConfig::Reason::ECONOMIC) ||
wellTestState_.hasWellClosed(well_name, WellTestConfig::Reason::PHYSICAL))
if (wellTestState().hasWellClosed(well_name, WellTestConfig::Reason::ECONOMIC) ||
wellTestState().hasWellClosed(well_name, WellTestConfig::Reason::PHYSICAL))
{
if (well_ecl.getAutomaticShutIn()) {
// shut wells are not added to the well container

View File

@ -24,7 +24,8 @@ namespace Opm {
WGState::WGState(const PhaseUsage& pu) :
well_state(pu),
group_state(pu.num_phases)
group_state(pu.num_phases),
well_test_state{}
{}
}

View File

@ -22,11 +22,12 @@
#include <opm/simulators/wells/WellState.hpp>
#include <opm/simulators/wells/GroupState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
namespace Opm {
/*
Microscopic class to handle a pair of well and group state.
Microscopic class to handle well , group and well test state.
*/
struct PhaseUsage;
@ -36,6 +37,8 @@ struct WGState {
WellState well_state;
GroupState group_state;
WellTestState well_test_state;
};
}