not considering wells with wrong flow direction as converged

under THP constraint, well can get converged with wrong flow direction
(e.g. a producer is injecting), becasue we cut off the wrong flow
direction as zero rate in the VFP evaluation
This commit is contained in:
Kai Bao 2023-02-23 15:24:50 +01:00
parent 1b92971e8b
commit 460aa5027b
3 changed files with 27 additions and 1 deletions

View File

@ -81,7 +81,7 @@ namespace Opm
class WellFailure
{
public:
enum struct Type { Invalid, MassBalance, Pressure, ControlBHP, ControlTHP, ControlRate, Unsolvable };
enum struct Type { Invalid, MassBalance, Pressure, ControlBHP, ControlTHP, ControlRate, Unsolvable, WrongFlowDirection };
WellFailure(Type t, Severity s, int phase, const std::string& well_name)
: type_(t), severity_(s), phase_(phase), well_name_(well_name)
{

View File

@ -164,6 +164,19 @@ getWellConvergence(const WellState& well_state,
report,
deferred_logger);
// for stopped well, we do not enforce the following checking to avoid dealing with sign of near-zero values
// for BHP or THP controlled wells, we need to make sure the flow direction is correct
if (!baseif_.wellIsStopped() && baseif_.isPressureControlled(well_state)) {
// checking the flow direction
const double sign = baseif_.isProducer() ? -1. : 1.;
const auto weight_total_flux = this->primary_variables_.getWQTotal() * sign;
constexpr int dummy_phase = -1;
if (weight_total_flux < 0.) {
report.setWellFailed(
{CR::WellFailure::Type::WrongFlowDirection, CR::Severity::Normal, dummy_phase, baseif_.name()});
}
}
return report;
}

View File

@ -151,6 +151,19 @@ getWellConvergence(const WellState& well_state,
report,
deferred_logger);
// for stopped well, we do not enforce the following checking to avoid dealing with sign of near-zero values
// for BHP or THP controlled wells, we need to make sure the flow direction is correct
if (!baseif_.wellIsStopped() && baseif_.isPressureControlled(well_state)) {
// checking the flow direction
const double sign = baseif_.isProducer() ? -1. : 1.;
const auto weight_total_flux = this->primary_variables_.value(PrimaryVariables::WQTotal) * sign;
constexpr int dummy_phase = -1;
if (weight_total_flux < 0.) {
report.setWellFailed(
{CR::WellFailure::Type::WrongFlowDirection, CR::Severity::Normal, dummy_phase, baseif_.name()});
}
}
return report;
}