diff --git a/src/Backends/Tabular/BicubicBackend.cpp b/src/Backends/Tabular/BicubicBackend.cpp index 0bd30ead..a9157767 100644 --- a/src/Backends/Tabular/BicubicBackend.cpp +++ b/src/Backends/Tabular/BicubicBackend.cpp @@ -251,9 +251,11 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v double TR = single_phase_logpT.T[cached_single_phase_i+1][cached_single_phase_j]; if (TL < Ts && Ts < TR){ if (_T < Ts){ + if (cached_single_phase_i == 0){throw ValueError(format("P, T are near saturation, but cannot move the cell to the left")); } // It's liquid, move the cell to the left cached_single_phase_i--; }else{ + if (cached_single_phase_i > single_phase_logpT.Nx-2){ throw ValueError(format("P,T are near saturation, but cannot move the cell to the right")); } // It's vapor, move to the right cached_single_phase_i++; } @@ -267,6 +269,7 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v std::size_t iL = 0, iV = 0; CoolPropDbl hL = 0, hV = 0; _p = val1; _Q = val2; + if (_p < pure_saturation.pL[0]){throw ValueError(format("p (%g) Pa below minimum pressure", static_cast(_p)));} pure_saturation.is_inside(iP, _p, iQ, _Q, iL, iV, hL, hV); using_single_phase_table = false; if(!is_in_closed_range(0.0,1.0,static_cast(_Q))){ diff --git a/src/Backends/Tabular/TabularBackends.h b/src/Backends/Tabular/TabularBackends.h index 6c72f55a..66c81678 100644 --- a/src/Backends/Tabular/TabularBackends.h +++ b/src/Backends/Tabular/TabularBackends.h @@ -183,6 +183,10 @@ class PureFluidSaturationTableData{ }; double evaluate(parameters output, double p, double Q, std::size_t iL, std::size_t iV) { + if (iL <= 2){ iL = 2; } + else if (iL+1 == N){ iL = N-2; } + if (iV <= 2){ iV = 2; } + else if (iV+1 == N){ iV = N-2; } double logp = log(p); switch(output){ case iT: