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;
107 void flag_lgr_well();
108 void set_lgr_well_tag(
const std::string& lgr_tag_name);
109 bool is_lgr_well()
const;
110 std::optional<std::string> get_lgr_well_tag()
const;
114 GuideRateTarget guide_phase;
120 result.available =
true;
121 result.guide_rate = 1.0;
122 result.guide_phase = GuideRateTarget::COMB;
123 result.scale_factor = 2.0;
129 return available == data.available &&
130 guide_rate == data.guide_rate &&
131 guide_phase == data.guide_phase &&
132 scale_factor == data.scale_factor;
135 template<
class Serializer>
138 serializer(available);
139 serializer(guide_rate);
140 serializer(guide_phase);
141 serializer(scale_factor);
154 double bhp_hist_limit = 0.0;
155 double thp_hist_limit = 0.0;
161 int injectionControls;
162 InjectorType injectorType;
163 InjectorCMode controlMode;
168 std::optional<std::vector<double>> gas_inj_composition{};
178 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
187 const double bhp_def,
188 bool availableForGroupControl,
189 const std::string& well_name,
200 const int vfp_table_nr,
201 const double bhp_def,
202 const bool is_producer,
203 const std::string& well_name,
206 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
207 if (injectionControls &
static_cast<int>(controlModeArg))
213 void dropInjectionControl(InjectorCMode controlModeArg) {
214 auto int_arg =
static_cast<int>(controlModeArg);
215 if ((injectionControls & int_arg) != 0)
216 injectionControls -= int_arg;
219 void addInjectionControl(InjectorCMode controlModeArg) {
220 auto int_arg =
static_cast<int>(controlModeArg);
221 if ((injectionControls & int_arg) == 0)
222 injectionControls += int_arg;
225 void clearControls();
227 void resetDefaultHistoricalBHPLimit();
228 void resetBHPLimit();
229 void setBHPLimit(
const double limit);
232 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
234 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
236 void setGasInjComposition(
const std::vector<double>& composition);
237 const std::vector<double>& gasInjComposition()
const;
239 template<
class Serializer>
243 serializer(surfaceInjectionRate);
244 serializer(reservoirInjectionRate);
245 serializer(BHPTarget);
246 serializer(THPTarget);
247 serializer(bhp_hist_limit);
248 serializer(thp_hist_limit);
251 serializer(VFPTableNumber);
252 serializer(predictionMode);
253 serializer(injectionControls);
254 serializer(injectorType);
255 serializer(controlMode);
257 serializer(gas_inj_composition);
278 double bhp_hist_limit = 0.0;
279 double thp_hist_limit = 0.0;
280 bool bhp_hist_limit_defaulted =
true;
285 int VFPTableNumber = 0;
286 bool predictionMode =
false;
287 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
288 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
298 bool hasProductionControl(ProducerCMode controlModeArg)
const {
299 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
302 void dropProductionControl(ProducerCMode controlModeArg) {
303 if (hasProductionControl(controlModeArg))
304 m_productionControls -=
static_cast<int>(controlModeArg);
307 void addProductionControl(ProducerCMode controlModeArg) {
308 if (! hasProductionControl(controlModeArg))
309 m_productionControls +=
static_cast<int>(controlModeArg);
313 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
323 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
324 const int vfp_table_nr,
325 const double bhp_def,
327 const std::string& well,
337 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
338 const int vfp_table_nr,
339 const double bhp_def,
342 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
343 void resetDefaultBHPLimit();
344 void clearControls();
347 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
350 void setBHPLimit(
const double limit);
351 int productionControls()
const {
return this->m_productionControls; }
352 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
354 template<
class Serializer>
359 serializer(WaterRate);
361 serializer(LiquidRate);
362 serializer(ResVRate);
363 serializer(BHPTarget);
364 serializer(THPTarget);
365 serializer(ALQValue);
366 serializer(bhp_hist_limit);
367 serializer(thp_hist_limit);
370 serializer(VFPTableNumber);
371 serializer(predictionMode);
372 serializer(controlMode);
373 serializer(whistctl_cmode);
374 serializer(m_productionControls);
378 int m_productionControls = 0;
382 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const int vfp_table_nr,
const UnitSystem& unit_system,
const DeckRecord& record);
386 double getBHPLimit()
const;
389 static int eclipseControlMode(
const Well::InjectorCMode imode,
390 const InjectorType itype);
392 static int eclipseControlMode(
const Well::ProducerCMode pmode);
394 static int eclipseControlMode(
const Well& well,
398 Well(
const std::string& wname,
399 const std::string& gname,
400 std::size_t init_step,
401 std::size_t insert_index,
404 const std::optional<double>& ref_depth,
406 ProducerCMode whistctl_cmode,
407 Connection::Order ordering,
409 double udq_undefined,
414 GasInflowEquation inflow_eq,
415 bool temp_option =
false);
419 int rst_whistctl_cmode,
422 double udq_undefined,
423 const std::optional<VFPProdTable::ALQ_TYPE>& alq_type);
425 static Well serializationTestObject();
427 bool isMultiSegment()
const;
428 bool isAvailableForGroupControl()
const;
429 double getGuideRate()
const;
430 GuideRateTarget getGuideRatePhase()
const;
431 GuideRateTarget getRawGuideRatePhase()
const;
432 double getGuideRateScalingFactor()
const;
434 bool hasBeenDefined(std::size_t timeStep)
const;
435 std::size_t firstTimeStep()
const;
437 bool predictionMode()
const;
438 bool isProducer()
const;
439 bool isInjector()
const;
440 InjectorCMode injection_cmode()
const;
441 ProducerCMode production_cmode()
const;
442 InjectorType injectorType()
const;
443 std::size_t seqIndex()
const;
444 bool getAutomaticShutIn()
const;
445 bool getAllowCrossFlow()
const;
446 const std::string& name()
const;
447 const std::vector<std::string>& wListNames()
const;
448 int getHeadI()
const;
449 int getHeadJ()
const;
450 double getWPaveRefDepth()
const;
451 bool hasRefDepth()
const;
452 double getRefDepth()
const;
453 double getDrainageRadius()
const;
454 double getEfficiencyFactor(
bool network =
false)
const;
455 double getSolventFraction()
const;
456 Status getStatus()
const;
457 const std::string& groupName()
const;
458 Phase getPreferredPhase()
const;
459 InjMultMode getInjMultMode()
const;
460 const InjMult& getWellInjMult()
const;
461 bool aciveWellInjMult()
const;
463 bool hasConnections()
const;
464 std::vector<const Connection *> getConnections(
int completion)
const;
468 int maxSegmentID()
const;
469 int maxBranchID()
const;
479 const WVFPDP& getWVFPDP()
const;
480 const WVFPEXP& getWVFPEXP()
const;
481 const WDFAC& getWDFAC()
const;
491 double production_rate(
const SummaryState& st, Phase phase)
const;
492 double injection_rate(
const SummaryState& st, Phase phase)
const;
493 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
508 std::map<int, std::vector<Connection>> getCompletions()
const;
514 bool hasCompletion(
int completion)
const;
515 bool updatePrediction(
bool prediction_mode);
516 bool updateAutoShutin(
bool auto_shutin);
517 bool updateCrossFlow(
bool allow_cross_flow);
518 bool updatePVTTable(std::optional<int> pvt_table);
519 bool updateHead(std::optional<int> I, std::optional<int> J);
520 void updateRefDepth();
521 bool updateRefDepth(std::optional<double> ref_dpeth);
522 bool updateDrainageRadius(std::optional<double> drainage_radius);
523 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
524 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
525 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
526 bool updateStatus(Status status);
527 bool updateGroup(
const std::string& group);
528 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
529 bool updateWellGuideRate(
double guide_rate);
530 bool updateAvailableForGroupControl(
bool available);
531 bool updateEfficiencyFactor(
double efficiency_factor,
bool use_efficiency_in_network);
533 bool updateSolventFraction(
double solvent_fraction);
534 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
535 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
536 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
537 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
538 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
539 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
540 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
541 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
542 bool updateWellProductivityIndex();
543 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
544 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
545 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
546 bool updateWPAVE(
const PAvg& pavg);
549 void updateWPaveRefDepth(
double ref_depth);
550 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
551 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
552 bool updateWDFAC(std::shared_ptr<WDFAC> wdfac);
556 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
558 bool handleCOMPLUMP(
const DeckRecord& record);
563 void setFilterConc(
const UDAValue& conc);
564 double evalFilterConc(
const SummaryState& summary_sate)
const;
565 bool applyGlobalWPIMULT(
double scale_factor);
570 int vfp_table_number()
const;
571 int pvt_table_number()
const;
572 int fip_region_number()
const;
573 GasInflowEquation gas_inflow_equation()
const;
574 bool segmented_density_calculation()
const {
return true; }
576 double inj_temperature()
const;
577 bool hasInjTemperature()
const;
578 void setWellInjTemperature(
const double temp);
579 bool hasInjected( )
const;
580 bool hasProduced( )
const;
581 bool updateHasInjected( );
582 bool updateHasProduced();
583 bool cmp_structure(
const Well& other)
const;
584 bool operator==(
const Well& data)
const;
585 bool hasSameConnectionsPointers(
const Well& other)
const;
586 void setInsertIndex(std::size_t index);
587 double convertDeckPI(
double deckPI)
const;
588 void applyWellProdIndexScaling(
const double scalingFactor,
589 std::vector<bool>& scalingApplicable);
590 const PAvg& pavg()
const;
595 template<
class Serializer>
599 serializer(group_name);
600 serializer(init_step);
601 serializer(insert_index);
604 serializer(ref_depth);
605 serializer(wpave_ref_depth);
606 serializer(udq_undefined);
608 serializer(drainage_radius);
609 serializer(allow_cross_flow);
610 serializer(automatic_shutin);
611 serializer(pvt_table);
612 serializer(gas_inflow);
614 serializer(ref_type);
616 serializer(guide_rate);
617 serializer(efficiency_factor);
618 serializer(use_efficiency_in_network);
619 serializer(solvent_fraction);
620 serializer(has_produced);
621 serializer(has_injected);
622 serializer(prediction_mode);
623 serializer(derive_refdepth_from_conns_);
624 serializer(econ_limits);
625 serializer(foam_properties);
626 serializer(polymer_properties);
627 serializer(micp_properties);
628 serializer(brine_properties);
629 serializer(tracer_properties);
630 serializer(connections);
631 serializer(production);
632 serializer(injection);
633 serializer(segments);
638 serializer(well_inj_temperature);
639 serializer(default_well_inj_temperature);
640 serializer(inj_mult_mode);
641 serializer(well_inj_mult);
642 serializer(m_filter_concentration);
646 enum class WellRefinementType {
651 void switchToInjector();
652 void switchToProducer();
654 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
657 std::string group_name{};
659 std::size_t init_step{};
660 std::size_t insert_index{};
663 std::optional<double> ref_depth{};
664 std::optional<double> wpave_ref_depth{};
665 double drainage_radius{};
666 bool allow_cross_flow{
false};
667 bool automatic_shutin{
false};
672 GasInflowEquation gas_inflow = GasInflowEquation::STD;
674 const UnitSystem* unit_system{
nullptr};
675 double udq_undefined{};
677 WellRefinementType ref_type{WellRefinementType::STANDARD};
678 std::string lgr_tag{};
679 WellGuideRate guide_rate{};
680 double efficiency_factor{};
681 bool use_efficiency_in_network{};
682 double solvent_fraction{};
683 bool has_produced =
false;
684 bool has_injected =
false;
685 bool prediction_mode =
true;
686 bool derive_refdepth_from_conns_ {
true };
688 std::shared_ptr<WellEconProductionLimits> econ_limits{};
689 std::shared_ptr<WellFoamProperties> foam_properties{};
690 std::shared_ptr<WellPolymerProperties> polymer_properties{};
691 std::shared_ptr<WellMICPProperties> micp_properties{};
692 std::shared_ptr<WellBrineProperties> brine_properties{};
693 std::shared_ptr<WellTracerProperties> tracer_properties{};
697 std::shared_ptr<WellConnections> connections{};
699 std::shared_ptr<WellProductionProperties> production{};
700 std::shared_ptr<WellInjectionProperties> injection{};
701 std::shared_ptr<WellSegments> segments{};
702 std::shared_ptr<WVFPDP> wvfpdp{};
703 std::shared_ptr<WVFPEXP> wvfpexp{};
704 std::shared_ptr<WDFAC> wdfac{};
706 Status status{Status::AUTO};
708 std::optional<double> well_inj_temperature{};
709 std::optional<double> default_well_inj_temperature{std::nullopt};
710 InjMultMode inj_mult_mode = InjMultMode::NONE;
711 std::optional<InjMult> well_inj_mult{};
712 UDAValue m_filter_concentration{};