35 #include <opm/input/eclipse/Deck/UDAValue.hpp>
36 #include <opm/input/eclipse/EclipseState/Runspec.hpp>
37 #include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
38 #include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
39 #include <opm/input/eclipse/Schedule/ScheduleTypes.hpp>
40 #include <opm/input/eclipse/Schedule/Well/PAvg.hpp>
41 #include <opm/input/eclipse/Schedule/Well/PAvgCalculator.hpp>
42 #include <opm/input/eclipse/Schedule/Well/ProductionControls.hpp>
43 #include <opm/input/eclipse/Schedule/Well/InjectionControls.hpp>
44 #include <opm/input/eclipse/Schedule/Well/WellFoamProperties.hpp>
45 #include <opm/input/eclipse/Schedule/Well/WellBrineProperties.hpp>
46 #include <opm/input/eclipse/Schedule/Well/WellTracerProperties.hpp>
47 #include <opm/input/eclipse/Schedule/Well/WellPolymerProperties.hpp>
48 #include <opm/input/eclipse/Schedule/Well/WellMICPProperties.hpp>
49 #include <opm/input/eclipse/Schedule/Well/WellEconProductionLimits.hpp>
50 #include <opm/input/eclipse/Schedule/Well/WVFPEXP.hpp>
51 #include <opm/input/eclipse/Schedule/VFPProdTable.hpp>
52 #include <opm/input/eclipse/Units/Units.hpp>
53 #include <opm/input/eclipse/Units/UnitSystem.hpp>
55 #include <opm/common/utility/ActiveGridCells.hpp>
59 class ActiveGridCells;
87 static std::string Status2String(Status enumValue);
88 static Status StatusFromString(
const std::string& stringValue);
97 enum class InjectorCMode : int{
103 CMODE_UNDEFINED = 512
105 static const std::string InjectorCMode2String( InjectorCMode enumValue );
106 static InjectorCMode InjectorCModeFromString(
const std::string& stringValue );
120 enum class ProducerCMode : int {
131 CMODE_UNDEFINED = 1024
133 static const std::string ProducerCMode2String( ProducerCMode enumValue );
134 static ProducerCMode ProducerCModeFromString(
const std::string& stringValue );
138 enum class WELTARGCMode {
152 static WELTARGCMode WELTARGCModeFromString(
const std::string& stringValue);
155 enum class GuideRateTarget {
167 static const std::string GuideRateTarget2String( GuideRateTarget enumValue );
168 static GuideRateTarget GuideRateTargetFromString(
const std::string& stringValue );
171 enum class GasInflowEquation {
177 static const std::string GasInflowEquation2String(GasInflowEquation enumValue);
178 static GasInflowEquation GasInflowEquationFromString(
const std::string& stringValue);
185 GuideRateTarget guide_phase;
191 result.available =
true;
192 result.guide_rate = 1.0;
193 result.guide_phase = GuideRateTarget::COMB;
194 result.scale_factor = 2.0;
200 return available == data.available &&
201 guide_rate == data.guide_rate &&
202 guide_phase == data.guide_phase &&
203 scale_factor == data.scale_factor;
206 template<
class Serializer>
209 serializer(available);
210 serializer(guide_rate);
211 serializer(guide_phase);
212 serializer(scale_factor);
220 controls(controls_arg)
227 InjectorType injector_type;
228 InjectorCMode cmode = InjectorCMode::CMODE_UNDEFINED;
230 double reservoir_rate;
232 int vfp_table_number;
233 bool prediction_mode;
236 bool hasControl(InjectorCMode cmode_arg)
const {
237 return (this->controls &
static_cast<int>(cmode_arg)) != 0;
253 double bhp_hist_limit = 0.0;
254 double thp_hist_limit = 0.0;
261 int injectionControls;
262 InjectorType injectorType;
263 InjectorCMode controlMode;
275 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
276 void handleWCONINJE(
const DeckRecord& record,
bool availableForGroupControl,
const std::string& well_name);
277 void handleWCONINJH(
const DeckRecord& record,
bool is_producer,
const std::string& well_name);
278 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
279 if (injectionControls &
static_cast<int>(controlModeArg))
285 void dropInjectionControl(InjectorCMode controlModeArg) {
286 auto int_arg =
static_cast<int>(controlModeArg);
287 if ((injectionControls & int_arg) != 0)
288 injectionControls -= int_arg;
291 void addInjectionControl(InjectorCMode controlModeArg) {
292 auto int_arg =
static_cast<int>(controlModeArg);
293 if ((injectionControls & int_arg) == 0)
294 injectionControls += int_arg;
297 void clearControls();
299 void resetDefaultHistoricalBHPLimit();
300 void resetBHPLimit();
301 void setBHPLimit(
const double limit);
304 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
306 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
308 template<
class Serializer>
312 serializer(surfaceInjectionRate);
313 serializer(reservoirInjectionRate);
314 serializer(BHPTarget);
315 serializer(THPTarget);
316 serializer(bhp_hist_limit);
317 serializer(thp_hist_limit);
318 serializer(temperature);
321 serializer(VFPTableNumber);
322 serializer(predictionMode);
323 serializer(injectionControls);
324 serializer(injectorType);
325 serializer(controlMode);
333 controls(controls_arg)
337 ProducerCMode cmode = ProducerCMode::NONE;
339 double water_rate{0};
341 double liquid_rate{0};
343 double bhp_history{0};
344 double thp_history{0};
348 int vfp_table_number{0};
349 bool prediction_mode{0};
351 bool hasControl(ProducerCMode cmode_arg)
const {
352 return (this->controls &
static_cast<int>(cmode_arg)) != 0;
356 return this->cmode == other.cmode &&
357 this->oil_rate == other.oil_rate &&
358 this->water_rate == other.water_rate &&
359 this->gas_rate == other.gas_rate &&
360 this->liquid_rate == other.liquid_rate &&
361 this->resv_rate == other.resv_rate &&
362 this->bhp_history == other.bhp_history &&
363 this->thp_history == other.thp_history &&
364 this->bhp_limit == other.bhp_limit &&
365 this->thp_limit == other.thp_limit &&
366 this->alq_value == other.alq_value &&
367 this->vfp_table_number == other.vfp_table_number &&
368 this->prediction_mode == other.prediction_mode;
392 double bhp_hist_limit = 0.0;
393 double thp_hist_limit = 0.0;
398 int VFPTableNumber = 0;
399 bool predictionMode =
false;
400 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
401 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
411 bool hasProductionControl(ProducerCMode controlModeArg)
const {
412 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
415 void dropProductionControl(ProducerCMode controlModeArg) {
416 if (hasProductionControl(controlModeArg))
417 m_productionControls -=
static_cast<int>(controlModeArg);
420 void addProductionControl(ProducerCMode controlModeArg) {
421 if (! hasProductionControl(controlModeArg))
422 m_productionControls +=
static_cast<int>(controlModeArg);
426 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
427 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const std::string& well,
const DeckRecord& record);
428 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
429 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
430 void resetDefaultBHPLimit();
431 void clearControls();
434 bool updateUDQActive(
const UDQConfig& udq_config,
const WELTARGCMode cmode,
UDQActive& active)
const;
437 void setBHPLimit(
const double limit);
438 int productionControls()
const {
return this->m_productionControls; }
439 void handleWTMULT(Well::WELTARGCMode cmode,
double factor);
441 template<
class Serializer>
446 serializer(WaterRate);
448 serializer(LiquidRate);
449 serializer(ResVRate);
450 serializer(BHPTarget);
451 serializer(THPTarget);
452 serializer(ALQValue);
453 serializer(bhp_hist_limit);
454 serializer(thp_hist_limit);
457 serializer(VFPTableNumber);
458 serializer(predictionMode);
459 serializer(controlMode);
460 serializer(whistctl_cmode);
461 serializer(m_productionControls);
465 int m_productionControls = 0;
469 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
473 double getBHPLimit()
const;
476 static int eclipseControlMode(
const Well::InjectorCMode imode,
477 const InjectorType itype);
479 static int eclipseControlMode(
const Well::ProducerCMode pmode);
481 static int eclipseControlMode(
const Well& well,
486 Well(
const std::string& wname,
487 const std::string& gname,
488 std::size_t init_step,
489 std::size_t insert_index,
492 const std::optional<double>& ref_depth,
494 ProducerCMode whistctl_cmode,
495 Connection::Order ordering,
497 double udq_undefined,
502 GasInflowEquation inflow_eq);
508 double udq_undefined);
510 static Well serializationTestObject();
512 bool isMultiSegment()
const;
513 bool isAvailableForGroupControl()
const;
514 double getGuideRate()
const;
515 GuideRateTarget getGuideRatePhase()
const;
516 GuideRateTarget getRawGuideRatePhase()
const;
517 double getGuideRateScalingFactor()
const;
519 bool hasBeenDefined(
size_t timeStep)
const;
520 std::size_t firstTimeStep()
const;
522 bool predictionMode()
const;
523 bool canOpen()
const;
524 bool isProducer()
const;
525 bool isInjector()
const;
526 InjectorCMode injection_cmode()
const;
527 ProducerCMode production_cmode()
const;
528 InjectorType injectorType()
const;
529 size_t seqIndex()
const;
530 bool getAutomaticShutIn()
const;
531 bool getAllowCrossFlow()
const;
532 const std::string& name()
const;
533 const std::vector<std::string>& wListNames()
const;
534 int getHeadI()
const;
535 int getHeadJ()
const;
536 double getWPaveRefDepth()
const;
537 bool hasRefDepth()
const;
538 double getRefDepth()
const;
539 double getDrainageRadius()
const;
540 double getEfficiencyFactor()
const;
541 double getSolventFraction()
const;
542 Status getStatus()
const;
543 const std::string& groupName()
const;
544 Phase getPreferredPhase()
const;
546 const std::vector<const Connection *> getConnections(
int completion)
const;
558 const WVFPEXP& getWVFPEXP()
const;
567 double production_rate(
const SummaryState& st, Phase phase)
const;
568 double injection_rate(
const SummaryState& st, Phase phase)
const;
569 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
584 std::map<int, std::vector<Connection>> getCompletions()
const;
590 bool hasCompletion(
int completion)
const;
591 bool updatePrediction(
bool prediction_mode);
592 bool updateAutoShutin(
bool auto_shutin);
593 bool updateCrossFlow(
bool allow_cross_flow);
594 bool updatePVTTable(
int pvt_table);
595 bool updateHead(
int I,
int J);
596 void updateRefDepth();
597 bool updateRefDepth(
const std::optional<double>& ref_dpeth);
598 bool updateDrainageRadius(
double drainage_radius);
599 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
600 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
601 bool updateConnections(std::shared_ptr<WellConnections> connections,
const ScheduleGrid& grid);
602 bool updateStatus(Status status);
603 bool updateGroup(
const std::string& group);
604 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
605 bool updateWellGuideRate(
double guide_rate);
606 bool updateEfficiencyFactor(
double efficiency_factor);
607 bool updateSolventFraction(
double solvent_fraction);
608 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
609 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
610 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
611 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
612 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
613 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
614 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
615 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
616 bool updateWellProductivityIndex();
617 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
618 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
619 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
620 bool updateWPAVE(
const PAvg& pavg);
621 void updateWPaveRefDepth(
double ref_depth);
622 bool updateWVFPEXP(std::shared_ptr<WVFPEXP> wvfpexp);
626 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
627 bool handleCOMPLUMP(
const DeckRecord& record);
629 bool applyGlobalWPIMULT(
double scale_factor);
634 int vfp_table_number()
const;
635 int pvt_table_number()
const;
636 int fip_region_number()
const;
637 GasInflowEquation gas_inflow_equation()
const;
638 bool segmented_density_calculation()
const {
return true; }
639 double alq_value()
const;
640 double temperature()
const;
641 bool hasInjected( )
const;
642 bool hasProduced( )
const;
643 bool updateHasInjected( );
644 bool updateHasProduced();
645 bool cmp_structure(
const Well& other)
const;
646 bool operator==(
const Well& data)
const;
647 bool hasSameConnectionsPointers(
const Well& other)
const;
648 void setInsertIndex(std::size_t index);
649 double convertDeckPI(
double deckPI)
const;
650 void applyWellProdIndexScaling(
const double scalingFactor,
651 std::vector<bool>& scalingApplicable);
652 const PAvg& pavg()
const;
655 template<
class Serializer>
659 serializer(group_name);
660 serializer(init_step);
661 serializer(insert_index);
664 serializer(ref_depth);
665 serializer(wpave_ref_depth);
666 serializer(unit_system);
667 serializer(udq_undefined);
669 serializer(drainage_radius);
670 serializer(allow_cross_flow);
671 serializer(automatic_shutin);
672 serializer(pvt_table);
673 serializer(gas_inflow);
675 serializer(guide_rate);
676 serializer(efficiency_factor);
677 serializer(solvent_fraction);
678 serializer(has_produced);
679 serializer(has_injected);
680 serializer(prediction_mode);
681 serializer(econ_limits);
682 serializer(foam_properties);
683 serializer(polymer_properties);
684 serializer(micp_properties);
685 serializer(brine_properties);
686 serializer(tracer_properties);
687 serializer(connections);
688 serializer(production);
689 serializer(injection);
690 serializer(segments);
696 void switchToInjector();
697 void switchToProducer();
699 GuideRateTarget preferredPhaseAsGuideRatePhase()
const;
702 std::string group_name;
703 std::size_t init_step;
704 std::size_t insert_index;
707 std::optional<double> ref_depth;
708 std::optional<double> wpave_ref_depth;
709 double drainage_radius;
710 bool allow_cross_flow;
711 bool automatic_shutin;
713 GasInflowEquation gas_inflow = GasInflowEquation::STD;
714 UnitSystem unit_system;
715 double udq_undefined;
717 WellGuideRate guide_rate;
718 double efficiency_factor;
719 double solvent_fraction;
720 bool has_produced =
false;
721 bool has_injected =
false;
722 bool prediction_mode =
true;
724 std::shared_ptr<WellEconProductionLimits> econ_limits;
725 std::shared_ptr<WellFoamProperties> foam_properties;
726 std::shared_ptr<WellPolymerProperties> polymer_properties;
727 std::shared_ptr<WellMICPProperties> micp_properties;
728 std::shared_ptr<WellBrineProperties> brine_properties;
729 std::shared_ptr<WellTracerProperties> tracer_properties;
730 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<WVFPEXP> wvfpexp;
739 std::ostream& operator<<( std::ostream&,
const Well::WellInjectionProperties& );
740 std::ostream& operator<<( std::ostream&,
const Well::WellProductionProperties& );
743 std::ostream& operator<<(std::ostream& os,
const Well::Status& st);
744 std::ostream& operator<<(std::ostream& os,
const Well::ProducerCMode& cm);
745 std::ostream& operator<<(std::ostream& os,
const Well::InjectorCMode& cm);
Simple class capturing active cells of a grid.
Definition: ActiveGridCells.hpp:36
Definition: DeckKeyword.hpp:36
Definition: DeckRecord.hpp:32
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:54
Definition: ErrorGuard.hpp:29
Definition: KeywordLocation.hpp:27
Definition: PAvgCalculator.hpp:37
Definition: ParseContext.hpp:88
Definition: ScheduleGrid.hpp:29
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: SummaryState.hpp:69
Definition: TracerConfig.hpp:31
Definition: UDAValue.hpp:32
Definition: UDQActive.hpp:43
Definition: UDQConfig.hpp:51
Definition: UnitSystem.hpp:33
Definition: WVFPEXP.hpp:34
Definition: WellConnections.hpp:44
Definition: WellEconProductionLimits.hpp:33
Definition: WellSegments.hpp:41
Definition: WellTracerProperties.hpp:28
Definition: ScheduleTypes.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: WellBrineProperties.hpp:29
Definition: WellFoamProperties.hpp:29
Definition: WellMICPProperties.hpp:29
Definition: WellPolymerProperties.hpp:28