VFPInjProperties.hpp
1 /*
2  Copyright 2015 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_AUTODIFF_VFPINJPROPERTIES_HPP_
21 #define OPM_AUTODIFF_VFPINJPROPERTIES_HPP_
22 
23 #include <opm/parser/eclipse/EclipseState/Tables/VFPInjTable.hpp>
24 #include <opm/core/wells.h>
25 #include <opm/material/densead/Math.hpp>
26 #include <opm/material/densead/Evaluation.hpp>
27 #include <opm/autodiff/VFPHelpers.hpp>
28 
29 #include <vector>
30 #include <map>
31 
32 
33 
34 namespace Opm {
35 
36 template <class Scalar>
37 class AutoDiffBlock;
38 
40 public:
41  typedef AutoDiffBlock<double> ADB;
42 
47 
53  explicit VFPInjProperties(const VFPInjTable* inj_table);
54 
60  explicit VFPInjProperties(const std::map<int, VFPInjTable>& inj_tables);
61 
72  ADB bhp(const std::vector<int>& table_id,
73  const Wells& wells,
74  const ADB& qs,
75  const ADB& thp) const;
76 
92  ADB bhp(const std::vector<int>& table_id,
93  const ADB& aqua,
94  const ADB& liquid,
95  const ADB& vapour,
96  const ADB& thp) const;
97 
114  template <class EvalWell>
115  EvalWell bhp(const int table_id,
116  const EvalWell& aqua,
117  const EvalWell& liquid,
118  const EvalWell& vapour,
119  const double& thp) const {
120 
121  //Get the table
122  const VFPInjTable* table = detail::getTable(m_tables, table_id);
123  EvalWell bhp = 0.0;
124 
125  //Find interpolation variables
126  EvalWell flo = detail::getFlo(aqua, liquid, vapour, table->getFloType());
127 
128  //Compute the BHP for each well independently
129  if (table != nullptr) {
130  //First, find the values to interpolate between
131  //Value of FLO is negative in OPM for producers, but positive in VFP table
132  auto flo_i = detail::findInterpData(flo.value(), table->getFloAxis());
133  auto thp_i = detail::findInterpData( thp, table->getTHPAxis()); // assume constant
134 
135  detail::VFPEvaluation bhp_val = detail::interpolate(table->getTable(), flo_i, thp_i);
136 
137  bhp = bhp_val.dflo * flo;
138  bhp.setValue(bhp_val.value); // thp is assumed constant i.e.
139  }
140  else {
141  bhp.setValue(-1e100); //Signal that this value has not been calculated properly, due to "missing" table
142  }
143  return bhp;
144  }
145 
157  double bhp(int table_id,
158  const double& aqua,
159  const double& liquid,
160  const double& vapour,
161  const double& thp) const;
162 
163 
175  double thp(int table_id,
176  const double& aqua,
177  const double& liquid,
178  const double& vapour,
179  const double& bhp) const;
180 
185  const VFPInjTable* getTable(const int table_id) const;
186 
190  bool empty() const {
191  return m_tables.empty();
192  }
193 
194 private:
195  // Map which connects the table number with the table itself
196  std::map<int, const VFPInjTable*> m_tables;
197 };
198 
199 
200 
201 } //namespace
202 
203 
204 
205 #endif /* OPM_AUTODIFF_VFPINJPROPERTIES_HPP_ */
ADB bhp(const std::vector< int > &table_id, const Wells &wells, const ADB &qs, const ADB &thp) const
Linear interpolation of bhp as function of the input parameters.
Definition: VFPInjProperties.cpp:71
An "ADB-like" structure with a single value and a set of derivatives.
Definition: VFPHelpers.hpp:272
Definition: VFPInjProperties.hpp:39
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: AdditionalObjectDeleter.hpp:22
EvalWell bhp(const int table_id, const EvalWell &aqua, const EvalWell &liquid, const EvalWell &vapour, const double &thp) const
Linear interpolation of bhp as a function of the input parameters given as Evaluation Each entry corr...
Definition: VFPInjProperties.hpp:115
VFPInjProperties()
Empty constructor.
Definition: VFPInjProperties.cpp:52
const VFPInjTable * getTable(const int table_id) const
Returns the table associated with the ID, or throws an exception if the table does not exist...
Definition: VFPInjProperties.cpp:218
double thp(int table_id, const double &aqua, const double &liquid, const double &vapour, const double &bhp) const
Linear interpolation of thp as a function of the input parameters.
Definition: VFPInjProperties.cpp:183
bool empty() const
Returns true if no vfp tables are in the current map.
Definition: VFPInjProperties.hpp:190