changed: move mostStrictBhpFromBhpLimits to WellBhpThpCalculator

This commit is contained in:
Arne Morten Kvarving 2022-10-19 09:55:14 +02:00
parent d4e06536a0
commit f7f4352b68
6 changed files with 26 additions and 22 deletions

View File

@ -20,6 +20,7 @@
#include <opm/simulators/wells/MSWellHelpers.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
@ -1236,7 +1237,7 @@ namespace Opm
checkOperabilityUnderBHPLimit(const WellState& /*well_state*/, const Simulator& ebos_simulator, DeferredLogger& deferred_logger)
{
const auto& summaryState = ebos_simulator.vanguard().summaryState();
const double bhp_limit = Base::mostStrictBhpFromBhpLimits(summaryState);
const double bhp_limit = WellBhpThpCalculator(*this).mostStrictBhpFromBhpLimits(summaryState);
// Crude but works: default is one atmosphere.
// TODO: a better way to detect whether the BHP is defaulted or not
const bool bhp_limit_not_defaulted = bhp_limit > 1.5 * unit::barsa;
@ -1407,7 +1408,7 @@ namespace Opm
if (obtain_bhp) {
this->operability_status_.can_obtain_bhp_with_thp_limit = true;
const double bhp_limit = Base::mostStrictBhpFromBhpLimits(summaryState);
const double bhp_limit = WellBhpThpCalculator(*this).mostStrictBhpFromBhpLimits(summaryState);
this->operability_status_.obey_bhp_limit_with_thp_limit = (*obtain_bhp >= bhp_limit);
const double thp_limit = this->getTHPConstraint(summaryState);

View File

@ -23,6 +23,7 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/linalg/SmallDenseMatrixUtils.hpp>
#include <opm/simulators/wells/VFPHelpers.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
#include <opm/simulators/wells/WellConvergence.hpp>
#include <algorithm>
@ -1102,7 +1103,7 @@ namespace Opm
checkOperabilityUnderBHPLimit(const WellState& well_state, const Simulator& ebos_simulator, DeferredLogger& deferred_logger)
{
const auto& summaryState = ebos_simulator.vanguard().summaryState();
const double bhp_limit = this->mostStrictBhpFromBhpLimits(summaryState);
const double bhp_limit = WellBhpThpCalculator(*this).mostStrictBhpFromBhpLimits(summaryState);
// Crude but works: default is one atmosphere.
// TODO: a better way to detect whether the BHP is defaulted or not
const bool bhp_limit_not_defaulted = bhp_limit > 1.5 * unit::barsa;
@ -1170,7 +1171,7 @@ namespace Opm
if (obtain_bhp) {
this->operability_status_.can_obtain_bhp_with_thp_limit = true;
const double bhp_limit = this->mostStrictBhpFromBhpLimits(summaryState);
const double bhp_limit = WellBhpThpCalculator(*this).mostStrictBhpFromBhpLimits(summaryState);
this->operability_status_.obey_bhp_limit_with_thp_limit = (*obtain_bhp >= bhp_limit);
const double thp_limit = this->getTHPConstraint(summaryState);
@ -2017,7 +2018,7 @@ namespace Opm
const auto& summaryState = ebosSimulator.vanguard().summaryState();
if (!Base::wellHasTHPConstraints(summaryState) || bhp_controlled_well) {
// get the bhp value based on the bhp constraints
double bhp = this->mostStrictBhpFromBhpLimits(summaryState);
double bhp = WellBhpThpCalculator(*this).mostStrictBhpFromBhpLimits(summaryState);
// In some very special cases the bhp pressure target are
// temporary violated. This may lead to too small or negative potentials

View File

@ -64,4 +64,20 @@ double WellBhpThpCalculator::getTHPConstraint(const SummaryState& summaryState)
return 0.0;
}
double WellBhpThpCalculator::mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const
{
const auto& well_ecl = well_.wellEcl();
if (well_ecl.isInjector()) {
const auto& controls = well_ecl.injectionControls(summaryState);
return controls.bhp_limit;
}
if (well_ecl.isProducer( )) {
const auto& controls = well_ecl.productionControls(summaryState);
return controls.bhp_limit;
}
return 0.0;
}
} // namespace Opm

View File

@ -47,6 +47,9 @@ public:
//! \brief Get THP constraint for well.
double getTHPConstraint(const SummaryState& summaryState) const;
//! \brief Obtain the most strict BHP from BHP limits.
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
private:
const WellInterfaceGeneric& well_; //!< Reference to well interface
};

View File

@ -189,21 +189,6 @@ bool WellInterfaceGeneric::wellHasTHPConstraints(const SummaryState& summaryStat
return WellBhpThpCalculator(*this).wellHasTHPConstraints(summaryState);
}
double WellInterfaceGeneric::mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const
{
if (well_ecl_.isInjector()) {
const auto& controls = well_ecl_.injectionControls(summaryState);
return controls.bhp_limit;
}
if (well_ecl_.isProducer( )) {
const auto& controls = well_ecl_.productionControls(summaryState);
return controls.bhp_limit;
}
return 0.0;
}
void WellInterfaceGeneric::updateWellTestState(const SingleWellState& ws,
const double& simulationTime,
const bool& writeMessageToOPMLog,
@ -221,7 +206,6 @@ void WellInterfaceGeneric::updateWellTestState(const SingleWellState& ws,
// TODO: well can be shut/closed due to other reasons
}
double WellInterfaceGeneric::getTHPConstraint(const SummaryState& summaryState) const
{
if (dynamic_thp_limit_) {

View File

@ -205,7 +205,6 @@ public:
protected:
bool getAllowCrossFlow() const;
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
std::optional<double> bhpMax(const std::function<double(const double)>& fflo,
const double bhp_limit,