From cd734f7a0d1ba07e415b3440a4b2d1ab4324a0e2 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 19 Oct 2022 09:55:14 +0200 Subject: [PATCH] added: WellBhpThpCalculator this will hold the code for THP/BHP calculations. first method moved there is wellHasThpConstraints --- CMakeLists_files.cmake | 3 ++ opm/simulators/wells/WellBhpThpCalculator.cpp | 51 ++++++++++++++++++ opm/simulators/wells/WellBhpThpCalculator.hpp | 53 +++++++++++++++++++ opm/simulators/wells/WellInterfaceGeneric.cpp | 16 +----- 4 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 opm/simulators/wells/WellBhpThpCalculator.cpp create mode 100644 opm/simulators/wells/WellBhpThpCalculator.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index c7f2e1cab..151628c9f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -103,6 +103,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/wells/VFPHelpers.cpp opm/simulators/wells/VFPProdProperties.cpp opm/simulators/wells/VFPInjProperties.cpp + opm/simulators/wells/WellBhpThpCalculator.cpp opm/simulators/wells/WellConvergence.cpp opm/simulators/wells/WellGroupControls.cpp opm/simulators/wells/WellGroupHelpers.cpp @@ -384,12 +385,14 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/wells/VFPInjProperties.hpp opm/simulators/wells/VFPProdProperties.hpp opm/simulators/wells/VFPProperties.hpp + opm/simulators/wells/WellBhpThpCalculator.hpp opm/simulators/wells/WellConnectionAuxiliaryModule.hpp opm/simulators/wells/WellConvergence.hpp opm/simulators/wells/WellGroupControls.hpp opm/simulators/wells/WellGroupHelpers.hpp opm/simulators/wells/WellHelpers.hpp opm/simulators/wells/WellInterface.hpp + opm/simulators/wells/WellInterfaceGeneric.hpp opm/simulators/wells/WellInterface_impl.hpp opm/simulators/wells/WellProdIndexCalculator.hpp opm/simulators/wells/WellState.hpp diff --git a/opm/simulators/wells/WellBhpThpCalculator.cpp b/opm/simulators/wells/WellBhpThpCalculator.cpp new file mode 100644 index 000000000..835a4776d --- /dev/null +++ b/opm/simulators/wells/WellBhpThpCalculator.cpp @@ -0,0 +1,51 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + Copyright 2017 Statoil ASA. + Copyright 2018 IRIS + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +#include + +#include + +namespace Opm +{ + +bool +WellBhpThpCalculator::wellHasTHPConstraints(const SummaryState& summaryState) const +{ + const auto& well_ecl = well_.wellEcl(); + if (well_ecl.isInjector()) { + const auto controls = well_ecl.injectionControls(summaryState); + if (controls.hasControl(Well::InjectorCMode::THP)) + return true; + } + + if (well_ecl.isProducer()) { + const auto controls = well_ecl.productionControls(summaryState); + if (controls.hasControl(Well::ProducerCMode::THP)) + return true; + } + + return false; +} + +} // namespace Opm diff --git a/opm/simulators/wells/WellBhpThpCalculator.hpp b/opm/simulators/wells/WellBhpThpCalculator.hpp new file mode 100644 index 000000000..f4b3e3afc --- /dev/null +++ b/opm/simulators/wells/WellBhpThpCalculator.hpp @@ -0,0 +1,53 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + Copyright 2017 Statoil ASA. + Copyright 2017 IRIS + Copyright 2019 Norce + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + + +#ifndef OPM_WELL_BPH_THP_CALCULATOR_HEADER_INCLUDED +#define OPM_WELL_BPH_THP_CALCULATOR_HEADER_INCLUDED + +#include +#include +#include +#include + +namespace Opm +{ + +class SummaryState; +class WellInterfaceGeneric; + +//! \brief Class for computing BHP limits. +class WellBhpThpCalculator { +public: + //! \brief Constructor sets reference to well. + WellBhpThpCalculator(const WellInterfaceGeneric& well) : well_(well) {} + + //! \brief Checks if well has THP constraints. + bool wellHasTHPConstraints(const SummaryState& summaryState) const; + +private: + const WellInterfaceGeneric& well_; //!< Reference to well interface +}; + +} + +#endif // OPM_WELL_BHP_THP_CALCULATOR_HEADER_INCLUDED diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index a297cd116..e871235b5 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -185,20 +186,7 @@ bool WellInterfaceGeneric::wellHasTHPConstraints(const SummaryState& summaryStat return true; } - if (well_ecl_.isInjector()) { - const auto controls = well_ecl_.injectionControls(summaryState); - if (controls.hasControl(Well::InjectorCMode::THP)) - return true; - } - - if (well_ecl_.isProducer( )) { - const auto controls = well_ecl_.productionControls(summaryState); - if (controls.hasControl(Well::ProducerCMode::THP)) - return true; - } - - return false; - + return WellBhpThpCalculator(*this).wellHasTHPConstraints(summaryState); } double WellInterfaceGeneric::mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const