80 using Status = WellStatus;
85 using InjMultMode = InjMult::InjMultMode;
92 using InjectorCMode = WellInjectorCMode;
99 using ProducerCMode = WellProducerCMode;
101 using WELTARGCMode = WellWELTARGCMode;
103 using GuideRateTarget = WellGuideRateTarget;
105 using GasInflowEquation = WellGasInflowEquation;
110 GuideRateTarget guide_phase;
116 result.available =
true;
117 result.guide_rate = 1.0;
118 result.guide_phase = GuideRateTarget::COMB;
119 result.scale_factor = 2.0;
125 return available == data.available &&
126 guide_rate == data.guide_rate &&
127 guide_phase == data.guide_phase &&
128 scale_factor == data.scale_factor;
131 template<
class Serializer>
134 serializer(available);
135 serializer(guide_rate);
136 serializer(guide_phase);
137 serializer(scale_factor);
150 double bhp_hist_limit = 0.0;
151 double thp_hist_limit = 0.0;
157 int injectionControls;
158 InjectorType injectorType;
159 InjectorCMode controlMode;
171 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
180 const double bhp_def,
181 bool availableForGroupControl,
182 const std::string& well_name,
192 const double bhp_def,
193 const bool is_producer,
194 const std::string& well_name,
197 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
198 if (injectionControls &
static_cast<int>(controlModeArg))
204 void dropInjectionControl(InjectorCMode controlModeArg) {
205 auto int_arg =
static_cast<int>(controlModeArg);
206 if ((injectionControls & int_arg) != 0)
207 injectionControls -= int_arg;
210 void addInjectionControl(InjectorCMode controlModeArg) {
211 auto int_arg =
static_cast<int>(controlModeArg);
212 if ((injectionControls & int_arg) == 0)
213 injectionControls += int_arg;
216 void clearControls();
218 void resetDefaultHistoricalBHPLimit();
219 void resetBHPLimit();
220 void setBHPLimit(
const double limit);
223 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
225 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
227 template<
class Serializer>
231 serializer(surfaceInjectionRate);
232 serializer(reservoirInjectionRate);
233 serializer(BHPTarget);
234 serializer(THPTarget);
235 serializer(bhp_hist_limit);
236 serializer(thp_hist_limit);
239 serializer(VFPTableNumber);
240 serializer(predictionMode);
241 serializer(injectionControls);
242 serializer(injectorType);
243 serializer(controlMode);
265 double bhp_hist_limit = 0.0;
266 double thp_hist_limit = 0.0;
267 bool bhp_hist_limit_defaulted =
true;
272 int VFPTableNumber = 0;
273 bool predictionMode =
false;
274 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
275 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
285 bool hasProductionControl(ProducerCMode controlModeArg)
const {
286 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
289 void dropProductionControl(ProducerCMode controlModeArg) {
290 if (hasProductionControl(controlModeArg))
291 m_productionControls -=
static_cast<int>(controlModeArg);
294 void addProductionControl(ProducerCMode controlModeArg) {
295 if (! hasProductionControl(controlModeArg))
296 m_productionControls +=
static_cast<int>(controlModeArg);
300 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
309 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
310 const double bhp_def,
312 const std::string& well,
321 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
322 const double bhp_def,
325 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
326 void resetDefaultBHPLimit();
327 void clearControls();
330 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
333 void setBHPLimit(
const double limit);
334 int productionControls()
const {
return this->m_productionControls; }
335 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
337 template<
class Serializer>
342 serializer(WaterRate);
344 serializer(LiquidRate);
345 serializer(ResVRate);
346 serializer(BHPTarget);
347 serializer(THPTarget);
348 serializer(ALQValue);
349 serializer(bhp_hist_limit);
350 serializer(thp_hist_limit);
353 serializer(VFPTableNumber);
354 serializer(predictionMode);
355 serializer(controlMode);
356 serializer(whistctl_cmode);
357 serializer(m_productionControls);
361 int m_productionControls = 0;
365 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
369 double getBHPLimit()
const;
372 static int eclipseControlMode(
const Well::InjectorCMode imode,
373 const InjectorType itype);
375 static int eclipseControlMode(
const Well::ProducerCMode pmode);
377 static int eclipseControlMode(
const Well& well,
382 Well(
const std::string& wname,
383 const std::string& gname,
384 std::size_t init_step,
385 std::size_t insert_index,
388 const std::optional<double>& ref_depth,
390 ProducerCMode whistctl_cmode,
391 Connection::Order ordering,
393 double udq_undefined,
398 GasInflowEquation inflow_eq);
402 int rst_whistctl_cmode,
405 double udq_undefined);
407 static Well serializationTestObject();
409 bool isMultiSegment()
const;
410 bool isAvailableForGroupControl()
const;
411 double getGuideRate()
const;
412 GuideRateTarget getGuideRatePhase()
const;
413 GuideRateTarget getRawGuideRatePhase()
const;
414 double getGuideRateScalingFactor()
const;
416 bool hasBeenDefined(std::size_t timeStep)
const;
417 std::size_t firstTimeStep()
const;
419 bool predictionMode()
const;
420 bool isProducer()
const;
421 bool isInjector()
const;
422 InjectorCMode injection_cmode()
const;
423 ProducerCMode production_cmode()
const;
424 InjectorType injectorType()
const;
425 std::size_t seqIndex()
const;
426 bool getAutomaticShutIn()
const;
427 bool getAllowCrossFlow()
const;
428 const std::string& name()
const;
429 const std::vector<std::string>& wListNames()
const;
430 int getHeadI()
const;
431 int getHeadJ()
const;
432 double getWPaveRefDepth()
const;
433 bool hasRefDepth()
const;
434 double getRefDepth()
const;
435 double getDrainageRadius()
const;
436 double getEfficiencyFactor()
const;
437 double getSolventFraction()
const;
438 Status getStatus()
const;
439 const std::string& groupName()
const;
440 Phase getPreferredPhase()
const;
441 InjMultMode getInjMultMode()
const;
442 const InjMult& getWellInjMult()
const;
443 bool aciveWellInjMult()
const;
445 bool hasConnections()
const;
446 const std::vector<const Connection *> getConnections(
int completion)
const;
449 int maxSegmentID()
const;
450 int maxBranchID()
const;
460 const WVFPDP& getWVFPDP()
const;
461 const WVFPEXP& getWVFPEXP()
const;
462 const WDFAC& getWDFAC()
const;
472 double production_rate(
const SummaryState& st, Phase phase)
const;
473 double injection_rate(
const SummaryState& st, Phase phase)
const;
474 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
489 std::map<int, std::vector<Connection>> getCompletions()
const;
495 bool hasCompletion(
int completion)
const;
496 bool updatePrediction(
bool prediction_mode);
497 bool updateAutoShutin(
bool auto_shutin);
498 bool updateCrossFlow(
bool allow_cross_flow);
499 bool updatePVTTable(std::optional<int> pvt_table);
500 bool updateHead(std::optional<int> I, std::optional<int> J);
501 void updateRefDepth();
502 bool updateRefDepth(std::optional<double> ref_dpeth);
503 bool updateDrainageRadius(std::optional<double> drainage_radius);
504 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
505 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
506 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
507 bool updateStatus(Status status);
508 bool updateGroup(
const std::string& group);
509 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
510 bool updateWellGuideRate(
double guide_rate);
511 bool updateAvailableForGroupControl(
bool available);
512 bool updateEfficiencyFactor(
double efficiency_factor);
514 bool updateSolventFraction(
double solvent_fraction);
515 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
516 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
517 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
518 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
519 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
520 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
521 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
522 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
523 bool updateWellProductivityIndex();
524 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
525 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
526 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
527 bool updateWPAVE(
const PAvg& pavg);
528 void updateWPaveRefDepth(
double ref_depth);
529 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
530 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
531 bool updateWDFAC(std::shared_ptr<WDFAC> wdfac);
536 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
538 bool handleCOMPLUMP(
const DeckRecord& record);
543 void setFilterConc(
const UDAValue& conc);
544 double evalFilterConc(
const SummaryState& summary_sate)
const;
545 bool applyGlobalWPIMULT(
double scale_factor);
550 int vfp_table_number()
const;
551 int pvt_table_number()
const;
552 int fip_region_number()
const;
553 GasInflowEquation gas_inflow_equation()
const;
554 bool segmented_density_calculation()
const {
return true; }
556 double temperature()
const;
557 void setWellTemperature(
const double temp);
558 bool hasInjected( )
const;
559 bool hasProduced( )
const;
560 bool updateHasInjected( );
561 bool updateHasProduced();
562 bool cmp_structure(
const Well& other)
const;
563 bool operator==(
const Well& data)
const;
564 bool hasSameConnectionsPointers(
const Well& other)
const;
565 void setInsertIndex(std::size_t index);
566 double convertDeckPI(
double deckPI)
const;
567 void applyWellProdIndexScaling(
const double scalingFactor,
568 std::vector<bool>& scalingApplicable);
569 const PAvg& pavg()
const;
571 template<
class Serializer>
575 serializer(group_name);
576 serializer(init_step);
577 serializer(insert_index);
580 serializer(ref_depth);
581 serializer(wpave_ref_depth);
582 serializer(unit_system);
583 serializer(udq_undefined);
585 serializer(drainage_radius);
586 serializer(allow_cross_flow);
587 serializer(automatic_shutin);
588 serializer(pvt_table);
589 serializer(gas_inflow);
591 serializer(guide_rate);
592 serializer(efficiency_factor);
593 serializer(solvent_fraction);
594 serializer(has_produced);
595 serializer(has_injected);
596 serializer(prediction_mode);
597 serializer(derive_refdepth_from_conns_);
598 serializer(econ_limits);
599 serializer(foam_properties);
600 serializer(polymer_properties);
601 serializer(micp_properties);
602 serializer(brine_properties);
603 serializer(tracer_properties);
604 serializer(connections);
605 serializer(production);
606 serializer(injection);
607 serializer(segments);
612 serializer(well_temperature);
613 serializer(inj_mult_mode);
614 serializer(well_inj_mult);
615 serializer(m_filter_concentration);
619 void switchToInjector();
620 void switchToProducer();
622 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
625 std::string group_name;
626 std::size_t init_step;
627 std::size_t insert_index;
630 std::optional<double> ref_depth;
631 std::optional<double> wpave_ref_depth;
632 double drainage_radius;
633 bool allow_cross_flow;
634 bool automatic_shutin;
636 GasInflowEquation gas_inflow = GasInflowEquation::STD;
637 UnitSystem unit_system;
638 double udq_undefined;
640 WellGuideRate guide_rate;
641 double efficiency_factor;
642 double solvent_fraction;
643 bool has_produced =
false;
644 bool has_injected =
false;
645 bool prediction_mode =
true;
646 bool derive_refdepth_from_conns_ {
true };
648 std::shared_ptr<WellEconProductionLimits> econ_limits;
649 std::shared_ptr<WellFoamProperties> foam_properties;
650 std::shared_ptr<WellPolymerProperties> polymer_properties;
651 std::shared_ptr<WellMICPProperties> micp_properties;
652 std::shared_ptr<WellBrineProperties> brine_properties;
653 std::shared_ptr<WellTracerProperties> tracer_properties;
654 std::shared_ptr<WellConnections> connections;
655 std::shared_ptr<WellProductionProperties> production;
656 std::shared_ptr<WellInjectionProperties> injection;
657 std::shared_ptr<WellSegments> segments;
658 std::shared_ptr<WVFPDP> wvfpdp;
659 std::shared_ptr<WVFPEXP> wvfpexp;
660 std::shared_ptr<WDFAC> wdfac;
664 double well_temperature;
665 InjMultMode inj_mult_mode = InjMultMode::NONE;
666 std::optional<InjMult> well_inj_mult;
667 UDAValue m_filter_concentration;