Go to the documentation of this file.
20#ifndef OPM_THERMAL_OIL_PVT_WRAPPER_HPP
21#define OPM_THERMAL_OIL_PVT_WRAPPER_HPP
23#include <opm/core/props/pvt/PvtInterface.hpp>
24#include <opm/common/ErrorMacros.hpp>
26#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
27#include <opm/parser/eclipse/EclipseState/Tables/OilvisctTable.hpp>
43 void initFromDeck(std::shared_ptr<const PvtInterface> isothermalPvt,
44 const Opm::Deck& deck,
45 const Opm::EclipseState& eclipseState)
47 isothermalPvt_ = isothermalPvt;
50 auto tables = eclipseState->getTableManager();
52 if (deck->hasKeyword( "PVTO"))
53 numRegions = tables->getPvtoTables().size();
54 else if (deck->hasKeyword( "PVDO"))
55 numRegions = tables->getPvdoTables().size();
56 else if (deck->hasKeyword( "PVCDO"))
57 numRegions = deck->getKeyword( "PVCDO").size();
59 OPM_THROW(std::runtime_error, "Oil phase was not initialized using a known way");
62 if (deck->hasKeyword( "VISCREF")) {
63 oilvisctTables_ = &tables->getOilvisctTables();
64 const auto& viscrefKeyword = deck->getKeyword( "VISCREF");
66 assert( int(oilvisctTables_->size()) == numRegions);
67 assert( int(viscrefKeyword.size()) == numRegions);
69 viscrefPress_.resize(numRegions);
70 viscrefRs_.resize(numRegions);
71 muRef_.resize(numRegions);
72 for ( int regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
73 const auto& viscrefRecord = viscrefKeyword.getRecord(regionIdx);
74 viscrefPress_[regionIdx] = viscrefRecord.getItem( "REFERENCE_PRESSURE").getSIDouble(0);
75 viscrefRs_[regionIdx] = viscrefRecord.getItem( "REFERENCE_RS").getSIDouble(0);
80 double Tref = 273.15 + 20;
86 &viscrefPress_[regionIdx],
88 &viscrefRs_[regionIdx],
98 if (deck->hasKeyword( "THERMEX1")) {
99 oilCompIdx_ = deck->getKeyword( "OCOMPIDX").getRecord(0).getItem( "OIL_COMPONENT_INDEX").get< int >(0) - 1;
102 tref_ = deck->getKeyword( "TREF").getRecord(0).getItem( "TEMPERATURE").getSIDouble(oilCompIdx_);
103 pref_ = deck->getKeyword( "PREF").getRecord(0).getItem( "PRESSURE").getSIDouble(oilCompIdx_);
104 cref_ = deck->getKeyword( "CREF").getRecord(0).getItem( "COMPRESSIBILITY").getSIDouble(oilCompIdx_);
105 thermex1_ = deck->getKeyword( "THERMEX1").getRecord(0).getItem( "EXPANSION_COEFF").getSIDouble(oilCompIdx_);
109 virtual void mu( const int n,
110 const int* pvtRegionIdx,
114 double* output_mu) const
118 OPM_THROW(std::runtime_error,
119 "temperature dependent viscosity as a function of z "
120 "is not yet implemented!");
123 isothermalPvt_->mu(n, pvtRegionIdx, p, T, z, output_mu);
126 virtual void mu( const int n,
127 const int* pvtRegionIdx,
132 double* output_dmudp,
133 double* output_dmudr) const
136 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, output_mu, output_dmudp, output_dmudr);
138 if (!oilvisctTables_)
143 for ( int i = 0; i < n; ++i) {
144 int regionIdx = getPvtRegionIndex_(pvtRegionIdx, i);
148 double muRef = muRef_[regionIdx];
153 const OilvisctTable& oilvisctTable = oilvisctTables_->getTable<OilvisctTable>(regionIdx);
154 double muOilvisct = oilvisctTable.evaluate( "Viscosity", T[i]);
155 alpha = muOilvisct/muRef;
158 output_mu[i] *= alpha;
159 output_dmudp[i] *= alpha;
160 output_dmudr[i] *= alpha;
165 virtual void mu( const int n,
166 const int* pvtRegionIdx,
172 double* output_dmudp,
173 double* output_dmudr) const
176 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, cond, output_mu, output_dmudp, output_dmudr);
178 if (!oilvisctTables_)
183 for ( int i = 0; i < n; ++i) {
184 int regionIdx = getPvtRegionIndex_(pvtRegionIdx, i);
188 double muRef = muRef_[regionIdx];
193 const OilvisctTable& oilvisctTable = oilvisctTables_->getTable<OilvisctTable>(regionIdx);
194 double muOilvisct = oilvisctTable.evaluate( "Viscosity", T[i]);
195 alpha = muOilvisct/muRef;
197 output_mu[i] *= alpha;
198 output_dmudp[i] *= alpha;
199 output_dmudr[i] *= alpha;
204 virtual void B( const int n,
205 const int* pvtRegionIdx,
209 double* output_B) const
212 isothermalPvt_->B(n, pvtRegionIdx, p, T, z, output_B);
214 if (thermex1_ <= 0.0)
224 double cT1 = thermex1_;
226 for ( int i = 0; i < n; ++i) {
227 double alpha = (1 + cT1*(T[i] - TRef));
228 output_B[i] *= alpha;
233 const int* pvtRegionIdx,
238 double* output_dBdp) const
240 isothermalPvt_->dBdp(n, pvtRegionIdx, p, T, z, output_B, output_dBdp);
242 if (thermex1_ <= 0.0)
252 double cT1 = thermex1_;
254 for ( int i = 0; i < n; ++i) {
255 double alpha = (1 + cT1*(T[i] - TRef));
256 output_B[i] *= alpha;
257 output_dBdp[i] *= alpha;
261 virtual void b( const int n,
262 const int* pvtRegionIdx,
268 double* output_dbdr) const
270 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, output_b, output_dbdp, output_dbdr);
272 if (thermex1_ <= 0.0)
282 double cT1 = thermex1_;
284 for ( int i = 0; i < n; ++i) {
285 double alpha = 1.0/(1 + cT1*(T[i] - TRef));
286 output_b[i] *= alpha;
287 output_dbdp[i] *= alpha;
288 output_dbdr[i] *= alpha;
292 virtual void b( const int n,
293 const int* pvtRegionIdx,
300 double* output_dbdr) const
302 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, cond, output_b, output_dbdp, output_dbdr);
304 if (thermex1_ <= 0.0)
314 double cT1 = thermex1_;
316 for ( int i = 0; i < n; ++i) {
317 double alpha = 1.0/(1 + cT1*(T[i] - TRef));
318 output_b[i] *= alpha;
319 output_dbdp[i] *= alpha;
320 output_dbdr[i] *= alpha;
325 const int* pvtRegionIdx,
327 double* output_rsSat,
328 double* output_drsSatdp) const
330 isothermalPvt_->rsSat(n, pvtRegionIdx, p, output_rsSat, output_drsSatdp);
334 const int* pvtRegionIdx,
336 double* output_rvSat,
337 double* output_drvSatdp) const
339 isothermalPvt_->rvSat(n, pvtRegionIdx, p, output_rvSat, output_drvSatdp);
342 virtual void R( const int n,
343 const int* pvtRegionIdx,
346 double* output_R) const
348 isothermalPvt_->R(n, pvtRegionIdx, p, z, output_R);
352 const int* pvtRegionIdx,
356 double* output_dRdp) const
358 isothermalPvt_->dRdp(n, pvtRegionIdx, p, z, output_R, output_dRdp);
362 int getPvtRegionIndex_( const int* pvtRegionIdx, int cellIdx) const
366 return pvtRegionIdx[cellIdx];
370 std::shared_ptr<const PvtInterface> isothermalPvt_;
374 std::vector<double> viscrefPress_;
375 std::vector<double> viscrefRs_;
376 std::vector<double> muRef_;
378 const TableContainer* oilvisctTables_;
Definition: BlackoilPhases.hpp:59
Definition: ThermalOilPvtWrapper.hpp:36
virtual void mu(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *r, const PhasePresence *cond, double *output_mu, double *output_dmudp, double *output_dmudr) const Definition: ThermalOilPvtWrapper.hpp:165
virtual void rsSat(const int n, const int *pvtRegionIdx, const double *p, double *output_rsSat, double *output_drsSatdp) const Definition: ThermalOilPvtWrapper.hpp:324
void initFromDeck(std::shared_ptr< const PvtInterface > isothermalPvt, const Opm::Deck &deck, const Opm::EclipseState &eclipseState) set the tables which specify the temperature dependence of the oil viscosity Definition: ThermalOilPvtWrapper.hpp:43
virtual void b(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *r, const PhasePresence *cond, double *output_b, double *output_dbdp, double *output_dbdr) const Definition: ThermalOilPvtWrapper.hpp:292
virtual void mu(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *z, double *output_mu) const Definition: ThermalOilPvtWrapper.hpp:109
virtual void R(const int n, const int *pvtRegionIdx, const double *p, const double *z, double *output_R) const Definition: ThermalOilPvtWrapper.hpp:342
ThermalOilPvtWrapper() Definition: ThermalOilPvtWrapper.hpp:38
virtual void rvSat(const int n, const int *pvtRegionIdx, const double *p, double *output_rvSat, double *output_drvSatdp) const Definition: ThermalOilPvtWrapper.hpp:333
virtual void dBdp(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *z, double *output_B, double *output_dBdp) const Definition: ThermalOilPvtWrapper.hpp:232
virtual void b(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *r, double *output_b, double *output_dbdp, double *output_dbdr) const Definition: ThermalOilPvtWrapper.hpp:261
virtual void dRdp(const int n, const int *pvtRegionIdx, const double *p, const double *z, double *output_R, double *output_dRdp) const Definition: ThermalOilPvtWrapper.hpp:351
virtual void mu(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *r, double *output_mu, double *output_dmudp, double *output_dmudr) const Definition: ThermalOilPvtWrapper.hpp:126
virtual void B(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *z, double *output_B) const Definition: ThermalOilPvtWrapper.hpp:204
Definition: AnisotropicEikonal.hpp:44
|