GEOS
WellControls.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
16 /*
17  * @file WellControls.hpp
18  */
19 
20 
21 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
22 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
23 
25 #include "dataRepository/Group.hpp"
27 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
28 
29 namespace geos
30 {
31 namespace dataRepository
32 {
33 namespace keys
34 {
35 static constexpr auto wellControls = "WellControls";
36 }
37 }
38 
39 
45 {
46 public:
47 
51  enum class Type : integer
52  {
53  PRODUCER,
54  INJECTOR
55  };
56 
60  enum class Status : integer
61  {
62  OPEN,
63  CLOSED
64  };
65 
69  enum class Control : integer
70  {
71  BHP,
72  PHASEVOLRATE,
73  TOTALVOLRATE,
74  MASSRATE,
76  };
77 
78 
83 
89  explicit WellControls( string const & name, dataRepository::Group * const parent );
90 
91 
95  ~WellControls() override;
96 
100  WellControls() = delete;
101 
105  WellControls( WellControls const & ) = delete;
106 
110  WellControls( WellControls && ) = delete;
111 
116  WellControls & operator=( WellControls const & ) = delete;
117 
123 
125 
130 
135  void switchToBHPControl( real64 const & val );
136 
141  void switchToTotalRateControl( real64 const & val );
142 
147  void switchToMassRateControl( real64 const & val );
148 
153  void switchToPhaseRateControl( real64 const & val );
154 
159  Control getControl() const { return m_currentControl; }
160 
165  void setControl( Control const & newControl ) { m_currentControl = newControl; }
166 
171  Control getInputControl() const { return m_inputControl; }
172 
177  real64 getReferenceElevation() const { return m_refElevation; }
178 
183  real64 getReferenceGravityCoef() const { return m_refGravCoef; }
184 
188  void setReferenceGravityCoef( real64 const & refGravCoef ) { m_refGravCoef = refGravCoef; }
189 
190 
195  real64 getTargetBHP( real64 const & currentTime ) const
196  {
197  return m_targetBHPTable->evaluate( &currentTime );
198  }
199 
204  real64 getTargetTotalRate( real64 const & currentTime ) const
205  {
206  return m_rateSign * m_targetTotalRateTable->evaluate( &currentTime );
207  }
208 
213  real64 getTargetPhaseRate( real64 const & currentTime ) const
214  {
215  return m_rateSign * m_targetPhaseRateTable->evaluate( &currentTime );
216  }
217 
222  real64 getTargetMassRate( real64 const & currentTime ) const
223  {
224  return m_rateSign * m_targetMassRateTable->evaluate( &currentTime );
225  }
226 
231  const string & getTargetPhaseName() const { return m_targetPhaseName; }
232 
237  arrayView1d< real64 const > getInjectionStream() const { return m_injectionStream; }
238 
243  real64 getInjectionTemperature() const { return m_injectionTemperature; }
244 
249  integer useSurfaceConditions() const { return m_useSurfaceConditions; }
250 
255  string const & referenceReservoirRegion() const { return m_referenceReservoirRegion; }
256 
261  const real64 & getSurfacePressure() const { return m_surfacePres; }
262 
267  const real64 & getSurfaceTemperature() const { return m_surfaceTemp; }
268 
273  bool isInjector() const { return ( m_type == Type::INJECTOR ); }
274 
279  bool isProducer() const { return ( m_type == Type::PRODUCER ); }
280 
285  bool isWellOpen() const;
286 
291  bool isCrossflowEnabled() const { return m_isCrossflowEnabled; }
292 
297  real64 getInitialPressureCoefficient() const { return m_initialPressureCoefficient; }
298 
304  void setNextDtFromTables( real64 const & currentTime, real64 & nextDt );
305 
310  void setFluidSeparator( std::unique_ptr< constitutive::ConstitutiveBase > fluidSeparatorPtr ) { m_fluidSeparatorPtr = std::move( fluidSeparatorPtr );}
315  constitutive::MultiFluidBase & getMultiFluidSeparator() { return dynamicCast< constitutive::MultiFluidBase & >( *m_fluidSeparatorPtr ); }
316 
322  real64 getRegionAveragePressure() const { return m_regionAveragePressure; }
323 
329  void setRegionAveragePressure( real64 regionAveragePressure ) { m_regionAveragePressure = regionAveragePressure; }
330 
335  real64 getRegionAverageTemperature() const { return m_regionAverageTemperature; }
336 
341  void setRegionAverageTemperature( real64 regionAverageTemperature ) { m_regionAverageTemperature = regionAverageTemperature; }
342 
348  void setWellStatus ( real64 const & currentTime, WellControls::Status status );
349 
354  WellControls::Status getWellStatus () const { return m_wellStatus; }
356 
362  {
364  static constexpr char const * refElevString() { return "referenceElevation"; }
366  static constexpr char const * typeString() { return "type"; }
368  static constexpr char const * inputControlString() { return "control"; }
370  static constexpr char const * currentControlString() { return "currentControl"; }
372  static constexpr char const * targetBHPString() { return "targetBHP"; }
374  static constexpr char const * targetTotalRateString() { return "targetTotalRate"; }
376  static constexpr char const * targetPhaseRateString() { return "targetPhaseRate"; }
378  static constexpr char const * targetPhaseNameString() { return "targetPhaseName"; }
380  static constexpr char const * targetMassRateString() { return "targetMassRate"; }
382  static constexpr char const * injectionStreamString() { return "injectionStream"; }
384  static constexpr char const * injectionTemperatureString() { return "injectionTemperature"; }
386  static constexpr char const * useSurfaceConditionsString() { return "useSurfaceConditions"; }
388  static constexpr char const * referenceReservoirRegionString() { return "referenceReservoirRegion"; }
390  static constexpr char const * surfacePressureString() { return "surfacePressure"; }
392  static constexpr char const * surfaceTemperatureString() { return "surfaceTemperature"; }
394  static constexpr char const * targetTotalRateTableNameString() { return "targetTotalRateTableName"; }
396  static constexpr char const * targetPhaseRateTableNameString() { return "targetPhaseRateTableName"; }
398  static constexpr char const * targetMassRateTableNameString() { return "targetMassRateTableName"; }
400  static constexpr char const * targetBHPTableNameString() { return "targetBHPTableName"; }
402  static constexpr char const * statusTableNameString() { return "statusTableName"; }
404  static constexpr char const * perfStatusTableNameString() { return "perfStatusTableName"; }
406  static constexpr char const * enableCrossflowString() { return "enableCrossflow"; }
408  static constexpr char const * initialPressureCoefficientString() { return "initialPressureCoefficient"; }
409 
410  }
413 
414  static void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
415 
416 protected:
417 
418  virtual void postInputInitialization() override;
419 
420 
421 
422 private:
423 
425  Type m_type;
426 
428  real64 m_refElevation;
429 
431  real64 m_refGravCoef;
432 
434  Control m_inputControl;
435 
437  Control m_currentControl;
438 
440  real64 m_targetBHP;
441 
443  real64 m_targetTotalRate;
444 
446  real64 m_targetPhaseRate;
447 
449  string m_targetPhaseName;
450 
452  real64 m_targetMassRate;
453 
455  array1d< real64 > m_injectionStream;
456 
458  real64 m_injectionTemperature;
459 
461  integer m_useSurfaceConditions;
462 
463  // Fuild model to compute properties for constraint equation user specified conditions
464  std::unique_ptr< constitutive::ConstitutiveBase > m_fluidSeparatorPtr;
465 
467  string m_referenceReservoirRegion;
468 
470  real64 m_surfacePres;
471 
473  real64 m_surfaceTemp;
474 
476  string m_targetTotalRateTableName;
477 
479  string m_targetPhaseRateTableName;
480 
482  string m_targetMassRateTableName;
483 
485  string m_targetBHPTableName;
486 
488  string m_statusTableName;
489 
491  string m_perfStatusTableName;
492 
494  integer m_isCrossflowEnabled;
495 
497  real64 m_initialPressureCoefficient;
498 
500  real64 m_rateSign;
501 
503  TableFunction const * m_targetTotalRateTable;
504 
506  TableFunction const * m_targetPhaseRateTable;
507 
509  TableFunction const * m_targetMassRateTable;
510 
512  TableFunction const * m_targetBHPTable;
513 
515  TableFunction const * m_statusTable;
516 
518  WellControls::Status m_wellStatus;
519 
520 
522  real64 m_regionAveragePressure;
523 
525  real64 m_regionAverageTemperature;
526 
527 };
528 
530  "producer",
531  "injector" );
532 
534  "BHP",
535  "phaseVolRate",
536  "totalVolRate",
537  "massRate",
538  "uninitialized" );
539 
540 
541 } //namespace geos
542 
543 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
virtual void evaluate(dataRepository::Group const &group, real64 const time, SortedArrayView< localIndex const > const &set, arrayView1d< real64 > const &result) const override final
Method to evaluate a function on a target object.
This class describes the controls used to operate a well.
~WellControls() override
Default destructor.
void setWellStatus(real64 const &currentTime, WellControls::Status status)
Set well status from time and internal action, eg. all perfs closed.
bool isProducer() const
Is the well a producer?
virtual void postInputInitialization() override
WellControls & operator=(WellControls &&)=delete
Deleted move operator.
real64 getRegionAverageTemperature() const
Getter for the reservoir average temperature when m_useSurfaceConditions == 0.
Control getControl() const
Get the control type for the well.
void setNextDtFromTables(real64 const &currentTime, real64 &nextDt)
set next time step based on tables intervals
struct geos::WellControls::viewKeyStruct viewKeysWellControls
ViewKey struct for the WellControls class.
bool isInjector() const
Is the well an injector?
real64 getReferenceElevation() const
Getter for the reference elevation where the BHP control is enforced.
WellControls::Status getWellStatus() const
Is the well open (or shut) based on internal action.
WellControls(WellControls &&)=delete
Deleted move constructor.
real64 getTargetPhaseRate(real64 const &currentTime) const
Get the target phase rate.
void switchToBHPControl(real64 const &val)
Set the control type to BHP and set a numerical value for the control.
void switchToTotalRateControl(real64 const &val)
Set the control type to total rate and set a numerical value for the control.
real64 getRegionAveragePressure() const
Getter for the reservoir average pressure when m_useSurfaceConditions == 0.
integer useSurfaceConditions() const
Getter for the flag specifying whether we check rates at surface or reservoir conditions.
real64 getTargetTotalRate(real64 const &currentTime) const
Get the target total rate.
string const & referenceReservoirRegion() const
Getter for the reservoir region associated with reservoir volume constraint.
void setReferenceGravityCoef(real64 const &refGravCoef)
Setter for the reference gravity.
void setFluidSeparator(std::unique_ptr< constitutive::ConstitutiveBase > fluidSeparatorPtr)
setter for multi fluid separator
WellControls(string const &name, dataRepository::Group *const parent)
Constructor for WellControls Objects.
void setRegionAverageTemperature(real64 regionAverageTemperature)
Set the reservoir average temperature when m_useSurfaceConditions == 0.
void setControl(Control const &newControl)
Set the control type for the well.
WellControls(WellControls const &)=delete
Deleted copy constructor.
WellControls & operator=(WellControls const &)=delete
Deleted assignment operator.
const string & getTargetPhaseName() const
Get the target phase name.
void switchToMassRateControl(real64 const &val)
Set the control type to mass rate and set a numerical value for the control.
void switchToPhaseRateControl(real64 const &val)
Set the control type to phase rate and set a numerical value for the control.
real64 getTargetMassRate(real64 const &currentTime) const
Get the target mass rate.
bool isCrossflowEnabled() const
Getter for the flag to enable crossflow.
WellControls()=delete
Deleted default constructor.
real64 getTargetBHP(real64 const &currentTime) const
Get the target bottom hole pressure value.
bool isWellOpen() const
Is the well open (or shut) at currentTime, status initalized in WellSolverBase::implicitStepSetup.
const real64 & getSurfaceTemperature() const
Getter for the surface temperature when m_useSurfaceConditions == 1.
Control getInputControl() const
Get the input control type for the well.
arrayView1d< real64 const > getInjectionStream() const
Const accessor for the composition of the injection stream.
real64 getReferenceGravityCoef() const
Getter for the reference gravity coefficient.
real64 getInitialPressureCoefficient() const
Getter for the initial pressure coefficient.
const real64 & getSurfacePressure() const
Getter for the surface pressure when m_useSurfaceConditions == 1.
constitutive::MultiFluidBase & getMultiFluidSeparator()
Getter for multi fluid separator.
real64 getInjectionTemperature() const
Const accessor for the temperature of the injection stream.
void setRegionAveragePressure(real64 regionAveragePressure)
Set the reservoir average pressure when m_useSurfaceConditions == 0.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "richardson", "preconditioner")
Declare strings associated with enumeration values.
Struct to serve as a container for variable strings and keys.
static constexpr char const * targetBHPTableNameString()
string key for BHP table name
static constexpr char const * initialPressureCoefficientString()
string key for the initial pressure coefficient
static constexpr char const * useSurfaceConditionsString()
String key for checking the rates at surface conditions.
static constexpr char const * perfStatusTableNameString()
string key for perforation status table name
static constexpr char const * refElevString()
String key for the well reference elevation (for BHP control)
static constexpr char const * enableCrossflowString()
string key for the crossflow flag
static constexpr char const * targetMassRateTableNameString()
string key for mass rate table name
static constexpr char const * referenceReservoirRegionString()
String key for reference reservoir region.
static constexpr char const * injectionTemperatureString()
String key for the well injection temperature.
static constexpr char const * surfaceTemperatureString()
String key for the surface temperature.
static constexpr char const * injectionStreamString()
String key for the well injection stream.
static constexpr char const * statusTableNameString()
string key for status table name
static constexpr char const * targetTotalRateTableNameString()
string key for total rate table name
static constexpr char const * targetBHPString()
String key for the well target BHP.
static constexpr char const * targetTotalRateString()
String key for the well target rate.
static constexpr char const * targetPhaseRateTableNameString()
string key for phase rate table name
static constexpr char const * surfacePressureString()
String key for the surface pressure.
static constexpr char const * targetPhaseNameString()
String key for the well target phase name.
static constexpr char const * targetMassRateString()
String key for the well target phase name.
static constexpr char const * targetPhaseRateString()
String key for the well target phase rate.
static constexpr char const * inputControlString()
String key for the well input control.
static constexpr char const * typeString()
String key for the well type.
static constexpr char const * currentControlString()
String key for the well current control.