Go to the documentation of this file.
20 #ifndef OPM_THERMAL_OIL_PVT_WRAPPER_HPP
21 #define OPM_THERMAL_OIL_PVT_WRAPPER_HPP
24 #include <opm/common/ErrorMacros.hpp>
26 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
42 void initFromDeck(std::shared_ptr<const PvtInterface> isothermalPvt,
43 Opm::DeckConstPtr deck,
44 Opm::EclipseStateConstPtr eclipseState)
46 isothermalPvt_ = isothermalPvt;
49 auto tables = eclipseState->getTableManager();
51 if (deck->hasKeyword( "PVTO"))
52 numRegions = tables->getPvtoTables().size();
53 else if (deck->hasKeyword( "PVDO"))
54 numRegions = tables->getPvdoTables().size();
55 else if (deck->hasKeyword( "PVCDO"))
56 numRegions = deck->getKeyword( "PVCDO")->size();
58 OPM_THROW(std::runtime_error, "Oil phase was not initialized using a known way");
61 if (deck->hasKeyword( "VISCREF")) {
62 oilvisctTables_ = &tables->getOilvisctTables();
63 Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword( "VISCREF");
65 assert( int(oilvisctTables_->size()) == numRegions);
66 assert( int(viscrefKeyword->size()) == numRegions);
68 viscrefPress_.resize(numRegions);
69 viscrefRs_.resize(numRegions);
70 muRef_.resize(numRegions);
71 for ( int regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
72 DeckRecordConstPtr viscrefRecord = viscrefKeyword->getRecord(regionIdx);
73 viscrefPress_[regionIdx] = viscrefRecord->getItem( "REFERENCE_PRESSURE")->getSIDouble(0);
74 viscrefRs_[regionIdx] = viscrefRecord->getItem( "REFERENCE_RS")->getSIDouble(0);
79 double Tref = 273.15 + 20;
85 &viscrefPress_[regionIdx],
87 &viscrefRs_[regionIdx],
97 if (deck->hasKeyword( "THERMEX1")) {
98 oilCompIdx_ = deck->getKeyword( "OCOMPIDX")->getRecord(0)->getItem( "OIL_COMPONENT_INDEX")->getInt(0) - 1;
101 tref_ = deck->getKeyword( "TREF")->getRecord(0)->getItem( "TEMPERATURE")->getSIDouble(oilCompIdx_);
102 pref_ = deck->getKeyword( "PREF")->getRecord(0)->getItem( "PRESSURE")->getSIDouble(oilCompIdx_);
103 cref_ = deck->getKeyword( "CREF")->getRecord(0)->getItem( "COMPRESSIBILITY")->getSIDouble(oilCompIdx_);
104 thermex1_ = deck->getKeyword( "THERMEX1")->getRecord(0)->getItem( "EXPANSION_COEFF")->getSIDouble(oilCompIdx_);
108 virtual void mu( const int n,
109 const int* pvtRegionIdx,
113 double* output_mu) const
117 OPM_THROW(std::runtime_error,
118 "temperature dependent viscosity as a function of z "
119 "is not yet implemented!");
122 isothermalPvt_->mu(n, pvtRegionIdx, p, T, z, output_mu);
125 virtual void mu( const int n,
126 const int* pvtRegionIdx,
131 double* output_dmudp,
132 double* output_dmudr) const
135 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, output_mu, output_dmudp, output_dmudr);
137 if (!oilvisctTables_)
142 for ( int i = 0; i < n; ++i) {
143 int regionIdx = getPvtRegionIndex_(pvtRegionIdx, i);
147 double muRef = muRef_[regionIdx];
152 const OilvisctTable& oilvisctTable = oilvisctTables_->getTable<OilvisctTable>(regionIdx);
153 double muOilvisct = oilvisctTable.evaluate( "Viscosity", T[i]);
154 alpha = muOilvisct/muRef;
157 output_mu[i] *= alpha;
158 output_dmudp[i] *= alpha;
159 output_dmudr[i] *= alpha;
164 virtual void mu( const int n,
165 const int* pvtRegionIdx,
171 double* output_dmudp,
172 double* output_dmudr) const
175 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, cond, output_mu, output_dmudp, output_dmudr);
177 if (!oilvisctTables_)
182 for ( int i = 0; i < n; ++i) {
183 int regionIdx = getPvtRegionIndex_(pvtRegionIdx, i);
187 double muRef = muRef_[regionIdx];
192 const OilvisctTable& oilvisctTable = oilvisctTables_->getTable<OilvisctTable>(regionIdx);
193 double muOilvisct = oilvisctTable.evaluate( "Viscosity", T[i]);
194 alpha = muOilvisct/muRef;
196 output_mu[i] *= alpha;
197 output_dmudp[i] *= alpha;
198 output_dmudr[i] *= alpha;
203 virtual void B( const int n,
204 const int* pvtRegionIdx,
208 double* output_B) const
211 isothermalPvt_->B(n, pvtRegionIdx, p, T, z, output_B);
213 if (thermex1_ <= 0.0)
223 double cT1 = thermex1_;
225 for ( int i = 0; i < n; ++i) {
226 double alpha = (1 + cT1*(T[i] - TRef));
227 output_B[i] *= alpha;
232 const int* pvtRegionIdx,
237 double* output_dBdp) const
239 isothermalPvt_->dBdp(n, pvtRegionIdx, p, T, z, output_B, output_dBdp);
241 if (thermex1_ <= 0.0)
251 double cT1 = thermex1_;
253 for ( int i = 0; i < n; ++i) {
254 double alpha = (1 + cT1*(T[i] - TRef));
255 output_B[i] *= alpha;
256 output_dBdp[i] *= alpha;
260 virtual void b( const int n,
261 const int* pvtRegionIdx,
267 double* output_dbdr) const
269 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, output_b, output_dbdp, output_dbdr);
271 if (thermex1_ <= 0.0)
281 double cT1 = thermex1_;
283 for ( int i = 0; i < n; ++i) {
284 double alpha = 1.0/(1 + cT1*(T[i] - TRef));
285 output_b[i] *= alpha;
286 output_dbdp[i] *= alpha;
287 output_dbdr[i] *= alpha;
291 virtual void b( const int n,
292 const int* pvtRegionIdx,
299 double* output_dbdr) const
301 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, cond, output_b, output_dbdp, output_dbdr);
303 if (thermex1_ <= 0.0)
313 double cT1 = thermex1_;
315 for ( int i = 0; i < n; ++i) {
316 double alpha = 1.0/(1 + cT1*(T[i] - TRef));
317 output_b[i] *= alpha;
318 output_dbdp[i] *= alpha;
319 output_dbdr[i] *= alpha;
324 const int* pvtRegionIdx,
326 double* output_rsSat,
327 double* output_drsSatdp) const
329 isothermalPvt_->rsSat(n, pvtRegionIdx, p, output_rsSat, output_drsSatdp);
333 const int* pvtRegionIdx,
335 double* output_rvSat,
336 double* output_drvSatdp) const
338 isothermalPvt_->rvSat(n, pvtRegionIdx, p, output_rvSat, output_drvSatdp);
341 virtual void R( const int n,
342 const int* pvtRegionIdx,
345 double* output_R) const
347 isothermalPvt_->R(n, pvtRegionIdx, p, z, output_R);
351 const int* pvtRegionIdx,
355 double* output_dRdp) const
357 isothermalPvt_->dRdp(n, pvtRegionIdx, p, z, output_R, output_dRdp);
361 int getPvtRegionIndex_( const int* pvtRegionIdx, int cellIdx) const
365 return pvtRegionIdx[cellIdx];
369 std::shared_ptr<const PvtInterface> isothermalPvt_;
373 std::vector<double> viscrefPress_;
374 std::vector<double> viscrefRs_;
375 std::vector<double> muRef_;
377 const TableContainer* oilvisctTables_;
Definition: BlackoilPhases.hpp:48
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:125
Definition: AnisotropicEikonal.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:291
ThermalOilPvtWrapper() Definition: ThermalOilPvtWrapper.hpp:37
Definition: ThermalOilPvtWrapper.hpp:34
virtual void R(const int n, const int *pvtRegionIdx, const double *p, const double *z, double *output_R) const Solution factor as a function of p and z. Definition: ThermalOilPvtWrapper.hpp:341
virtual void dRdp(const int n, const int *pvtRegionIdx, const double *p, const double *z, double *output_R, double *output_dRdp) const Solution factor and p-derivative as functions of p and z. Definition: ThermalOilPvtWrapper.hpp:350
virtual void rsSat(const int n, const int *pvtRegionIdx, const double *p, double *output_rsSat, double *output_drsSatdp) const Solution gas/oil ratio and its derivatives at saturated conditions as a function of p... Definition: ThermalOilPvtWrapper.hpp:323
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:260
void initFromDeck(std::shared_ptr< const PvtInterface > isothermalPvt, Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState) set the tables which specify the temperature dependence of the oil viscosity Definition: ThermalOilPvtWrapper.hpp:42
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 Formation volume factor and p-derivative as functions of p and z. Definition: ThermalOilPvtWrapper.hpp:231
virtual void mu(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *z, double *output_mu) const Viscosity as a function of p, T and z. Definition: ThermalOilPvtWrapper.hpp:108
virtual void B(const int n, const int *pvtRegionIdx, const double *p, const double *T, const double *z, double *output_B) const Formation volume factor as a function of p, T and z. Definition: ThermalOilPvtWrapper.hpp:203
Definition: PvtInterface.hpp:30
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:164
virtual void rvSat(const int n, const int *pvtRegionIdx, const double *p, double *output_rvSat, double *output_drvSatdp) const Vapor oil/gas ratio and its derivatives at saturated conditions as a function of p. Definition: ThermalOilPvtWrapper.hpp:332
|