diff --git a/SConstruct b/SConstruct index b7f6dfeed..501ae7652 100644 --- a/SConstruct +++ b/SConstruct @@ -990,15 +990,10 @@ if env['use_sundials'] == 'default': env['use_sundials'] = 'n' elif env['use_sundials'] == 'y' and not env['HAS_SUNDIALS']: config_error("Unable to find Sundials headers and / or libraries.") -elif env['use_sundials'] == 'y' and env['sundials_version'] not in ('2.2','2.3','2.4','2.5'): +elif env['use_sundials'] == 'y' and env['sundials_version'] not in ('2.4','2.5'): print """ERROR: Sundials version %r is not supported.""" % env['sundials_version'] sys.exit(1) -# Deprecation warnings for old Sundials versions -if env.get('sundials_version') in ('2.2', '2.3'): - print 'WARNING: Support for Sundials %s is deprecated and will be removed.' % env['sundials_version'] - print 'WARNING: Upgrading to Sundials 2.5 is strongly recommended.' - # ********************************************** # *** Set additional configuration variables *** # ********************************************** diff --git a/include/cantera/numerics/CVodesIntegrator.h b/include/cantera/numerics/CVodesIntegrator.h index e2ae19d3c..3b70b205b 100644 --- a/include/cantera/numerics/CVodesIntegrator.h +++ b/include/cantera/numerics/CVodesIntegrator.h @@ -13,11 +13,7 @@ #ifdef HAS_SUNDIALS -#if SUNDIALS_VERSION == 22 -#include "nvector_serial.h" -#else #include "sundials/sundials_nvector.h" -#endif namespace Cantera { diff --git a/include/cantera/numerics/IDA_Solver.h b/include/cantera/numerics/IDA_Solver.h index 50bc66559..8d1629a9a 100644 --- a/include/cantera/numerics/IDA_Solver.h +++ b/include/cantera/numerics/IDA_Solver.h @@ -13,9 +13,6 @@ #if HAS_SUNDIALS -#if SUNDIALS_VERSION == 22 -#include "nvector_serial.h" -#else #include "sundials/sundials_nvector.h" // These constants are defined internally in the ida package, ida.c @@ -24,10 +21,7 @@ #define IDA_SV 2 #define IDA_WF 3 -#endif -#if SUNDIALS_VERSION >= 24 #define REAL_WORKSPACE_SIZE 0 -#endif namespace Cantera { diff --git a/src/numerics/CVodesIntegrator.cpp b/src/numerics/CVodesIntegrator.cpp index 6dbe25a78..cc4cff5d8 100644 --- a/src/numerics/CVodesIntegrator.cpp +++ b/src/numerics/CVodesIntegrator.cpp @@ -11,20 +11,6 @@ #include using namespace std; -#if SUNDIALS_VERSION == 22 - -#include "sundials_types.h" -#include "sundials_math.h" -#include "cvodes.h" -#include "cvodes_dense.h" -#include "cvodes_diag.h" -#include "cvodes_spgmr.h" -#include "cvodes_band.h" -#include "nvector_serial.h" - -#else - -#if SUNDIALS_VERSION >= 23 #include "sundials/sundials_types.h" #include "sundials/sundials_math.h" #include "sundials/sundials_nvector.h" @@ -35,16 +21,8 @@ using namespace std; #include "cvodes/cvodes_spgmr.h" #include "cvodes/cvodes_band.h" -#else -#error unsupported Sundials version! -#endif - -#if SUNDIALS_VERSION >= 24 #define CV_SS 1 #define CV_SV 2 -#endif - -#endif #include #include @@ -128,10 +106,6 @@ CVodesIntegrator::CVodesIntegrator() : m_mupper(0), m_mlower(0), m_sens_ok(false) { -#if SUNDIALS_VERSION <= 23 - warn_deprecated("Use of Sundials 2.2 and 2.3", - "Support for these versions will be removed in Cantera 2.2."); -#endif //m_ropt.resize(OPT_SIZE,0.0); //m_iopt = new long[OPT_SIZE]; //fill(m_iopt, m_iopt+OPT_SIZE,0); @@ -271,19 +245,8 @@ void CVodesIntegrator::sensInit(double t0, FuncEval& func) } } - int flag; - -#if SUNDIALS_VERSION <= 23 - flag = CVodeSensMalloc(m_cvode_mem, m_np, CV_STAGGERED, m_yS); - if (flag != CV_SUCCESS) { - throw CVodesErr("Error in CVodeSensMalloc"); - } - vector_fp atol(m_np, m_abstolsens); - double rtol = m_reltolsens; - flag = CVodeSetSensTolerances(m_cvode_mem, CV_SS, rtol, DATA_PTR(atol)); -#elif SUNDIALS_VERSION >= 24 - flag = CVodeSensInit(m_cvode_mem, m_np, CV_STAGGERED, - CVSensRhsFn(0), m_yS); + int flag = CVodeSensInit(m_cvode_mem, m_np, CV_STAGGERED, + CVSensRhsFn(0), m_yS); if (flag != CV_SUCCESS) { throw CVodesErr("Error in CVodeSensMalloc"); @@ -291,7 +254,6 @@ void CVodesIntegrator::sensInit(double t0, FuncEval& func) vector_fp atol(m_np, m_abstolsens); double rtol = m_reltolsens; flag = CVodeSensSStolerances(m_cvode_mem, rtol, DATA_PTR(atol)); -#endif } @@ -330,29 +292,7 @@ void CVodesIntegrator::initialize(double t0, FuncEval& func) throw CVodesErr("CVodeCreate failed."); } - int flag = 0; -#if SUNDIALS_VERSION <= 23 - if (m_itol == CV_SV) { - // vector atol - flag = CVodeMalloc(m_cvode_mem, cvodes_rhs, m_t0, m_y, m_itol, - m_reltol, m_abstol); - } else { - // scalar atol - flag = CVodeMalloc(m_cvode_mem, cvodes_rhs, m_t0, m_y, m_itol, - m_reltol, &m_abstols); - } - if (flag != CV_SUCCESS) { - if (flag == CV_MEM_FAIL) { - throw CVodesErr("Memory allocation failed."); - } else if (flag == CV_ILL_INPUT) { - throw CVodesErr("Illegal value for CVodeMalloc input argument."); - } else { - throw CVodesErr("CVodeMalloc failed."); - } - } -#elif SUNDIALS_VERSION >= 24 - - flag = CVodeInit(m_cvode_mem, cvodes_rhs, m_t0, m_y); + int flag = CVodeInit(m_cvode_mem, cvodes_rhs, m_t0, m_y); if (flag != CV_SUCCESS) { if (flag == CV_MEM_FAIL) { throw CVodesErr("Memory allocation failed."); @@ -377,24 +317,16 @@ void CVodesIntegrator::initialize(double t0, FuncEval& func) throw CVodesErr("CVodeInit failed."); } } -#endif // pass a pointer to func in m_data delete m_fdata; m_fdata = new FuncData(&func, func.nparams()); //m_data = (void*)&func; -#if SUNDIALS_VERSION <= 23 - flag = CVodeSetFdata(m_cvode_mem, (void*)m_fdata); - if (flag != CV_SUCCESS) { - throw CVodesErr("CVodeSetFdata failed."); - } -#elif SUNDIALS_VERSION >= 24 flag = CVodeSetUserData(m_cvode_mem, (void*)m_fdata); if (flag != CV_SUCCESS) { throw CVodesErr("CVodeSetUserData failed."); } -#endif if (func.nparams() > 0) { sensInit(t0, func); flag = CVodeSetSensParams(m_cvode_mem, DATA_PTR(m_fdata->m_pars), @@ -418,26 +350,10 @@ void CVodesIntegrator::reinitialize(double t0, FuncEval& func) int result; -#if SUNDIALS_VERSION <= 23 - if (m_itol == CV_SV) { - result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, m_y, - m_itol, m_reltol, - m_abstol); - } else { - result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, m_y, - m_itol, m_reltol, - &m_abstols); - } - if (result != CV_SUCCESS) { - throw CVodesErr("CVodeReInit failed. result = "+int2str(result)); - } -#elif SUNDIALS_VERSION >= 24 result = CVodeReInit(m_cvode_mem, m_t0, m_y); if (result != CV_SUCCESS) { throw CVodesErr("CVodeReInit failed. result = "+int2str(result)); } -#endif - applyOptions(); } @@ -513,11 +429,7 @@ double CVodesIntegrator::sensitivity(size_t k, size_t p) return 0.0; } if (!m_sens_ok && m_np) { -#if SUNDIALS_VERSION <= 23 - int flag = CVodeGetSens(m_cvode_mem, m_time, m_yS); -#elif SUNDIALS_VERSION >= 24 int flag = CVodeGetSens(m_cvode_mem, &m_time, m_yS); -#endif if (flag != CV_SUCCESS) { throw CVodesErr("CVodeGetSens failed. Error code: " + int2str(flag)); } diff --git a/src/numerics/IDA_Solver.cpp b/src/numerics/IDA_Solver.cpp index a438025de..a82b780e5 100644 --- a/src/numerics/IDA_Solver.cpp +++ b/src/numerics/IDA_Solver.cpp @@ -7,7 +7,7 @@ #include "cantera/numerics/IDA_Solver.h" #include "cantera/base/stringUtils.h" -#if SUNDIALS_VERSION >= 24 +#if HAVE_SUNDIALS #include "sundials/sundials_types.h" #include "sundials/sundials_math.h" #include "ida/ida.h" @@ -350,21 +350,6 @@ void IDA_Solver::init(doublereal t0) if (m_itol == IDA_SV) { -#if SUNDIALS_VERSION <= 23 - // vector atol - flag = IDAMalloc(m_ida_mem, ida_resid, m_t0, m_y, m_ydot, - m_itol, m_reltol, m_abstol); - if (flag != IDA_SUCCESS) { - if (flag == IDA_MEM_FAIL) { - throw IDA_Err("Memory allocation failed."); - } else if (flag == IDA_ILL_INPUT) { - throw IDA_Err("Illegal value for IDAMalloc input argument."); - } else { - throw IDA_Err("IDAMalloc failed."); - } - } - -#elif SUNDIALS_VERSION >= 24 flag = IDAInit(m_ida_mem, ida_resid, m_t0, m_y, m_ydot); if (flag != IDA_SUCCESS) { if (flag == IDA_MEM_FAIL) { @@ -379,23 +364,7 @@ void IDA_Solver::init(doublereal t0) if (flag != IDA_SUCCESS) { throw IDA_Err("Memory allocation failed."); } -#endif } else { -#if SUNDIALS_VERSION <= 23 - // scalar atol - flag = IDAMalloc(m_ida_mem, ida_resid, m_t0, m_y, m_ydot, - m_itol, m_reltol, &m_abstols); - if (flag != IDA_SUCCESS) { - if (flag == IDA_MEM_FAIL) { - throw IDA_Err("Memory allocation failed."); - } else if (flag == IDA_ILL_INPUT) { - throw IDA_Err("Illegal value for IDAMalloc input argument."); - } else { - throw IDA_Err("IDAMalloc failed."); - } - } - -#elif SUNDIALS_VERSION >= 24 flag = IDAInit(m_ida_mem, ida_resid, m_t0, m_y, m_ydot); if (flag != IDA_SUCCESS) { if (flag == IDA_MEM_FAIL) { @@ -410,7 +379,6 @@ void IDA_Solver::init(doublereal t0) if (flag != IDA_SUCCESS) { throw IDA_Err("Memory allocation failed."); } -#endif } //----------------------------------- @@ -441,17 +409,10 @@ void IDA_Solver::init(doublereal t0) // pass a pointer to func in m_data m_fdata = new ResidData(&m_resid, this, m_resid.nparams()); -#if SUNDIALS_VERSION <= 23 - flag = IDASetRdata(m_ida_mem, (void*)m_fdata); - if (flag != IDA_SUCCESS) { - throw IDA_Err("IDASetRdata failed."); - } -#elif SUNDIALS_VERSION >= 24 flag = IDASetUserData(m_ida_mem, (void*)m_fdata); if (flag != IDA_SUCCESS) { throw IDA_Err("IDASetUserData failed."); } -#endif // set options if (m_maxord > 0) {