35 #include <opm/parser/eclipse/Deck/UDAValue.hpp>
36 #include <opm/parser/eclipse/EclipseState/Runspec.hpp>
37 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
38 #include <opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp>
39 #include <opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp>
40 #include <opm/parser/eclipse/EclipseState/Schedule/Well/PAvg.hpp>
41 #include <opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp>
42 #include <opm/parser/eclipse/EclipseState/Schedule/Well/ProductionControls.hpp>
43 #include <opm/parser/eclipse/EclipseState/Schedule/Well/InjectionControls.hpp>
44 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellFoamProperties.hpp>
45 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellBrineProperties.hpp>
46 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTracerProperties.hpp>
47 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellPolymerProperties.hpp>
48 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellMICPProperties.hpp>
49 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellEconProductionLimits.hpp>
50 #include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
51 #include <opm/parser/eclipse/Units/Units.hpp>
52 #include <opm/parser/eclipse/Units/UnitSystem.hpp>
54 #include <opm/common/utility/ActiveGridCells.hpp>
58 class ActiveGridCells;
84 static std::string Status2String(Status enumValue);
85 static Status StatusFromString(
const std::string& stringValue);
94 enum class InjectorCMode : int{
100 CMODE_UNDEFINED = 512
102 static const std::string InjectorCMode2String( InjectorCMode enumValue );
103 static InjectorCMode InjectorCModeFromString(
const std::string& stringValue );
117 enum class ProducerCMode : int {
128 CMODE_UNDEFINED = 1024
130 static const std::string ProducerCMode2String( ProducerCMode enumValue );
131 static ProducerCMode ProducerCModeFromString(
const std::string& stringValue );
135 enum class WELTARGCMode {
149 static WELTARGCMode WELTARGCModeFromString(
const std::string& stringValue);
152 enum class GuideRateTarget {
164 static const std::string GuideRateTarget2String( GuideRateTarget enumValue );
165 static GuideRateTarget GuideRateTargetFromString(
const std::string& stringValue );
168 enum class GasInflowEquation {
174 static const std::string GasInflowEquation2String(GasInflowEquation enumValue);
175 static GasInflowEquation GasInflowEquationFromString(
const std::string& stringValue);
182 GuideRateTarget guide_phase;
188 result.available =
true;
189 result.guide_rate = 1.0;
190 result.guide_phase = GuideRateTarget::COMB;
191 result.scale_factor = 2.0;
197 return available == data.available &&
198 guide_rate == data.guide_rate &&
199 guide_phase == data.guide_phase &&
200 scale_factor == data.scale_factor;
203 template<
class Serializer>
206 serializer(available);
207 serializer(guide_rate);
208 serializer(guide_phase);
209 serializer(scale_factor);
217 controls(controls_arg)
224 InjectorType injector_type;
225 InjectorCMode cmode = InjectorCMode::CMODE_UNDEFINED;
227 double reservoir_rate;
229 int vfp_table_number;
230 bool prediction_mode;
232 bool hasControl(InjectorCMode cmode_arg)
const {
233 return (this->controls &
static_cast<int>(cmode_arg)) != 0;
249 double bhp_hist_limit = 0.0;
250 double thp_hist_limit = 0.0;
257 int injectionControls;
258 InjectorType injectorType;
259 InjectorCMode controlMode;
269 void handleWELTARG(WELTARGCMode cmode,
const UDAValue& new_arg,
double SIFactorP);
270 void handleWCONINJE(
const DeckRecord& record,
bool availableForGroupControl,
const std::string& well_name);
271 void handleWCONINJH(
const DeckRecord& record,
bool is_producer,
const std::string& well_name);
272 bool hasInjectionControl(InjectorCMode controlModeArg)
const {
273 if (injectionControls &
static_cast<int>(controlModeArg))
279 void dropInjectionControl(InjectorCMode controlModeArg) {
280 auto int_arg =
static_cast<int>(controlModeArg);
281 if ((injectionControls & int_arg) != 0)
282 injectionControls -= int_arg;
285 void addInjectionControl(InjectorCMode controlModeArg) {
286 auto int_arg =
static_cast<int>(controlModeArg);
287 if ((injectionControls & int_arg) == 0)
288 injectionControls += int_arg;
291 void clearControls();
293 void resetDefaultHistoricalBHPLimit();
294 void resetBHPLimit();
295 void setBHPLimit(
const double limit);
300 template<
class Serializer>
304 surfaceInjectionRate.serializeOp(serializer);
305 reservoirInjectionRate.serializeOp(serializer);
306 BHPTarget.serializeOp(serializer);
307 THPTarget.serializeOp(serializer);
308 serializer(bhp_hist_limit);
309 serializer(thp_hist_limit);
310 serializer(temperature);
313 serializer(VFPTableNumber);
314 serializer(predictionMode);
315 serializer(injectionControls);
316 serializer(injectorType);
317 serializer(controlMode);
324 controls(controls_arg)
328 ProducerCMode cmode = ProducerCMode::NONE;
330 double water_rate{0};
332 double liquid_rate{0};
334 double bhp_history{0};
335 double thp_history{0};
339 int vfp_table_number{0};
340 bool prediction_mode{0};
342 bool hasControl(ProducerCMode cmode_arg)
const {
343 return (this->controls &
static_cast<int>(cmode_arg)) != 0;
347 return this->cmode == other.cmode &&
348 this->oil_rate == other.oil_rate &&
349 this->water_rate == other.water_rate &&
350 this->gas_rate == other.gas_rate &&
351 this->liquid_rate == other.liquid_rate &&
352 this->resv_rate == other.resv_rate &&
353 this->bhp_history == other.bhp_history &&
354 this->thp_history == other.thp_history &&
355 this->bhp_limit == other.bhp_limit &&
356 this->thp_limit == other.thp_limit &&
357 this->alq_value == other.alq_value &&
358 this->vfp_table_number == other.vfp_table_number &&
359 this->prediction_mode == other.prediction_mode;
383 double bhp_hist_limit = 0.0;
384 double thp_hist_limit = 0.0;
389 int VFPTableNumber = 0;
390 bool predictionMode =
false;
391 ProducerCMode controlMode = ProducerCMode::CMODE_UNDEFINED;
392 ProducerCMode whistctl_cmode = ProducerCMode::CMODE_UNDEFINED;
402 bool hasProductionControl(ProducerCMode controlModeArg)
const {
403 return (m_productionControls &
static_cast<int>(controlModeArg)) != 0;
406 void dropProductionControl(ProducerCMode controlModeArg) {
407 if (hasProductionControl(controlModeArg))
408 m_productionControls -=
static_cast<int>(controlModeArg);
411 void addProductionControl(ProducerCMode controlModeArg) {
412 if (! hasProductionControl(controlModeArg))
413 m_productionControls +=
static_cast<int>(controlModeArg);
417 static bool effectiveHistoryProductionControl(ProducerCMode cmode);
418 void handleWCONPROD(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const std::string& well,
const DeckRecord& record);
419 void handleWCONHIST(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
420 void handleWELTARG( WELTARGCMode cmode,
const UDAValue& new_arg,
double SiFactorP);
421 void resetDefaultBHPLimit();
422 void clearControls();
427 void setBHPLimit(
const double limit);
428 int productionControls()
const {
return this->m_productionControls; }
430 template<
class Serializer>
434 OilRate.serializeOp(serializer);
435 WaterRate.serializeOp(serializer);
436 GasRate.serializeOp(serializer);
437 LiquidRate.serializeOp(serializer);
438 ResVRate.serializeOp(serializer);
439 BHPTarget.serializeOp(serializer);
440 THPTarget.serializeOp(serializer);
441 ALQValue.serializeOp(serializer);
442 serializer(bhp_hist_limit);
443 serializer(thp_hist_limit);
446 serializer(VFPTableNumber);
447 serializer(predictionMode);
448 serializer(controlMode);
449 serializer(whistctl_cmode);
450 serializer(m_productionControls);
454 int m_productionControls = 0;
458 void init_vfp(
const std::optional<VFPProdTable::ALQ_TYPE>& alq_type,
const UnitSystem& unit_system,
const DeckRecord& record);
462 double getBHPLimit()
const;
465 static int eclipseControlMode(
const Well::InjectorCMode imode,
466 const InjectorType itype);
468 static int eclipseControlMode(
const Well::ProducerCMode pmode);
470 static int eclipseControlMode(
const Well& well,
475 Well(
const std::string& wname,
476 const std::string& gname,
477 std::size_t init_step,
478 std::size_t insert_index,
481 const std::optional<double>& ref_depth,
483 ProducerCMode whistctl_cmode,
484 Connection::Order ordering,
486 double udq_undefined,
491 GasInflowEquation inflow_eq);
496 double udq_undefined);
498 static Well serializeObject();
500 bool isMultiSegment()
const;
501 bool isAvailableForGroupControl()
const;
502 double getGuideRate()
const;
503 GuideRateTarget getGuideRatePhase()
const;
504 double getGuideRateScalingFactor()
const;
506 bool hasBeenDefined(
size_t timeStep)
const;
507 std::size_t firstTimeStep()
const;
509 bool predictionMode()
const;
510 bool canOpen()
const;
511 bool isProducer()
const;
512 bool isInjector()
const;
513 InjectorCMode injection_cmode()
const;
514 ProducerCMode production_cmode()
const;
515 InjectorType injectorType()
const;
516 size_t seqIndex()
const;
517 bool getAutomaticShutIn()
const;
518 bool getAllowCrossFlow()
const;
519 const std::string& name()
const;
520 const std::vector<std::string>& wListNames()
const;
521 int getHeadI()
const;
522 int getHeadJ()
const;
523 double getWPaveRefDepth()
const;
524 double getRefDepth()
const;
525 double getDrainageRadius()
const;
526 double getEfficiencyFactor()
const;
527 double getSolventFraction()
const;
528 Status getStatus()
const;
529 const std::string& groupName()
const;
530 Phase getPreferredPhase()
const;
532 const std::vector<const Connection *> getConnections(
int completion)
const;
552 double production_rate(
const SummaryState& st, Phase phase)
const;
553 double injection_rate(
const SummaryState& st, Phase phase)
const;
554 static bool wellNameInWellNamePattern(
const std::string& wellName,
const std::string& wellNamePattern);
569 std::map<int, std::vector<Connection>> getCompletions()
const;
575 bool hasCompletion(
int completion)
const;
576 bool updatePrediction(
bool prediction_mode);
577 bool updateAutoShutin(
bool auto_shutin);
578 bool updateCrossFlow(
bool allow_cross_flow);
579 bool updatePVTTable(
int pvt_table);
580 bool updateHead(
int I,
int J);
581 void updateRefDepth();
582 bool updateRefDepth(
const std::optional<double>& ref_dpeth);
583 bool updateDrainageRadius(
double drainage_radius);
584 void updateSegments(std::shared_ptr<WellSegments> segments_arg);
585 bool updateConnections(std::shared_ptr<WellConnections> connections,
bool force);
586 bool updateConnections(std::shared_ptr<WellConnections> connections,
const EclipseGrid& grid,
const std::vector<int>& pvtnum);
587 bool updateStatus(Status status);
588 bool updateGroup(
const std::string& group);
589 bool updateWellGuideRate(
bool available,
double guide_rate, GuideRateTarget guide_phase,
double scale_factor);
590 bool updateWellGuideRate(
double guide_rate);
591 bool updateEfficiencyFactor(
double efficiency_factor);
592 bool updateSolventFraction(
double solvent_fraction);
593 bool updateTracer(std::shared_ptr<WellTracerProperties> tracer_properties);
594 bool updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties);
595 bool updatePolymerProperties(std::shared_ptr<WellPolymerProperties> polymer_properties);
596 bool updateMICPProperties(std::shared_ptr<WellMICPProperties> micp_properties);
597 bool updateBrineProperties(std::shared_ptr<WellBrineProperties> brine_properties);
598 bool updateEconLimits(std::shared_ptr<WellEconProductionLimits> econ_limits);
599 bool updateProduction(std::shared_ptr<WellProductionProperties> production);
600 bool updateInjection(std::shared_ptr<WellInjectionProperties> injection);
601 bool updateWellProductivityIndex();
602 bool updateWSEGSICD(
const std::vector<std::pair<int, SICD> >& sicd_pairs);
603 bool updateWSEGVALV(
const std::vector<std::pair<int, Valve> >& valve_pairs);
604 bool updateWSEGAICD(
const std::vector<std::pair<int, AutoICD> >& aicd_pairs,
const KeywordLocation& location);
605 bool updateWPAVE(
const PAvg& pavg);
606 void updateWPaveRefDepth(
double ref_depth);
610 bool handleWELOPENConnections(
const DeckRecord& record, Connection::State status);
611 bool handleCOMPLUMP(
const DeckRecord& record);
617 int vfp_table_number()
const;
618 int pvt_table_number()
const;
619 int fip_region_number()
const;
620 GasInflowEquation gas_inflow_equation()
const;
621 bool segmented_density_calculation()
const {
return true; }
622 double alq_value()
const;
623 double temperature()
const;
624 bool hasInjected( )
const;
625 bool hasProduced( )
const;
626 bool updateHasInjected( );
627 bool updateHasProduced();
628 bool cmp_structure(
const Well& other)
const;
629 bool operator==(
const Well& data)
const;
630 bool hasSameConnectionsPointers(
const Well& other)
const;
631 void setInsertIndex(std::size_t index);
632 double convertDeckPI(
double deckPI)
const;
633 void applyWellProdIndexScaling(
const double scalingFactor,
634 std::vector<bool>& scalingApplicable);
635 const PAvg& pavg()
const;
638 template<
class Serializer>
642 serializer(group_name);
643 serializer(init_step);
644 serializer(insert_index);
647 serializer(ref_depth);
648 serializer(wpave_ref_depth);
649 unit_system.serializeOp(serializer);
650 serializer(udq_undefined);
652 serializer(drainage_radius);
653 serializer(allow_cross_flow);
654 serializer(automatic_shutin);
655 serializer(pvt_table);
656 serializer(gas_inflow);
657 wtype.serializeOp(serializer);
658 guide_rate.serializeOp(serializer);
659 serializer(efficiency_factor);
660 serializer(solvent_fraction);
661 serializer(has_produced);
662 serializer(has_injected);
663 serializer(prediction_mode);
664 serializer(econ_limits);
665 serializer(foam_properties);
666 serializer(polymer_properties);
667 serializer(micp_properties);
668 serializer(brine_properties);
669 serializer(tracer_properties);
670 serializer(connections);
671 serializer(production);
672 serializer(injection);
673 serializer(segments);
674 m_pavg.serializeOp(serializer);
678 void switchToInjector();
679 void switchToProducer();
682 std::string group_name;
683 std::size_t init_step;
684 std::size_t insert_index;
687 std::optional<double> ref_depth;
688 std::optional<double> wpave_ref_depth;
689 double drainage_radius;
690 bool allow_cross_flow;
691 bool automatic_shutin;
693 GasInflowEquation gas_inflow = GasInflowEquation::STD;
694 UnitSystem unit_system;
695 double udq_undefined;
697 WellGuideRate guide_rate;
698 double efficiency_factor;
699 double solvent_fraction;
700 bool has_produced =
false;
701 bool has_injected =
false;
702 bool prediction_mode =
true;
704 std::shared_ptr<WellEconProductionLimits> econ_limits;
705 std::shared_ptr<WellFoamProperties> foam_properties;
706 std::shared_ptr<WellPolymerProperties> polymer_properties;
707 std::shared_ptr<WellMICPProperties> micp_properties;
708 std::shared_ptr<WellBrineProperties> brine_properties;
709 std::shared_ptr<WellTracerProperties> tracer_properties;
710 std::shared_ptr<WellConnections> connections;
711 std::shared_ptr<WellProductionProperties> production;
712 std::shared_ptr<WellInjectionProperties> injection;
713 std::shared_ptr<WellSegments> segments;
718 std::ostream& operator<<( std::ostream&,
const Well::WellInjectionProperties& );
719 std::ostream& operator<<( std::ostream&,
const Well::WellProductionProperties& );
722 std::ostream& operator<<(std::ostream& os,
const Well::Status& st);
723 std::ostream& operator<<(std::ostream& os,
const Well::ProducerCMode& cm);
724 std::ostream& operator<<(std::ostream& os,
const Well::InjectorCMode& cm);
Simple class capturing active cells of a grid.
Definition: ActiveGridCells.hpp:35
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:55
Definition: ErrorGuard.hpp:29
Definition: KeywordLocation.hpp:27
Definition: PAvgCalculator.hpp:37
Definition: ParseContext.hpp:88
Definition: Serializer.hpp:38
Definition: SummaryState.hpp:69
Definition: UDAValue.hpp:32
Definition: UDQActive.hpp:43
Definition: UDQConfig.hpp:51
Definition: UnitSystem.hpp:34
Definition: WellConnections.hpp:38
Definition: WellEconProductionLimits.hpp:29
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