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,
193 const int vfp_table_nr,
194 const double bhp_def,
195 const bool is_producer,
196 const std::string& well_name,
199 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
200 if (injectionControls &
static_cast<int>(controlModeArg))
206 void dropInjectionControl(InjectorCMode controlModeArg) {
207 auto int_arg =
static_cast<int>(controlModeArg);
208 if ((injectionControls & int_arg) != 0)
209 injectionControls -= int_arg;
212 void addInjectionControl(InjectorCMode controlModeArg) {
213 auto int_arg =
static_cast<int>(controlModeArg);
214 if ((injectionControls & int_arg) == 0)
215 injectionControls += int_arg;
218 void clearControls();
220 void resetDefaultHistoricalBHPLimit();
221 void resetBHPLimit();
222 void setBHPLimit(
const double limit);
225 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
227 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
229 template<
class Serializer>
233 serializer(surfaceInjectionRate);
234 serializer(reservoirInjectionRate);
235 serializer(BHPTarget);
236 serializer(THPTarget);
237 serializer(bhp_hist_limit);
238 serializer(thp_hist_limit);
241 serializer(VFPTableNumber);
242 serializer(predictionMode);
243 serializer(injectionControls);
244 serializer(injectorType);
245 serializer(controlMode);
267 double bhp_hist_limit = 0.0;
268 double thp_hist_limit = 0.0;
269 bool bhp_hist_limit_defaulted =
true;
274 int VFPTableNumber = 0;
275 bool predictionMode =
false;
276 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
277 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
287 bool hasProductionControl(ProducerCMode controlModeArg)
const {
288 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
291 void dropProductionControl(ProducerCMode controlModeArg) {
292 if (hasProductionControl(controlModeArg))
293 m_productionControls -=
static_cast<int>(controlModeArg);
296 void addProductionControl(ProducerCMode controlModeArg) {
297 if (! hasProductionControl(controlModeArg))
298 m_productionControls +=
static_cast<int>(controlModeArg);
302 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
312 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
313 const int vfp_table_nr,
314 const double bhp_def,
316 const std::string& well,
326 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
327 const int vfp_table_nr,
328 const double bhp_def,
331 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
332 void resetDefaultBHPLimit();
333 void clearControls();
336 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
339 void setBHPLimit(
const double limit);
340 int productionControls()
const {
return this->m_productionControls; }
341 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
343 template<
class Serializer>
348 serializer(WaterRate);
350 serializer(LiquidRate);
351 serializer(ResVRate);
352 serializer(BHPTarget);
353 serializer(THPTarget);
354 serializer(ALQValue);
355 serializer(bhp_hist_limit);
356 serializer(thp_hist_limit);
359 serializer(VFPTableNumber);
360 serializer(predictionMode);
361 serializer(controlMode);
362 serializer(whistctl_cmode);
363 serializer(m_productionControls);
367 int m_productionControls = 0;
371 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const int vfp_table_nr,
const UnitSystem& unit_system,
const DeckRecord& record);
375 double getBHPLimit()
const;
378 static int eclipseControlMode(
const Well::InjectorCMode imode,
379 const InjectorType itype);
381 static int eclipseControlMode(
const Well::ProducerCMode pmode);
383 static int eclipseControlMode(
const Well& well,
387 Well(
const std::string& wname,
388 const std::string& gname,
389 std::size_t init_step,
390 std::size_t insert_index,
393 const std::optional<double>& ref_depth,
395 ProducerCMode whistctl_cmode,
396 Connection::Order ordering,
398 double udq_undefined,
403 GasInflowEquation inflow_eq);
407 int rst_whistctl_cmode,
410 double udq_undefined);
412 static Well serializationTestObject();
414 bool isMultiSegment()
const;
415 bool isAvailableForGroupControl()
const;
416 double getGuideRate()
const;
417 GuideRateTarget getGuideRatePhase()
const;
418 GuideRateTarget getRawGuideRatePhase()
const;
419 double getGuideRateScalingFactor()
const;
421 bool hasBeenDefined(std::size_t timeStep)
const;
422 std::size_t firstTimeStep()
const;
424 bool predictionMode()
const;
425 bool isProducer()
const;
426 bool isInjector()
const;
427 InjectorCMode injection_cmode()
const;
428 ProducerCMode production_cmode()
const;
429 InjectorType injectorType()
const;
430 std::size_t seqIndex()
const;
431 bool getAutomaticShutIn()
const;
432 bool getAllowCrossFlow()
const;
433 const std::string& name()
const;
434 const std::vector<std::string>& wListNames()
const;
435 int getHeadI()
const;
436 int getHeadJ()
const;
437 double getWPaveRefDepth()
const;
438 bool hasRefDepth()
const;
439 double getRefDepth()
const;
440 double getDrainageRadius()
const;
441 double getEfficiencyFactor()
const;
442 double getSolventFraction()
const;
443 Status getStatus()
const;
444 const std::string& groupName()
const;
445 Phase getPreferredPhase()
const;
446 InjMultMode getInjMultMode()
const;
447 const InjMult& getWellInjMult()
const;
448 bool aciveWellInjMult()
const;
450 bool hasConnections()
const;
451 const std::vector<const Connection *> getConnections(
int completion)
const;
454 int maxSegmentID()
const;
455 int maxBranchID()
const;
465 const WVFPDP& getWVFPDP()
const;
466 const WVFPEXP& getWVFPEXP()
const;
467 const WDFAC& getWDFAC()
const;
477 double production_rate(
const SummaryState& st, Phase phase)
const;
478 double injection_rate(
const SummaryState& st, Phase phase)
const;
479 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
494 std::map<int, std::vector<Connection>> getCompletions()
const;
500 bool hasCompletion(
int completion)
const;
501 bool updatePrediction(
bool prediction_mode);
502 bool updateAutoShutin(
bool auto_shutin);
503 bool updateCrossFlow(
bool allow_cross_flow);
504 bool updatePVTTable(std::optional<int> pvt_table);
505 bool updateHead(std::optional<int> I, std::optional<int> J);
506 void updateRefDepth();
507 bool updateRefDepth(std::optional<double> ref_dpeth);
508 bool updateDrainageRadius(std::optional<double> drainage_radius);
509 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
510 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
511 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
512 bool updateStatus(Status status);
513 bool updateGroup(
const std::string& group);
514 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
515 bool updateWellGuideRate(
double guide_rate);
516 bool updateAvailableForGroupControl(
bool available);
517 bool updateEfficiencyFactor(
double efficiency_factor);
519 bool updateSolventFraction(
double solvent_fraction);
520 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
521 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
522 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
523 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
524 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
525 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
526 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
527 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
528 bool updateWellProductivityIndex();
529 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
530 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
531 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
532 bool updateWPAVE(
const PAvg& pavg);
533 void updateWPaveRefDepth(
double ref_depth);
534 bool updateWVFPDP(std::shared_ptr<WVFPDP> wvfpdp);
535 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
536 bool updateWDFAC(std::shared_ptr<WDFAC> wdfac);
541 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
543 bool handleCOMPLUMP(
const DeckRecord& record);
548 void setFilterConc(
const UDAValue& conc);
549 double evalFilterConc(
const SummaryState& summary_sate)
const;
550 bool applyGlobalWPIMULT(
double scale_factor);
555 int vfp_table_number()
const;
556 int pvt_table_number()
const;
557 int fip_region_number()
const;
558 GasInflowEquation gas_inflow_equation()
const;
559 bool segmented_density_calculation()
const {
return true; }
561 double inj_temperature()
const;
562 bool hasInjTemperature()
const;
563 void setWellInjTemperature(
const double temp);
564 bool hasInjected( )
const;
565 bool hasProduced( )
const;
566 bool updateHasInjected( );
567 bool updateHasProduced();
568 bool cmp_structure(
const Well& other)
const;
569 bool operator==(
const Well& data)
const;
570 bool hasSameConnectionsPointers(
const Well& other)
const;
571 void setInsertIndex(std::size_t index);
572 double convertDeckPI(
double deckPI)
const;
573 void applyWellProdIndexScaling(
const double scalingFactor,
574 std::vector<bool>& scalingApplicable);
575 const PAvg& pavg()
const;
580 template<
class Serializer>
584 serializer(group_name);
585 serializer(init_step);
586 serializer(insert_index);
589 serializer(ref_depth);
590 serializer(wpave_ref_depth);
591 serializer(udq_undefined);
593 serializer(drainage_radius);
594 serializer(allow_cross_flow);
595 serializer(automatic_shutin);
596 serializer(pvt_table);
597 serializer(gas_inflow);
599 serializer(guide_rate);
600 serializer(efficiency_factor);
601 serializer(solvent_fraction);
602 serializer(has_produced);
603 serializer(has_injected);
604 serializer(prediction_mode);
605 serializer(derive_refdepth_from_conns_);
606 serializer(econ_limits);
607 serializer(foam_properties);
608 serializer(polymer_properties);
609 serializer(micp_properties);
610 serializer(brine_properties);
611 serializer(tracer_properties);
612 serializer(connections);
613 serializer(production);
614 serializer(injection);
615 serializer(segments);
620 serializer(well_inj_temperature);
621 serializer(inj_mult_mode);
622 serializer(well_inj_mult);
623 serializer(m_filter_concentration);
627 void switchToInjector();
628 void switchToProducer();
630 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
633 std::string group_name{};
634 std::size_t init_step{};
635 std::size_t insert_index{};
638 std::optional<double> ref_depth{};
639 std::optional<double> wpave_ref_depth{};
640 double drainage_radius{};
641 bool allow_cross_flow{
false};
642 bool automatic_shutin{
false};
644 GasInflowEquation gas_inflow = GasInflowEquation::STD;
645 const UnitSystem* unit_system{
nullptr};
646 double udq_undefined{};
648 WellGuideRate guide_rate{};
649 double efficiency_factor{};
650 double solvent_fraction{};
651 bool has_produced =
false;
652 bool has_injected =
false;
653 bool prediction_mode =
true;
654 bool derive_refdepth_from_conns_ {
true };
656 std::shared_ptr<WellEconProductionLimits> econ_limits{};
657 std::shared_ptr<WellFoamProperties> foam_properties{};
658 std::shared_ptr<WellPolymerProperties> polymer_properties{};
659 std::shared_ptr<WellMICPProperties> micp_properties{};
660 std::shared_ptr<WellBrineProperties> brine_properties{};
661 std::shared_ptr<WellTracerProperties> tracer_properties{};
662 std::shared_ptr<WellConnections> connections{};
663 std::shared_ptr<WellProductionProperties> production{};
664 std::shared_ptr<WellInjectionProperties> injection{};
665 std::shared_ptr<WellSegments> segments{};
666 std::shared_ptr<WVFPDP> wvfpdp{};
667 std::shared_ptr<WVFPEXP> wvfpexp{};
668 std::shared_ptr<WDFAC> wdfac{};
670 Status status{Status::AUTO};
672 std::optional<double> well_inj_temperature{};
673 InjMultMode inj_mult_mode = InjMultMode::NONE;
674 std::optional<InjMult> well_inj_mult{};
675 UDAValue m_filter_concentration{};