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 
28 namespace geos
29 {
30 namespace dataRepository
31 {
32 namespace keys
33 {
34 static constexpr auto wellControls = "WellControls";
35 }
36 }
37 
38 
44 {
45 public:
46 
50  enum class Type : integer
51  {
52  PRODUCER,
53  INJECTOR
54  };
55 
59  enum class Status : integer
60  {
61  OPEN,
62  CLOSED
63  };
64 
68  enum class Control : integer
69  {
70  BHP,
71  PHASEVOLRATE,
72  TOTALVOLRATE,
73  MASSRATE,
75  };
76 
77 
82 
88  explicit WellControls( string const & name, dataRepository::Group * const parent );
89 
90 
94  ~WellControls() override;
95 
99  WellControls() = delete;
100 
104  WellControls( WellControls const & ) = delete;
105 
109  WellControls( WellControls && ) = delete;
110 
115  WellControls & operator=( WellControls const & ) = delete;
116 
122 
124 
129 
134  void switchToBHPControl( real64 const & val );
135 
140  void switchToTotalRateControl( real64 const & val );
141 
146  void switchToMassRateControl( real64 const & val );
147 
152  void switchToPhaseRateControl( real64 const & val );
153 
158  Control getControl() const { return m_currentControl; }
159 
164  void setControl( Control const & newControl ) { m_currentControl = newControl; }
165 
170  Control getInputControl() const { return m_inputControl; }
171 
176  real64 getReferenceElevation() const { return m_refElevation; }
177 
182  real64 getReferenceGravityCoef() const { return m_refGravCoef; }
183 
187  void setReferenceGravityCoef( real64 const & refGravCoef ) { m_refGravCoef = refGravCoef; }
188 
189 
194  real64 getTargetBHP( real64 const & currentTime ) const
195  {
196  return m_targetBHPTable->evaluate( &currentTime );
197  }
198 
203  real64 getTargetTotalRate( real64 const & currentTime ) const
204  {
205  return m_rateSign * m_targetTotalRateTable->evaluate( &currentTime );
206  }
207 
212  real64 getTargetPhaseRate( real64 const & currentTime ) const
213  {
214  return m_rateSign * m_targetPhaseRateTable->evaluate( &currentTime );
215  }
216 
221  real64 getTargetMassRate( real64 const & currentTime ) const
222  {
223  return m_rateSign * m_targetMassRateTable->evaluate( &currentTime );
224  }
225 
230  const string & getTargetPhaseName() const { return m_targetPhaseName; }
231 
236  arrayView1d< real64 const > getInjectionStream() const { return m_injectionStream; }
237 
242  real64 getInjectionTemperature() const { return m_injectionTemperature; }
243 
248  integer useSurfaceConditions() const { return m_useSurfaceConditions; }
249 
254  string referenceReservoirRegion() const { return m_referenceReservoirRegion; }
255 
260  const real64 & getSurfacePressure() const { return m_surfacePres; }
261 
266  const real64 & getSurfaceTemperature() const { return m_surfaceTemp; }
267 
272  bool isInjector() const { return ( m_type == Type::INJECTOR ); }
273 
278  bool isProducer() const { return ( m_type == Type::PRODUCER ); }
279 
284  bool isWellOpen() const;
285 
290  bool isCrossflowEnabled() const { return m_isCrossflowEnabled; }
291 
296  real64 getInitialPressureCoefficient() const { return m_initialPressureCoefficient; }
297 
303  void setNextDtFromTables( real64 const & currentTime, real64 & nextDt );
304 
309  real64 getRegionAveragePressure() const { return m_regionAveragePressure; }
310 
315  void setRegionAveragePressure( real64 regionAveragePressure ) { m_regionAveragePressure = regionAveragePressure; }
316 
321  real64 getRegionAverageTemperature() const { return m_regionAverageTemperature; }
322 
327  void setRegionAverageTemperature( real64 regionAverageTemperature ) { m_regionAverageTemperature = regionAverageTemperature; }
328 
334  void setWellStatus ( real64 const & currentTime, WellControls::Status status );
335 
340  WellControls::Status getWellStatus () const { return m_wellStatus; }
342 
348  {
350  static constexpr char const * refElevString() { return "referenceElevation"; }
352  static constexpr char const * typeString() { return "type"; }
354  static constexpr char const * inputControlString() { return "control"; }
356  static constexpr char const * currentControlString() { return "currentControl"; }
358  static constexpr char const * targetBHPString() { return "targetBHP"; }
360  static constexpr char const * targetTotalRateString() { return "targetTotalRate"; }
362  static constexpr char const * targetPhaseRateString() { return "targetPhaseRate"; }
364  static constexpr char const * targetPhaseNameString() { return "targetPhaseName"; }
366  static constexpr char const * targetMassRateString() { return "targetMassRate"; }
368  static constexpr char const * injectionStreamString() { return "injectionStream"; }
370  static constexpr char const * injectionTemperatureString() { return "injectionTemperature"; }
372  static constexpr char const * useSurfaceConditionsString() { return "useSurfaceConditions"; }
374  static constexpr char const * referenceReservoirRegionString() { return "referenceReservoirRegion"; }
376  static constexpr char const * surfacePressureString() { return "surfacePressure"; }
378  static constexpr char const * surfaceTemperatureString() { return "surfaceTemperature"; }
380  static constexpr char const * targetTotalRateTableNameString() { return "targetTotalRateTableName"; }
382  static constexpr char const * targetPhaseRateTableNameString() { return "targetPhaseRateTableName"; }
384  static constexpr char const * targetMassRateTableNameString() { return "targetMassRateTableName"; }
386  static constexpr char const * targetBHPTableNameString() { return "targetBHPTableName"; }
388  static constexpr char const * statusTableNameString() { return "statusTableName"; }
390  static constexpr char const * perfStatusTableNameString() { return "perfStatusTableName"; }
392  static constexpr char const * enableCrossflowString() { return "enableCrossflow"; }
394  static constexpr char const * initialPressureCoefficientString() { return "initialPressureCoefficient"; }
395 
396  }
399 
400  static void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
401 
402 protected:
403 
404  virtual void postInputInitialization() override;
405 
406 
407 
408 private:
409 
411  Type m_type;
412 
414  real64 m_refElevation;
415 
417  real64 m_refGravCoef;
418 
420  Control m_inputControl;
421 
423  Control m_currentControl;
424 
426  real64 m_targetBHP;
427 
429  real64 m_targetTotalRate;
430 
432  real64 m_targetPhaseRate;
433 
435  string m_targetPhaseName;
436 
438  real64 m_targetMassRate;
439 
441  array1d< real64 > m_injectionStream;
442 
444  real64 m_injectionTemperature;
445 
447  integer m_useSurfaceConditions;
448 
450  string m_referenceReservoirRegion;
451 
453  real64 m_surfacePres;
454 
456  real64 m_surfaceTemp;
457 
459  string m_targetTotalRateTableName;
460 
462  string m_targetPhaseRateTableName;
463 
465  string m_targetMassRateTableName;
466 
468  string m_targetBHPTableName;
469 
471  string m_statusTableName;
472 
474  string m_perfStatusTableName;
475 
477  integer m_isCrossflowEnabled;
478 
480  real64 m_initialPressureCoefficient;
481 
483  real64 m_rateSign;
484 
486  TableFunction const * m_targetTotalRateTable;
487 
489  TableFunction const * m_targetPhaseRateTable;
490 
492  TableFunction const * m_targetMassRateTable;
493 
495  TableFunction const * m_targetBHPTable;
496 
498  TableFunction const * m_statusTable;
499 
501  WellControls::Status m_wellStatus;
502 
503 
505  real64 m_regionAveragePressure;
506 
508  real64 m_regionAverageTemperature;
509 
510 };
511 
513  "producer",
514  "injector" );
515 
517  "BHP",
518  "phaseVolRate",
519  "totalVolRate",
520  "massRate",
521  "uninitialized" );
522 
523 
524 } //namespace geos
525 
526 #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.
string referenceReservoirRegion() const
Getter for the reservoir region associated with reservoir volume constraint.
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.
void setReferenceGravityCoef(real64 const &refGravCoef)
Setter for the reference gravity.
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.
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.