diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index c084e9ab0..a47aab56a 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -350,6 +350,10 @@ namespace Opm // whether a well is specified with a non-zero and valid VFP table number bool isVFPActive() const; + struct OperabilityStatus; + + OperabilityStatus operability_status_; + void wellTestingEconomic(Simulator& simulator, const std::vector& B_avg, const double simulation_time, const int report_step, const bool terminal_output, const WellState& well_state, WellTestState& welltest_state); @@ -366,6 +370,65 @@ namespace Opm }; + + + + // definition of the struct OperabilityStatus + template + struct + WellInterface:: + OperabilityStatus { + bool isOperable() const { + if (!operable_under_only_bhp_limit) { + return false; + } else { + return !negative_well_rates && (isOperableUnderBHPLimit() || isOperableUnderTHPLimit()); + } + } + + bool isOperableUnderBHPLimit() const { + return operable_under_only_bhp_limit && !violate_thp_limit_under_bhp_limit; + } + + bool isOperableUnderTHPLimit() const { + return obtain_solution_with_thp_limit && !violate_bhp_limit_with_thp_limit; + } + + void reset() { + operable_under_only_bhp_limit = true; + violate_thp_limit_under_bhp_limit = false; + obtain_solution_with_thp_limit = true; + violate_bhp_limit_with_thp_limit = false; + // TODO: the following one might need to be different + negative_well_rates = false; + } + + // TODO: re-design the boolean variables so that they have meaning in the same directions. + // For example, true are all for positive situation, and false are all for negative circumstances. + + // whether the well can be operated under bhp limit + // without considering other limits. + // if it is false, then the well is not operable for sure. + bool operable_under_only_bhp_limit = true; + // if the well can be operated under bhp limit, will it violate + // the thp limit when operated under bhp limit + bool violate_thp_limit_under_bhp_limit = false; + // whether the well operate under the thp limit only + bool obtain_solution_with_thp_limit = true; + // whether the well violate bhp limit when operated under thp limit + bool violate_bhp_limit_with_thp_limit = false; + + // we get negatvie well rates + // currently, we are trying to address the one result from updateWellStateWithTHPTargetIPR + bool negative_well_rates = false; + + // could not get converged, maybe at the end of the time step, after chopping for some steps. + // TODO: the best way is that this well can not get converged during local iterations. + bool could_not_get_converged = false; + }; + +} + } #include "WellInterface_impl.hpp"