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 
56 
60  enum class Control : integer
61  {
62  BHP,
63  PHASEVOLRATE,
64  TOTALVOLRATE,
65  MASSRATE,
67  };
68 
69 
74 
80  explicit WellControls( string const & name, dataRepository::Group * const parent );
81 
82 
86  ~WellControls() override;
87 
91  WellControls() = delete;
92 
96  WellControls( WellControls const & ) = delete;
97 
101  WellControls( WellControls && ) = delete;
102 
107  WellControls & operator=( WellControls const & ) = delete;
108 
114 
116 
121 
126  void switchToBHPControl( real64 const & val );
127 
132  void switchToTotalRateControl( real64 const & val );
133 
138  void switchToMassRateControl( real64 const & val );
139 
144  void switchToPhaseRateControl( real64 const & val );
145 
150  Control getControl() const { return m_currentControl; }
151 
156  void setControl( Control const & newControl ) { m_currentControl = newControl; }
157 
162  Control getInputControl() const { return m_inputControl; }
163 
168  real64 getReferenceElevation() const { return m_refElevation; }
169 
174  real64 getReferenceGravityCoef() const { return m_refGravCoef; }
175 
179  void setReferenceGravityCoef( real64 const & refGravCoef ) { m_refGravCoef = refGravCoef; }
180 
181 
186  real64 getTargetBHP( real64 const & currentTime ) const
187  {
188  return m_targetBHPTable->evaluate( &currentTime );
189  }
190 
195  real64 getTargetTotalRate( real64 const & currentTime ) const
196  {
197  return m_rateSign * m_targetTotalRateTable->evaluate( &currentTime );
198  }
199 
204  real64 getTargetPhaseRate( real64 const & currentTime ) const
205  {
206  return m_rateSign * m_targetPhaseRateTable->evaluate( &currentTime );
207  }
212  const string & getTargetPhaseName() const { return m_targetPhaseName; }
213 
218  real64 getTargetMassRate( real64 const & currentTime ) const
219  {
220  return m_rateSign * m_targetMassRateTable->evaluate( &currentTime );
221  }
222 
223 
228  arrayView1d< real64 const > getInjectionStream() const { return m_injectionStream; }
229 
234  real64 getInjectionTemperature() const { return m_injectionTemperature; }
235 
240  integer useSurfaceConditions() const { return m_useSurfaceConditions; }
241 
246  const real64 & getSurfacePressure() const { return m_surfacePres; }
247 
252  const real64 & getSurfaceTemperature() const { return m_surfaceTemp; }
253 
258  bool isInjector() const { return ( m_type == Type::INJECTOR ); }
259 
264  bool isProducer() const { return ( m_type == Type::PRODUCER ); }
265 
271  bool isWellOpen( real64 const & currentTime ) const;
272 
277  bool isCrossflowEnabled() const { return m_isCrossflowEnabled; }
278 
283  real64 getInitialPressureCoefficient() const { return m_initialPressureCoefficient; }
284 
286 
292  {
294  static constexpr char const * refElevString() { return "referenceElevation"; }
296  static constexpr char const * typeString() { return "type"; }
298  static constexpr char const * inputControlString() { return "control"; }
300  static constexpr char const * currentControlString() { return "currentControl"; }
302  static constexpr char const * targetBHPString() { return "targetBHP"; }
304  static constexpr char const * targetTotalRateString() { return "targetTotalRate"; }
306  static constexpr char const * targetPhaseRateString() { return "targetPhaseRate"; }
308  static constexpr char const * targetPhaseNameString() { return "targetPhaseName"; }
310  static constexpr char const * targetMassRateString() { return "targetMassRate"; }
312  static constexpr char const * injectionStreamString() { return "injectionStream"; }
314  static constexpr char const * injectionTemperatureString() { return "injectionTemperature"; }
316  static constexpr char const * useSurfaceConditionsString() { return "useSurfaceConditions"; }
318  static constexpr char const * surfacePressureString() { return "surfacePressure"; }
320  static constexpr char const * surfaceTemperatureString() { return "surfaceTemperature"; }
322  static constexpr char const * targetTotalRateTableNameString() { return "targetTotalRateTableName"; }
324  static constexpr char const * targetPhaseRateTableNameString() { return "targetPhaseRateTableName"; }
326  static constexpr char const * targetMassRateTableNameString() { return "targetMassRateTableName"; }
328  static constexpr char const * targetBHPTableNameString() { return "targetBHPTableName"; }
330  static constexpr char const * statusTableNameString() { return "statusTableName"; }
332  static constexpr char const * enableCrossflowString() { return "enableCrossflow"; }
334  static constexpr char const * initialPressureCoefficientString() { return "initialPressureCoefficient"; }
335 
336  }
339 
340 protected:
341 
342  virtual void postInputInitialization() override;
343 
344 private:
345 
347  Type m_type;
348 
350  real64 m_refElevation;
351 
353  real64 m_refGravCoef;
354 
356  Control m_inputControl;
357 
359  Control m_currentControl;
360 
362  real64 m_targetBHP;
363 
365  real64 m_targetTotalRate;
366 
368  real64 m_targetPhaseRate;
369 
371  string m_targetPhaseName;
372 
374  real64 m_targetMassRate;
375 
377  array1d< real64 > m_injectionStream;
378 
380  real64 m_injectionTemperature;
381 
383  integer m_useSurfaceConditions;
384 
386  real64 m_surfacePres;
387 
389  real64 m_surfaceTemp;
390 
392  string m_targetTotalRateTableName;
393 
395  string m_targetPhaseRateTableName;
396 
398  string m_targetMassRateTableName;
399 
401  string m_targetBHPTableName;
402 
404  string m_statusTableName;
405 
407  integer m_isCrossflowEnabled;
408 
410  real64 m_initialPressureCoefficient;
411 
413  real64 m_rateSign;
414 
416  TableFunction const * m_targetTotalRateTable;
417 
419  TableFunction const * m_targetPhaseRateTable;
420 
422  TableFunction const * m_targetMassRateTable;
423 
425  TableFunction const * m_targetBHPTable;
426 
428  TableFunction const * m_statusTable;
429 };
430 
432  "producer",
433  "injector" );
434 
436  "BHP",
437  "phaseVolRate",
438  "totalVolRate",
439  "massRate",
440  "uninitialized" );
441 
442 
443 } //namespace geos
444 
445 #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.
bool isProducer() const
Is the well a producer?
virtual void postInputInitialization() override
WellControls & operator=(WellControls &&)=delete
Deleted move operator.
Control getControl() const
Get the control type for the well.
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.
bool isWellOpen(real64 const &currentTime) const
Is the well open (or shut) at currentTime?
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.
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 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.
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.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
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 * 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 * 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.