Do not extrapolate initial rs and rv values in the depth tables

This commit is contained in:
Tor Harald Sandve 2017-03-16 12:33:43 +01:00
parent 7bf6da1953
commit 7579f2bdb9
2 changed files with 18 additions and 2 deletions

View File

@ -273,7 +273,7 @@ namespace Opm
if (sat_gas > 0.0) {
return satRs(press, temp);
} else {
return std::min(satRs(press, temp), linearInterpolation(depth_, rs_, depth));
return std::min(satRs(press, temp), linearInterpolationNoExtrapolation(depth_, rs_, depth));
}
}
@ -353,7 +353,7 @@ namespace Opm
if (std::abs(sat_oil) > 1e-16) {
return satRv(press, temp);
} else {
return std::min(satRv(press, temp), linearInterpolation(depth_, rv_, depth));
return std::min(satRv(press, temp), linearInterpolationNoExtrapolation(depth_, rv_, depth));
}
}

View File

@ -70,6 +70,22 @@ namespace Opm
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
}
inline double linearInterpolationNoExtrapolation(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Return end values if x is outside xv
if (x < xv.front()) {
return yv.front();
}
if (x > xv.back()) {
return yv.back();
}
int ix1 = tableIndex(xv, x);
int ix2 = ix1 + 1;
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
}
inline double linearInterpolation(const std::vector<double>& xv,
const std::vector<double>& yv,
double x, int& ix1)