Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions opm/input/eclipse/Schedule/Well/WellTestConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum class Reason {
GROUP = 4,
THP_DESIGN=8,
COMPLETION=16,
CONVERGENCE=32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is fine, but you need to be aware that we'll throw an exception, and not create any restart file output. if the well is closed due to CONVERGENCE at restart file writing time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not good. Can we return WTest::EclCloseReason::NONE for CONVERGENCE to avoid adding new reasons to the restart files? Otherwise, we may break restart compatibility. The force-shut option for non-convergent wells is a back-door solution when we cannot converge the well and properly shut it down due to operability. Currently, they are tagged as PHYSICAL. But since the purpose of these PRs is to allow for checking these wells regardless of WTEST I think setting them as NONE is more robust.

Copy link
Member

@GitPaean GitPaean Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever shut wells due to WellTestConfig::Reason::NONE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever shut wells due to WellTestConfig::Reason::NONE?

I don't think so, but you know the well testing module better than I. That said, it would be a little strange for a closed/stopped well in the restart file to have a NONE reason. Such a well, at restart time, would be treated as open as far as the well testing code is concerned.

Is that okay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. It is better to open this well than to potentially shut it forever (like we do now). It will break perfect restart, but I think that is better than breaking restart compatibility.

};

}
Expand Down
16 changes: 15 additions & 1 deletion opm/input/eclipse/Schedule/Well/WellTestState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ namespace Opm {
return iter->second.closed;
}

bool WellTestState::well_is_closed_due_to_convergence_issues(const std::string& well_name) const {
auto iter = this->wells.find(well_name);
if (iter == this->wells.end())
return false;

return iter->second.closed && iter->second.reason == WellTestConfig::Reason::CONVERGENCE;
}

void WellTestState::filter_wells(const std::vector<std::string>& existing_wells) {
std::unordered_set<std::string> well_set{ existing_wells.begin(), existing_wells.end() };
Expand All @@ -135,13 +142,20 @@ namespace Opm {

std::vector<std::string>
WellTestState::test_wells(const WellTestConfig& config,
double sim_time) {
double sim_time) {
std::vector<std::string> output;

for (auto& [wname, well] : this->wells) {
if (!well.closed)
continue;

// we always try to open well shut due to convergence issues
if (well.reason == WellTestConfig::Reason::CONVERGENCE)
output.push_back(well.name);

if (config.empty())
continue;

if (config.has(wname, well.reason)) {
const auto& well_config = config.get(wname);
const double elapsed = sim_time - well.last_test;
Expand Down
1 change: 1 addition & 0 deletions opm/input/eclipse/Schedule/Well/WellTestState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class WellTestState {
*/
void close_well(const std::string& well_name, WTest::Reason reason, double sim_time);
bool well_is_closed(const std::string& well_name) const;
bool well_is_closed_due_to_convergence_issues(const std::string& well_name) const;
void open_well(const std::string& well_name);
std::size_t num_closed_wells() const;
double lastTestTime(const std::string& well_name) const;
Expand Down