mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: move calculateThpFromBhp to WellBhpThpCalculator
This commit is contained in:
parent
f7f4352b68
commit
4fcb1e9d37
@ -33,6 +33,7 @@
|
||||
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
#include <opm/simulators/wells/MSWellHelpers.hpp>
|
||||
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
|
||||
#include <opm/simulators/wells/WellConvergence.hpp>
|
||||
#include <opm/simulators/wells/WellInterfaceIndices.hpp>
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
@ -1306,7 +1307,11 @@ updateThp(WellState& well_state,
|
||||
rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ];
|
||||
}
|
||||
|
||||
ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, deferred_logger);
|
||||
ws.thp = WellBhpThpCalculator(baseif_).calculateThpFromBhp(rates,
|
||||
ws.bhp,
|
||||
rho,
|
||||
baseif_.wellEcl().alq_value(),
|
||||
deferred_logger);
|
||||
}
|
||||
|
||||
template<typename FluidSystem, typename Indices, typename Scalar>
|
||||
|
@ -178,47 +178,6 @@ segmentNumberToIndex(const int segment_number) const
|
||||
return segmentSet().segmentNumberToIndex(segment_number);
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
double
|
||||
MultisegmentWellGeneric<Scalar>::
|
||||
calculateThpFromBhp(const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
const double rho,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
assert(int(rates.size()) == 3); // the vfp related only supports three phases now.
|
||||
|
||||
static constexpr int Water = BlackoilPhases::Aqua;
|
||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||
|
||||
const double aqua = rates[Water];
|
||||
const double liquid = rates[Oil];
|
||||
const double vapour = rates[Gas];
|
||||
|
||||
double thp = 0.0;
|
||||
if (baseif_.isInjector()) {
|
||||
const int table_id = baseif_.wellEcl().vfp_table_number();
|
||||
const double vfp_ref_depth = baseif_.vfpProperties()->getInj()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, rho, baseif_.gravity());
|
||||
|
||||
thp = baseif_.vfpProperties()->getInj()->thp(table_id, aqua, liquid, vapour, bhp + dp);
|
||||
}
|
||||
else if (baseif_.isProducer()) {
|
||||
const int table_id = baseif_.wellEcl().vfp_table_number();
|
||||
const double alq = baseif_.wellEcl().alq_value();
|
||||
const double vfp_ref_depth = baseif_.vfpProperties()->getProd()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, rho, baseif_.gravity());
|
||||
|
||||
thp = baseif_.vfpProperties()->getProd()->thp(table_id, aqua, liquid, vapour, bhp + dp, alq);
|
||||
}
|
||||
else {
|
||||
OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER well", deferred_logger);
|
||||
}
|
||||
|
||||
return thp;
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
void
|
||||
MultisegmentWellGeneric<Scalar>::
|
||||
|
@ -60,11 +60,6 @@ protected:
|
||||
/// number of segments for this well
|
||||
int numberOfSegments() const;
|
||||
|
||||
double calculateThpFromBhp(const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
const double rho,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
std::optional<double> computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>& frates,
|
||||
const SummaryState& summary_state,
|
||||
const double rho,
|
||||
|
@ -1269,7 +1269,11 @@ namespace Opm
|
||||
std::vector<double> well_rates_bhp_limit;
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp_limit, well_rates_bhp_limit, deferred_logger);
|
||||
|
||||
const double thp = this->calculateThpFromBhp(well_rates_bhp_limit, bhp_limit, getRefDensity(), deferred_logger);
|
||||
const double thp = WellBhpThpCalculator(*this).calculateThpFromBhp(well_rates_bhp_limit,
|
||||
bhp_limit,
|
||||
this->getRefDensity(),
|
||||
this->wellEcl().alq_value(),
|
||||
deferred_logger);
|
||||
const double thp_limit = this->getTHPConstraint(summaryState);
|
||||
if ( (this->isProducer() && thp < thp_limit) || (this->isInjector() && thp > thp_limit) ) {
|
||||
this->operability_status_.obey_thp_limit_under_bhp_limit = false;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
#include <opm/simulators/wells/ParallelWellInfo.hpp>
|
||||
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
|
||||
#include <opm/simulators/wells/WellConvergence.hpp>
|
||||
#include <opm/simulators/wells/WellInterfaceIndices.hpp>
|
||||
#include <opm/simulators/wells/WellState.hpp>
|
||||
@ -595,10 +596,11 @@ updateThp(WellState& well_state,
|
||||
rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ];
|
||||
}
|
||||
|
||||
ws.thp = this->calculateThpFromBhp(well_state,
|
||||
rates,
|
||||
ws.bhp,
|
||||
deferred_logger);
|
||||
ws.thp = WellBhpThpCalculator(this->baseif_).calculateThpFromBhp(rates,
|
||||
ws.bhp,
|
||||
this->getRho(),
|
||||
this->baseif_.getALQ(well_state),
|
||||
deferred_logger);
|
||||
}
|
||||
|
||||
template<class FluidSystem, class Indices, class Scalar>
|
||||
|
@ -112,48 +112,6 @@ relaxationFactorFraction(const double old_value,
|
||||
return relaxation_factor;
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
double
|
||||
StandardWellGeneric<Scalar>::
|
||||
calculateThpFromBhp(const WellState &well_state,
|
||||
const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
assert(int(rates.size()) == 3); // the vfp related only supports three phases now.
|
||||
|
||||
static constexpr int Water = BlackoilPhases::Aqua;
|
||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||
|
||||
const double aqua = rates[Water];
|
||||
const double liquid = rates[Oil];
|
||||
const double vapour = rates[Gas];
|
||||
|
||||
// pick the density in the top layer
|
||||
double thp = 0.0;
|
||||
if (baseif_.isInjector()) {
|
||||
const int table_id = baseif_.wellEcl().vfp_table_number();
|
||||
const double vfp_ref_depth = baseif_.vfpProperties()->getInj()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, getRho(), baseif_.gravity());
|
||||
|
||||
thp = baseif_.vfpProperties()->getInj()->thp(table_id, aqua, liquid, vapour, bhp + dp);
|
||||
}
|
||||
else if (baseif_.isProducer()) {
|
||||
const int table_id = baseif_.wellEcl().vfp_table_number();
|
||||
const double alq = baseif_.getALQ(well_state);
|
||||
const double vfp_ref_depth = baseif_.vfpProperties()->getProd()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, getRho(), baseif_.gravity());
|
||||
|
||||
thp = baseif_.vfpProperties()->getProd()->thp(table_id, aqua, liquid, vapour, bhp + dp, alq);
|
||||
}
|
||||
else {
|
||||
OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER well", deferred_logger);
|
||||
}
|
||||
|
||||
return thp;
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
void
|
||||
StandardWellGeneric<Scalar>::
|
||||
|
@ -79,11 +79,6 @@ protected:
|
||||
static double relaxationFactorFraction(const double old_value,
|
||||
const double dx);
|
||||
|
||||
double calculateThpFromBhp(const WellState& well_state,
|
||||
const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void computeConnectionPressureDelta();
|
||||
|
||||
std::optional<double> computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>& frates,
|
||||
|
@ -1136,7 +1136,11 @@ namespace Opm
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp_limit, well_rates_bhp_limit, deferred_logger);
|
||||
|
||||
this->adaptRatesForVFP(well_rates_bhp_limit);
|
||||
const double thp = this->calculateThpFromBhp(well_state, well_rates_bhp_limit, bhp_limit, deferred_logger);
|
||||
const double thp = WellBhpThpCalculator(*this).calculateThpFromBhp(well_rates_bhp_limit,
|
||||
bhp_limit,
|
||||
this->getRho(),
|
||||
this->getALQ(well_state),
|
||||
deferred_logger);
|
||||
const double thp_limit = this->getTHPConstraint(summaryState);
|
||||
if ( (this->isProducer() && thp < thp_limit) || (this->isInjector() && thp > thp_limit) ) {
|
||||
this->operability_status_.obey_thp_limit_under_bhp_limit = false;
|
||||
|
@ -22,10 +22,19 @@
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
|
||||
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/VFPInjTable.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
|
||||
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
|
||||
#include <opm/simulators/wells/VFPProperties.hpp>
|
||||
#include <opm/simulators/wells/WellHelpers.hpp>
|
||||
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
@ -80,4 +89,43 @@ double WellBhpThpCalculator::mostStrictBhpFromBhpLimits(const SummaryState& summ
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double WellBhpThpCalculator::calculateThpFromBhp(const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
const double rho,
|
||||
const double alq,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
assert(int(rates.size()) == 3); // the vfp related only supports three phases now.
|
||||
|
||||
static constexpr int Water = BlackoilPhases::Aqua;
|
||||
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||
|
||||
const double aqua = rates[Water];
|
||||
const double liquid = rates[Oil];
|
||||
const double vapour = rates[Gas];
|
||||
|
||||
// pick the density in the top layer
|
||||
double thp = 0.0;
|
||||
if (well_.isInjector()) {
|
||||
const int table_id = well_.wellEcl().vfp_table_number();
|
||||
const double vfp_ref_depth = well_.vfpProperties()->getInj()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(well_.refDepth(), vfp_ref_depth, rho, well_.gravity());
|
||||
|
||||
thp = well_.vfpProperties()->getInj()->thp(table_id, aqua, liquid, vapour, bhp + dp);
|
||||
}
|
||||
else if (well_.isProducer()) {
|
||||
const int table_id = well_.wellEcl().vfp_table_number();
|
||||
const double vfp_ref_depth = well_.vfpProperties()->getProd()->getTable(table_id).getDatumDepth();
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(well_.refDepth(), vfp_ref_depth, rho, well_.gravity());
|
||||
|
||||
thp = well_.vfpProperties()->getProd()->thp(table_id, aqua, liquid, vapour, bhp + dp, alq);
|
||||
}
|
||||
else {
|
||||
OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER well", deferred_logger);
|
||||
}
|
||||
|
||||
return thp;
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -32,6 +32,7 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class DeferredLogger;
|
||||
class SummaryState;
|
||||
class WellInterfaceGeneric;
|
||||
|
||||
@ -50,6 +51,13 @@ public:
|
||||
//! \brief Obtain the most strict BHP from BHP limits.
|
||||
double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
|
||||
|
||||
//! \brief Calculates THP from BHP.
|
||||
double calculateThpFromBhp(const std::vector<double>& rates,
|
||||
const double bhp,
|
||||
const double rho,
|
||||
const double alq,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
private:
|
||||
const WellInterfaceGeneric& well_; //!< Reference to well interface
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user