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

View File

@@ -116,6 +116,10 @@ public:
GroupState& groupState() { return this->active_wgstate_.group_state; } 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 int well_index) const;
double wellPI(const std::string& well_name) const; double wellPI(const std::string& well_name) const;
@@ -405,7 +409,6 @@ protected:
mutable std::unordered_set<std::string> closed_this_step_; mutable std::unordered_set<std::string> closed_this_step_;
WellTestState wellTestState_{};
GuideRate guideRate_; GuideRate guideRate_;
std::unique_ptr<VFPProperties> vfp_properties_{}; std::unique_ptr<VFPProperties> vfp_properties_{};
std::map<std::string, double> node_pressures_; // Storing network pressures for output. 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 // Close completions due to economical reasons
for (auto& well : well_container_) { for (auto& well : well_container_) {
well->closeCompletions(wellTestState_); well->closeCompletions(wellTestState());
} }
// calculate the well potentials // calculate the well potentials
@@ -412,7 +412,7 @@ namespace Opm {
{ {
const auto& wtest_config = schedule()[timeStepIdx].wtest_config(); const auto& wtest_config = schedule()[timeStepIdx].wtest_config();
if (wtest_config.size() != 0) { // there is a WTEST request if (wtest_config.size() != 0) { // there is a WTEST request
const auto wellsForTesting = wellTestState_ const auto wellsForTesting = wellTestState()
.updateWells(wtest_config, wells_ecl_, simulationTime); .updateWells(wtest_config, wells_ecl_, simulationTime);
for (const auto& testWell : wellsForTesting) { for (const auto& testWell : wellsForTesting) {
@@ -435,7 +435,7 @@ namespace Opm {
const WellTestConfig::Reason testing_reason = testWell.second; const WellTestConfig::Reason testing_reason = testWell.second;
well->wellTesting(ebosSimulator_, simulationTime, timeStepIdx, 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); local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg);
} }
updateWellTestState(simulationTime, wellTestState_); updateWellTestState(simulationTime, wellTestState());
// check group sales limits at the end of the timestep // check group sales limits at the end of the timestep
checkGconsaleLimits(fieldGroup, this->wellState(), 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 // 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 // TODO: more checking here, to make sure this standard more specific and complete
// maybe there is some WCON keywords will not open the well // maybe there is some WCON keywords will not open the well
auto& events = this->wellState().well(w).events; auto& events = this->wellState().well(w).events;
if (events.hasEvent(WellState::event_mask)) { 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 // The well was shut this timestep, we are most likely retrying
// a timestep without the well in question, after it caused // a timestep without the well in question, after it caused
// repeated timestep cuts. It should therefore not be opened, // repeated timestep cuts. It should therefore not be opened,
// even if it was new or received new targets this report step. // even if it was new or received new targets this report step.
events.clearEvent(WellState::event_mask); events.clearEvent(WellState::event_mask);
} else { } else {
wellTestState_.openWell(well_name); wellTestState().openWell(well_name);
} }
} }
} }
// TODO: should we do this for all kinds of closing reasons? // 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; bool wellIsStopped = false;
if (wellTestState_.hasWellClosed(well_name, WellTestConfig::Reason::ECONOMIC) || if (wellTestState().hasWellClosed(well_name, WellTestConfig::Reason::ECONOMIC) ||
wellTestState_.hasWellClosed(well_name, WellTestConfig::Reason::PHYSICAL)) wellTestState().hasWellClosed(well_name, WellTestConfig::Reason::PHYSICAL))
{ {
if (well_ecl.getAutomaticShutIn()) { if (well_ecl.getAutomaticShutIn()) {
// shut wells are not added to the well container // shut wells are not added to the well container

View File

@@ -24,7 +24,8 @@ namespace Opm {
WGState::WGState(const PhaseUsage& pu) : WGState::WGState(const PhaseUsage& pu) :
well_state(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/WellState.hpp>
#include <opm/simulators/wells/GroupState.hpp> #include <opm/simulators/wells/GroupState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
namespace Opm { 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; struct PhaseUsage;
@@ -36,6 +37,8 @@ struct WGState {
WellState well_state; WellState well_state;
GroupState group_state; GroupState group_state;
WellTestState well_test_state;
}; };
} }