we should not request alq_value for injectors

through the function { return well_.wellEcl().alq_value(); }.

It will throw a runtime_error which is not properly caught.
This commit is contained in:
Kai Bao 2023-05-11 14:01:22 +02:00
parent ca0c650110
commit 49a327f372
3 changed files with 10 additions and 4 deletions

View File

@ -393,6 +393,8 @@ copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
[maxVel](const auto hf) { return (hf > 0.0) ? maxVel : 0.0; });
}
// Note: for the ALQ value, in the StandardWell, WellInterfaceGeneric::getALQ(well_state) is used.
// We might want to unify the way regarding AQL value.
WellBhpThpCalculator(well_)
.updateThp(rho, stop_or_zero_rate_target, [this]() { return well_.wellEcl().alq_value(); },
{FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx),

View File

@ -41,6 +41,7 @@
#include <cassert>
#include <cmath>
#include <optional>
static constexpr bool extraBhpAtThpLimitOutput = false;
@ -101,7 +102,7 @@ double WellBhpThpCalculator::mostStrictBhpFromBhpLimits(const SummaryState& summ
double WellBhpThpCalculator::calculateThpFromBhp(const std::vector<double>& rates,
const double bhp,
const double rho,
const double alq,
const std::optional<double>& alq,
DeferredLogger& deferred_logger) const
{
assert(int(rates.size()) == 3); // the vfp related only supports three phases now.
@ -117,6 +118,7 @@ double WellBhpThpCalculator::calculateThpFromBhp(const std::vector<double>& rate
// pick the density in the top layer
double thp = 0.0;
if (well_.isInjector()) {
assert(!alq.has_value());
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());
@ -128,7 +130,8 @@ double WellBhpThpCalculator::calculateThpFromBhp(const std::vector<double>& rate
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);
assert(alq.has_value());
thp = well_.vfpProperties()->getProd()->thp(table_id, aqua, liquid, vapour, bhp + dp, alq.value());
}
else {
OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER well", deferred_logger);
@ -261,7 +264,8 @@ void WellBhpThpCalculator::updateThp(const double rho,
rates[ Gas ] = ws.surface_rates[pu.phase_pos[ Gas ] ];
}
ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, alq_value(), deferred_logger);
const std::optional<double> alq = this->well_.isProducer() ? std::optional<double>(alq_value()) : std::nullopt;
ws.thp = this->calculateThpFromBhp(rates, ws.bhp, rho, alq, deferred_logger);
}
template<class EvalWell>

View File

@ -57,7 +57,7 @@ public:
double calculateThpFromBhp(const std::vector<double>& rates,
const double bhp,
const double rho,
const double alq,
const std::optional<double>& alq,
DeferredLogger& deferred_logger) const;
//! \brief Compute BHP from THP limit for a producer.