Merge pull request #4500 from GitPaean/unifying_interface_assemble_noiteration

make sure computeWellRatesWithBhpIterations honor bhp limit (can change) for StandardWell
This commit is contained in:
Atgeirr Flø Rasmussen 2023-03-07 21:02:44 +01:00 committed by GitHub
commit fc06fc77c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 18 deletions

View File

@ -374,6 +374,8 @@ namespace Opm
void assembleWellEqWithoutIterationImpl(const Simulator& ebosSimulator, void assembleWellEqWithoutIterationImpl(const Simulator& ebosSimulator,
const double dt, const double dt,
const Well::InjectionControls& inj_controls,
const Well::ProductionControls& prod_controls,
WellState& well_state, WellState& well_state,
const GroupState& group_state, const GroupState& group_state,
DeferredLogger& deferred_logger); DeferredLogger& deferred_logger);

View File

@ -87,6 +87,8 @@ assembleControlEq(const WellState& well_state,
const GroupState& group_state, const GroupState& group_state,
const Schedule& schedule, const Schedule& schedule,
const SummaryState& summaryState, const SummaryState& summaryState,
const Well::InjectionControls& inj_controls,
const Well::ProductionControls& prod_controls,
const PrimaryVariables& primary_variables, const PrimaryVariables& primary_variables,
const double rho, const double rho,
StandardWellEquations<Scalar,Indices::numEq>& eqns1, StandardWellEquations<Scalar,Indices::numEq>& eqns1,
@ -129,8 +131,6 @@ assembleControlEq(const WellState& well_state,
deferred_logger); deferred_logger);
}; };
// Call generic implementation.
const auto& inj_controls = well.injectionControls(summaryState);
WellAssemble(well_). WellAssemble(well_).
assembleControlEqInj(well_state, assembleControlEqInj(well_state,
group_state, group_state,
@ -154,8 +154,6 @@ assembleControlEq(const WellState& well_state,
rho, rho,
deferred_logger); deferred_logger);
}; };
// Call generic implementation.
const auto& prod_controls = well.productionControls(summaryState);
WellAssemble(well_). WellAssemble(well_).
assembleControlEqProd(well_state, assembleControlEqProd(well_state,
group_state, group_state,

View File

@ -23,6 +23,8 @@
#ifndef OPM_STANDARDWELL_ASSEMBLE_HEADER_INCLUDED #ifndef OPM_STANDARDWELL_ASSEMBLE_HEADER_INCLUDED
#define OPM_STANDARDWELL_ASSEMBLE_HEADER_INCLUDED #define OPM_STANDARDWELL_ASSEMBLE_HEADER_INCLUDED
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
namespace Opm namespace Opm
{ {
@ -53,6 +55,8 @@ public:
const GroupState& group_state, const GroupState& group_state,
const Schedule& schedule, const Schedule& schedule,
const SummaryState& summaryState, const SummaryState& summaryState,
const Well::InjectionControls& inj_controls,
const Well::ProductionControls& prod_controls,
const PrimaryVariables& primary_variables, const PrimaryVariables& primary_variables,
const double rho, const double rho,
StandardWellEquations<Scalar,Indices::numEq>& eqns, StandardWellEquations<Scalar,Indices::numEq>& eqns,

View File

@ -476,8 +476,8 @@ namespace Opm
StandardWell<TypeTag>:: StandardWell<TypeTag>::
assembleWellEqWithoutIteration(const Simulator& ebosSimulator, assembleWellEqWithoutIteration(const Simulator& ebosSimulator,
const double dt, const double dt,
const Well::InjectionControls& /*inj_controls*/, const Well::InjectionControls& inj_controls,
const Well::ProductionControls& /*prod_controls*/, const Well::ProductionControls& prod_controls,
WellState& well_state, WellState& well_state,
const GroupState& group_state, const GroupState& group_state,
DeferredLogger& deferred_logger) DeferredLogger& deferred_logger)
@ -489,7 +489,7 @@ namespace Opm
// clear all entries // clear all entries
this->linSys_.clear(); this->linSys_.clear();
assembleWellEqWithoutIterationImpl(ebosSimulator, dt, well_state, group_state, deferred_logger); assembleWellEqWithoutIterationImpl(ebosSimulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger);
} }
@ -500,6 +500,8 @@ namespace Opm
StandardWell<TypeTag>:: StandardWell<TypeTag>::
assembleWellEqWithoutIterationImpl(const Simulator& ebosSimulator, assembleWellEqWithoutIterationImpl(const Simulator& ebosSimulator,
const double dt, const double dt,
const Well::InjectionControls& inj_controls,
const Well::ProductionControls& prod_controls,
WellState& well_state, WellState& well_state,
const GroupState& group_state, const GroupState& group_state,
DeferredLogger& deferred_logger) DeferredLogger& deferred_logger)
@ -603,6 +605,7 @@ namespace Opm
StandardWellAssemble<FluidSystem,Indices,Scalar>(*this). StandardWellAssemble<FluidSystem,Indices,Scalar>(*this).
assembleControlEq(well_state, group_state, assembleControlEq(well_state, group_state,
schedule, summaryState, schedule, summaryState,
inj_controls, prod_controls,
this->primary_variables_, this->primary_variables_,
this->connections_.rho(), this->connections_.rho(),
this->linSys_, this->linSys_,
@ -1705,18 +1708,32 @@ namespace Opm
std::vector<double>& well_flux, std::vector<double>& well_flux,
DeferredLogger& deferred_logger) const DeferredLogger& deferred_logger) const
{ {
// creating a copy of the well itself, to avoid messing up the explicit information
// during this copy, the only information not copied properly is the well controls
StandardWell<TypeTag> well_copy(*this);
// iterate to get a more accurate well density // iterate to get a more accurate well density
// create a copy of the well_state to use. If the operability checking is sucessful, we use this one // create a copy of the well_state to use. If the operability checking is sucessful, we use this one
// to replace the original one // to replace the original one
WellState well_state_copy = ebosSimulator.problem().wellModel().wellState(); WellState well_state_copy = ebosSimulator.problem().wellModel().wellState();
const auto& group_state = ebosSimulator.problem().wellModel().groupState(); const auto& group_state = ebosSimulator.problem().wellModel().groupState();
auto& ws = well_state_copy.well(this->index_of_well_);
// Get the current controls.
const auto& summary_state = ebosSimulator.vanguard().summaryState();
auto inj_controls = well_copy.well_ecl_.isInjector()
? well_copy.well_ecl_.injectionControls(summary_state)
: Well::InjectionControls(0);
auto prod_controls = well_copy.well_ecl_.isProducer()
? well_copy.well_ecl_.productionControls(summary_state) :
Well::ProductionControls(0);
// Set current control to bhp, and bhp value in state, modify bhp limit in control object. // Set current control to bhp, and bhp value in state, modify bhp limit in control object.
if (this->well_ecl_.isInjector()) { auto& ws = well_state_copy.well(this->index_of_well_);
if (well_copy.well_ecl_.isInjector()) {
inj_controls.bhp_limit = bhp;
ws.injection_cmode = Well::InjectorCMode::BHP; ws.injection_cmode = Well::InjectorCMode::BHP;
} else { } else {
prod_controls.bhp_limit = bhp;
ws.production_cmode = Well::ProducerCMode::BHP; ws.production_cmode = Well::ProducerCMode::BHP;
} }
ws.bhp = bhp; ws.bhp = bhp;
@ -1728,22 +1745,19 @@ namespace Opm
well_state_copy.wellRates(this->index_of_well_)[phase] well_state_copy.wellRates(this->index_of_well_)[phase]
= sign * ws.well_potentials[phase]; = sign * ws.well_potentials[phase];
} }
// creating a copy of the well itself, to avoid messing up the explicit informations well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
// during this copy, the only information not copied properly is the well controls
StandardWell<TypeTag> well(*this);
well.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
const double dt = ebosSimulator.timeStepSize(); const double dt = ebosSimulator.timeStepSize();
bool converged = well.iterateWellEquations(ebosSimulator, dt, well_state_copy, group_state, deferred_logger); const bool converged = well_copy.iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state_copy, group_state, deferred_logger);
if (!converged) { if (!converged) {
const std::string msg = " well " + name() + " did not get converged during well potential calculations " const std::string msg = " well " + name() + " did not get converged during well potential calculations "
" potentials are computed based on unconverged solution"; " potentials are computed based on unconverged solution";
deferred_logger.debug(msg); deferred_logger.debug(msg);
} }
well.updatePrimaryVariables(well_state_copy, deferred_logger); well_copy.updatePrimaryVariables(well_state_copy, deferred_logger);
well.computeWellConnectionPressures(ebosSimulator, well_state_copy, deferred_logger); well_copy.computeWellConnectionPressures(ebosSimulator, well_state_copy, deferred_logger);
well.initPrimaryVariablesEvaluation(); well_copy.initPrimaryVariablesEvaluation();
well.computeWellRatesWithBhp(ebosSimulator, bhp, well_flux, deferred_logger); well_copy.computeWellRatesWithBhp(ebosSimulator, bhp, well_flux, deferred_logger);
} }