20 #ifndef OPM_GASLIFT_SINGLE_WELL_GENERIC_HEADER_INCLUDED
21 #define OPM_GASLIFT_SINGLE_WELL_GENERIC_HEADER_INCLUDED
23 #include <dune/common/version.hh>
24 #include <dune/common/parallel/mpihelper.hh>
26 #include <opm/core/props/BlackoilPhases.hpp>
28 #include <opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp>
29 #include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
30 #include <opm/simulators/wells/GasLiftGroupInfo.hpp>
43 class GasLiftWellState;
46 class WellInterfaceGeneric;
53 static const int Water = BlackoilPhases::Aqua;
54 static const int Oil = BlackoilPhases::Liquid;
55 static const int Gas = BlackoilPhases::Vapour;
56 static constexpr
double ALQ_EPSILON = 1e-8;
59 using GLiftSyncGroups = std::set<int>;
64 GradInfo(
double grad_,
double new_oil_rate_,
bool oil_is_limited_,
65 double new_gas_rate_,
bool gas_is_limited_,
66 double alq_,
bool alq_is_limited_) :
68 new_oil_rate{new_oil_rate_},
69 oil_is_limited{oil_is_limited_},
70 new_gas_rate{new_gas_rate_},
71 gas_is_limited{gas_is_limited_},
73 alq_is_limited{alq_is_limited_} {}
85 const std::string& name()
const {
return well_name_; }
87 std::optional<GradInfo> calcIncOrDecGradient(
double oil_rate,
double gas_rate,
88 double alq,
bool increase)
const;
90 std::unique_ptr<GasLiftWellState> runOptimize(
const int iteration_idx);
100 const SummaryState& summary_state,
102 const Schedule& schedule,
103 const int report_step_idx,
104 GLiftSyncGroups &sync_groups
113 stop_iteration{
false},
123 std::pair<std::optional<double>,
bool> addOrSubtractAlqIncrement(
double alq);
124 double calcEcoGradient(
double oil_rate,
double new_oil_rate,
125 double gas_rate,
double new_gas_rate);
126 bool checkAlqOutsideLimits(
double alq,
double oil_rate);
127 bool checkEcoGradient(
double gradient);
128 bool checkGroupALQrateExceeded(
double delta_alq);
129 bool checkGroupTargetsViolated(
double delta_oil,
double delta_gas);
130 std::tuple<double,double,double>
131 reduceALQtoGroupTarget(
double alq,
double oil_rate,
double gas_rate, std::vector<double> &potentials);
132 bool checkNegativeOilRate(
double oil_rate);
133 bool checkThpControl();
134 bool checkOilRateExceedsTarget(
double oil_rate);
135 bool checkRate(
double rate,
double limit,
const std::string &rate_str)
const;
136 bool checkWellRatesViolated(std::vector<double> &potentials);
137 bool computeBhpAtThpLimit(
double alq);
138 void debugShowIterationInfo(
double alq);
139 double getBhpWithLimit();
140 void updateGroupRates(
double delta_oil,
double delta_gas,
double delta_alq);
141 void warn_(std::string msg) {parent.displayWarning_(msg);}
144 std::pair<std::optional<double>,
bool>
145 addOrSubtractAlqIncrement_(
double alq,
bool increase)
const;
147 double calcEcoGradient_(
double oil_rate,
double new_oil_rate,
148 double gas_rate,
double new_gas_rate,
bool increase)
const;
150 bool checkALQequal_(
double alq1,
double alq2)
const;
151 bool checkInitialALQmodified_(
double alq,
double initial_alq)
const;
153 bool checkWellRatesViolated_(std::vector<double>& potentials,
154 const std::function<
bool(
double,
double,
const std::string &)>& callback,
157 virtual std::optional<double> computeBhpAtThpLimit_(
double alq)
const = 0;
158 virtual void computeWellRates_(
double bhp,
159 std::vector<double>& potentials,
160 bool debug_output =
true)
const = 0;
162 bool computeInitialWellRates_(std::vector<double>& potentials);
164 void debugCheckNegativeGradient_(
double grad,
double alq,
double new_alq,
165 double oil_rate,
double new_oil_rate,
double gas_rate,
166 double new_gas_rate,
bool increase)
const;
168 void debugShowAlqIncreaseDecreaseCounts_();
170 void debugShowBhpAlqTable_();
172 void debugShowStartIteration_(
double alq,
bool increase,
double oil_rate);
174 void debugShowTargets_();
176 void displayDebugMessage_(
const std::string& msg)
const;
177 void displayWarning_(
const std::string& warning);
179 std::pair<double, bool> getBhpWithLimit_(
double bhp)
const;
180 std::pair<double, bool> getGasRateWithLimit_(
const std::vector<double>& potentials)
const;
181 std::tuple<double,double,bool,bool>
182 getInitialRatesWithLimit_(
const std::vector<double>& potentials);
183 std::pair<double, bool> getOilRateWithLimit_(
const std::vector<double>& potentials)
const;
185 std::tuple<double,double,bool,bool,double>
186 increaseALQtoPositiveOilRate_(
double alq,
191 std::vector<double>& potentials);
193 std::tuple<double,double,bool,bool,double>
194 increaseALQtoMinALQ_(
double alq,
199 std::vector<double>& potentials);
201 void logSuccess_(
double alq,
202 const int iteration_idx);
203 std::tuple<double,double,double,bool,bool>
204 maybeAdjustALQbeforeOptimizeLoop_(
205 bool increase,
double alq,
double oil_rate,
double gas_rate,
206 bool oil_is_limited,
bool gas_is_limited, std::vector<double> &potentials);
207 std::tuple<double,double,bool,bool,double>
208 reduceALQtoOilTarget_(
double alq,
double oil_rate,
double gas_rate,
209 bool oil_is_limited,
bool gas_is_limited, std::vector<double> &potentials);
211 std::unique_ptr<GasLiftWellState> runOptimize1_();
212 std::unique_ptr<GasLiftWellState> runOptimize2_();
213 std::unique_ptr<GasLiftWellState> runOptimizeLoop_(
bool increase);
215 void setAlqMinRate_(
const GasLiftOpt::Well& well);
217 std::unique_ptr<GasLiftWellState> tryIncreaseLiftGas_();
218 std::unique_ptr<GasLiftWellState> tryDecreaseLiftGas_();
220 void updateWellStateAlqFixedValue_(
const GasLiftOpt::Well& well);
222 bool useFixedAlq_(
const GasLiftOpt::Well& well);
224 void warnMaxIterationsExceeded_();
229 const Well& ecl_well_;
230 const SummaryState& summary_state_;
232 GLiftSyncGroups& sync_groups_;
233 const Well::ProductionControls controls_;
251 std::string well_name_;
253 const GasLiftOpt::Well* gl_well_;
257 bool debug_limit_increase_decrease_;
258 bool debug_abort_if_decrease_and_oil_is_limited_ =
false;
259 bool debug_abort_if_increase_and_gas_is_limited_ =
false;
Definition: DeferredLogger.hpp:57
Definition: GasLiftGroupInfo.hpp:46
Definition: GasLiftSingleWellGeneric.hpp:51
Definition: GroupState.hpp:34
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:26
Definition: GasLiftSingleWellGeneric.hpp:61
Definition: GasLiftSingleWellGeneric.hpp:108