79 using Status = WellStatus;
84 using InjMultMode = InjMult::InjMultMode;
91 using InjectorCMode = WellInjectorCMode;
98 using ProducerCMode = WellProducerCMode;
100 using WELTARGCMode = WellWELTARGCMode;
102 using GuideRateTarget = WellGuideRateTarget;
104 using GasInflowEquation = WellGasInflowEquation;
106 void flag_lgr_well();
107 void set_lgr_well_tag(
const std::string& lgr_tag_name);
108 void setInsertIndexLGR(
const std::size_t index);
109 void setInsertIndexAllLGR(
const std::size_t index);
111 std::size_t seqIndexLGR()
const {
return insert_index_lgr; }
112 std::size_t seqIndexAllLGR()
const {
return insert_index_all_lgr; }
114 bool is_lgr_well()
const;
115 std::optional<std::string> get_lgr_well_tag()
const;
119 GuideRateTarget guide_phase;
125 result.available =
true;
126 result.guide_rate = 1.0;
127 result.guide_phase = GuideRateTarget::COMB;
128 result.scale_factor = 2.0;
134 return available == data.available &&
135 guide_rate == data.guide_rate &&
136 guide_phase == data.guide_phase &&
137 scale_factor == data.scale_factor;
140 template<
class Serializer>
143 serializer(available);
144 serializer(guide_rate);
145 serializer(guide_phase);
146 serializer(scale_factor);
152 struct WellInjectionProperties {
159 double bhp_hist_limit = 0.0;
160 double thp_hist_limit = 0.0;
166 int injectionControls;
167 InjectorType injectorType;
168 InjectorCMode controlMode;
173 std::optional<std::vector<double>> gas_inj_composition{};
175 bool operator==(
const WellInjectionProperties& other)
const;
176 bool operator!=(
const WellInjectionProperties& other)
const;
178 WellInjectionProperties();
179 WellInjectionProperties(
const UnitSystem& units,
const std::string& wname);
181 static WellInjectionProperties serializationTestObject();
183 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
192 const double bhp_def,
193 bool availableForGroupControl,
194 const std::string& well_name,
205 const int vfp_table_nr,
206 const double bhp_def,
207 const bool is_producer,
208 const std::string& well_name,
211 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
212 if (injectionControls &
static_cast<int>(controlModeArg))
218 void dropInjectionControl(InjectorCMode controlModeArg) {
219 auto int_arg =
static_cast<int>(controlModeArg);
220 if ((injectionControls & int_arg) != 0)
221 injectionControls -= int_arg;
224 void addInjectionControl(InjectorCMode controlModeArg) {
225 auto int_arg =
static_cast<int>(controlModeArg);
226 if ((injectionControls & int_arg) == 0)
227 injectionControls += int_arg;
230 void clearControls();
232 void resetDefaultHistoricalBHPLimit();
233 void resetBHPLimit();
234 void setBHPLimit(
const double limit);
235 InjectionControls controls(
const UnitSystem& unit_system,
const SummaryState& st,
double udq_default)
const;
237 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
239 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
241 void setGasInjComposition(
const std::vector<double>& composition);
242 const std::vector<double>& gasInjComposition()
const;
244 template<
class Serializer>
248 serializer(surfaceInjectionRate);
249 serializer(reservoirInjectionRate);
250 serializer(BHPTarget);
251 serializer(THPTarget);
252 serializer(bhp_hist_limit);
253 serializer(thp_hist_limit);
256 serializer(VFPTableNumber);
257 serializer(predictionMode);
258 serializer(injectionControls);
259 serializer(injectorType);
260 serializer(controlMode);
262 serializer(gas_inj_composition);
268 class WellProductionProperties {
283 double bhp_hist_limit = 0.0;
284 double thp_hist_limit = 0.0;
285 bool bhp_hist_limit_defaulted =
true;
290 int VFPTableNumber = 0;
291 bool predictionMode =
false;
292 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
293 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
295 bool operator==(
const WellProductionProperties& other)
const;
296 bool operator!=(
const WellProductionProperties& other)
const;
298 WellProductionProperties();
299 WellProductionProperties(
const UnitSystem& units,
const std::string& name_arg);
301 static WellProductionProperties serializationTestObject();
303 bool hasProductionControl(ProducerCMode controlModeArg)
const {
304 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
307 void dropProductionControl(ProducerCMode controlModeArg) {
308 if (hasProductionControl(controlModeArg))
309 m_productionControls -=
static_cast<int>(controlModeArg);
312 void addProductionControl(ProducerCMode controlModeArg) {
313 if (! hasProductionControl(controlModeArg))
314 m_productionControls +=
static_cast<int>(controlModeArg);
318 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
328 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
329 const int vfp_table_nr,
330 const double bhp_def,
332 const std::string& well,
342 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
343 const int vfp_table_nr,
344 const double bhp_def,
347 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
348 void resetDefaultBHPLimit();
349 void clearControls();
350 ProductionControls controls(
const SummaryState& st,
double udq_default)
const;
352 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
355 void setBHPLimit(
const double limit);
356 int productionControls()
const {
return this->m_productionControls; }
357 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
359 template<
class Serializer>
364 serializer(WaterRate);
366 serializer(LiquidRate);
367 serializer(ResVRate);
368 serializer(BHPTarget);
369 serializer(THPTarget);
370 serializer(ALQValue);
371 serializer(bhp_hist_limit);
372 serializer(thp_hist_limit);
375 serializer(VFPTableNumber);
376 serializer(predictionMode);
377 serializer(controlMode);
378 serializer(whistctl_cmode);
379 serializer(m_productionControls);
383 int m_productionControls = 0;
387 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const int vfp_table_nr,
const UnitSystem& unit_system,
const DeckRecord& record);
389 explicit WellProductionProperties(
const DeckRecord& record);
391 double getBHPLimit()
const;
394 static int eclipseControlMode(
const Well::InjectorCMode imode,
395 const InjectorType itype);
397 static int eclipseControlMode(
const Well::ProducerCMode pmode);
399 static int eclipseControlMode(
const Well& well,
403 Well(
const std::string& wname,
404 const std::string& gname,
405 std::size_t init_step,
406 std::size_t insert_index,
409 const std::optional<double>& ref_depth,
411 ProducerCMode whistctl_cmode,
412 Connection::Order ordering,
414 double udq_undefined,
419 GasInflowEquation inflow_eq,
420 bool temp_option =
false);
424 int rst_whistctl_cmode,
427 double udq_undefined,
428 const std::optional<VFPProdTable::ALQ_TYPE>& alq_type);
430 static Well serializationTestObject();
432 bool isMultiSegment()
const;
433 bool isAvailableForGroupControl()
const;
434 double getGuideRate()
const;
435 GuideRateTarget getGuideRatePhase()
const;
436 GuideRateTarget getRawGuideRatePhase()
const;
437 double getGuideRateScalingFactor()
const;
439 bool hasBeenDefined(std::size_t timeStep)
const;
440 std::size_t firstTimeStep()
const;
442 bool predictionMode()
const;
443 bool isProducer()
const;
444 bool isInjector()
const;
445 InjectorCMode injection_cmode()
const;
446 ProducerCMode production_cmode()
const;
447 InjectorType injectorType()
const;
448 std::size_t seqIndex()
const;
449 bool getAutomaticShutIn()
const;
450 bool getAllowCrossFlow()
const;
451 const std::string& name()
const;
452 const std::vector<std::string>& wListNames()
const;
453 int getHeadI()
const;
454 int getHeadJ()
const;
455 double getWPaveRefDepth()
const;
456 bool hasRefDepth()
const;
457 double getRefDepth()
const;
458 double getDrainageRadius()
const;
459 double getEfficiencyFactor(
bool network =
false)
const;
460 double getSolventFraction()
const;
461 Status getStatus()
const;
462 const std::string& groupName()
const;
463 Phase getPreferredPhase()
const;
464 InjMultMode getInjMultMode()
const;
465 const InjMult& getWellInjMult()
const;
466 bool aciveWellInjMult()
const;
468 bool hasConnections()
const;
469 std::vector<const Connection *> getConnections(
int completion)
const;
473 int maxSegmentID()
const;
474 int maxBranchID()
const;
484 const WVFPDP& getWVFPDP()
const;
485 const WVFPEXP& getWVFPEXP()
const;
486 const WDFAC& getWDFAC()
const;
496 double production_rate(
const SummaryState& st, Phase phase)
const;
497 double injection_rate(
const SummaryState& st, Phase phase)
const;
498 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
513 std::map<int, std::vector<Connection>> getCompletions()
const;
519 bool hasCompletion(
int completion)
const;
520 bool updatePrediction(
bool prediction_mode);
521 bool updateAutoShutin(
bool auto_shutin);
522 bool updateCrossFlow(
bool allow_cross_flow);
523 bool updatePVTTable(std::optional<int> pvt_table);
524 bool updateHead(std::optional<int> I, std::optional<int> J);
525 void updateRefDepth();
526 bool updateRefDepth(std::optional<double> ref_dpeth);
527 bool updateDrainageRadius(std::optional<double> drainage_radius);
528 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
529 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
530 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
531 bool updateStatus(Status status);
532 bool updateGroup(
const std::string& group);
533 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
534 bool updateWellGuideRate(
double guide_rate);
535 bool updateAvailableForGroupControl(
bool available);
536 bool updateEfficiencyFactor(
double efficiency_factor,
bool use_efficiency_in_network);
538 bool updateSolventFraction(
double solvent_fraction);
539 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
540 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
541 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
542 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
543 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
544 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
545 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
546 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
547 bool updateWellProductivityIndex();
548 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
549 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
550 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
551 bool updateWPAVE(
const PAvg& pavg);
554 void updateWPaveRefDepth(
double ref_depth);
555 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
556 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
557 bool updateWDFAC(std::shared_ptr<WDFAC> wdfac);
561 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
563 bool handleCOMPLUMP(
const DeckRecord& record);
568 void setFilterConc(
const UDAValue& conc);
569 double evalFilterConc(
const SummaryState& summary_sate)
const;
570 bool applyGlobalWPIMULT(
double scale_factor);
573 ProductionControls productionControls(
const SummaryState& st)
const;
574 InjectionControls injectionControls(
const SummaryState& st)
const;
575 int vfp_table_number()
const;
576 int pvt_table_number()
const;
577 int fip_region_number()
const;
578 GasInflowEquation gas_inflow_equation()
const;
579 bool segmented_density_calculation()
const {
return true; }
581 double inj_temperature()
const;
582 bool hasInjTemperature()
const;
583 void setWellInjTemperature(
const double temp);
584 bool hasInjected( )
const;
585 bool hasProduced( )
const;
586 bool updateHasInjected( );
587 bool updateHasProduced();
588 bool cmp_structure(
const Well& other)
const;
589 bool operator==(
const Well& data)
const;
590 bool hasSameConnectionsPointers(
const Well& other)
const;
591 void setInsertIndex(std::size_t index);
592 double convertDeckPI(
double deckPI)
const;
593 void applyWellProdIndexScaling(
const double scalingFactor,
594 std::vector<bool>& scalingApplicable);
595 const PAvg& pavg()
const;
600 template<
class Serializer>
604 serializer(group_name);
605 serializer(init_step);
606 serializer(insert_index);
607 serializer(insert_index_lgr);
608 serializer(insert_index_all_lgr);
611 serializer(ref_depth);
612 serializer(wpave_ref_depth);
613 serializer(udq_undefined);
615 serializer(drainage_radius);
616 serializer(allow_cross_flow);
617 serializer(automatic_shutin);
618 serializer(pvt_table);
619 serializer(gas_inflow);
621 serializer(ref_type);
623 serializer(guide_rate);
624 serializer(efficiency_factor);
625 serializer(use_efficiency_in_network);
626 serializer(solvent_fraction);
627 serializer(has_produced);
628 serializer(has_injected);
629 serializer(prediction_mode);
630 serializer(derive_refdepth_from_conns_);
631 serializer(econ_limits);
632 serializer(foam_properties);
633 serializer(polymer_properties);
634 serializer(micp_properties);
635 serializer(brine_properties);
636 serializer(tracer_properties);
637 serializer(connections);
638 serializer(production);
639 serializer(injection);
640 serializer(segments);
645 serializer(well_inj_temperature);
646 serializer(default_well_inj_temperature);
647 serializer(inj_mult_mode);
648 serializer(well_inj_mult);
649 serializer(m_filter_concentration);
653 enum class WellRefinementType {
658 void switchToInjector();
659 void switchToProducer();
661 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
664 std::string group_name{};
666 std::size_t init_step{};
667 std::size_t insert_index{};
669 std::size_t insert_index_lgr{0};
671 std::size_t insert_index_all_lgr{0};
674 std::optional<double> ref_depth{};
675 std::optional<double> wpave_ref_depth{};
676 double drainage_radius{};
677 bool allow_cross_flow{
false};
678 bool automatic_shutin{
false};
683 GasInflowEquation gas_inflow = GasInflowEquation::STD;
685 const UnitSystem* unit_system{
nullptr};
686 double udq_undefined{};
688 WellRefinementType ref_type{WellRefinementType::STANDARD};
689 std::string lgr_tag{};
691 double efficiency_factor{};
692 bool use_efficiency_in_network{};
693 double solvent_fraction{};
694 bool has_produced =
false;
695 bool has_injected =
false;
696 bool prediction_mode =
true;
697 bool derive_refdepth_from_conns_ {
true };
699 std::shared_ptr<WellEconProductionLimits> econ_limits{};
700 std::shared_ptr<WellFoamProperties> foam_properties{};
701 std::shared_ptr<WellPolymerProperties> polymer_properties{};
702 std::shared_ptr<WellMICPProperties> micp_properties{};
703 std::shared_ptr<WellBrineProperties> brine_properties{};
704 std::shared_ptr<WellTracerProperties> tracer_properties{};
708 std::shared_ptr<WellConnections> connections{};
710 std::shared_ptr<WellProductionProperties> production{};
711 std::shared_ptr<WellInjectionProperties> injection{};
712 std::shared_ptr<WellSegments> segments{};
713 std::shared_ptr<WVFPDP> wvfpdp{};
714 std::shared_ptr<WVFPEXP> wvfpexp{};
715 std::shared_ptr<WDFAC> wdfac{};
717 Status status{Status::AUTO};
719 std::optional<double> well_inj_temperature{};
720 std::optional<double> default_well_inj_temperature{std::nullopt};
721 InjMultMode inj_mult_mode = InjMultMode::NONE;
722 std::optional<InjMult> well_inj_mult{};
723 UDAValue m_filter_concentration{};