diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index e2b59e4cf..f2ed3975d 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -334,6 +334,9 @@ namespace Opm double scalingFactor(const int comp_idx) const; + // whether a well is specified with a non-zero and valid VFP table number + bool isVFPActive() const; + 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); diff --git a/opm/autodiff/WellInterface_impl.hpp b/opm/autodiff/WellInterface_impl.hpp index 22588c3fa..98958ea0a 100644 --- a/opm/autodiff/WellInterface_impl.hpp +++ b/opm/autodiff/WellInterface_impl.hpp @@ -979,6 +979,50 @@ namespace Opm + + template + bool + WellInterface::isVFPActive() const + { + // since the well_controls only handles the VFP number when THP constraint/target is there. + // we need to get the table number through the parser, in case THP constraint/target is not there. + // When THP control/limit is not active, if available VFP table is provided, we will still need to + // update THP value. However, it will only used for output purpose. + + if (well_type_ == PRODUCER) { // producer + const int table_id = well_ecl_->getProductionProperties(current_step_).VFPTableNumber; + if (table_id <= 0) { + return false; + } else { + if (vfp_properties_->getProd()->getTable(table_id)) { + return true; + } else { + OPM_THROW(std::runtime_error, "VFPPROD table " << std::to_string(table_id) << " is specfied," + << " for well " << name() << ", while we could not access it during simulation"); + return false; + } + } + + } else { // injector + const int table_id = well_ecl_->getInjectionProperties(current_step_).VFPTableNumber; + if (table_id <= 0) { + return false; + } else { + if (vfp_properties_->getInj()->getTable(table_id)) { + return true; + } else { + OPM_THROW(std::runtime_error, "VFPINJ table " << std::to_string(table_id) << " is specfied," + << " for well " << name() << ", while we could not access it during simulation"); + return false; + } + } + } + } + + + + + template void WellInterface::calculateReservoirRates(WellState& well_state) const