20#ifndef OPM_GASLIFT_STAGE2_HEADER_INCLUDED
21#define OPM_GASLIFT_STAGE2_HEADER_INCLUDED
23#include <opm/core/props/BlackoilPhases.hpp>
24#include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
26#include <dune/common/version.hh>
27#include <dune/common/parallel/mpihelper.hh>
42class GasLiftWellState;
45class WellInterfaceGeneric;
50 using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
51 using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
52 using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
53 using GradPair = std::pair<std::string, double>;
54 using GradPairItr = std::vector<GradPair>::iterator;
56 using GradMap = std::map<std::string, GradInfo>;
57 using MPIComm =
typename Dune::MPIHelper::MPICommunicator;
58 static const int Water = BlackoilPhases::Aqua;
59 static const int Oil = BlackoilPhases::Liquid;
60 static const int Gas = BlackoilPhases::Vapour;
63 const int report_step_idx,
64 const Parallel::Communication& comm,
65 const Schedule& schedule,
66 const SummaryState& summary_state,
69 GLiftProdWells& prod_wells,
70 GLiftOptWells& glift_wells,
71 GLiftWellStateMap& state_map,
76 void addOrRemoveALQincrement_(
77 GradMap& grad_map,
const std::string& well_name,
bool add);
78 std::optional<GradInfo> calcIncOrDecGrad_(
81 GradInfo deleteDecGradItem_(
const std::string& name);
82 GradInfo deleteIncGradItem_(
const std::string& name);
83 GradInfo deleteGrad_(
const std::string& name,
bool increase);
84 void displayDebugMessage_(
const std::string& msg)
const override;
85 void displayDebugMessage2B_(
const std::string& msg);
86 void displayDebugMessage_(
const std::string& msg,
const std::string& group_name);
87 void displayWarning_(
const std::string& msg,
const std::string& group_name);
88 void displayWarning_(
const std::string& msg);
89 std::tuple<double, double, double> getCurrentGroupRates_(
91 std::array<double,3> getCurrentGroupRatesRecursive_(
93 std::tuple<double, double, double> getCurrentWellRates_(
94 const std::string& well_name,
const std::string& group_name);
95 std::vector<GasLiftSingleWell *> getGroupGliftWells_(
97 void getGroupGliftWellsRecursive_(
98 const Group& group, std::vector<GasLiftSingleWell *>& wells);
100 void optimizeGroup_(
const Group& group);
101 void optimizeGroupsRecursive_(
const Group& group);
102 void recalculateGradientAndUpdateData_(
103 GradPairItr& grad_itr,
bool increase,
104 std::vector<GradPair>& grads, std::vector<GradPair>& other_grads);
105 void redistributeALQ_(
106 std::vector<GasLiftSingleWell *>& wells,
const Group& group,
107 std::vector<GradPair>& inc_grads, std::vector<GradPair>& dec_grads);
108 void removeSurplusALQ_(
110 std::vector<GradPair>& inc_grads, std::vector<GradPair>& dec_grads);
111 void saveGrad_(GradMap& map,
const std::string& name, GradInfo& grad);
112 void saveDecGrad_(
const std::string& name, GradInfo& grad);
113 void saveIncGrad_(
const std::string& name, GradInfo& grad);
114 void sortGradients_(std::vector<GradPair>& grads);
115 std::optional<GradInfo> updateGrad_(
116 const std::string& name, GradInfo& grad,
bool increase);
117 void updateGradVector_(
118 const std::string& name, std::vector<GradPair>& grads,
double grad);
119 void mpiSyncGlobalGradVector_(std::vector<GradPair>& grads_global)
const;
120 void mpiSyncLocalToGlobalGradVector_(
121 const std::vector<GradPair>& grads_local,
122 std::vector<GradPair>& grads_global)
const;
125 GLiftProdWells& prod_wells_;
126 GLiftOptWells& stage1_wells_;
127 GLiftWellStateMap& well_state_map_;
129 int report_step_idx_;
130 const SummaryState& summary_state_;
131 const Schedule& schedule_;
132 const GasLiftOpt& glo_;
135 int max_iterations_ = 1000;
148 using GradInfo =
typename GasLiftStage2::GradInfo;
149 using GradPair =
typename GasLiftStage2::GradPair;
150 using GradPairItr =
typename GasLiftStage2::GradPairItr;
151 using GradMap =
typename GasLiftStage2::GradMap;
152 void calculateEcoGradients(std::vector<GasLiftSingleWell *>& wells,
153 std::vector<GradPair>& inc_grads, std::vector<GradPair>& dec_grads);
154 bool checkAtLeastTwoWells(std::vector<GasLiftSingleWell *>& wells);
155 void debugShowIterationInfo();
156 std::pair<std::optional<GradPairItr>,std::optional<GradPairItr>>
158 std::vector<GradPair>& inc_grads, std::vector<GradPair>& dec_grads);
159 void recalculateGradients(
160 std::vector<GradPair>& inc_grads, std::vector<GradPair>& dec_grads,
161 GradPairItr& min_dec_grad_itr, GradPairItr &max_inc_grad_itr);
162 void redistributeALQ( GradPairItr& min_dec_grad, GradPairItr& max_inc_grad);
165 void displayDebugMessage_(
const std::string& msg);
166 void displayWarning_(
const std::string& msg);
172 double oil_rate_,
double gas_rate_,
double alq_,
double min_eco_grad_,
173 double oil_target_,
double gas_target_,
174 std::optional<double> max_glift_) :
180 min_eco_grad{min_eco_grad_},
181 oil_target{oil_target_},
182 gas_target{gas_target_},
183 max_glift{max_glift_},
191 const double min_eco_grad;
192 const double oil_target;
193 const double gas_target;
194 std::optional<double> max_glift;
197 void addOrRemoveALQincrement(
198 GradMap &grad_map,
const std::string& well_name,
bool add);
199 bool checkALQlimit();
200 bool checkEcoGradient(
const std::string& well_name,
double eco_grad);
201 bool checkGasTarget();
202 bool checkOilTarget();
203 void updateRates(
const std::string& name);
Definition: DeferredLogger.hpp:57
Definition: GasLiftCommon.hpp:32
Definition: GasLiftSingleWellGeneric.hpp:52
Definition: GasLiftStage2.hpp:48
Definition: GasLiftWellState.hpp:29
Definition: WellInterfaceGeneric.hpp:51
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Definition: GasLiftSingleWellGeneric.hpp:64
Definition: GasLiftStage2.hpp:138
Definition: GasLiftStage2.hpp:170