mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3120 from totto82/refactorBAVG
only compute Bavg once pr timestep
This commit is contained in:
commit
c23ce16879
@ -357,6 +357,8 @@ namespace Opm {
|
|||||||
// used to better efficiency of calcuation
|
// used to better efficiency of calcuation
|
||||||
mutable BVector scaleAddRes_;
|
mutable BVector scaleAddRes_;
|
||||||
|
|
||||||
|
std::vector< Scalar > B_avg_;
|
||||||
|
|
||||||
const Grid& grid() const
|
const Grid& grid() const
|
||||||
{ return ebosSimulator_.vanguard().grid(); }
|
{ return ebosSimulator_.vanguard().grid(); }
|
||||||
|
|
||||||
@ -409,7 +411,7 @@ namespace Opm {
|
|||||||
void setRepRadiusPerfLength();
|
void setRepRadiusPerfLength();
|
||||||
|
|
||||||
|
|
||||||
void computeAverageFormationFactor(std::vector<Scalar>& B_avg) const;
|
void updateAverageFormationFactor();
|
||||||
|
|
||||||
// Calculating well potentials for each well
|
// Calculating well potentials for each well
|
||||||
void computeWellPotentials(std::vector<double>& well_potentials, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
|
void computeWellPotentials(std::vector<double>& well_potentials, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
|
||||||
@ -438,7 +440,7 @@ namespace Opm {
|
|||||||
|
|
||||||
int reportStepIndex() const;
|
int reportStepIndex() const;
|
||||||
|
|
||||||
void assembleWellEq(const std::vector<Scalar>& B_avg, const double dt, Opm::DeferredLogger& deferred_logger);
|
void assembleWellEq(const double dt, Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
// some preparation work, mostly related to group control and RESV,
|
// some preparation work, mostly related to group control and RESV,
|
||||||
// at the beginning of each time step (Not report step)
|
// at the beginning of each time step (Not report step)
|
||||||
|
@ -301,6 +301,7 @@ namespace Opm {
|
|||||||
beginTimeStep()
|
beginTimeStep()
|
||||||
{
|
{
|
||||||
updatePerforationIntensiveQuantities();
|
updatePerforationIntensiveQuantities();
|
||||||
|
updateAverageFormationFactor();
|
||||||
|
|
||||||
Opm::DeferredLogger local_deferredLogger;
|
Opm::DeferredLogger local_deferredLogger;
|
||||||
|
|
||||||
@ -321,11 +322,8 @@ namespace Opm {
|
|||||||
// do the initialization for all the wells
|
// do the initialization for all the wells
|
||||||
// TODO: to see whether we can postpone of the intialization of the well containers to
|
// TODO: to see whether we can postpone of the intialization of the well containers to
|
||||||
// optimize the usage of the following several member variables
|
// optimize the usage of the following several member variables
|
||||||
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
|
||||||
computeAverageFormationFactor(B_avg);
|
|
||||||
|
|
||||||
for (auto& well : well_container_) {
|
for (auto& well : well_container_) {
|
||||||
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg);
|
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the updated cell flag
|
// update the updated cell flag
|
||||||
@ -462,13 +460,6 @@ namespace Opm {
|
|||||||
{
|
{
|
||||||
const auto& wtest_config = schedule()[timeStepIdx].wtest_config();
|
const auto& wtest_config = schedule()[timeStepIdx].wtest_config();
|
||||||
if (wtest_config.size() != 0) { // there is a WTEST request
|
if (wtest_config.size() != 0) { // there is a WTEST request
|
||||||
|
|
||||||
// average B factors are required for the convergence checking of well equations
|
|
||||||
// Note: this must be done on all processes, even those with
|
|
||||||
// no wells needing testing, otherwise we will have locking.
|
|
||||||
std::vector< Scalar > B_avg(numComponents(), Scalar());
|
|
||||||
computeAverageFormationFactor(B_avg);
|
|
||||||
|
|
||||||
const auto wellsForTesting = wellTestState_
|
const auto wellsForTesting = wellTestState_
|
||||||
.updateWells(wtest_config, wells_ecl_, simulationTime);
|
.updateWells(wtest_config, wells_ecl_, simulationTime);
|
||||||
|
|
||||||
@ -479,8 +470,7 @@ namespace Opm {
|
|||||||
WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger);
|
WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger);
|
||||||
|
|
||||||
// some preparation before the well can be used
|
// some preparation before the well can be used
|
||||||
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg);
|
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_);
|
||||||
|
|
||||||
const Well& wellEcl = schedule().getWell(well_name, timeStepIdx);
|
const Well& wellEcl = schedule().getWell(well_name, timeStepIdx);
|
||||||
double well_efficiency_factor = wellEcl.getEfficiencyFactor();
|
double well_efficiency_factor = wellEcl.getEfficiencyFactor();
|
||||||
WellGroupHelpers::accumulateGroupEfficiencyFactor(schedule().getGroup(wellEcl.groupName(), timeStepIdx),
|
WellGroupHelpers::accumulateGroupEfficiencyFactor(schedule().getGroup(wellEcl.groupName(), timeStepIdx),
|
||||||
@ -492,7 +482,7 @@ namespace Opm {
|
|||||||
|
|
||||||
const WellTestConfig::Reason testing_reason = testWell.second;
|
const WellTestConfig::Reason testing_reason = testWell.second;
|
||||||
|
|
||||||
well->wellTesting(ebosSimulator_, B_avg, simulationTime, timeStepIdx,
|
well->wellTesting(ebosSimulator_, simulationTime, timeStepIdx,
|
||||||
testing_reason, well_state_, wellTestState_, deferred_logger);
|
testing_reason, well_state_, wellTestState_, deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1029,9 +1019,6 @@ namespace Opm {
|
|||||||
// Set the well primary variables based on the value of well solutions
|
// Set the well primary variables based on the value of well solutions
|
||||||
initPrimaryVariablesEvaluation();
|
initPrimaryVariablesEvaluation();
|
||||||
|
|
||||||
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
|
||||||
computeAverageFormationFactor(B_avg);
|
|
||||||
|
|
||||||
if (param_.solve_welleq_initially_ && iterationIdx == 0) {
|
if (param_.solve_welleq_initially_ && iterationIdx == 0) {
|
||||||
for (auto& well : well_container_) {
|
for (auto& well : well_container_) {
|
||||||
well->solveWellEquation(ebosSimulator_, well_state_, local_deferredLogger);
|
well->solveWellEquation(ebosSimulator_, well_state_, local_deferredLogger);
|
||||||
@ -1041,7 +1028,7 @@ namespace Opm {
|
|||||||
|
|
||||||
gliftDebug("assemble() : running assembleWellEq()..", local_deferredLogger);
|
gliftDebug("assemble() : running assembleWellEq()..", local_deferredLogger);
|
||||||
well_state_.enableGliftOptimization();
|
well_state_.enableGliftOptimization();
|
||||||
assembleWellEq(B_avg, dt, local_deferredLogger);
|
assembleWellEq(dt, local_deferredLogger);
|
||||||
well_state_.disableGliftOptimization();
|
well_state_.disableGliftOptimization();
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
exc_type = ExceptionType::RUNTIME_ERROR;
|
exc_type = ExceptionType::RUNTIME_ERROR;
|
||||||
@ -1056,7 +1043,6 @@ namespace Opm {
|
|||||||
exc_type = ExceptionType::DEFAULT;
|
exc_type = ExceptionType::DEFAULT;
|
||||||
exc_msg = e.what();
|
exc_msg = e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
logAndCheckForExceptionsAndThrow(local_deferredLogger, exc_type, "assemble() failed: " + exc_msg, terminal_output_);
|
logAndCheckForExceptionsAndThrow(local_deferredLogger, exc_type, "assemble() failed: " + exc_msg, terminal_output_);
|
||||||
last_report_.converged = true;
|
last_report_.converged = true;
|
||||||
last_report_.assemble_time_well += perfTimer.stop();
|
last_report_.assemble_time_well += perfTimer.stop();
|
||||||
@ -1065,12 +1051,12 @@ namespace Opm {
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::
|
BlackoilWellModel<TypeTag>::
|
||||||
assembleWellEq(const std::vector<Scalar>& B_avg, const double dt, Opm::DeferredLogger& deferred_logger)
|
assembleWellEq(const double dt, Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
for (auto& well : well_container_) {
|
for (auto& well : well_container_) {
|
||||||
well->maybeDoGasLiftOptimization(
|
well->maybeDoGasLiftOptimization(
|
||||||
well_state_, ebosSimulator_, deferred_logger);
|
well_state_, ebosSimulator_, deferred_logger);
|
||||||
well->assembleWellEq(ebosSimulator_, B_avg, dt, well_state_, deferred_logger);
|
well->assembleWellEq(ebosSimulator_, dt, well_state_, deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1491,12 +1477,6 @@ namespace Opm {
|
|||||||
|
|
||||||
auto well_state_copy = well_state_;
|
auto well_state_copy = well_state_;
|
||||||
|
|
||||||
// average B factors are required for the convergence checking of well equations
|
|
||||||
// Note: this must be done on all processes, even those with
|
|
||||||
// no wells needing testing, otherwise we will have locking.
|
|
||||||
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
|
||||||
computeAverageFormationFactor(B_avg);
|
|
||||||
|
|
||||||
const Opm::SummaryConfig& summaryConfig = ebosSimulator_.vanguard().summaryConfig();
|
const Opm::SummaryConfig& summaryConfig = ebosSimulator_.vanguard().summaryConfig();
|
||||||
const bool write_restart_file = ebosSimulator_.vanguard().schedule().write_rst_file(reportStepIdx);
|
const bool write_restart_file = ebosSimulator_.vanguard().schedule().write_rst_file(reportStepIdx);
|
||||||
auto exc_type = ExceptionType::NONE;
|
auto exc_type = ExceptionType::NONE;
|
||||||
@ -1514,7 +1494,7 @@ namespace Opm {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::vector<double> potentials;
|
std::vector<double> potentials;
|
||||||
well->computeWellPotentials(ebosSimulator_, B_avg, well_state_copy, potentials, deferred_logger);
|
well->computeWellPotentials(ebosSimulator_, well_state_copy, potentials, deferred_logger);
|
||||||
// putting the sucessfully calculated potentials to the well_potentials
|
// putting the sucessfully calculated potentials to the well_potentials
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
well_potentials[well->indexOfWell() * np + p] = std::abs(potentials[p]);
|
well_potentials[well->indexOfWell() * np + p] = std::abs(potentials[p]);
|
||||||
@ -1693,8 +1673,9 @@ namespace Opm {
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::
|
BlackoilWellModel<TypeTag>::
|
||||||
computeAverageFormationFactor(std::vector<Scalar>& B_avg) const
|
updateAverageFormationFactor()
|
||||||
{
|
{
|
||||||
|
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
||||||
const auto& grid = ebosSimulator_.vanguard().grid();
|
const auto& grid = ebosSimulator_.vanguard().grid();
|
||||||
const auto& gridView = grid.leafGridView();
|
const auto& gridView = grid.leafGridView();
|
||||||
ElementContext elemCtx(ebosSimulator_);
|
ElementContext elemCtx(ebosSimulator_);
|
||||||
@ -1732,6 +1713,7 @@ namespace Opm {
|
|||||||
{
|
{
|
||||||
bval/=global_num_cells_;
|
bval/=global_num_cells_;
|
||||||
}
|
}
|
||||||
|
B_avg_ = B_avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2811,11 +2793,8 @@ namespace Opm {
|
|||||||
this->previous_well_state_ = this->well_state_;
|
this->previous_well_state_ = this->well_state_;
|
||||||
|
|
||||||
well_container_ = createWellContainer(timeStepIdx);
|
well_container_ = createWellContainer(timeStepIdx);
|
||||||
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
|
||||||
// we don't plan to iterate so just passing trivial B_avg
|
|
||||||
// for now
|
|
||||||
for (auto& well : well_container_) {
|
for (auto& well : well_container_) {
|
||||||
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg);
|
well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill(is_cell_perforated_.begin(), is_cell_perforated_.end(), false);
|
std::fill(is_cell_perforated_.begin(), is_cell_perforated_.end(), false);
|
||||||
|
@ -129,7 +129,6 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger) override;
|
Opm::DeferredLogger& deferred_logger) override;
|
||||||
@ -160,7 +159,6 @@ namespace Opm
|
|||||||
|
|
||||||
/// computing the well potentials for group control
|
/// computing the well potentials for group control
|
||||||
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const WellState& well_state,
|
const WellState& well_state,
|
||||||
std::vector<double>& well_potentials,
|
std::vector<double>& well_potentials,
|
||||||
Opm::DeferredLogger& deferred_logger) override;
|
Opm::DeferredLogger& deferred_logger) override;
|
||||||
@ -402,19 +400,16 @@ namespace Opm
|
|||||||
std::vector<EvalWell>& mob) const;
|
std::vector<EvalWell>& mob) const;
|
||||||
|
|
||||||
void computeWellRatesAtBhpLimit(const Simulator& ebosSimulator,
|
void computeWellRatesAtBhpLimit(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
void computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const Scalar bhp,
|
const Scalar bhp,
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
std::vector<double>
|
std::vector<double>
|
||||||
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void assembleControlEq(const WellState& well_state,
|
void assembleControlEq(const WellState& well_state,
|
||||||
@ -447,7 +442,6 @@ namespace Opm
|
|||||||
bool accelerationalPressureLossConsidered() const;
|
bool accelerationalPressureLossConsidered() const;
|
||||||
|
|
||||||
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
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,
|
||||||
@ -496,12 +490,10 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
std::optional<double> computeBhpAtThpLimitProd(const Simulator& ebos_simulator,
|
std::optional<double> computeBhpAtThpLimitProd(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const SummaryState& summary_state,
|
const SummaryState& summary_state,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
std::optional<double> computeBhpAtThpLimitInj(const Simulator& ebos_simulator,
|
std::optional<double> computeBhpAtThpLimitInj(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const SummaryState& summary_state,
|
const SummaryState& summary_state,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
@ -261,7 +261,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
assembleWellEq(const Simulator& ebosSimulator,
|
assembleWellEq(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -271,7 +270,7 @@ namespace Opm
|
|||||||
|
|
||||||
const bool use_inner_iterations = param_.use_inner_iterations_ms_wells_;
|
const bool use_inner_iterations = param_.use_inner_iterations_ms_wells_;
|
||||||
if (use_inner_iterations) {
|
if (use_inner_iterations) {
|
||||||
this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger);
|
this->iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& summary_state = ebosSimulator.vanguard().summaryState();
|
const auto& summary_state = ebosSimulator.vanguard().summaryState();
|
||||||
@ -779,7 +778,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeWellPotentials(const Simulator& ebosSimulator,
|
computeWellPotentials(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const WellState& well_state,
|
const WellState& well_state,
|
||||||
std::vector<double>& well_potentials,
|
std::vector<double>& well_potentials,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -819,9 +817,9 @@ namespace Opm
|
|||||||
const auto& summaryState = ebosSimulator.vanguard().summaryState();
|
const auto& summaryState = ebosSimulator.vanguard().summaryState();
|
||||||
const Well::ProducerCMode& current_control = well_state.currentProductionControls()[this->index_of_well_];
|
const Well::ProducerCMode& current_control = well_state.currentProductionControls()[this->index_of_well_];
|
||||||
if ( !Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP) {
|
if ( !Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP) {
|
||||||
computeWellRatesAtBhpLimit(ebosSimulator, B_avg, well_potentials, deferred_logger);
|
computeWellRatesAtBhpLimit(ebosSimulator, well_potentials, deferred_logger);
|
||||||
} else {
|
} else {
|
||||||
well_potentials = computeWellPotentialWithTHP(ebosSimulator, B_avg, deferred_logger);
|
well_potentials = computeWellPotentialWithTHP(ebosSimulator, deferred_logger);
|
||||||
}
|
}
|
||||||
deferred_logger.debug("Cost in iterations of finding well potential for well "
|
deferred_logger.debug("Cost in iterations of finding well potential for well "
|
||||||
+ name() + ": " + std::to_string(debug_cost_counter_));
|
+ name() + ": " + std::to_string(debug_cost_counter_));
|
||||||
@ -834,16 +832,15 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeWellRatesAtBhpLimit(const Simulator& ebosSimulator,
|
computeWellRatesAtBhpLimit(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger) const
|
Opm::DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
if (well_ecl_.isInjector()) {
|
if (well_ecl_.isInjector()) {
|
||||||
const auto controls = well_ecl_.injectionControls(ebosSimulator.vanguard().summaryState());
|
const auto controls = well_ecl_.injectionControls(ebosSimulator.vanguard().summaryState());
|
||||||
computeWellRatesWithBhp(ebosSimulator, B_avg, controls.bhp_limit, well_flux, deferred_logger);
|
computeWellRatesWithBhp(ebosSimulator, controls.bhp_limit, well_flux, deferred_logger);
|
||||||
} else {
|
} else {
|
||||||
const auto controls = well_ecl_.productionControls(ebosSimulator.vanguard().summaryState());
|
const auto controls = well_ecl_.productionControls(ebosSimulator.vanguard().summaryState());
|
||||||
computeWellRatesWithBhp(ebosSimulator, B_avg, controls.bhp_limit, well_flux, deferred_logger);
|
computeWellRatesWithBhp(ebosSimulator, controls.bhp_limit, well_flux, deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,7 +850,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const Scalar bhp,
|
const Scalar bhp,
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger) const
|
Opm::DeferredLogger& deferred_logger) const
|
||||||
@ -898,7 +894,7 @@ namespace Opm
|
|||||||
well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
|
well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
|
||||||
const double dt = ebosSimulator.timeStepSize();
|
const double dt = ebosSimulator.timeStepSize();
|
||||||
// iterate to get a solution at the given bhp.
|
// iterate to get a solution at the given bhp.
|
||||||
well_copy.iterateWellEqWithControl(ebosSimulator, B_avg, dt, inj_controls, prod_controls, well_state_copy,
|
well_copy.iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state_copy,
|
||||||
deferred_logger);
|
deferred_logger);
|
||||||
|
|
||||||
// compute the potential and store in the flux vector.
|
// compute the potential and store in the flux vector.
|
||||||
@ -917,7 +913,6 @@ namespace Opm
|
|||||||
std::vector<double>
|
std::vector<double>
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
Opm::DeferredLogger& deferred_logger) const
|
Opm::DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
std::vector<double> potentials(number_of_phases_, 0.0);
|
std::vector<double> potentials(number_of_phases_, 0.0);
|
||||||
@ -925,11 +920,11 @@ namespace Opm
|
|||||||
|
|
||||||
const auto& well = well_ecl_;
|
const auto& well = well_ecl_;
|
||||||
if (well.isInjector()){
|
if (well.isInjector()){
|
||||||
auto bhp_at_thp_limit = computeBhpAtThpLimitInj(ebos_simulator, B_avg, summary_state, deferred_logger);
|
auto bhp_at_thp_limit = computeBhpAtThpLimitInj(ebos_simulator, summary_state, deferred_logger);
|
||||||
if (bhp_at_thp_limit) {
|
if (bhp_at_thp_limit) {
|
||||||
const auto& controls = well_ecl_.injectionControls(summary_state);
|
const auto& controls = well_ecl_.injectionControls(summary_state);
|
||||||
const double bhp = std::min(*bhp_at_thp_limit, controls.bhp_limit);
|
const double bhp = std::min(*bhp_at_thp_limit, controls.bhp_limit);
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||||
deferred_logger.debug("Converged thp based potential calculation for well "
|
deferred_logger.debug("Converged thp based potential calculation for well "
|
||||||
+ name() + ", at bhp = " + std::to_string(bhp));
|
+ name() + ", at bhp = " + std::to_string(bhp));
|
||||||
} else {
|
} else {
|
||||||
@ -938,14 +933,14 @@ namespace Opm
|
|||||||
+ name() + ". Instead the bhp based value is used");
|
+ name() + ". Instead the bhp based value is used");
|
||||||
const auto& controls = well_ecl_.injectionControls(summary_state);
|
const auto& controls = well_ecl_.injectionControls(summary_state);
|
||||||
const double bhp = controls.bhp_limit;
|
const double bhp = controls.bhp_limit;
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto bhp_at_thp_limit = computeBhpAtThpLimitProd(ebos_simulator, B_avg, summary_state, deferred_logger);
|
auto bhp_at_thp_limit = computeBhpAtThpLimitProd(ebos_simulator, summary_state, deferred_logger);
|
||||||
if (bhp_at_thp_limit) {
|
if (bhp_at_thp_limit) {
|
||||||
const auto& controls = well_ecl_.productionControls(summary_state);
|
const auto& controls = well_ecl_.productionControls(summary_state);
|
||||||
const double bhp = std::max(*bhp_at_thp_limit, controls.bhp_limit);
|
const double bhp = std::max(*bhp_at_thp_limit, controls.bhp_limit);
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||||
deferred_logger.debug("Converged thp based potential calculation for well "
|
deferred_logger.debug("Converged thp based potential calculation for well "
|
||||||
+ name() + ", at bhp = " + std::to_string(bhp));
|
+ name() + ", at bhp = " + std::to_string(bhp));
|
||||||
} else {
|
} else {
|
||||||
@ -954,7 +949,7 @@ namespace Opm
|
|||||||
+ name() + ". Instead the bhp based value is used");
|
+ name() + ". Instead the bhp based value is used");
|
||||||
const auto& controls = well_ecl_.productionControls(summary_state);
|
const auto& controls = well_ecl_.productionControls(summary_state);
|
||||||
const double bhp = controls.bhp_limit;
|
const double bhp = controls.bhp_limit;
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2447,7 +2442,7 @@ namespace Opm
|
|||||||
// option 2: stick with the above IPR curve
|
// option 2: stick with the above IPR curve
|
||||||
// we use IPR here
|
// we use IPR here
|
||||||
std::vector<double> well_rates_bhp_limit;
|
std::vector<double> well_rates_bhp_limit;
|
||||||
computeWellRatesWithBhp(ebos_simulator, Base::B_avg_, bhp_limit, well_rates_bhp_limit, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp_limit, well_rates_bhp_limit, deferred_logger);
|
||||||
|
|
||||||
const double thp = calculateThpFromBhp(well_rates_bhp_limit, bhp_limit, deferred_logger);
|
const double thp = calculateThpFromBhp(well_rates_bhp_limit, bhp_limit, deferred_logger);
|
||||||
|
|
||||||
@ -2586,7 +2581,7 @@ namespace Opm
|
|||||||
checkOperabilityUnderTHPLimitProducer(const Simulator& ebos_simulator, const WellState& /*well_state*/, Opm::DeferredLogger& deferred_logger)
|
checkOperabilityUnderTHPLimitProducer(const Simulator& ebos_simulator, const WellState& /*well_state*/, Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
const auto& summaryState = ebos_simulator.vanguard().summaryState();
|
const auto& summaryState = ebos_simulator.vanguard().summaryState();
|
||||||
const auto obtain_bhp = computeBhpAtThpLimitProd(ebos_simulator, Base::B_avg_, summaryState, deferred_logger);
|
const auto obtain_bhp = computeBhpAtThpLimitProd(ebos_simulator, summaryState, deferred_logger);
|
||||||
|
|
||||||
if (obtain_bhp) {
|
if (obtain_bhp) {
|
||||||
this->operability_status_.can_obtain_bhp_with_thp_limit = true;
|
this->operability_status_.can_obtain_bhp_with_thp_limit = true;
|
||||||
@ -2709,7 +2704,6 @@ namespace Opm
|
|||||||
bool
|
bool
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
iterateWellEqWithControl(const Simulator& ebosSimulator,
|
iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
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,
|
||||||
@ -2720,7 +2714,7 @@ namespace Opm
|
|||||||
|
|
||||||
const int max_iter_number = param_.max_inner_iter_ms_wells_;
|
const int max_iter_number = param_.max_inner_iter_ms_wells_;
|
||||||
const WellState well_state0 = well_state;
|
const WellState well_state0 = well_state;
|
||||||
const std::vector<Scalar> residuals0 = getWellResiduals(B_avg, deferred_logger);
|
const std::vector<Scalar> residuals0 = getWellResiduals(Base::B_avg_, deferred_logger);
|
||||||
std::vector<std::vector<Scalar> > residual_history;
|
std::vector<std::vector<Scalar> > residual_history;
|
||||||
std::vector<double> measure_history;
|
std::vector<double> measure_history;
|
||||||
int it = 0;
|
int it = 0;
|
||||||
@ -2739,13 +2733,13 @@ namespace Opm
|
|||||||
if (it > param_.strict_inner_iter_ms_wells_)
|
if (it > param_.strict_inner_iter_ms_wells_)
|
||||||
relax_convergence = true;
|
relax_convergence = true;
|
||||||
|
|
||||||
const auto report = getWellConvergence(well_state, B_avg, deferred_logger, relax_convergence);
|
const auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger, relax_convergence);
|
||||||
if (report.converged()) {
|
if (report.converged()) {
|
||||||
converged = true;
|
converged = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
residual_history.push_back(getWellResiduals(B_avg, deferred_logger));
|
residual_history.push_back(getWellResiduals(Base::B_avg_, deferred_logger));
|
||||||
measure_history.push_back(getResidualMeasureValue(well_state, residual_history[it], deferred_logger) );
|
measure_history.push_back(getResidualMeasureValue(well_state, residual_history[it], deferred_logger) );
|
||||||
|
|
||||||
bool is_oscillate = false;
|
bool is_oscillate = false;
|
||||||
@ -2763,7 +2757,7 @@ namespace Opm
|
|||||||
++stagnate_count;
|
++stagnate_count;
|
||||||
if (stagnate_count == 6) {
|
if (stagnate_count == 6) {
|
||||||
sstr << " well " << name() << " observes severe stagnation and/or oscillation. We relax the tolerance and check for convergence. \n";
|
sstr << " well " << name() << " observes severe stagnation and/or oscillation. We relax the tolerance and check for convergence. \n";
|
||||||
const auto reportStag = getWellConvergence(well_state, B_avg, deferred_logger, true);
|
const auto reportStag = getWellConvergence(well_state, Base::B_avg_, deferred_logger, true);
|
||||||
if (reportStag.converged()) {
|
if (reportStag.converged()) {
|
||||||
converged = true;
|
converged = true;
|
||||||
sstr << " well " << name() << " manages to get converged with relaxed tolerances in " << it << " inner iterations";
|
sstr << " well " << name() << " manages to get converged with relaxed tolerances in " << it << " inner iterations";
|
||||||
@ -3578,7 +3572,6 @@ namespace Opm
|
|||||||
std::optional<double>
|
std::optional<double>
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeBhpAtThpLimitProd(const Simulator& ebos_simulator,
|
computeBhpAtThpLimitProd(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const SummaryState& summary_state,
|
const SummaryState& summary_state,
|
||||||
DeferredLogger& deferred_logger) const
|
DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
@ -3617,14 +3610,14 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
auto frates = [this, &ebos_simulator, &B_avg, &deferred_logger](const double bhp) {
|
auto frates = [this, &ebos_simulator, &deferred_logger](const double bhp) {
|
||||||
// Not solving the well equations here, which means we are
|
// Not solving the well equations here, which means we are
|
||||||
// calculating at the current Fg/Fw values of the
|
// calculating at the current Fg/Fw values of the
|
||||||
// well. This does not matter unless the well is
|
// well. This does not matter unless the well is
|
||||||
// crossflowing, and then it is likely still a good
|
// crossflowing, and then it is likely still a good
|
||||||
// approximation.
|
// approximation.
|
||||||
std::vector<double> rates(3);
|
std::vector<double> rates(3);
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, rates, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, rates, deferred_logger);
|
||||||
return rates;
|
return rates;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3778,7 +3771,6 @@ namespace Opm
|
|||||||
std::optional<double>
|
std::optional<double>
|
||||||
MultisegmentWell<TypeTag>::
|
MultisegmentWell<TypeTag>::
|
||||||
computeBhpAtThpLimitInj(const Simulator& ebos_simulator,
|
computeBhpAtThpLimitInj(const Simulator& ebos_simulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const SummaryState& summary_state,
|
const SummaryState& summary_state,
|
||||||
DeferredLogger& deferred_logger) const
|
DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
@ -3840,14 +3832,14 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
auto frates = [this, &ebos_simulator, &B_avg, &deferred_logger](const double bhp) {
|
auto frates = [this, &ebos_simulator, &deferred_logger](const double bhp) {
|
||||||
// Not solving the well equations here, which means we are
|
// Not solving the well equations here, which means we are
|
||||||
// calculating at the current Fg/Fw values of the
|
// calculating at the current Fg/Fw values of the
|
||||||
// well. This does not matter unless the well is
|
// well. This does not matter unless the well is
|
||||||
// crossflowing, and then it is likely still a good
|
// crossflowing, and then it is likely still a good
|
||||||
// approximation.
|
// approximation.
|
||||||
std::vector<double> rates(3);
|
std::vector<double> rates(3);
|
||||||
computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, rates, deferred_logger);
|
computeWellRatesWithBhp(ebos_simulator, bhp, rates, deferred_logger);
|
||||||
return rates;
|
return rates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,7 +176,6 @@ namespace Opm
|
|||||||
virtual void initPrimaryVariablesEvaluation() const override;
|
virtual void initPrimaryVariablesEvaluation() const override;
|
||||||
|
|
||||||
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger) override;
|
Opm::DeferredLogger& deferred_logger) override;
|
||||||
@ -212,7 +211,6 @@ namespace Opm
|
|||||||
|
|
||||||
/// computing the well potentials for group control
|
/// computing the well potentials for group control
|
||||||
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const WellState& well_state,
|
const WellState& well_state,
|
||||||
std::vector<double>& well_potentials,
|
std::vector<double>& well_potentials,
|
||||||
Opm::DeferredLogger& deferred_logger) /* const */ override;
|
Opm::DeferredLogger& deferred_logger) /* const */ override;
|
||||||
@ -234,7 +232,6 @@ namespace Opm
|
|||||||
|
|
||||||
// iterate well equations with the specified control until converged
|
// iterate well equations with the specified control until converged
|
||||||
bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
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,
|
||||||
@ -469,7 +466,6 @@ namespace Opm
|
|||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
void computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double& bhp,
|
const double& bhp,
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger);
|
Opm::DeferredLogger& deferred_logger);
|
||||||
|
@ -542,7 +542,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
StandardWell<TypeTag>::
|
StandardWell<TypeTag>::
|
||||||
assembleWellEq(const Simulator& ebosSimulator,
|
assembleWellEq(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -551,7 +550,7 @@ namespace Opm
|
|||||||
|
|
||||||
const bool use_inner_iterations = param_.use_inner_iterations_wells_;
|
const bool use_inner_iterations = param_.use_inner_iterations_wells_;
|
||||||
if (use_inner_iterations) {
|
if (use_inner_iterations) {
|
||||||
this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger);
|
this->iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: inj_controls and prod_controls are not used in the following function for now
|
// TODO: inj_controls and prod_controls are not used in the following function for now
|
||||||
@ -2598,7 +2597,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
StandardWell<TypeTag>::
|
StandardWell<TypeTag>::
|
||||||
computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double& bhp,
|
const double& bhp,
|
||||||
std::vector<double>& well_flux,
|
std::vector<double>& well_flux,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -2618,7 +2616,7 @@ namespace Opm
|
|||||||
well_state_copy.bhp()[index_of_well_] = bhp;
|
well_state_copy.bhp()[index_of_well_] = bhp;
|
||||||
|
|
||||||
const double dt = ebosSimulator.timeStepSize();
|
const double dt = ebosSimulator.timeStepSize();
|
||||||
bool converged = this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state_copy, deferred_logger);
|
bool converged = this->iterateWellEquations(ebosSimulator, dt, well_state_copy, 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 "
|
||||||
"returning zero values for the potential";
|
"returning zero values for the potential";
|
||||||
@ -2852,7 +2850,6 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
StandardWell<TypeTag>::
|
StandardWell<TypeTag>::
|
||||||
computeWellPotentials(const Simulator& ebosSimulator,
|
computeWellPotentials(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const WellState& well_state,
|
const WellState& well_state,
|
||||||
std::vector<double>& well_potentials,
|
std::vector<double>& well_potentials,
|
||||||
Opm::DeferredLogger& deferred_logger) // const
|
Opm::DeferredLogger& deferred_logger) // const
|
||||||
@ -2876,7 +2873,7 @@ namespace Opm
|
|||||||
// get the bhp value based on the bhp constraints
|
// get the bhp value based on the bhp constraints
|
||||||
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
|
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
|
||||||
assert(std::abs(bhp) != std::numeric_limits<double>::max());
|
assert(std::abs(bhp) != std::numeric_limits<double>::max());
|
||||||
well.computeWellRatesWithBhpPotential(ebosSimulator, B_avg, bhp, well_potentials, deferred_logger);
|
well.computeWellRatesWithBhpPotential(ebosSimulator, bhp, well_potentials, deferred_logger);
|
||||||
} else {
|
} else {
|
||||||
// the well has a THP related constraint
|
// the well has a THP related constraint
|
||||||
well_potentials = well.computeWellPotentialWithTHP(ebosSimulator, deferred_logger, well_state);
|
well_potentials = well.computeWellPotentialWithTHP(ebosSimulator, deferred_logger, well_state);
|
||||||
@ -4077,7 +4074,6 @@ namespace Opm
|
|||||||
bool
|
bool
|
||||||
StandardWell<TypeTag>::
|
StandardWell<TypeTag>::
|
||||||
iterateWellEqWithControl(const Simulator& ebosSimulator,
|
iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
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,
|
||||||
@ -4090,7 +4086,7 @@ namespace Opm
|
|||||||
do {
|
do {
|
||||||
assembleWellEqWithoutIteration(ebosSimulator, dt, inj_controls, prod_controls, well_state, deferred_logger);
|
assembleWellEqWithoutIteration(ebosSimulator, dt, inj_controls, prod_controls, well_state, deferred_logger);
|
||||||
|
|
||||||
auto report = getWellConvergence(well_state, B_avg, deferred_logger);
|
auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger);
|
||||||
|
|
||||||
converged = report.converged();
|
converged = report.converged();
|
||||||
if (converged) {
|
if (converged) {
|
||||||
|
@ -169,7 +169,6 @@ namespace Opm
|
|||||||
virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) = 0;
|
virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) = 0;
|
||||||
|
|
||||||
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger
|
Opm::DeferredLogger& deferred_logger
|
||||||
@ -205,7 +204,6 @@ namespace Opm
|
|||||||
|
|
||||||
// TODO: before we decide to put more information under mutable, this function is not const
|
// TODO: before we decide to put more information under mutable, this function is not const
|
||||||
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
||||||
const std::vector<Scalar>& B_avg,
|
|
||||||
const WellState& well_state,
|
const WellState& well_state,
|
||||||
std::vector<double>& well_potentials,
|
std::vector<double>& well_potentials,
|
||||||
Opm::DeferredLogger& deferred_logger) = 0;
|
Opm::DeferredLogger& deferred_logger) = 0;
|
||||||
@ -265,7 +263,7 @@ namespace Opm
|
|||||||
|
|
||||||
// TODO: theoretically, it should be a const function
|
// TODO: theoretically, it should be a const function
|
||||||
// Simulator is not const is because that assembleWellEq is non-const Simulator
|
// Simulator is not const is because that assembleWellEq is non-const Simulator
|
||||||
void wellTesting(const Simulator& simulator, const std::vector<double>& B_avg,
|
void wellTesting(const Simulator& simulator,
|
||||||
const double simulation_time, const int report_step,
|
const double simulation_time, const int report_step,
|
||||||
const WellTestConfig::Reason testing_reason,
|
const WellTestConfig::Reason testing_reason,
|
||||||
/* const */ WellState& well_state, WellTestState& welltest_state,
|
/* const */ WellState& well_state, WellTestState& welltest_state,
|
||||||
@ -513,11 +511,11 @@ namespace Opm
|
|||||||
virtual void updateIPR(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger) const=0;
|
virtual void updateIPR(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger) const=0;
|
||||||
|
|
||||||
|
|
||||||
void wellTestingEconomic(const Simulator& simulator, const std::vector<double>& B_avg,
|
void wellTestingEconomic(const Simulator& simulator,
|
||||||
const double simulation_time, const WellState& well_state,
|
const double simulation_time, const WellState& well_state,
|
||||||
WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger);
|
WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
void wellTestingPhysical(const Simulator& simulator, const std::vector<double>& B_avg,
|
void wellTestingPhysical(const Simulator& simulator,
|
||||||
const double simulation_time, const int report_step,
|
const double simulation_time, const int report_step,
|
||||||
WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger);
|
WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
@ -531,7 +529,6 @@ namespace Opm
|
|||||||
|
|
||||||
// iterate well equations with the specified control until converged
|
// iterate well equations with the specified control until converged
|
||||||
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
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,
|
||||||
@ -539,7 +536,6 @@ namespace Opm
|
|||||||
Opm::DeferredLogger& deferred_logger) = 0;
|
Opm::DeferredLogger& deferred_logger) = 0;
|
||||||
|
|
||||||
bool iterateWellEquations(const Simulator& ebosSimulator,
|
bool iterateWellEquations(const Simulator& ebosSimulator,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger);
|
Opm::DeferredLogger& deferred_logger);
|
||||||
@ -557,7 +553,6 @@ namespace Opm
|
|||||||
Opm::DeferredLogger& deferred_logger) const;
|
Opm::DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state,
|
void solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
Opm::DeferredLogger& deferred_logger);
|
Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
void initCompletions();
|
void initCompletions();
|
||||||
|
@ -1109,7 +1109,7 @@ namespace Opm
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
wellTesting(const Simulator& simulator, const std::vector<double>& B_avg,
|
wellTesting(const Simulator& simulator,
|
||||||
const double simulation_time, const int report_step,
|
const double simulation_time, const int report_step,
|
||||||
const WellTestConfig::Reason testing_reason,
|
const WellTestConfig::Reason testing_reason,
|
||||||
/* const */ WellState& well_state,
|
/* const */ WellState& well_state,
|
||||||
@ -1117,12 +1117,12 @@ namespace Opm
|
|||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
if (testing_reason == WellTestConfig::Reason::PHYSICAL) {
|
if (testing_reason == WellTestConfig::Reason::PHYSICAL) {
|
||||||
wellTestingPhysical(simulator, B_avg, simulation_time, report_step,
|
wellTestingPhysical(simulator, simulation_time, report_step,
|
||||||
well_state, well_test_state, deferred_logger);
|
well_state, well_test_state, deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testing_reason == WellTestConfig::Reason::ECONOMIC) {
|
if (testing_reason == WellTestConfig::Reason::ECONOMIC) {
|
||||||
wellTestingEconomic(simulator, B_avg, simulation_time,
|
wellTestingEconomic(simulator, simulation_time,
|
||||||
well_state, well_test_state, deferred_logger);
|
well_state, well_test_state, deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1134,7 +1134,7 @@ namespace Opm
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
wellTestingEconomic(const Simulator& simulator, const std::vector<double>& B_avg,
|
wellTestingEconomic(const Simulator& simulator,
|
||||||
const double simulation_time, const WellState& well_state,
|
const double simulation_time, const WellState& well_state,
|
||||||
WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger)
|
WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
@ -1155,7 +1155,7 @@ namespace Opm
|
|||||||
// untill the number of closed completions do not increase anymore.
|
// untill the number of closed completions do not increase anymore.
|
||||||
while (testWell) {
|
while (testWell) {
|
||||||
const size_t original_number_closed_completions = welltest_state_temp.sizeCompletions();
|
const size_t original_number_closed_completions = welltest_state_temp.sizeCompletions();
|
||||||
solveWellForTesting(simulator, well_state_copy, B_avg, deferred_logger);
|
solveWellForTesting(simulator, well_state_copy, deferred_logger);
|
||||||
updateWellTestState(well_state_copy, simulation_time, /*writeMessageToOPMLog=*/ false, welltest_state_temp, deferred_logger);
|
updateWellTestState(well_state_copy, simulation_time, /*writeMessageToOPMLog=*/ false, welltest_state_temp, deferred_logger);
|
||||||
closeCompletions(welltest_state_temp);
|
closeCompletions(welltest_state_temp);
|
||||||
|
|
||||||
@ -1297,7 +1297,6 @@ namespace Opm
|
|||||||
bool
|
bool
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
iterateWellEquations(const Simulator& ebosSimulator,
|
iterateWellEquations(const Simulator& ebosSimulator,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
const double dt,
|
const double dt,
|
||||||
WellState& well_state,
|
WellState& well_state,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -1306,7 +1305,7 @@ namespace Opm
|
|||||||
const auto inj_controls = well_ecl_.isInjector() ? well_ecl_.injectionControls(summary_state) : Well::InjectionControls(0);
|
const auto inj_controls = well_ecl_.isInjector() ? well_ecl_.injectionControls(summary_state) : Well::InjectionControls(0);
|
||||||
const auto prod_controls = well_ecl_.isProducer() ? well_ecl_.productionControls(summary_state) : Well::ProductionControls(0);
|
const auto prod_controls = well_ecl_.isProducer() ? well_ecl_.productionControls(summary_state) : Well::ProductionControls(0);
|
||||||
|
|
||||||
return this->iterateWellEqWithControl(ebosSimulator, B_avg, dt, inj_controls, prod_controls, well_state, deferred_logger);
|
return this->iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state, deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1354,13 +1353,12 @@ namespace Opm
|
|||||||
void
|
void
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state,
|
solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state,
|
||||||
const std::vector<double>& B_avg,
|
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
// keep a copy of the original well state
|
// keep a copy of the original well state
|
||||||
const WellState well_state0 = well_state;
|
const WellState well_state0 = well_state;
|
||||||
const double dt = ebosSimulator.timeStepSize();
|
const double dt = ebosSimulator.timeStepSize();
|
||||||
const bool converged = iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger);
|
const bool converged = iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger);
|
||||||
if (converged) {
|
if (converged) {
|
||||||
deferred_logger.debug("WellTest: Well equation for well " + name() + " converged");
|
deferred_logger.debug("WellTest: Well equation for well " + name() + " converged");
|
||||||
} else {
|
} else {
|
||||||
@ -1384,7 +1382,7 @@ namespace Opm
|
|||||||
// keep a copy of the original well state
|
// keep a copy of the original well state
|
||||||
const WellState well_state0 = well_state;
|
const WellState well_state0 = well_state;
|
||||||
const double dt = ebosSimulator.timeStepSize();
|
const double dt = ebosSimulator.timeStepSize();
|
||||||
const bool converged = iterateWellEquations(ebosSimulator, B_avg_, dt, well_state, deferred_logger);
|
const bool converged = iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger);
|
||||||
if (converged) {
|
if (converged) {
|
||||||
deferred_logger.debug("Compute initial well solution for well " + name() + ". Converged");
|
deferred_logger.debug("Compute initial well solution for well " + name() + ". Converged");
|
||||||
} else {
|
} else {
|
||||||
@ -1427,7 +1425,7 @@ namespace Opm
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
WellInterface<TypeTag>::
|
WellInterface<TypeTag>::
|
||||||
wellTestingPhysical(const Simulator& ebos_simulator, const std::vector<double>& B_avg,
|
wellTestingPhysical(const Simulator& ebos_simulator,
|
||||||
const double /* simulation_time */, const int /* report_step */,
|
const double /* simulation_time */, const int /* report_step */,
|
||||||
WellState& well_state, WellTestState& welltest_state,
|
WellState& well_state, WellTestState& welltest_state,
|
||||||
Opm::DeferredLogger& deferred_logger)
|
Opm::DeferredLogger& deferred_logger)
|
||||||
@ -1464,7 +1462,7 @@ namespace Opm
|
|||||||
calculateExplicitQuantities(ebos_simulator, well_state_copy, deferred_logger);
|
calculateExplicitQuantities(ebos_simulator, well_state_copy, deferred_logger);
|
||||||
|
|
||||||
const double dt = ebos_simulator.timeStepSize();
|
const double dt = ebos_simulator.timeStepSize();
|
||||||
const bool converged = this->iterateWellEquations(ebos_simulator, B_avg, dt, well_state_copy, deferred_logger);
|
const bool converged = this->iterateWellEquations(ebos_simulator, dt, well_state_copy, deferred_logger);
|
||||||
|
|
||||||
if (!converged) {
|
if (!converged) {
|
||||||
const std::string msg = " well " + name() + " did not get converged during well testing for physical reason";
|
const std::string msg = " well " + name() + " did not get converged during well testing for physical reason";
|
||||||
|
Loading…
Reference in New Issue
Block a user