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 void setInsertIndexLGR(
const std::size_t index);
110 void setInsertIndexAllLGR(
const std::size_t index);
112 std::size_t seqIndexLGR()
const {
return insert_index_lgr; }
113 std::size_t seqIndexAllLGR()
const {
return insert_index_all_lgr; }
115 bool is_lgr_well()
const;
116 std::optional<std::string> get_lgr_well_tag()
const;
120 GuideRateTarget guide_phase;
126 result.available =
true;
127 result.guide_rate = 1.0;
128 result.guide_phase = GuideRateTarget::COMB;
129 result.scale_factor = 2.0;
135 return available == data.available &&
136 guide_rate == data.guide_rate &&
137 guide_phase == data.guide_phase &&
138 scale_factor == data.scale_factor;
141 template<
class Serializer>
144 serializer(available);
145 serializer(guide_rate);
146 serializer(guide_phase);
147 serializer(scale_factor);
153 struct WellInjectionProperties {
160 double bhp_hist_limit = 0.0;
161 double thp_hist_limit = 0.0;
167 int injectionControls;
168 InjectorType injectorType;
169 InjectorCMode controlMode;
174 std::optional<std::vector<double>> gas_inj_composition{};
176 bool operator==(
const WellInjectionProperties& other)
const;
177 bool operator!=(
const WellInjectionProperties& other)
const;
179 WellInjectionProperties();
180 WellInjectionProperties(
const UnitSystem& units,
const std::string& wname);
182 static WellInjectionProperties serializationTestObject();
184 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
193 const double bhp_def,
194 bool availableForGroupControl,
195 const std::string& well_name,
206 const int vfp_table_nr,
207 const double bhp_def,
208 const bool is_producer,
209 const std::string& well_name,
212 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
213 if (injectionControls &
static_cast<int>(controlModeArg))
219 void dropInjectionControl(InjectorCMode controlModeArg) {
220 auto int_arg =
static_cast<int>(controlModeArg);
221 if ((injectionControls & int_arg) != 0)
222 injectionControls -= int_arg;
225 void addInjectionControl(InjectorCMode controlModeArg) {
226 auto int_arg =
static_cast<int>(controlModeArg);
227 if ((injectionControls & int_arg) == 0)
228 injectionControls += int_arg;
231 void clearControls();
233 void resetDefaultHistoricalBHPLimit();
234 void resetBHPLimit();
235 void setBHPLimit(
const double limit);
236 InjectionControls controls(
const UnitSystem& unit_system,
const SummaryState& st,
double udq_default)
const;
238 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
240 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
242 void setGasInjComposition(
const std::vector<double>& composition);
243 const std::vector<double>& gasInjComposition()
const;
245 template<
class Serializer>
249 serializer(surfaceInjectionRate);
250 serializer(reservoirInjectionRate);
251 serializer(BHPTarget);
252 serializer(THPTarget);
253 serializer(bhp_hist_limit);
254 serializer(thp_hist_limit);
257 serializer(VFPTableNumber);
258 serializer(predictionMode);
259 serializer(injectionControls);
260 serializer(injectorType);
261 serializer(controlMode);
263 serializer(gas_inj_composition);
269 class WellProductionProperties {
284 double bhp_hist_limit = 0.0;
285 double thp_hist_limit = 0.0;
286 bool bhp_hist_limit_defaulted =
true;
291 int VFPTableNumber = 0;
292 bool predictionMode =
false;
293 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
294 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
296 bool operator==(
const WellProductionProperties& other)
const;
297 bool operator!=(
const WellProductionProperties& other)
const;
299 WellProductionProperties();
300 WellProductionProperties(
const UnitSystem& units,
const std::string& name_arg);
302 static WellProductionProperties serializationTestObject();
304 bool hasProductionControl(ProducerCMode controlModeArg)
const {
305 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
308 void dropProductionControl(ProducerCMode controlModeArg) {
309 if (hasProductionControl(controlModeArg))
310 m_productionControls -=
static_cast<int>(controlModeArg);
313 void addProductionControl(ProducerCMode controlModeArg) {
314 if (! hasProductionControl(controlModeArg))
315 m_productionControls +=
static_cast<int>(controlModeArg);
319 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
330 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
331 const int vfp_table_nr,
332 const double bhp_def,
334 const std::string& well,
345 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
346 const int vfp_table_nr,
347 const double bhp_def,
350 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
351 void resetDefaultBHPLimit();
352 void clearControls();
353 ProductionControls controls(
const SummaryState& st,
double udq_default)
const;
355 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
358 void setBHPLimit(
const double limit);
359 int productionControls()
const {
return this->m_productionControls; }
360 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
362 template<
class Serializer>
367 serializer(WaterRate);
369 serializer(LiquidRate);
370 serializer(ResVRate);
371 serializer(BHPTarget);
372 serializer(THPTarget);
373 serializer(ALQValue);
374 serializer(bhp_hist_limit);
375 serializer(thp_hist_limit);
378 serializer(VFPTableNumber);
379 serializer(predictionMode);
380 serializer(controlMode);
381 serializer(whistctl_cmode);
382 serializer(m_productionControls);
386 int m_productionControls = 0;
390 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const int vfp_table_nr,
const UnitSystem& unit_system,
const DeckRecord& record);
392 explicit WellProductionProperties(
const DeckRecord& record);
394 double getBHPLimit()
const;
397 static int eclipseControlMode(
const Well::InjectorCMode imode,
398 const InjectorType itype);
400 static int eclipseControlMode(
const Well::ProducerCMode pmode);
402 static int eclipseControlMode(
const Well& well,
406 Well(
const std::string& wname,
407 const std::string& gname,
408 std::size_t init_step,
409 std::size_t insert_index,
412 const std::optional<double>& ref_depth,
414 ProducerCMode whistctl_cmode,
415 Connection::Order ordering,
417 double udq_undefined,
422 GasInflowEquation inflow_eq,
423 bool temp_option =
false);
427 int rst_whistctl_cmode,
430 double udq_undefined,
431 const std::optional<VFPProdTable::ALQ_TYPE>& alq_type);
433 static Well serializationTestObject();
435 bool isMultiSegment()
const;
436 bool isAvailableForGroupControl()
const;
437 double getGuideRate()
const;
438 GuideRateTarget getGuideRatePhase()
const;
439 GuideRateTarget getRawGuideRatePhase()
const;
440 double getGuideRateScalingFactor()
const;
442 bool hasBeenDefined(std::size_t timeStep)
const;
443 std::size_t firstTimeStep()
const;
445 bool predictionMode()
const;
446 bool isProducer()
const;
447 bool isInjector()
const;
448 InjectorCMode injection_cmode()
const;
449 ProducerCMode production_cmode()
const;
450 InjectorType injectorType()
const;
451 std::size_t seqIndex()
const;
452 bool getAutomaticShutIn()
const;
453 bool getAllowCrossFlow()
const;
454 const std::string& name()
const;
455 const std::vector<std::string>& wListNames()
const;
456 int getHeadI()
const;
457 int getHeadJ()
const;
458 double getWPaveRefDepth()
const;
459 bool hasRefDepth()
const;
460 double getRefDepth()
const;
461 double getDrainageRadius()
const;
462 double getEfficiencyFactor(
bool network =
false)
const;
463 double getSolventFraction()
const;
464 Status getStatus()
const;
465 const std::string& groupName()
const;
466 Phase getPreferredPhase()
const;
467 InjMultMode getInjMultMode()
const;
468 const InjMult& getWellInjMult()
const;
469 bool aciveWellInjMult()
const;
471 bool hasConnections()
const;
472 std::vector<const Connection *> getConnections(
int completion)
const;
476 int maxSegmentID()
const;
477 int maxBranchID()
const;
488 const WVFPDP& getWVFPDP()
const;
489 const WVFPEXP& getWVFPEXP()
const;
490 const WDFAC& getWDFAC()
const;
500 double production_rate(
const SummaryState& st, Phase phase)
const;
501 double injection_rate(
const SummaryState& st, Phase phase)
const;
502 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
517 std::map<int, std::vector<Connection>> getCompletions()
const;
523 bool hasCompletion(
int completion)
const;
524 bool updatePrediction(
bool prediction_mode);
525 bool updateAutoShutin(
bool auto_shutin);
526 bool updateCrossFlow(
bool allow_cross_flow);
527 bool updatePVTTable(std::optional<int> pvt_table);
528 bool updateHead(std::optional<int> I, std::optional<int> J);
529 void updateRefDepth();
530 bool updateRefDepth(std::optional<double> ref_dpeth);
531 bool updateDrainageRadius(std::optional<double> drainage_radius);
532 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
533 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
534 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
535 bool updateStatus(Status status);
536 bool updateGroup(
const std::string& group);
537 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
538 bool updateWellGuideRate(
double guide_rate);
539 bool updateAvailableForGroupControl(
bool available);
540 bool updateEfficiencyFactor(
double efficiency_factor,
bool use_efficiency_in_network);
542 bool updateSolventFraction(
double solvent_fraction);
543 bool updateSpecies(std::shared_ptr<WellTracerProperties> species_properties);
544 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
545 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
546 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
547 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
548 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
549 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
550 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
551 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
552 bool updateWellProductivityIndex();
554 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD>>& aicd_pairs,
559 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD>>& sicd_pairs,
564 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve>>& valve_pairs,
569 bool updateICDFlowScalingFactors();
570 bool updateWPAVE(
const PAvg& pavg);
573 void updateWPaveRefDepth(
double ref_depth);
574 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
575 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
576 bool updateWDFAC(std::shared_ptr<WDFAC> wdfac);
580 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
582 bool handleCOMPLUMP(
const DeckRecord& record);
587 void setFilterConc(
const UDAValue& conc);
588 double evalFilterConc(
const SummaryState& summary_sate)
const;
589 bool applyGlobalWPIMULT(
double scale_factor);
590 void addWellSegmentsFromLengthsAndDepths(
const std::vector<std::pair<double, double>>& lengths_and_depths,
double diameter,
const KeywordLocation& location);
592 ProductionControls productionControls(
const SummaryState& st)
const;
593 InjectionControls injectionControls(
const SummaryState& st)
const;
594 int vfp_table_number()
const;
595 int pvt_table_number()
const;
596 int fip_region_number()
const;
597 GasInflowEquation gas_inflow_equation()
const;
598 bool segmented_density_calculation()
const {
return true; }
600 double inj_temperature()
const;
601 bool hasInjTemperature()
const;
602 void setWellInjTemperature(
const double temp);
603 bool hasInjected( )
const;
604 bool hasProduced( )
const;
605 bool updateHasInjected( );
606 bool updateHasProduced();
607 bool cmp_structure(
const Well& other)
const;
608 bool operator==(
const Well& data)
const;
609 bool hasSameConnectionsPointers(
const Well& other)
const;
610 void setInsertIndex(std::size_t index);
611 double convertDeckPI(
double deckPI)
const;
612 void applyWellProdIndexScaling(
const double scalingFactor,
613 std::vector<bool>& scalingApplicable);
614 const PAvg& pavg()
const;
619 template<
class Serializer>
623 serializer(group_name);
624 serializer(init_step);
625 serializer(insert_index);
626 serializer(insert_index_lgr);
627 serializer(insert_index_all_lgr);
630 serializer(ref_depth);
631 serializer(wpave_ref_depth);
632 serializer(udq_undefined);
634 serializer(drainage_radius);
635 serializer(allow_cross_flow);
636 serializer(automatic_shutin);
637 serializer(pvt_table);
638 serializer(gas_inflow);
640 serializer(ref_type);
642 serializer(guide_rate);
643 serializer(efficiency_factor);
644 serializer(use_efficiency_in_network);
645 serializer(solvent_fraction);
646 serializer(has_produced);
647 serializer(has_injected);
648 serializer(prediction_mode);
649 serializer(derive_refdepth_from_conns_);
650 serializer(econ_limits);
651 serializer(foam_properties);
652 serializer(polymer_properties);
653 serializer(micp_properties);
654 serializer(brine_properties);
655 serializer(species_properties);
656 serializer(tracer_properties);
657 serializer(connections);
658 serializer(production);
659 serializer(injection);
660 serializer(segments);
665 serializer(well_inj_temperature);
666 serializer(default_well_inj_temperature);
667 serializer(inj_mult_mode);
668 serializer(well_inj_mult);
669 serializer(m_filter_concentration);
673 enum class WellRefinementType {
678 void switchToInjector();
679 void switchToProducer();
681 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
684 std::string group_name{};
686 std::size_t init_step{};
687 std::size_t insert_index{};
689 std::size_t insert_index_lgr{0};
691 std::size_t insert_index_all_lgr{0};
694 std::optional<double> ref_depth{};
695 std::optional<double> wpave_ref_depth{};
696 double drainage_radius{};
697 bool allow_cross_flow{
false};
698 bool automatic_shutin{
false};
703 GasInflowEquation gas_inflow = GasInflowEquation::STD;
705 const UnitSystem* unit_system{
nullptr};
706 double udq_undefined{};
708 WellRefinementType ref_type{WellRefinementType::STANDARD};
709 std::string lgr_tag{};
711 double efficiency_factor{};
712 bool use_efficiency_in_network{};
713 double solvent_fraction{};
714 bool has_produced =
false;
715 bool has_injected =
false;
716 bool prediction_mode =
true;
717 bool derive_refdepth_from_conns_ {
true };
719 std::shared_ptr<WellEconProductionLimits> econ_limits{};
720 std::shared_ptr<WellFoamProperties> foam_properties{};
721 std::shared_ptr<WellPolymerProperties> polymer_properties{};
722 std::shared_ptr<WellMICPProperties> micp_properties{};
723 std::shared_ptr<WellBrineProperties> brine_properties{};
724 std::shared_ptr<WellTracerProperties> species_properties{};
725 std::shared_ptr<WellTracerProperties> tracer_properties{};
729 std::shared_ptr<WellConnections> connections{};
731 std::shared_ptr<WellProductionProperties> production{};
732 std::shared_ptr<WellInjectionProperties> injection{};
733 std::shared_ptr<WellSegments> segments{};
734 std::shared_ptr<WVFPDP> wvfpdp{};
735 std::shared_ptr<WVFPEXP> wvfpexp{};
736 std::shared_ptr<WDFAC> wdfac{};
738 Status status{Status::AUTO};
740 std::optional<double> well_inj_temperature{};
741 std::optional<double> default_well_inj_temperature{std::nullopt};
742 InjMultMode inj_mult_mode = InjMultMode::NONE;
743 std::optional<InjMult> well_inj_mult{};
744 UDAValue m_filter_concentration{};