From 77653643d57689d05eeadff2c4f2893b1a105ed0 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Sat, 14 Mar 2015 20:30:00 -0600 Subject: [PATCH] Clear cached variables for tabular methods Signed-off-by: Ian Bell --- src/Backends/Tabular/BicubicBackend.cpp | 5 ++++- src/Backends/Tabular/TTSEBackend.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Backends/Tabular/BicubicBackend.cpp b/src/Backends/Tabular/BicubicBackend.cpp index f75b0fd3..c7e2cfda 100644 --- a/src/Backends/Tabular/BicubicBackend.cpp +++ b/src/Backends/Tabular/BicubicBackend.cpp @@ -135,6 +135,9 @@ void CoolProp::BicubicBackend::build_coeffs(SinglePhaseGriddedTableData &table, void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double val1, double val2) { + // Clear cached values + clear(); + // Flush the cached indices (set to large number) cached_single_phase_i = std::numeric_limits::max(); cached_single_phase_j = std::numeric_limits::max(); @@ -236,7 +239,7 @@ double CoolProp::BicubicBackend::evaluate_single_phase_transport(SinglePhaseGrid } double x1 = table.xvec[i], x2 = table.xvec[i+1], y1 = table.yvec[j], y2 = table.yvec[j+1]; double f11 = (*f)[i][j], f12 = (*f)[i][j+1], f21 = (*f)[i+1][j], f22 = (*f)[i+1][j+1]; - double val = 1/((x2-x1)*(y2-y1))*( f11*(x2- x1)*(y2 - y) + double val = 1/((x2-x1)*(y2-y1))*( f11*(x2 - x)*(y2 - y) +f21*(x - x1)*(y2 - y) +f12*(x2 - x)*(y - y1) +f22*(x - x1)*(y - y1)); diff --git a/src/Backends/Tabular/TTSEBackend.cpp b/src/Backends/Tabular/TTSEBackend.cpp index 6a788e86..957665cf 100644 --- a/src/Backends/Tabular/TTSEBackend.cpp +++ b/src/Backends/Tabular/TTSEBackend.cpp @@ -6,6 +6,8 @@ void CoolProp::TTSEBackend::update(CoolProp::input_pairs input_pair, double val1, double val2) { + // Clear cached variables + clear(); // Flush the cached indices (set to large number) cached_single_phase_i = std::numeric_limits::max(); cached_single_phase_j = std::numeric_limits::max();