20 #ifndef OPM_THERMAL_WATER_PVT_WRAPPER_HPP
21 #define OPM_THERMAL_WATER_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;
50 Opm::DeckKeywordConstPtr pvtwKeyword = deck->getKeyword(
"PVTW");
51 int numRegions = pvtwKeyword->size();
52 pvtwRefPress_.resize(numRegions);
53 pvtwRefB_.resize(numRegions);
54 pvtwCompressibility_.resize(numRegions);
55 pvtwViscosity_.resize(numRegions);
56 pvtwViscosibility_.resize(numRegions);
57 for (
int regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
58 Opm::DeckRecordConstPtr pvtwRecord = pvtwKeyword->getRecord(regionIdx);
59 pvtwRefPress_[regionIdx] = pvtwRecord->getItem(
"P_REF")->getSIDouble(0);
60 pvtwRefB_[regionIdx] = pvtwRecord->getItem(
"WATER_VOL_FACTOR")->getSIDouble(0);
61 pvtwViscosity_[regionIdx] = pvtwRecord->getItem(
"WATER_VISCOSITY")->getSIDouble(0);
62 pvtwViscosibility_[regionIdx] = pvtwRecord->getItem(
"WATER_VISCOSIBILITY")->getSIDouble(0);
67 if (deck->hasKeyword(
"VISCREF")) {
68 auto tables = eclipseState->getTableManager();
69 watvisctTables_ = &tables->getWatvisctTables();
70 Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword(
"VISCREF");
72 assert(
int(watvisctTables_->size()) == numRegions);
73 assert(
int(viscrefKeyword->size()) == numRegions);
75 viscrefPress_.resize(numRegions);
76 for (
int regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
77 Opm::DeckRecordConstPtr viscrefRecord = viscrefKeyword->getRecord(regionIdx);
79 viscrefPress_[regionIdx] = viscrefRecord->getItem(
"REFERENCE_PRESSURE")->getSIDouble(0);
84 if (deck->hasKeyword(
"WATDENT")) {
85 DeckKeywordConstPtr watdentKeyword = deck->getKeyword(
"WATDENT");
87 assert(
int(watdentKeyword->size()) == numRegions);
89 watdentRefTemp_.resize(numRegions);
90 watdentCT1_.resize(numRegions);
91 watdentCT2_.resize(numRegions);
92 for (
int regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
93 Opm::DeckRecordConstPtr watdentRecord = watdentKeyword->getRecord(regionIdx);
95 watdentRefTemp_[regionIdx] = watdentRecord->getItem(
"REFERENCE_TEMPERATURE")->getSIDouble(0);
96 watdentCT1_[regionIdx] = watdentRecord->getItem(
"EXPANSION_COEFF_LINEAR")->getSIDouble(0);
97 watdentCT2_[regionIdx] = watdentRecord->getItem(
"EXPANSION_COEFF_QUADRATIC")->getSIDouble(0);
102 virtual void mu(
const int n,
103 const int* pvtRegionIdx,
107 double* output_mu)
const
111 OPM_THROW(std::runtime_error,
112 "temperature dependent viscosity as a function of z "
113 "is not yet implemented!");
116 isothermalPvt_->mu(n, pvtRegionIdx, p, T, z, output_mu);
119 virtual void mu(
const int n,
120 const int* pvtRegionIdx,
125 double* output_dmudp,
126 double* output_dmudr)
const
129 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, output_mu, output_dmudp, output_dmudr);
131 if (!watvisctTables_)
136 for (
int i = 0; i < n; ++i) {
137 int tableIdx = getTableIndex_(pvtRegionIdx, i);
141 double x = -pvtwViscosibility_[tableIdx]*(viscrefPress_[tableIdx] - pvtwRefPress_[tableIdx]);
142 double muRef = pvtwViscosity_[tableIdx]/(1.0 + x + 0.5*x*x);
147 const WatvisctTable& watVisctTable = watvisctTables_->getTable<WatvisctTable>(tableIdx);
148 double muWatvisct = watVisctTable.evaluate(
"Viscosity", T[i]);
149 alpha = muWatvisct/muRef;
152 output_mu[i] *= alpha;
153 output_dmudp[i] *= alpha;
154 output_dmudr[i] *= alpha;
159 virtual void mu(
const int n,
160 const int* pvtRegionIdx,
166 double* output_dmudp,
167 double* output_dmudr)
const
170 isothermalPvt_->mu(n, pvtRegionIdx, p, T, r, cond, output_mu, output_dmudp, output_dmudr);
172 if (!watvisctTables_)
177 for (
int i = 0; i < n; ++i) {
178 int tableIdx = getTableIndex_(pvtRegionIdx, i);
182 double x = -pvtwViscosibility_[tableIdx]*(viscrefPress_[tableIdx] - pvtwRefPress_[tableIdx]);
183 double muRef = pvtwViscosity_[tableIdx]/(1.0 + x + 0.5*x*x);
188 const WatvisctTable& watVisctTable = watvisctTables_->getTable<WatvisctTable>(tableIdx);
189 double muWatvisct = watVisctTable.evaluate(
"Viscosity", T[i]);
190 alpha = muWatvisct/muRef;
192 output_mu[i] *= alpha;
193 output_dmudp[i] *= alpha;
194 output_dmudr[i] *= alpha;
199 virtual void B(
const int n,
200 const int* pvtRegionIdx,
204 double* output_B)
const
206 if (watdentRefTemp_.empty()) {
208 isothermalPvt_->B(n, pvtRegionIdx, p, T, z, output_B);
215 for (
int i = 0; i < n; ++i) {
216 int tableIdx = getTableIndex_(pvtRegionIdx, i);
217 double BwRef = pvtwRefB_[tableIdx];
218 double TRef = watdentRefTemp_[tableIdx];
219 double X = pvtwCompressibility_[tableIdx]*(p[i] - pvtwRefPress_[tableIdx]);
220 double cT1 = watdentCT1_[tableIdx];
221 double cT2 = watdentCT2_[tableIdx];
222 double Y = T[i] - TRef;
223 double Bw = BwRef*(1 - X)*(1 + cT1*Y + cT2*Y*Y);
229 const int* pvtRegionIdx,
234 double* output_dBdp)
const
236 if (watdentRefTemp_.empty()) {
238 isothermalPvt_->dBdp(n, pvtRegionIdx, p, T, z, output_B, output_dBdp);
245 for (
int i = 0; i < n; ++i) {
246 int tableIdx = getTableIndex_(pvtRegionIdx, i);
247 double BwRef = pvtwRefB_[tableIdx];
248 double TRef = watdentRefTemp_[tableIdx];
249 double X = pvtwCompressibility_[tableIdx]*(p[i] - pvtwRefPress_[tableIdx]);
250 double cT1 = watdentCT1_[tableIdx];
251 double cT2 = watdentCT2_[tableIdx];
252 double Y = T[i] - TRef;
253 double Bw = BwRef*(1 - X)*(1 + cT1*Y + cT2*Y*Y);
257 std::fill(output_dBdp, output_dBdp + n, 0.0);
260 virtual void b(
const int n,
261 const int* pvtRegionIdx,
267 double* output_dbdr)
const
269 if (watdentRefTemp_.empty()) {
271 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, output_b, output_dbdp, output_dbdr);
278 for (
int i = 0; i < n; ++i) {
279 int tableIdx = getTableIndex_(pvtRegionIdx, i);
280 double BwRef = pvtwRefB_[tableIdx];
281 double TRef = watdentRefTemp_[tableIdx];
282 double X = pvtwCompressibility_[tableIdx]*(p[i] - pvtwRefPress_[tableIdx]);
283 double cT1 = watdentCT1_[tableIdx];
284 double cT2 = watdentCT2_[tableIdx];
285 double Y = T[i] - TRef;
286 double Bw = BwRef*(1 - X)*(1 + cT1*Y + cT2*Y*Y);
287 output_b[i] = 1.0/Bw;
290 std::fill(output_dbdp, output_dbdp + n, 0.0);
291 std::fill(output_dbdr, output_dbdr + n, 0.0);
294 virtual void b(
const int n,
295 const int* pvtRegionIdx,
302 double* output_dbdr)
const
304 if (watdentRefTemp_.empty()) {
306 isothermalPvt_->b(n, pvtRegionIdx, p, T, r, cond, output_b, output_dbdp, output_dbdr);
313 for (
int i = 0; i < n; ++i) {
314 int tableIdx = getTableIndex_(pvtRegionIdx, i);
315 double BwRef = pvtwRefB_[tableIdx];
316 double TRef = watdentRefTemp_[tableIdx];
317 double X = pvtwCompressibility_[tableIdx]*(p[i] - pvtwRefPress_[tableIdx]);
318 double cT1 = watdentCT1_[tableIdx];
319 double cT2 = watdentCT2_[tableIdx];
320 double Y = T[i] - TRef;
321 double Bw = BwRef*(1 - X)*(1 + cT1*Y + cT2*Y*Y);
322 output_b[i] = 1.0/Bw;
325 std::fill(output_dbdp, output_dbdp + n, 0.0);
326 std::fill(output_dbdr, output_dbdr + n, 0.0);
331 const int* pvtRegionIdx,
333 double* output_rsSat,
334 double* output_drsSatdp)
const
336 isothermalPvt_->rsSat(n, pvtRegionIdx, p, output_rsSat, output_drsSatdp);
340 const int* pvtRegionIdx,
342 double* output_rvSat,
343 double* output_drvSatdp)
const
345 isothermalPvt_->rvSat(n, pvtRegionIdx, p, output_rvSat, output_drvSatdp);
348 virtual void R(
const int n,
349 const int* pvtRegionIdx,
352 double* output_R)
const
354 isothermalPvt_->R(n, pvtRegionIdx, p, z, output_R);
358 const int* pvtRegionIdx,
362 double* output_dRdp)
const
364 isothermalPvt_->dRdp(n, pvtRegionIdx, p, z, output_R, output_dRdp);
368 int getTableIndex_(
const int* pvtTableIdx,
int cellIdx)
const
372 return pvtTableIdx[cellIdx];
376 std::shared_ptr<const PvtInterface> isothermalPvt_;
380 std::vector<double> viscrefPress_;
382 std::vector<double> watdentRefTemp_;
383 std::vector<double> watdentCT1_;
384 std::vector<double> watdentCT2_;
386 std::vector<double> pvtwRefPress_;
387 std::vector<double> pvtwRefB_;
388 std::vector<double> pvtwCompressibility_;
389 std::vector<double> pvtwViscosity_;
390 std::vector<double> pvtwViscosibility_;
392 const TableContainer* watvisctTables_;
Definition: BlackoilPhases.hpp:48
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: ThermalWaterPvtWrapper.hpp:260
Definition: AnisotropicEikonal.hpp:43
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: ThermalWaterPvtWrapper.hpp:199
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: ThermalWaterPvtWrapper.hpp:228
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: ThermalWaterPvtWrapper.hpp:159
void initFromDeck(std::shared_ptr< const PvtInterface > isothermalPvt, Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState)
set the tables which specify the temperature dependence of the water viscosity
Definition: ThermalWaterPvtWrapper.hpp:42
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: ThermalWaterPvtWrapper.hpp:294
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: ThermalWaterPvtWrapper.hpp:348
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: ThermalWaterPvtWrapper.hpp:330
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: ThermalWaterPvtWrapper.hpp:119
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: ThermalWaterPvtWrapper.hpp:102
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: ThermalWaterPvtWrapper.hpp:339
ThermalWaterPvtWrapper()
Definition: ThermalWaterPvtWrapper.hpp:37
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: ThermalWaterPvtWrapper.hpp:357
Definition: PvtInterface.hpp:30
Definition: ThermalWaterPvtWrapper.hpp:34