78 using Status = WellStatus;
83 using InjMultMode = InjMult::InjMultMode;
90 using InjectorCMode = WellInjectorCMode;
97 using ProducerCMode = WellProducerCMode;
99 using WELTARGCMode = WellWELTARGCMode;
101 using GuideRateTarget = WellGuideRateTarget;
103 using GasInflowEquation = WellGasInflowEquation;
108 GuideRateTarget guide_phase;
114 result.available =
true;
115 result.guide_rate = 1.0;
116 result.guide_phase = GuideRateTarget::COMB;
117 result.scale_factor = 2.0;
123 return available == data.available &&
124 guide_rate == data.guide_rate &&
125 guide_phase == data.guide_phase &&
126 scale_factor == data.scale_factor;
129 template<
class Serializer>
132 serializer(available);
133 serializer(guide_rate);
134 serializer(guide_phase);
135 serializer(scale_factor);
148 double bhp_hist_limit = 0.0;
149 double thp_hist_limit = 0.0;
155 int injectionControls;
156 InjectorType injectorType;
157 InjectorCMode controlMode;
169 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
170 void handleWCONINJE(
const DeckRecord& record,
bool availableForGroupControl,
const std::string& well_name);
171 void handleWCONINJH(
const DeckRecord& record,
const bool is_producer,
const std::string& well_name,
const KeywordLocation& loc);
172 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
173 if (injectionControls &
static_cast<int>(controlModeArg))
179 void dropInjectionControl(InjectorCMode controlModeArg) {
180 auto int_arg =
static_cast<int>(controlModeArg);
181 if ((injectionControls & int_arg) != 0)
182 injectionControls -= int_arg;
185 void addInjectionControl(InjectorCMode controlModeArg) {
186 auto int_arg =
static_cast<int>(controlModeArg);
187 if ((injectionControls & int_arg) == 0)
188 injectionControls += int_arg;
191 void clearControls();
193 void resetDefaultHistoricalBHPLimit();
194 void resetBHPLimit();
195 void setBHPLimit(
const double limit);
198 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
200 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
202 template<
class Serializer>
206 serializer(surfaceInjectionRate);
207 serializer(reservoirInjectionRate);
208 serializer(BHPTarget);
209 serializer(THPTarget);
210 serializer(bhp_hist_limit);
211 serializer(thp_hist_limit);
214 serializer(VFPTableNumber);
215 serializer(predictionMode);
216 serializer(injectionControls);
217 serializer(injectorType);
218 serializer(controlMode);
240 double bhp_hist_limit = 0.0;
241 double thp_hist_limit = 0.0;
246 int VFPTableNumber = 0;
247 bool predictionMode =
false;
248 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
249 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
259 bool hasProductionControl(ProducerCMode controlModeArg)
const {
260 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
263 void dropProductionControl(ProducerCMode controlModeArg) {
264 if (hasProductionControl(controlModeArg))
265 m_productionControls -=
static_cast<int>(controlModeArg);
268 void addProductionControl(ProducerCMode controlModeArg) {
269 if (! hasProductionControl(controlModeArg))
270 m_productionControls +=
static_cast<int>(controlModeArg);
274 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
275 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const std::string& well,
const DeckRecord& record);
276 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
277 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
278 void resetDefaultBHPLimit();
279 void clearControls();
282 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
285 void setBHPLimit(
const double limit);
286 int productionControls()
const {
return this->m_productionControls; }
287 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
289 template<
class Serializer>
294 serializer(WaterRate);
296 serializer(LiquidRate);
297 serializer(ResVRate);
298 serializer(BHPTarget);
299 serializer(THPTarget);
300 serializer(ALQValue);
301 serializer(bhp_hist_limit);
302 serializer(thp_hist_limit);
305 serializer(VFPTableNumber);
306 serializer(predictionMode);
307 serializer(controlMode);
308 serializer(whistctl_cmode);
309 serializer(m_productionControls);
313 int m_productionControls = 0;
317 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
321 double getBHPLimit()
const;
324 static int eclipseControlMode(
const Well::InjectorCMode imode,
325 const InjectorType itype);
327 static int eclipseControlMode(
const Well::ProducerCMode pmode);
329 static int eclipseControlMode(
const Well& well,
334 Well(
const std::string& wname,
335 const std::string& gname,
336 std::size_t init_step,
337 std::size_t insert_index,
340 const std::optional<double>& ref_depth,
342 ProducerCMode whistctl_cmode,
343 Connection::Order ordering,
345 double udq_undefined,
350 GasInflowEquation inflow_eq);
356 double udq_undefined);
358 static Well serializationTestObject();
360 bool isMultiSegment()
const;
361 bool isAvailableForGroupControl()
const;
362 double getGuideRate()
const;
363 GuideRateTarget getGuideRatePhase()
const;
364 GuideRateTarget getRawGuideRatePhase()
const;
365 double getGuideRateScalingFactor()
const;
367 bool hasBeenDefined(std::size_t timeStep)
const;
368 std::size_t firstTimeStep()
const;
370 bool predictionMode()
const;
371 bool isProducer()
const;
372 bool isInjector()
const;
373 InjectorCMode injection_cmode()
const;
374 ProducerCMode production_cmode()
const;
375 InjectorType injectorType()
const;
376 std::size_t seqIndex()
const;
377 bool getAutomaticShutIn()
const;
378 bool getAllowCrossFlow()
const;
379 const std::string& name()
const;
380 const std::vector<std::string>& wListNames()
const;
381 int getHeadI()
const;
382 int getHeadJ()
const;
383 double getWPaveRefDepth()
const;
384 bool hasRefDepth()
const;
385 double getRefDepth()
const;
386 double getDrainageRadius()
const;
387 double getEfficiencyFactor()
const;
388 double getSolventFraction()
const;
389 Status getStatus()
const;
390 const std::string& groupName()
const;
391 Phase getPreferredPhase()
const;
392 InjMultMode getInjMultMode()
const;
393 const InjMult& getWellInjMult()
const;
394 bool aciveWellInjMult()
const;
396 bool hasConnections()
const;
397 const std::vector<const Connection *> getConnections(
int completion)
const;
400 int maxSegmentID()
const;
401 int maxBranchID()
const;
411 const WVFPDP& getWVFPDP()
const;
412 const WVFPEXP& getWVFPEXP()
const;
421 double production_rate(
const SummaryState& st, Phase phase)
const;
422 double injection_rate(
const SummaryState& st, Phase phase)
const;
423 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
438 std::map<int, std::vector<Connection>> getCompletions()
const;
444 bool hasCompletion(
int completion)
const;
445 bool updatePrediction(
bool prediction_mode);
446 bool updateAutoShutin(
bool auto_shutin);
447 bool updateCrossFlow(
bool allow_cross_flow);
448 bool updatePVTTable(
int pvt_table);
449 bool updateHead(
int I,
int J);
450 void updateRefDepth();
451 bool updateRefDepth(
const std::optional<double>& ref_dpeth);
452 bool updateDrainageRadius(
double drainage_radius);
453 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
454 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
455 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
456 bool updateStatus(Status status);
457 bool updateGroup(
const std::string& group);
458 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
459 bool updateWellGuideRate(
double guide_rate);
460 bool updateEfficiencyFactor(
double efficiency_factor);
461 bool updateSolventFraction(
double solvent_fraction);
462 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
463 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
464 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
465 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
466 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
467 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
468 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
469 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
470 bool updateWellProductivityIndex();
471 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
472 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
473 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
474 bool updateWPAVE(
const PAvg& pavg);
475 void updateWPaveRefDepth(
double ref_depth);
476 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
477 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
481 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
482 bool handleCSKINConnections(
const DeckRecord& record);
483 bool handleCOMPLUMP(
const DeckRecord& record);
488 void setFilterConc(
const UDAValue& conc);
489 double evalFilterConc(
const SummaryState& summary_sate)
const;
490 bool applyGlobalWPIMULT(
double scale_factor);
495 int vfp_table_number()
const;
496 int pvt_table_number()
const;
497 int fip_region_number()
const;
498 GasInflowEquation gas_inflow_equation()
const;
499 bool segmented_density_calculation()
const {
return true; }
500 double alq_value()
const;
501 double temperature()
const;
502 void setWellTemperature(
const double temp);
503 bool hasInjected( )
const;
504 bool hasProduced( )
const;
505 bool updateHasInjected( );
506 bool updateHasProduced();
507 bool cmp_structure(
const Well& other)
const;
508 bool operator==(
const Well& data)
const;
509 bool hasSameConnectionsPointers(
const Well& other)
const;
510 void setInsertIndex(std::size_t index);
511 double convertDeckPI(
double deckPI)
const;
512 void applyWellProdIndexScaling(
const double scalingFactor,
513 std::vector<bool>& scalingApplicable);
514 const PAvg& pavg()
const;
516 template<
class Serializer>
520 serializer(group_name);
521 serializer(init_step);
522 serializer(insert_index);
525 serializer(ref_depth);
526 serializer(wpave_ref_depth);
527 serializer(unit_system);
528 serializer(udq_undefined);
530 serializer(drainage_radius);
531 serializer(allow_cross_flow);
532 serializer(automatic_shutin);
533 serializer(pvt_table);
534 serializer(gas_inflow);
536 serializer(guide_rate);
537 serializer(efficiency_factor);
538 serializer(solvent_fraction);
539 serializer(has_produced);
540 serializer(has_injected);
541 serializer(prediction_mode);
542 serializer(econ_limits);
543 serializer(foam_properties);
544 serializer(polymer_properties);
545 serializer(micp_properties);
546 serializer(brine_properties);
547 serializer(tracer_properties);
548 serializer(connections);
549 serializer(production);
550 serializer(injection);
551 serializer(segments);
555 serializer(well_temperature);
556 serializer(inj_mult_mode);
557 serializer(well_inj_mult);
558 serializer(m_filter_concentration);
562 void switchToInjector();
563 void switchToProducer();
565 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
568 std::string group_name;
569 std::size_t init_step;
570 std::size_t insert_index;
573 std::optional<double> ref_depth;
574 std::optional<double> wpave_ref_depth;
575 double drainage_radius;
576 bool allow_cross_flow;
577 bool automatic_shutin;
579 GasInflowEquation gas_inflow = GasInflowEquation::STD;
580 UnitSystem unit_system;
581 double udq_undefined;
583 WellGuideRate guide_rate;
584 double efficiency_factor;
585 double solvent_fraction;
586 bool has_produced =
false;
587 bool has_injected =
false;
588 bool prediction_mode =
true;
590 std::shared_ptr<WellEconProductionLimits> econ_limits;
591 std::shared_ptr<WellFoamProperties> foam_properties;
592 std::shared_ptr<WellPolymerProperties> polymer_properties;
593 std::shared_ptr<WellMICPProperties> micp_properties;
594 std::shared_ptr<WellBrineProperties> brine_properties;
595 std::shared_ptr<WellTracerProperties> tracer_properties;
596 std::shared_ptr<WellConnections> connections;
597 std::shared_ptr<WellProductionProperties> production;
598 std::shared_ptr<WellInjectionProperties> injection;
599 std::shared_ptr<WellSegments> segments;
600 std::shared_ptr<WVFPDP> wvfpdp;
601 std::shared_ptr<WVFPEXP> wvfpexp;
604 double well_temperature;
605 InjMultMode inj_mult_mode = InjMultMode::NONE;
606 std::optional<InjMult> well_inj_mult;
607 UDAValue m_filter_concentration;