22 template<
typename TypeTag>
23 GasLiftSingleWell<TypeTag>::
24 GasLiftSingleWell(
const WellInterface<TypeTag> &well,
25 const Simulator &ebos_simulator,
26 const SummaryState &summary_state,
27 DeferredLogger &deferred_logger,
28 WellState &well_state,
29 const GroupState &group_state,
30 GasLiftGroupInfo &group_info,
31 GLiftSyncGroups &sync_groups,
32 const Parallel::Communication& comm,
37 : GasLiftSingleWellGeneric(
45 ebos_simulator.vanguard().schedule(),
46 ebos_simulator.episodeIndex(),
51 , ebos_simulator_{ebos_simulator}
54 const auto& gl_well = *gl_well_;
55 if(useFixedAlq_(gl_well)) {
56 updateWellStateAlqFixedValue_(gl_well);
57 this->optimize_ =
false;
60 setAlqMaxRate_(gl_well);
61 this->optimize_ =
true;
64 setupPhaseVariables_();
69 this->orig_alq_ = this->well_state_.getALQ(this->well_name_);
71 setAlqMinRate_(gl_well);
75 this->alpha_w_ = gl_well.weight_factor();
76 if (this->alpha_w_ <= 0 ) {
77 displayWarning_(
"Nonpositive value for alpha_w ignored");
87 this->alpha_g_ = gl_well.inc_weight_factor();
91 this->max_iterations_ = 1000;
99 template<
typename TypeTag>
100 GasLiftSingleWellGeneric::BasicRates
101 GasLiftSingleWell<TypeTag>::
102 computeWellRates_(
double bhp,
bool bhp_is_limited,
bool debug_output )
const
104 std::vector<double> potentials(NUM_PHASES, 0.0);
105 this->well_.computeWellRatesWithBhp(
106 this->ebos_simulator_, bhp, potentials, this->deferred_logger_);
108 const std::string msg = fmt::format(
"computed well potentials given bhp {}, "
109 "oil: {}, gas: {}, water: {}", bhp,
110 -potentials[this->oil_pos_], -potentials[this->gas_pos_],
111 -potentials[this->water_pos_]);
112 displayDebugMessage_(msg);
115 for (
auto& potential : potentials) {
116 potential = std::min(0.0, potential);
118 return {-potentials[this->oil_pos_],
119 -potentials[this->gas_pos_],
120 -potentials[this->water_pos_],
125 template<
typename TypeTag>
126 std::optional<double>
127 GasLiftSingleWell<TypeTag>::
128 computeBhpAtThpLimit_(
double alq)
const
130 auto bhp_at_thp_limit = this->well_.computeBhpAtThpLimitProdWithAlq(
131 this->ebos_simulator_,
132 this->summary_state_,
133 this->deferred_logger_,
135 if (bhp_at_thp_limit) {
136 if (*bhp_at_thp_limit < this->controls_.bhp_limit) {
137 const std::string msg = fmt::format(
138 "Computed bhp ({}) from thp limit is below bhp limit ({}), (ALQ = {})."
139 " Using bhp limit instead",
140 *bhp_at_thp_limit, this->controls_.bhp_limit, alq);
141 displayDebugMessage_(msg);
142 bhp_at_thp_limit = this->controls_.bhp_limit;
147 const std::string msg = fmt::format(
148 "Failed in getting converged bhp potential from thp limit (ALQ = {})", alq);
149 displayDebugMessage_(msg);
151 return bhp_at_thp_limit;
154 template<
typename TypeTag>
156 GasLiftSingleWell<TypeTag>::
157 setupPhaseVariables_()
159 const auto& pu = this->phase_usage_;
160 bool num_phases_ok = (pu.num_phases == 3);
161 if (pu.num_phases == 2) {
172 if ( pu.phase_used[BlackoilPhases::Aqua] == 1
173 && pu.phase_used[BlackoilPhases::Liquid] == 1
174 && pu.phase_used[BlackoilPhases::Vapour] == 0)
176 num_phases_ok =
true;
179 throw std::logic_error(
"Two-phase gas lift optimization only supported"
180 " for oil and water");
183 assert(num_phases_ok);
184 this->oil_pos_ = pu.phase_pos[Oil];
185 this->gas_pos_ = pu.phase_pos[Gas];
186 this->water_pos_ = pu.phase_pos[Water];
189 template<
typename TypeTag>
191 GasLiftSingleWell<TypeTag>::
192 setAlqMaxRate_(
const GasLiftOpt::Well &well)
194 auto& max_alq_optional = well.max_rate();
195 if (max_alq_optional) {
198 this->max_alq_ = *max_alq_optional;
204 const auto& table = well_.vfpProperties()->getProd()->getTable(
205 this->controls_.vfp_table_number);
206 const auto& alq_values = table.getALQAxis();
209 this->max_alq_ = alq_values.back();
213 template<
typename TypeTag>
215 GasLiftSingleWell<TypeTag>::
216 checkThpControl_()
const
218 const int well_index = this->well_state_.index(this->well_name_).value();
219 const Well::ProducerCMode& control_mode =
220 this->well_state_.well(well_index).production_cmode;
221 bool thp_control = control_mode == Well::ProducerCMode::THP;
222 const WellInterfaceGeneric &well = getWell();
223 thp_control = thp_control || well.thpLimitViolatedButNotSwitched();
226 displayDebugMessage_(
"Well is not under THP control, skipping iteration..");
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
PhaseUsage phaseUsage(const Phases &phases)
Determine the active phases.
Definition: phaseUsageFromDeck.cpp:37