All Classes Namespaces Files Functions Variables Typedefs Enumerator Pages
VFPProdProperties.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_VFPPRODPROPERTIES_HPP_
21 #define OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_
22 
23 #include <opm/parser/eclipse/EclipseState/Tables/VFPProdTable.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 namespace Opm {
34 
35 template <class Scalar>
36 class AutoDiffBlock;
37 
44 public:
45  typedef AutoDiffBlock<double> ADB;
46 
51 
57  explicit VFPProdProperties(const VFPProdTable* prod_table);
58 
64  explicit VFPProdProperties(const std::map<int, VFPProdTable>& prod_tables);
65 
77  ADB bhp(const std::vector<int>& table_id,
78  const Wells& wells,
79  const ADB& qs,
80  const ADB& thp,
81  const ADB& alq) const;
82 
99  ADB bhp(const std::vector<int>& table_id,
100  const ADB& aqua,
101  const ADB& liquid,
102  const ADB& vapour,
103  const ADB& thp,
104  const ADB& alq) const;
105 
106 
124  template <class EvalWell>
125  EvalWell bhp(const int table_id,
126  const EvalWell& aqua,
127  const EvalWell& liquid,
128  const EvalWell& vapour,
129  const double& thp,
130  const double& alq) const {
131 
132  //Get the table
133  const VFPProdTable* table = detail::getTable(m_tables, table_id);
134  EvalWell bhp = 0.0;
135 
136  //Find interpolation variables
137  EvalWell flo = detail::getFlo(aqua, liquid, vapour, table->getFloType());
138  EvalWell wfr = detail::getWFR(aqua, liquid, vapour, table->getWFRType());
139  EvalWell gfr = detail::getGFR(aqua, liquid, vapour, table->getGFRType());
140 
141  //Compute the BHP for each well independently
142  if (table != nullptr) {
143  //First, find the values to interpolate between
144  //Value of FLO is negative in OPM for producers, but positive in VFP table
145  auto flo_i = detail::findInterpData(-flo.value(), table->getFloAxis());
146  auto thp_i = detail::findInterpData( thp, table->getTHPAxis()); // assume constant
147  auto wfr_i = detail::findInterpData( wfr.value(), table->getWFRAxis());
148  auto gfr_i = detail::findInterpData( gfr.value(), table->getGFRAxis());
149  auto alq_i = detail::findInterpData( alq, table->getALQAxis()); //assume constant
150 
151  detail::VFPEvaluation bhp_val = detail::interpolate(table->getTable(), flo_i, thp_i, wfr_i, gfr_i, alq_i);
152 
153  bhp = (bhp_val.dwfr * wfr) + (bhp_val.dgfr * gfr) - (bhp_val.dflo * flo);
154  bhp.setValue(bhp_val.value);
155  }
156  else {
157  bhp.setValue(-1e100); //Signal that this value has not been calculated properly, due to "missing" table
158  }
159  return bhp;
160  }
161 
174  double bhp(int table_id,
175  const double& aqua,
176  const double& liquid,
177  const double& vapour,
178  const double& thp,
179  const double& alq) const;
180 
193  double thp(int table_id,
194  const double& aqua,
195  const double& liquid,
196  const double& vapour,
197  const double& bhp,
198  const double& alq) const;
199 
204  const VFPProdTable* getTable(const int table_id) const;
205 
209  bool empty() const {
210  return m_tables.empty();
211  }
212 
213 private:
214  // Map which connects the table number with the table itself
215  std::map<int, const VFPProdTable*> m_tables;
216 };
217 
218 
219 
220 
221 } //namespace
222 
223 
224 #endif /* OPM_AUTODIFF_VFPPRODPROPERTIES_HPP_ */
An &quot;ADB-like&quot; structure with a single value and a set of derivatives.
Definition: VFPHelpers.hpp:272
Class which linearly interpolates BHP as a function of rate, tubing head pressure, water fraction, gas fraction, and artificial lift for production VFP tables, and similarly the BHP as a function of the rate and tubing head pressure.
Definition: VFPProdProperties.hpp:43
double thp(int table_id, const double &aqua, const double &liquid, const double &vapour, const double &bhp, const double &alq) const
Linear interpolation of thp as a function of the input parameters.
Definition: VFPProdProperties.cpp:192
bool empty() const
Returns true if no vfp tables are in the current map.
Definition: VFPProdProperties.hpp:209
const VFPProdTable * getTable(const int table_id) const
Returns the table associated with the ID, or throws an exception if the table does not exist...
Definition: VFPProdProperties.cpp:234
VFPProdProperties()
Empty constructor.
Definition: VFPProdProperties.cpp:39
ADB bhp(const std::vector< int > &table_id, const Wells &wells, const ADB &qs, const ADB &thp, const ADB &alq) const
Linear interpolation of bhp as function of the input parameters.
Definition: VFPProdProperties.cpp:58
EvalWell bhp(const int table_id, const EvalWell &aqua, const EvalWell &liquid, const EvalWell &vapour, const double &thp, const double &alq) const
Linear interpolation of bhp as a function of the input parameters given as Evalutions Each entry corr...
Definition: VFPProdProperties.hpp:125