diff --git a/Cantera/src/base/Array.h b/Cantera/src/base/Array.h index 191c50ac3..003700a8c 100755 --- a/Cantera/src/base/Array.h +++ b/Cantera/src/base/Array.h @@ -38,14 +38,27 @@ namespace Cantera { public: + //! Type definition for the iterator class that is + //! can be used by Array2D types. + /*! + * this is just equal to vector_fp iterator. + */ typedef vector_fp::iterator iterator; + + + //! Type definition for the const_iterator class that is + //! can be used by Array2D types. + /*! + * this is just equal to vector_fp const_iterator. + */ typedef vector_fp::const_iterator const_iterator; /** * Default constructor. Create an empty array. */ - Array2D() : m_nrows(0), m_ncols(0) { m_data.clear(); } - + Array2D() : m_nrows(0), m_ncols(0) { + m_data.clear(); + } //! Constructor. /*! @@ -86,7 +99,7 @@ namespace Cantera { return *this; } - //! resize the array, and fill the new entries with 'v' + //! Resize the array, and fill the new entries with 'v' /*! * @param n This is the number of rows * @param m This is the number of columns in the new matrix @@ -98,7 +111,14 @@ namespace Cantera { m_data.resize(n*m, v); } - /// append a column + //! Append a column to the existing matrix using a std vector + /*! + * This operation will add a column onto the existing matrix. + * + * @param c This vector is the entries in the + * column to be added. It must have a length + * equal to m_nrows or greater. + */ void appendColumn(const vector_fp& c) { m_ncols++; m_data.resize(m_nrows*m_ncols); @@ -106,37 +126,66 @@ namespace Cantera { for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m]; } - /// append a column - void appendColumn(doublereal* c) { + //! Append a column to the existing matrix + /*! + * This operation will add a column onto the existing matrix. + * + * @param c This vector of doubles is the entries in the + * column to be added. It must have a length + * equal to m_nrows or greater. + */ + void appendColumn(const doublereal* const c) { m_ncols++; m_data.resize(m_nrows*m_ncols); int m; for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m]; } - /// set the nth row to array rw - void setRow(int n, doublereal* rw) { + //! Set the nth row to array rw + /*! + * @param n Index of the row to be changed + * @param rw Vector for the row. Must have a length of m_ncols. + */ + void setRow(int n, const doublereal* const rw) { for (int j = 0; j < m_ncols; j++) { m_data[m_nrows*j + n] = rw[j]; } } - /// get the nth row - void getRow(int n, doublereal* rw) { + //! Get the nth row and return it in a vector + /*! + * @param n Index of the row to be returned. + * @param rw Return Vector for the operation. + * Must have a length of m_ncols. + */ + void getRow(int n, doublereal* const rw) { for (int j = 0; j < m_ncols; j++) { rw[j] = m_data[m_nrows*j + n]; } } - /// set the values in column m to those in array col - void setColumn(int m, doublereal* col) { + //! Set the values in column m to those in array col + /*! + * A(i,m) = col(i) + * + * @param m Column to set + * @param col pointer to a col vector. Vector + * must have a length of m_nrows. + */ + void setColumn(int m, doublereal* const col) { for (int i = 0; i < m_nrows; i++) { m_data[m_nrows*m + i] = col[i]; } } - /// get the values in column m - void getColumn(int m, doublereal* col) { + //! Get the values in column m + /*! + * col(i) = A(i,m) + * + * @param m Column to set + * @param col pointer to a col vector that will be returned + */ + void getColumn(int m, doublereal* const col) { for (int i = 0; i < m_nrows; i++) { col[i] = m_data[m_nrows*m + i]; } @@ -147,10 +196,18 @@ namespace Cantera { * heap. */ virtual ~Array2D(){} - - - /** - * Evaluate a*x + y. + + //! Evaluate z = a*x + y. + /*! + * This function evaluates the AXPY operation, and stores + * the result in the object's Array2D object. + * It's assumed that all 3 objects have the same dimensions, + * but no error checking is done. + * + * @param a scalar to multiply x with + * @param x First Array2D object to be used + * @param y Second Array2D object to be used + * */ void axpy(doublereal a, const Array2D& x, const Array2D& y) { iterator b = begin(); @@ -169,20 +226,43 @@ namespace Cantera { */ doublereal& operator()( int i, int j) { return value(i,j); } - /** - * Allows retrieving elements using the syntax x = A(i,j). + + //! Allows retrieving elements using the syntax x = A(i,j). + /*! + * @param i Index for the row to be retrieved + * @param j Index for the column to be retrieved. + * + * @return Returns the value of the matrix entry */ - doublereal operator() ( int i, int j) const {return value(i,j);} + doublereal operator() (int i, int j) const { + return value(i,j); + } //! Returns a changeable reference to position in the matrix /*! * This is a key entry. Returns a reference to the matrixes (i,j) * element. This may be used as an L value. + * + * @param i The row index + * @param j The column index + * + * @return Returns a changeable reference to the matrix entry + */ + doublereal& value(int i, int j) { + return m_data[m_nrows*j + i]; + } + + //! Returns the value of a single matrix entry + /*! + * This is a key entry. Returns the value of the matrix position (i,j) + * element. + * * @param i The row index * @param j The column index */ - doublereal& value( int i, int j) {return m_data[m_nrows*j + i];} - doublereal value( int i, int j) const {return m_data[m_nrows*j + i];} + doublereal value(int i, int j) const { + return m_data[m_nrows*j + i]; + } /// Number of rows size_t nRows() const { return m_nrows; } @@ -208,10 +288,25 @@ namespace Cantera { /// Return a const reference to the data vector const vector_fp& data() const { return m_data; } - /// Return a pointer to the top of column j, columns are contiguous - /// in memory + //! Return a pointer to the top of column j, columns are contiguous + //! in memory + /*! + * @param j Value of the column + * + * @return Returns a pointer to the top of the column + */ doublereal * ptrColumn(int j) { return &(m_data[m_nrows*j]); } - const doublereal * ptrColumn(int j) const { return &(m_data[m_nrows*j]); } + + //! Return a const pointer to the top of column j, columns are contiguous + //! in memory + /*! + * @param j Value of the column + * + * @return Returns a const pointer to the top of the column + */ + const doublereal * ptrColumn(int j) const { + return &(m_data[m_nrows*j]); + } protected: @@ -225,7 +320,16 @@ namespace Cantera { int m_ncols; }; - /// output the array + //! Output the current contents of the Array2D object + /*! + * Example of usage: + * s << m << endl; + * + * @param s Reference to the ostream to write to + * @param m Object of type Array2D that you are querying + * + * @return Returns a reference to the ostream. + */ inline std::ostream& operator<<(std::ostream& s, const Array2D& m) { int nr = static_cast(m.nRows()); int nc = static_cast(m.nColumns()); diff --git a/Cantera/src/base/misc.cpp b/Cantera/src/base/misc.cpp index 692d90bb0..f0a9d8e8e 100755 --- a/Cantera/src/base/misc.cpp +++ b/Cantera/src/base/misc.cpp @@ -1519,10 +1519,6 @@ protected: app()->writelog(msg); } - void writelogAM(const std::string& msg) { - app()->writelog(msg); - } - // Write a message to the screen void Application::Messages::writelog(const std::string& msg) { logwriter->write(msg); @@ -1532,9 +1528,6 @@ protected: void writelog(const char* msg) { app()->writelog(msg); } - void writelogAM(const char* msg) { - app()->writelog(msg); - } // Write a message to the screen void Application::Messages::writelog(const char* pszmsg) { diff --git a/Cantera/src/base/vec_functions.h b/Cantera/src/base/vec_functions.h index 3fce9dae9..3b74ca33c 100755 --- a/Cantera/src/base/vec_functions.h +++ b/Cantera/src/base/vec_functions.h @@ -39,9 +39,13 @@ namespace Cantera { std::copy(x.begin(), x.begin() + n, y.begin()); } - /** - * Divide each element of x by the corresponding element of y. + //! Divide each element of x by the corresponding element of y. + /*! * This function replaces x[n] by x[n]/y[n], for 0 <= n < x.size() + * + * @param x Numerator object of the division operation with template type T + * At the end of the calculation, it contains the result. + * @param y Denominator object of the division template type T */ template inline void divide_each(T& x, const T& y) { @@ -49,9 +53,15 @@ namespace Cantera { x.begin(), std::divides()); } - /** - * multiply each element of x by the corresponding element of y. + //! Multiply each element of x by the corresponding element of y. + /*! * This function replaces x[n] by x[n]*y[n], for 0 <= n < x.size() + * This is a templated function with just one template type. + * + * @param x First object of the multiplication with template type T + * At the end of the calculation, it contains the result. + * @param y Second object of the multiplication with template type T + * */ template inline void multiply_each(T& x, const T& y) { @@ -59,32 +69,52 @@ namespace Cantera { x.begin(), std::multiplies()); } - /** - * Multiply each element of x by scale_factor. + //! Multiply each element of x by scale_factor. + /*! + * This function replaces x[n] by x[n]*scale_factor, for 0 <= n < x.size() + * + * @param x First object of the multiplication with template type T + * At the end of the calculation, it contains the result. + * @param scale_factor scale factor with template type S */ template inline void scale(T& x, S scale_factor) { scale(x.begin(), x.end(), x.begin(), scale_factor); } - /** + //! Return the templated dot product of two objects + /*! * Returns the sum of x[n]*y[n], for 0 <= n < x.size(). + * + * @param x First object of the dot product with template type T + * At the end of the calculation, it contains the result. + * @param y Second object of the dot product with template type T */ template inline doublereal dot_product(const T& x, const T& y) { return std::inner_product(x.begin(), x.end(), y.begin(), 0.0); } + //! Returns the templated dot ratio of two objects /** * Returns the sum of x[n]/y[n], for 0 <= n < x.size(). + * + * @param x First object of the dot product with template type T + * At the end of the calculation, it contains the result. + * @param y Second object of the dot product with template type T */ template inline doublereal dot_ratio(const T& x, const T& y) { return _dot_ratio(x.begin(), x.end(), y.begin(), 0.0); } + //! Returns a templated addition operation of two objects /** * Replaces x[n] by x[n] + y[n] for 0 <= n < x.size() + * + * @param x First object of the addition with template type T + * At the end of the calculation, it contains the result. + * @param y Second object of the addition with template type T */ template inline void add_each(T& x, const T& y) { @@ -119,9 +149,13 @@ namespace Cantera { return start_value; } - /** - * Finds the entry in a vector with maximum absolute - * value, and return this value. + + //! Finds the entry in a vector with maximum absolute + //! value, and return this value. + /*! + * @param v Vector to be queried for maximum value, with template type T + * + * @return Returns an object of type T that is the maximum value, */ template inline T absmax(const std::vector& v) { diff --git a/Cantera/src/equil/MultiPhase.h b/Cantera/src/equil/MultiPhase.h index 8bd66fbb9..7dfa0a5a3 100644 --- a/Cantera/src/equil/MultiPhase.h +++ b/Cantera/src/equil/MultiPhase.h @@ -496,7 +496,8 @@ namespace Cantera { //! Adds moles of a certain species to the mixture /*! - * + * @param indexS Index of the species in the MultiPhase object + * @param addedMoles Value of the moles that are added to the species. */ void addSpeciesMoles(const int indexS, const doublereal addedMoles); diff --git a/Cantera/src/equil/vcs_internal.h b/Cantera/src/equil/vcs_internal.h index 349c00a40..6756c4a7a 100644 --- a/Cantera/src/equil/vcs_internal.h +++ b/Cantera/src/equil/vcs_internal.h @@ -15,6 +15,8 @@ #ifndef _VCS_INTERNAL_H #define _VCS_INTERNAL_H +#include + #include "vcs_defs.h" #include "vcs_DoubleStarStar.h" #include "vcs_Exception.h" @@ -324,7 +326,6 @@ namespace VCSnonideal { //! available if this ever fails. #define USE_MEMSET #ifdef USE_MEMSET -#include //! Zero a double vector /*! @@ -473,6 +474,15 @@ namespace VCSnonideal { */ void vcs_print_line(const char *str, int num); + //! Returns a const char string representing the type of the + //! species given by the first argument + /*! + * @param speciesStatus Species status integer representing the type + * of the species. + * @param length Maximum length of the string to be returned. + * Shorter values will yield abbreviated strings. + * Defaults to a value of 100. + */ const char *vcs_speciesType_string(int speciesStatus, int length = 100); //! Print a string within a given space limit diff --git a/Cantera/src/numerics/CVodesIntegrator.cpp b/Cantera/src/numerics/CVodesIntegrator.cpp index b08806560..bf651bfea 100644 --- a/Cantera/src/numerics/CVodesIntegrator.cpp +++ b/Cantera/src/numerics/CVodesIntegrator.cpp @@ -25,7 +25,7 @@ using namespace std; #else -#ifdef SUNDIALS_VERSION_23 +#if defined(SUNDIALS_VERSION_23) || defined (SUNDIALS_VERSION_24) #include #include #include @@ -42,383 +42,471 @@ unsupported sundials version! #endif +#if defined (SUNDIALS_VERSION_24) +#define CV_SS 1 +#define CV_SV 2 + +#endif + #endif inline static N_Vector nv(void* x) { - return reinterpret_cast(x); + return reinterpret_cast(x); } namespace Cantera { - class FuncData { - public: - FuncData(FuncEval* f, int npar = 0) { - m_pars.resize(npar, 1.0); - m_func = f; - } - virtual ~FuncData() {} - vector_fp m_pars; - FuncEval* m_func; - }; + class FuncData { + public: + FuncData(FuncEval* f, int npar = 0) { + m_pars.resize(npar, 1.0); + m_func = f; + } + virtual ~FuncData() {} + vector_fp m_pars; + FuncEval* m_func; + }; } extern "C" { - /** - * Function called by cvodes to evaluate ydot given y. The cvode - * integrator allows passing in a void* pointer to access - * external data. This pointer is cast to a pointer to a instance - * of class FuncEval. The equations to be integrated should be - * specified by deriving a class from FuncEval that evaluates the - * desired equations. - * @ingroup odeGroup - */ - static int cvodes_rhs(realtype t, N_Vector y, N_Vector ydot, - void *f_data) { - double* ydata = NV_DATA_S(y); //N_VDATA(y); - double* ydotdata = NV_DATA_S(ydot); //N_VDATA(ydot); - Cantera::FuncData* d = (Cantera::FuncData*)f_data; - Cantera::FuncEval* f = d->m_func; - //try { - if (d->m_pars.size() == 0) - f->eval(t, ydata, ydotdata, NULL); - else - f->eval(t, ydata, ydotdata, DATA_PTR(d->m_pars)); - //} - //catch (...) { - //Cantera::showErrors(); - //Cantera::error("Teminating execution"); - //} - return 0; - } + /** + * Function called by cvodes to evaluate ydot given y. The cvode + * integrator allows passing in a void* pointer to access + * external data. This pointer is cast to a pointer to a instance + * of class FuncEval. The equations to be integrated should be + * specified by deriving a class from FuncEval that evaluates the + * desired equations. + * @ingroup odeGroup + */ + static int cvodes_rhs(realtype t, N_Vector y, N_Vector ydot, + void *f_data) { + double* ydata = NV_DATA_S(y); //N_VDATA(y); + double* ydotdata = NV_DATA_S(ydot); //N_VDATA(ydot); + Cantera::FuncData* d = (Cantera::FuncData*)f_data; + Cantera::FuncEval* f = d->m_func; + //try { + if (d->m_pars.size() == 0) + f->eval(t, ydata, ydotdata, NULL); + else + f->eval(t, ydata, ydotdata, DATA_PTR(d->m_pars)); + //} + //catch (...) { + //Cantera::showErrors(); + //Cantera::error("Teminating execution"); + //} + return 0; + } } namespace Cantera { - /** - * Constructor. Default settings: dense jacobian, no user-supplied - * Jacobian function, Newton iteration. - */ - CVodesIntegrator::CVodesIntegrator() : m_neq(0), - m_cvode_mem(0), - m_t0(0.0), - m_y(0), - m_abstol(0), - m_type(DENSE+NOJAC), - m_itol(CV_SS), - m_method(CV_BDF), - m_iter(CV_NEWTON), - m_maxord(0), - m_reltol(1.e-9), - m_abstols(1.e-15), - m_reltolsens(1.0e-5), - m_abstolsens(1.0e-4), - m_nabs(0), - m_hmax(0.0), - m_maxsteps(20000), m_np(0), - m_mupper(0), m_mlower(0) - { - //m_ropt.resize(OPT_SIZE,0.0); - //m_iopt = new long[OPT_SIZE]; - //fill(m_iopt, m_iopt+OPT_SIZE,0); + /** + * Constructor. Default settings: dense jacobian, no user-supplied + * Jacobian function, Newton iteration. + */ + CVodesIntegrator::CVodesIntegrator() : + m_neq(0), + m_cvode_mem(0), + m_t0(0.0), + m_y(0), + m_abstol(0), + m_type(DENSE+NOJAC), + m_itol(CV_SS), + m_method(CV_BDF), + m_iter(CV_NEWTON), + m_maxord(0), + m_reltol(1.e-9), + m_abstols(1.e-15), + m_reltolsens(1.0e-5), + m_abstolsens(1.0e-4), + m_nabs(0), + m_hmax(0.0), + m_maxsteps(20000), m_np(0), + m_mupper(0), m_mlower(0) + { + //m_ropt.resize(OPT_SIZE,0.0); + //m_iopt = new long[OPT_SIZE]; + //fill(m_iopt, m_iopt+OPT_SIZE,0); + } + + + /// Destructor. + CVodesIntegrator::~CVodesIntegrator() + { + if (m_cvode_mem) { + if (m_np > 0) + CVodeSensFree(m_cvode_mem); + CVodeFree(&m_cvode_mem); } + if (m_y) N_VDestroy_Serial(nv(m_y)); + if (m_abstol) N_VDestroy_Serial(nv(m_abstol)); + delete m_fdata; - - /// Destructor. - CVodesIntegrator::~CVodesIntegrator() - { - if (m_cvode_mem) { - if (m_np > 0) - CVodeSensFree(m_cvode_mem); - CVodeFree(&m_cvode_mem); - } - if (m_y) N_VDestroy_Serial(nv(m_y)); - if (m_abstol) N_VDestroy_Serial(nv(m_abstol)); - delete m_fdata; - - //delete[] m_iopt; - } + //delete[] m_iopt; + } - double& CVodesIntegrator::solution(int k){ - return NV_Ith_S(nv(m_y),k); - } + double& CVodesIntegrator::solution(int k){ + return NV_Ith_S(nv(m_y),k); + } - double* CVodesIntegrator::solution(){ return NV_DATA_S(nv(m_y)); + double* CVodesIntegrator::solution(){ return NV_DATA_S(nv(m_y)); + } + + void CVodesIntegrator::setTolerances(double reltol, int n, double* abstol) { + m_itol = CV_SV; + m_nabs = n; + if (n != m_neq) { + if (m_abstol) N_VDestroy_Serial(nv(m_abstol)); + m_abstol = reinterpret_cast(N_VNew_Serial(n)); } - - void CVodesIntegrator::setTolerances(double reltol, int n, double* abstol) { - m_itol = CV_SV; - m_nabs = n; - if (n != m_neq) { - if (m_abstol) N_VDestroy_Serial(nv(m_abstol)); - m_abstol = reinterpret_cast(N_VNew_Serial(n)); - } - for (int i=0; i(N_VNew_Serial(m_neq)); // allocate solution vector - for (int i=0; i 0) { - sensInit(t0, func); - flag = CVodeSetSensParams(m_cvode_mem, DATA_PTR(m_fdata->m_pars), - NULL, NULL); - } - - // set options - if (m_maxord > 0) - flag = CVodeSetMaxOrd(m_cvode_mem, m_maxord); - if (m_maxsteps > 0) - flag = CVodeSetMaxNumSteps(m_cvode_mem, m_maxsteps); - if (m_hmax > 0) - flag = CVodeSetMaxStep(m_cvode_mem, m_hmax); - } - - - void CVodesIntegrator::reinitialize(double t0, FuncEval& func) - { - m_t0 = t0; - //try { - func.getInitialConditions(m_t0, m_neq, NV_DATA_S(nv(m_y))); - //} - //catch (CanteraError) { - //showErrors(); - //error("Teminating execution"); - //} - - int result, flag; - if (m_itol == CV_SV) { - result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, nv(m_y), - m_itol, m_reltol, - nv(m_abstol)); - } - else { - result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, nv(m_y), - m_itol, m_reltol, - &m_abstols); - } - if (result != CV_SUCCESS) - throw CVodesErr("CVReInit failed. result = "+int2str(result)); - - if (m_type == DENSE + NOJAC) { - long int N = m_neq; - CVDense(m_cvode_mem, N); - } - else if (m_type == DIAG) { - CVDiag(m_cvode_mem); - } - else if (m_type == BAND + NOJAC) { - long int N = m_neq; - long int nu = m_mupper; - long int nl = m_mlower; - CVBand(m_cvode_mem, N, nu, nl); - } - else if (m_type == GMRES) { - CVSpgmr(m_cvode_mem, PREC_NONE, 0); - } - else { - throw CVodesErr("unsupported option"); - } - - - // set options - if (m_maxord > 0) - flag = CVodeSetMaxOrd(m_cvode_mem, m_maxord); - if (m_maxsteps > 0) - flag = CVodeSetMaxNumSteps(m_cvode_mem, m_maxsteps); - if (m_hmax > 0) - flag = CVodeSetMaxStep(m_cvode_mem, m_hmax); - } - - void CVodesIntegrator::integrate(double tout) - { - double t; - int flag; - flag = CVode(m_cvode_mem, tout, nv(m_y), &t, CV_NORMAL); - if (flag != CV_SUCCESS) - throw CVodesErr(" CVodes error encountered."); - if (m_np > 0) { - CVodeGetSens(m_cvode_mem, tout, m_yS); - } - } - - double CVodesIntegrator::step(double tout) - { - double t; - int flag; - flag = CVode(m_cvode_mem, tout, nv(m_y), &t, CV_ONE_STEP); - if (flag != CV_SUCCESS) - throw CVodesErr(" CVodes error encountered."); - return t; + doublereal* data; + int n, j; + N_Vector y; + y = N_VNew_Serial(nv); + m_yS = N_VCloneVectorArray_Serial(m_np, y); + for (n = 0; n < m_np; n++) { + data = NV_DATA_S(m_yS[n]); + for (j = 0; j < nv; j++) { + data[j] =0.0; } - - int CVodesIntegrator::nEvals() const { - long int ne; - CVodeGetNumRhsEvals(m_cvode_mem, &ne); - return ne; - //return m_iopt[NFE]; } - double CVodesIntegrator::sensitivity(int k, int p) { - if (k < 0 || k >= m_neq) - throw CVodesErr("sensitivity: k out of range ("+int2str(p)+")"); - if (p < 0 || p >= m_np) - throw CVodesErr("sensitivity: p out of range ("+int2str(p)+")"); - return NV_Ith_S(m_yS[p],k); + int flag; + +#if defined(SUNDIALS_VERSION_22) || defined(SUNDIALS_VERSION23) + 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 defined(SUNDIALS_VERSION_24) + flag = CVodeSensInit(m_cvode_mem, m_np, CV_STAGGERED, + CVSensRhsFn (0), m_yS); + + if (flag != CV_SUCCESS) { + throw CVodesErr("Error in CVodeSensMalloc"); + } + vector_fp atol(m_np, m_abstolsens); + double rtol = m_reltolsens; + flag = CVodeSensSStolerances(m_cvode_mem, rtol, DATA_PTR(atol)); + +#endif + + } + + void CVodesIntegrator::initialize(double t0, FuncEval& func) + { + m_neq = func.neq(); + m_t0 = t0; + + if (m_y) { + N_VDestroy_Serial(nv(m_y)); // free solution vector if already allocated + } + m_y = reinterpret_cast(N_VNew_Serial(m_neq)); // allocate solution vector + for (int i=0; i 0) { + sensInit(t0, func); + flag = CVodeSetSensParams(m_cvode_mem, DATA_PTR(m_fdata->m_pars), + NULL, NULL); + } + + // set options + if (m_maxord > 0) + flag = CVodeSetMaxOrd(m_cvode_mem, m_maxord); + if (m_maxsteps > 0) + flag = CVodeSetMaxNumSteps(m_cvode_mem, m_maxsteps); + if (m_hmax > 0) + flag = CVodeSetMaxStep(m_cvode_mem, m_hmax); + } + + + void CVodesIntegrator::reinitialize(double t0, FuncEval& func) + { + m_t0 = t0; + //try { + func.getInitialConditions(m_t0, m_neq, NV_DATA_S(nv(m_y))); + //} + //catch (CanteraError) { + //showErrors(); + //error("Teminating execution"); + //} + + int result, flag; + +#if defined(SUNDIALS_VERSION_22) || defined(SUNDIALS_VERSION23) + if (m_itol == CV_SV) { + result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, nv(m_y), + m_itol, m_reltol, + nv(m_abstol)); + } + else { + result = CVodeReInit(m_cvode_mem, cvodes_rhs, m_t0, nv(m_y), + m_itol, m_reltol, + &m_abstols); + } + if (result != CV_SUCCESS) { + throw CVodesErr("CVodeReInit failed. result = "+int2str(result)); + } +#elif defined(SUNDIALS_VERSION_24) + result = CVodeReInit(m_cvode_mem, m_t0, nv(m_y)); + if (result != CV_SUCCESS) { + throw CVodesErr("CVodeReInit failed. result = "+int2str(result)); + } +#endif + + if (m_type == DENSE + NOJAC) { + long int N = m_neq; + CVDense(m_cvode_mem, N); + } + else if (m_type == DIAG) { + CVDiag(m_cvode_mem); + } + else if (m_type == BAND + NOJAC) { + long int N = m_neq; + long int nu = m_mupper; + long int nl = m_mlower; + CVBand(m_cvode_mem, N, nu, nl); + } + else if (m_type == GMRES) { + CVSpgmr(m_cvode_mem, PREC_NONE, 0); + } + else { + throw CVodesErr("unsupported option"); + } + + + // set options + if (m_maxord > 0) + flag = CVodeSetMaxOrd(m_cvode_mem, m_maxord); + if (m_maxsteps > 0) + flag = CVodeSetMaxNumSteps(m_cvode_mem, m_maxsteps); + if (m_hmax > 0) + flag = CVodeSetMaxStep(m_cvode_mem, m_hmax); + } + + void CVodesIntegrator::integrate(double tout) + { + double t; + int flag; + double tretn; + flag = CVode(m_cvode_mem, tout, nv(m_y), &t, CV_NORMAL); + if (flag != CV_SUCCESS) + throw CVodesErr(" CVodes error encountered."); +#if defined(SUNDIALS_VERSION_22) || defined(SUNDIALS_VERSION23) + if (m_np > 0) { + CVodeGetSens(m_cvode_mem, tout, m_yS); + } +#elif defined(SUNDIALS_VERSION_24) + if (m_np > 0) { + CVodeGetSens(m_cvode_mem, &tretn, m_yS); + if (fabs(tretn - tout) > 1.0E-5) { + throw CVodesErr("Time of Sensitivities different than time of tout"); + } + } +#endif + } + + double CVodesIntegrator::step(double tout) + { + double t; + int flag; + flag = CVode(m_cvode_mem, tout, nv(m_y), &t, CV_ONE_STEP); + if (flag != CV_SUCCESS) + throw CVodesErr(" CVodes error encountered."); + return t; + } + + int CVodesIntegrator::nEvals() const { + long int ne; + CVodeGetNumRhsEvals(m_cvode_mem, &ne); + return ne; + //return m_iopt[NFE]; + } + + double CVodesIntegrator::sensitivity(int k, int p) { + if (k < 0 || k >= m_neq) + throw CVodesErr("sensitivity: k out of range ("+int2str(p)+")"); + if (p < 0 || p >= m_np) + throw CVodesErr("sensitivity: p out of range ("+int2str(p)+")"); + return NV_Ith_S(m_yS[p],k); + } } diff --git a/Cantera/src/thermo/Crystal.h b/Cantera/src/thermo/Crystal.h index 009ee4857..efe4a8c3b 100644 --- a/Cantera/src/thermo/Crystal.h +++ b/Cantera/src/thermo/Crystal.h @@ -53,6 +53,16 @@ namespace Cantera { }; + //! Prints out the current internal state of the Crystal ThermoPhase object + /*! + * Example of usage: + * s << x << endl; + * + * @param s Reference to the ostream to write to + * @param x Object of type Crystal that you are querying + * + * @return Returns a reference to the ostream. + */ inline std::ostream& operator<<(std::ostream& s, Cantera::Crystal& x) { size_t ip; for (ip = 0; ip < x.nPhases(); ip++) { diff --git a/Cantera/src/thermo/HMWSoln.h b/Cantera/src/thermo/HMWSoln.h index e476d3069..7c55e8ab4 100644 --- a/Cantera/src/thermo/HMWSoln.h +++ b/Cantera/src/thermo/HMWSoln.h @@ -551,7 +551,6 @@ namespace Cantera { * It can be shown that the expression * * - * * \f[ * B^{\phi}_{ca} = \beta^{(0)}_{ca} + \beta^{(1)}_{ca} \exp{(- \alpha^{(1)}_{ca} \sqrt{I})} * + \beta^{(2)}_{ca} \exp{(- \alpha^{(2)}_{ca} \sqrt{I} )} @@ -3201,6 +3200,7 @@ namespace Cantera { //! gamma_o value for the cutoff process at the zero solvent point doublereal MC_X_o_min_; + //! Parameter in the Molality Exp cutoff treatment /*! * This is the slope of the p function at the zero solvent point @@ -3223,10 +3223,16 @@ namespace Cantera { //! Parameter in the Molality Exp cutoff treatment doublereal MC_cpCut_; + //! Parameter in the Molality Exp cutoff treatment doublereal CROP_ln_gamma_o_min; + + //! Parameter in the Molality Exp cutoff treatment doublereal CROP_ln_gamma_o_max; + //! Parameter in the Molality Exp cutoff treatment doublereal CROP_ln_gamma_k_min; + + //! Parameter in the Molality Exp cutoff treatment doublereal CROP_ln_gamma_k_max; //! This is a boolean-type vector indicating whether @@ -3500,7 +3506,10 @@ namespace Cantera { //! Precalculate the IMS Cutoff parameters for typeCutoff = 2 void calcIMSCutoffParams_(); + + //! Calculate molality cut-off parameters void calcMCCutoffParams_(); + //! Utility function to assign an integer value from a string //! for the ElectrolyteSpeciesType field. /*! diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp index 2a437d931..93dd6402f 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -970,7 +970,7 @@ namespace Cantera { numNeutralMoleculeSpecies_ = neutralMoleculePhase_->nSpecies(); moleFractions_.resize(m_kk); fm_neutralMolec_ions_.resize(numNeutralMoleculeSpecies_ * m_kk); - fm_invert_ionForNeutral.resize(numNeutralMoleculeSpecies_); + fm_invert_ionForNeutral.resize(m_kk); NeutralMolecMoleFractions_.resize(numNeutralMoleculeSpecies_); cationList_.resize(m_kk); anionList_.resize(m_kk); diff --git a/Cantera/src/thermo/State.h b/Cantera/src/thermo/State.h index 9265013fe..b5bd5eca8 100755 --- a/Cantera/src/thermo/State.h +++ b/Cantera/src/thermo/State.h @@ -335,7 +335,12 @@ namespace Cantera { //! True if the number species has been set bool ready() const; - + //! Every time the mole fractions have changed, this routine + //! will increment the stateMFNumber + /*! + * @param forceChange If this is true then the stateMFNumber always + * changes. This defaults to false. + */ void stateMFChangeCalc(bool forceChange = false); //! Return the state number @@ -423,7 +428,7 @@ namespace Cantera { }; - + //! Return the State Mole Fraction Number inline int State::stateMFNumber() const { return m_stateNum; } diff --git a/Cantera/src/thermo/WaterSSTP.cpp b/Cantera/src/thermo/WaterSSTP.cpp index 4bd2c8db8..af1922645 100644 --- a/Cantera/src/thermo/WaterSSTP.cpp +++ b/Cantera/src/thermo/WaterSSTP.cpp @@ -127,11 +127,6 @@ namespace Cantera { - void WaterSSTP::constructPhase() { - throw CanteraError("WaterSSTP::constructPhase()", "unimplemented"); - - } - /* * @param infile XML file containing the description of the diff --git a/Cantera/src/thermo/WaterSSTP.h b/Cantera/src/thermo/WaterSSTP.h index b8bfdac46..bbc46b18a 100644 --- a/Cantera/src/thermo/WaterSSTP.h +++ b/Cantera/src/thermo/WaterSSTP.h @@ -400,13 +400,24 @@ namespace Cantera { */ virtual doublereal vaporFraction() const; - + //! Set the temperature of the phase + /*! + * The density and composition of the phase is constant during this + * operator. + * + * @param temp Temperature (Kelvin) + */ virtual void setTemperature(const doublereal temp); + //! Set the density of the phase + /*! + * The temperature and composition of the phase is constant during this + * operator. + * + * @param dens value of the density in kg m-3 + */ virtual void setDensity(const doublereal dens); - void constructPhase(); - //! Initialization of a pure water phase using an //! xml file. diff --git a/config.h.in b/config.h.in index 95cf514fe..9cc487cbe 100755 --- a/config.h.in +++ b/config.h.in @@ -47,6 +47,7 @@ typedef int ftnlen; // Fortran hidden string length type #undef HAS_SUNDIALS #undef SUNDIALS_VERSION_22 #undef SUNDIALS_VERSION_23 +#undef SUNDIALS_VERSION_24 //-------- LAPACK / BLAS --------- diff --git a/configure b/configure index 53226af7d..b8e9c815c 100755 --- a/configure +++ b/configure @@ -2428,38 +2428,63 @@ sundials_lib_dep= if test ${use_sundials} = 1; then -cat >>confdefs.h <<\_ACEOF -#define HAS_SUNDIALS 1 -_ACEOF - echo "using CVODES from SUNDIALS... Sensitivity analysis enabled." CVODE_LIBS='-lsundials_cvodes -lsundials_nvecserial' IDA_LIBS='-lsundials_ida -lsundials_nvecserial' if test "$SUNDIALS_VERSION" = "2.2"; then -cat >>confdefs.h <<\_ACEOF + cat >>confdefs.h <<\_ACEOF +#define HAS_SUNDIALS 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF #define SUNDIALS_VERSION_22 1 _ACEOF -sundials_include='-I'${SUNDIALS_HOME}'/include -I'${SUNDIALS_HOME}'/include/sundials -I'${SUNDIALS_HOME}'/include/cvodes -I'${SUNDIALS_HOME}'/include/ida' -echo "sundials include directory: " ${sundials_include} -echo "sundials library directory: " $SUNDIALS_LIB_DIR -sundials_lib_dir=$SUNDIALS_LIB_DIR -sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" -sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" -else -cat >>confdefs.h <<\_ACEOF + sundials_include='-I'${SUNDIALS_HOME}'/include -I'${SUNDIALS_HOME}'/include/sundials -I'${SUNDIALS_HOME}'/include/cvodes -I'${SUNDIALS_HOME}'/include/ida' + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +elif test "$SUNDIALS_VERSION" = "2.3"; then + cat >>confdefs.h <<\_ACEOF +#define HAS_SUNDIALS 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF #define SUNDIALS_VERSION_23 1 _ACEOF -sundials_include='-I'${SUNDIALS_INC_DIR} -echo "sundials include directory: " ${sundials_include} -echo "sundials library directory: " $SUNDIALS_LIB_DIR -sundials_lib_dir=$SUNDIALS_LIB_DIR -sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" -sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" -# python tools/src/sundials_version.py $SUNDIALS_HOME + sundials_include='-I'${SUNDIALS_INC_DIR} + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +# python tools/src/sundials_version.py $SUNDIALS_HOME +elif test "$SUNDIALS_VERSION" = "2.4"; then + cat >>confdefs.h <<\_ACEOF +#define HAS_SUNDIALS 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define SUNDIALS_VERSION_24 1 +_ACEOF + + sundials_include='-I'${SUNDIALS_INC_DIR} + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +# python tools/src/sundials_version.py $SUNDIALS_HOME +else + echo "ERROR: unknown or unsupported sundials version #: $SUNDIALS_VERSION" + echo " Supported versions are 2.2, 2.3, and 2.4" + echo " Please fix or turn off the sundials option by setting USE_SUNDIALS to no" + use_sundials=0 fi fi @@ -9855,7 +9880,7 @@ fi # Provide some information about the compiler. -echo "$as_me:9858:" \ +echo "$as_me:9883:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -10062,7 +10087,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FFLAGS FFLAGS="$FFLAGS $ac_verb" -(eval echo $as_me:10065: \"$ac_link\") >&5 +(eval echo $as_me:10090: \"$ac_link\") >&5 ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_f77_v_output" >&5 FFLAGS=$ac_save_FFLAGS @@ -10140,7 +10165,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FFLAGS FFLAGS="$FFLAGS $ac_cv_prog_f77_v" -(eval echo $as_me:10143: \"$ac_link\") >&5 +(eval echo $as_me:10168: \"$ac_link\") >&5 ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_f77_v_output" >&5 FFLAGS=$ac_save_FFLAGS @@ -10647,7 +10672,7 @@ fi - ac_config_files="$ac_config_files Makefile Cantera/Makefile Cantera/src/Makefile Cantera/src/base/Makefile Cantera/src/zeroD/Makefile Cantera/src/oneD/Makefile Cantera/src/converters/Makefile Cantera/src/transport/Makefile Cantera/src/thermo/Makefile Cantera/src/kinetics/Makefile Cantera/src/numerics/Makefile Cantera/src/spectra/Makefile Cantera/src/equil/Makefile Cantera/clib/src/Makefile Cantera/fortran/src/Makefile Cantera/fortran/f77demos/f77demos.mak Cantera/fortran/f77demos/Makefile Cantera/matlab/Makefile Cantera/matlab/setup_matlab.py Cantera/python/Makefile Cantera/python/setup.py Cantera/cxx/Makefile Cantera/cxx/src/Makefile Cantera/cxx/demos/Makefile Cantera/cxx/demos/combustor/Makefile Cantera/cxx/demos/combustor/Makefile.install Cantera/cxx/demos/flamespeed/Makefile Cantera/cxx/demos/flamespeed/Makefile.install Cantera/cxx/demos/kinetics1/Makefile Cantera/cxx/demos/kinetics1/Makefile.install Cantera/cxx/demos/NASA_coeffs/Makefile Cantera/cxx/demos/NASA_coeffs/Makefile.install Cantera/cxx/demos/rankine/Makefile Cantera/cxx/demos/rankine/Makefile.install Cantera/cxx/include/Cantera.mak Cantera/cxx/include/Cantera_bt.mak Cantera/user/Makefile Cantera/python/src/Makefile Cantera/python/examples/Makefile Cantera/python/examples/equilibrium/Makefile Cantera/python/examples/equilibrium/adiabatic_flame/Makefile Cantera/python/examples/equilibrium/multiphase_plasma/Makefile Cantera/python/examples/equilibrium/simple_test/Makefile Cantera/python/examples/equilibrium/stoich_flame/Makefile Cantera/python/examples/gasdynamics/isentropic/Makefile Cantera/python/examples/gasdynamics/soundSpeed/Makefile Cantera/python/examples/flames/adiabatic_flame/Makefile Cantera/python/examples/flames/flame1/Makefile Cantera/python/examples/flames/flame2/Makefile Cantera/python/examples/flames/flame_fixed_T/Makefile Cantera/python/examples/flames/free_h2_air/Makefile Cantera/python/examples/flames/npflame1/Makefile Cantera/python/examples/flames/stflame1/Makefile Cantera/python/examples/fuel_cells/Makefile Cantera/python/examples/liquid_vapor/critProperties/Makefile Cantera/python/examples/liquid_vapor/rankine/Makefile Cantera/python/examples/kinetics/Makefile Cantera/python/examples/misc/Makefile Cantera/python/examples/reactors/combustor_sim/Makefile Cantera/python/examples/reactors/functors_sim/Makefile Cantera/python/examples/reactors/mix1_sim/Makefile Cantera/python/examples/reactors/mix2_sim/Makefile Cantera/python/examples/reactors/piston_sim/Makefile Cantera/python/examples/reactors/reactor1_sim/Makefile Cantera/python/examples/reactors/reactor2_sim/Makefile Cantera/python/examples/reactors/sensitivity_sim/Makefile Cantera/python/examples/reactors/surf_pfr_sim/Makefile Cantera/python/examples/surface_chemistry/diamond_cvd/Makefile Cantera/python/examples/surface_chemistry/catcomb_stagflow/Makefile Cantera/python/examples/transport/Makefile Cantera/python/examples/flames/Makefile Cantera/python/examples/gasdynamics/Makefile Cantera/python/examples/liquid_vapor/Makefile Cantera/python/examples/reactors/Makefile Cantera/python/examples/surface_chemistry/Makefile ext/lapack/Makefile ext/blas/Makefile ext/cvode/Makefile ext/math/Makefile ext/recipes/Makefile ext/tpx/Makefile ext/Makefile ext/f2c_libs/Makefile ext/f2c_blas/Makefile ext/f2c_lapack/Makefile ext/f2c_math/Makefile examples/Makefile examples/cxx/Makefile tools/Makefile tools/doc/Cantera.cfg tools/doc/Makefile tools/src/Makefile tools/src/sample.mak tools/src/finish_install.py tools/src/package4mac tools/templates/f77/demo.mak tools/templates/f90/demo.mak tools/templates/cxx/demo.mak tools/testtools/Makefile data/inputs/Makefile data/inputs/mkxml test_problems/Makefile test_problems/cxx_ex/Makefile test_problems/silane_equil/Makefile test_problems/surfkin/Makefile test_problems/spectroscopy/Makefile test_problems/surfSolverTest/Makefile test_problems/diamondSurf/Makefile test_problems/diamondSurf_dupl/Makefile test_problems/ChemEquil_gri_matrix/Makefile test_problems/ChemEquil_gri_pairs/Makefile test_problems/ChemEquil_ionizedGas/Makefile test_problems/ChemEquil_red1/Makefile test_problems/CpJump/Makefile test_problems/mixGasTransport/Makefile test_problems/multiGasTransport/Makefile test_problems/printUtilUnitTest/Makefile test_problems/fracCoeff/Makefile test_problems/negATest/Makefile test_problems/NASA9poly_test/Makefile test_problems/ck2cti_test/Makefile test_problems/ck2cti_test/runtest test_problems/nasa9_reader/Makefile test_problems/nasa9_reader/runtest test_problems/min_python/Makefile test_problems/min_python/minDiamond/Makefile test_problems/min_python/negATest/Makefile test_problems/pureFluidTest/Makefile test_problems/rankine_democxx/Makefile test_problems/python/Makefile test_problems/cathermo/Makefile test_problems/cathermo/issp/Makefile test_problems/cathermo/ims/Makefile test_problems/cathermo/stoichSubSSTP/Makefile test_problems/cathermo/testIAPWS/Makefile test_problems/cathermo/testIAPWSPres/Makefile test_problems/cathermo/testIAPWSTripP/Makefile test_problems/cathermo/testWaterPDSS/Makefile test_problems/cathermo/testWaterTP/Makefile test_problems/cathermo/HMW_test_1/Makefile test_problems/cathermo/HMW_test_3/Makefile test_problems/cathermo/HMW_graph_GvT/Makefile test_problems/cathermo/HMW_graph_GvI/Makefile test_problems/cathermo/HMW_graph_HvT/Makefile test_problems/cathermo/HMW_graph_CpvT/Makefile test_problems/cathermo/HMW_graph_VvT/Makefile test_problems/cathermo/DH_graph_1/Makefile test_problems/cathermo/DH_graph_acommon/Makefile test_problems/cathermo/DH_graph_NM/Makefile test_problems/cathermo/DH_graph_Pitzer/Makefile test_problems/cathermo/DH_graph_bdotak/Makefile test_problems/cathermo/HMW_dupl_test/Makefile test_problems/cathermo/VPissp/Makefile test_problems/cathermo/wtWater/Makefile test_problems/VCSnonideal/Makefile test_problems/VPsilane_test/Makefile test_problems/VPsilane_test/runtest test_problems/VCSnonideal/NaCl_equil/Makefile bin/install_tsc" + ac_config_files="$ac_config_files Makefile Cantera/Makefile Cantera/src/Makefile Cantera/src/base/Makefile Cantera/src/zeroD/Makefile Cantera/src/oneD/Makefile Cantera/src/converters/Makefile Cantera/src/transport/Makefile Cantera/src/thermo/Makefile Cantera/src/kinetics/Makefile Cantera/src/numerics/Makefile Cantera/src/spectra/Makefile Cantera/src/equil/Makefile Cantera/clib/src/Makefile Cantera/fortran/src/Makefile Cantera/fortran/f77demos/f77demos.mak Cantera/fortran/f77demos/Makefile Cantera/matlab/Makefile Cantera/matlab/setup_matlab.py Cantera/python/Makefile Cantera/python/setup.py Cantera/cxx/Makefile Cantera/cxx/src/Makefile Cantera/cxx/demos/Makefile Cantera/cxx/demos/combustor/Makefile Cantera/cxx/demos/combustor/Makefile.install Cantera/cxx/demos/flamespeed/Makefile Cantera/cxx/demos/flamespeed/Makefile.install Cantera/cxx/demos/kinetics1/Makefile Cantera/cxx/demos/kinetics1/Makefile.install Cantera/cxx/demos/NASA_coeffs/Makefile Cantera/cxx/demos/NASA_coeffs/Makefile.install Cantera/cxx/demos/rankine/Makefile Cantera/cxx/demos/rankine/Makefile.install Cantera/cxx/include/Cantera.mak Cantera/cxx/include/Cantera_bt.mak Cantera/user/Makefile Cantera/python/src/Makefile Cantera/python/examples/Makefile Cantera/python/examples/equilibrium/Makefile Cantera/python/examples/equilibrium/adiabatic_flame/Makefile Cantera/python/examples/equilibrium/multiphase_plasma/Makefile Cantera/python/examples/equilibrium/simple_test/Makefile Cantera/python/examples/equilibrium/stoich_flame/Makefile Cantera/python/examples/gasdynamics/isentropic/Makefile Cantera/python/examples/gasdynamics/soundSpeed/Makefile Cantera/python/examples/flames/adiabatic_flame/Makefile Cantera/python/examples/flames/flame1/Makefile Cantera/python/examples/flames/flame2/Makefile Cantera/python/examples/flames/flame_fixed_T/Makefile Cantera/python/examples/flames/free_h2_air/Makefile Cantera/python/examples/flames/npflame1/Makefile Cantera/python/examples/flames/stflame1/Makefile Cantera/python/examples/fuel_cells/Makefile Cantera/python/examples/liquid_vapor/critProperties/Makefile Cantera/python/examples/liquid_vapor/rankine/Makefile Cantera/python/examples/kinetics/Makefile Cantera/python/examples/misc/Makefile Cantera/python/examples/reactors/combustor_sim/Makefile Cantera/python/examples/reactors/functors_sim/Makefile Cantera/python/examples/reactors/mix1_sim/Makefile Cantera/python/examples/reactors/mix2_sim/Makefile Cantera/python/examples/reactors/piston_sim/Makefile Cantera/python/examples/reactors/reactor1_sim/Makefile Cantera/python/examples/reactors/reactor2_sim/Makefile Cantera/python/examples/reactors/sensitivity_sim/Makefile Cantera/python/examples/reactors/surf_pfr_sim/Makefile Cantera/python/examples/surface_chemistry/diamond_cvd/Makefile Cantera/python/examples/surface_chemistry/catcomb_stagflow/Makefile Cantera/python/examples/transport/Makefile Cantera/python/examples/flames/Makefile Cantera/python/examples/gasdynamics/Makefile Cantera/python/examples/liquid_vapor/Makefile Cantera/python/examples/reactors/Makefile Cantera/python/examples/surface_chemistry/Makefile ext/lapack/Makefile ext/blas/Makefile ext/cvode/Makefile ext/math/Makefile ext/recipes/Makefile ext/tpx/Makefile ext/Makefile ext/f2c_libs/Makefile ext/f2c_blas/Makefile ext/f2c_lapack/Makefile ext/f2c_math/Makefile examples/Makefile examples/cxx/Makefile tools/Makefile tools/doc/Cantera.cfg tools/doc/Makefile tools/src/Makefile tools/src/sample.mak tools/src/finish_install.py tools/src/package4mac tools/templates/f77/demo.mak tools/templates/f90/demo.mak tools/templates/cxx/demo.mak tools/testtools/Makefile data/inputs/Makefile data/inputs/mkxml test_problems/Makefile test_problems/cxx_ex/Makefile test_problems/silane_equil/Makefile test_problems/surfkin/Makefile test_problems/spectroscopy/Makefile test_problems/surfSolverTest/Makefile test_problems/diamondSurf/Makefile test_problems/diamondSurf_dupl/Makefile test_problems/ChemEquil_gri_matrix/Makefile test_problems/ChemEquil_gri_pairs/Makefile test_problems/ChemEquil_ionizedGas/Makefile test_problems/ChemEquil_red1/Makefile test_problems/CpJump/Makefile test_problems/mixGasTransport/Makefile test_problems/multiGasTransport/Makefile test_problems/printUtilUnitTest/Makefile test_problems/fracCoeff/Makefile test_problems/negATest/Makefile test_problems/NASA9poly_test/Makefile test_problems/ck2cti_test/Makefile test_problems/ck2cti_test/runtest test_problems/nasa9_reader/Makefile test_problems/nasa9_reader/runtest test_problems/min_python/Makefile test_problems/min_python/minDiamond/Makefile test_problems/min_python/negATest/Makefile test_problems/pureFluidTest/Makefile test_problems/rankine_democxx/Makefile test_problems/python/Makefile test_problems/cathermo/Makefile test_problems/cathermo/issp/Makefile test_problems/cathermo/ims/Makefile test_problems/cathermo/stoichSubSSTP/Makefile test_problems/cathermo/testIAPWS/Makefile test_problems/cathermo/testIAPWSPres/Makefile test_problems/cathermo/testIAPWSTripP/Makefile test_problems/cathermo/testWaterPDSS/Makefile test_problems/cathermo/testWaterTP/Makefile test_problems/cathermo/HMW_test_1/Makefile test_problems/cathermo/HMW_test_3/Makefile test_problems/cathermo/HMW_graph_GvT/Makefile test_problems/cathermo/HMW_graph_GvI/Makefile test_problems/cathermo/HMW_graph_HvT/Makefile test_problems/cathermo/HMW_graph_CpvT/Makefile test_problems/cathermo/HMW_graph_VvT/Makefile test_problems/cathermo/DH_graph_1/Makefile test_problems/cathermo/DH_graph_acommon/Makefile test_problems/cathermo/DH_graph_NM/Makefile test_problems/cathermo/DH_graph_Pitzer/Makefile test_problems/cathermo/DH_graph_bdotak/Makefile test_problems/cathermo/HMW_dupl_test/Makefile test_problems/cathermo/VPissp/Makefile test_problems/VCSnonideal/Makefile test_problems/VPsilane_test/Makefile test_problems/VPsilane_test/runtest test_problems/VCSnonideal/NaCl_equil/Makefile bin/install_tsc" test "x$prefix" = xNONE && prefix=$ac_default_prefix @@ -11273,7 +11298,6 @@ do "test_problems/cathermo/DH_graph_bdotak/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/cathermo/DH_graph_bdotak/Makefile" ;; "test_problems/cathermo/HMW_dupl_test/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/cathermo/HMW_dupl_test/Makefile" ;; "test_problems/cathermo/VPissp/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/cathermo/VPissp/Makefile" ;; - "test_problems/cathermo/wtWater/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/cathermo/wtWater/Makefile" ;; "test_problems/VCSnonideal/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/VCSnonideal/Makefile" ;; "test_problems/VPsilane_test/Makefile" ) CONFIG_FILES="$CONFIG_FILES test_problems/VPsilane_test/Makefile" ;; "test_problems/VPsilane_test/runtest" ) CONFIG_FILES="$CONFIG_FILES test_problems/VPsilane_test/runtest" ;; diff --git a/configure.in b/configure.in index 0e0e9f88d..0ffaada6c 100755 --- a/configure.in +++ b/configure.in @@ -365,29 +365,45 @@ sundials_lib_dep= if test ${use_sundials} = 1; then -AC_DEFINE(HAS_SUNDIALS) echo "using CVODES from SUNDIALS... Sensitivity analysis enabled." CVODE_LIBS='-lsundials_cvodes -lsundials_nvecserial' IDA_LIBS='-lsundials_ida -lsundials_nvecserial' if test "$SUNDIALS_VERSION" = "2.2"; then -AC_DEFINE(SUNDIALS_VERSION_22) -sundials_include='-I'${SUNDIALS_HOME}'/include -I'${SUNDIALS_HOME}'/include/sundials -I'${SUNDIALS_HOME}'/include/cvodes -I'${SUNDIALS_HOME}'/include/ida' -echo "sundials include directory: " ${sundials_include} -echo "sundials library directory: " $SUNDIALS_LIB_DIR -sundials_lib_dir=$SUNDIALS_LIB_DIR -sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" -sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" + AC_DEFINE(HAS_SUNDIALS) + AC_DEFINE(SUNDIALS_VERSION_22) + sundials_include='-I'${SUNDIALS_HOME}'/include -I'${SUNDIALS_HOME}'/include/sundials -I'${SUNDIALS_HOME}'/include/cvodes -I'${SUNDIALS_HOME}'/include/ida' + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +elif test "$SUNDIALS_VERSION" = "2.3"; then + AC_DEFINE(HAS_SUNDIALS) + AC_DEFINE(SUNDIALS_VERSION_23) + sundials_include='-I'${SUNDIALS_INC_DIR} + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +# python tools/src/sundials_version.py $SUNDIALS_HOME +elif test "$SUNDIALS_VERSION" = "2.4"; then + AC_DEFINE(HAS_SUNDIALS) + AC_DEFINE(SUNDIALS_VERSION_24) + sundials_include='-I'${SUNDIALS_INC_DIR} + echo "sundials include directory: " ${sundials_include} + echo "sundials library directory: " $SUNDIALS_LIB_DIR + sundials_lib_dir=$SUNDIALS_LIB_DIR + sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" + sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" +# python tools/src/sundials_version.py $SUNDIALS_HOME else -AC_DEFINE(SUNDIALS_VERSION_23) -sundials_include='-I'${SUNDIALS_INC_DIR} -echo "sundials include directory: " ${sundials_include} -echo "sundials library directory: " $SUNDIALS_LIB_DIR -sundials_lib_dir=$SUNDIALS_LIB_DIR -sundials_lib="-L$SUNDIALS_LIB_DIR -lsundials_cvodes -lsundials_ida -lsundials_nvecserial" -sundials_lib_dep="$SUNDIALS_LIB_DIR/libsundials_cvodes.a $SUNDIALS_LIB_DIR/libsundials_ida.a $SUNDIALS_LIB_DIR/libsundials_nvecserial.a" -# python tools/src/sundials_version.py $SUNDIALS_HOME + echo "ERROR: unknown or unsupported sundials version #: $SUNDIALS_VERSION" + echo " Supported versions are 2.2, 2.3, and 2.4" + echo " Please fix or turn off the sundials option by setting USE_SUNDIALS to no" + use_sundials=0 fi fi diff --git a/preconfig b/preconfig index fe2b5f655..ee7b62fea 100755 --- a/preconfig +++ b/preconfig @@ -315,11 +315,11 @@ USE_SUNDIALS=${USE_SUNDIALS:='default'} # It is recommended that you install the newest release of sundials -# (currently 2.3.0) before building Cantera. But if you want to use an +# (currently 2.4.0) before building Cantera. But if you want to use an # older version, set SUNDIALS_VERSION to the version you have. -# Acceptable values are '2.2' and '2.3' only; anything else will cause -# Cantera to not use sundials. -SUNDIALS_VERSION=${SUNDIALS_VERSION:='2.3'} +# Acceptable values are '2.2', '2.3', or '2.4' ; anything else will cause +# Cantera to +SUNDIALS_VERSION=${SUNDIALS_VERSION:='2.4'} #----------------------------------------------------------------- # BLAS and LAPACK diff --git a/test_problems/surfSolverTest/surfaceSolver2_blessed.out b/test_problems/surfSolverTest/surfaceSolver2_blessed.out index 3c200799d..5ddcf2dcf 100644 --- a/test_problems/surfSolverTest/surfaceSolver2_blessed.out +++ b/test_problems/surfSolverTest/surfaceSolver2_blessed.out @@ -21,9 +21,9 @@ Number of reactions = 8 3 4.8454e-06 3.0554e-06 6.8484e+04 4.0505e+04 Csoot-* 4 2.6364e-05 2.1519e-05 1.1250e+04 5.8320e+03 Csoot-* 5 1.3012e-03 1.2749e-03 1.4427e+03 7.3573e+02 Csoot-* - 6 4.7372e+00 4.7359e+00 5.8161e-01 2.9647e-01 Csoot-* - 7 6.1771e-08 3.1736e-08 - FIN 7 6.1771e-08 2.1591e-11 -- success + 6 4.7372e+00 4.7359e+00 5.8160e-01 2.9647e-01 Csoot-* + 7 6.4112e-08 3.2378e-08 + FIN 7 6.4112e-08 3.6822e-12 -- success Gas Temperature = 1.4e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -81,8 +81,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- 1 5.3218e+03 2.7005e+03 - 2 8.9325e-06 4.0777e-06 - FIN 2 8.9325e-06 6.2499e-12 -- success + 2 8.8765e-06 4.0574e-06 + FIN 2 8.8765e-06 8.4527e-11 -- success Gas Temperature = 1.4e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -140,8 +140,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- 1 2.1569e+05 9.5571e+04 - 2 1.7622e-04 2.0108e-04 - FIN 2 1.7622e-04 2.0335e-10 -- success + 2 7.8671e-04 4.6185e-04 + FIN 2 7.8671e-04 1.5306e-10 -- success Gas Temperature = 1.5e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -198,8 +198,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- - 1 2.8875e-10 1.4792e-10 - FIN 1 2.8875e-10 1.2324e-10 -- success + 1 3.0635e-10 1.5694e-10 + FIN 1 3.0635e-10 1.2314e-10 -- success Gas Temperature = 1.5e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) diff --git a/test_problems/surfSolverTest/surfaceSolver_blessed.out b/test_problems/surfSolverTest/surfaceSolver_blessed.out index cbe9bbbe5..44ee2543a 100644 --- a/test_problems/surfSolverTest/surfaceSolver_blessed.out +++ b/test_problems/surfSolverTest/surfaceSolver_blessed.out @@ -19,9 +19,9 @@ Number of reactions = 8 3 4.8454e-06 3.0554e-06 6.8484e+04 4.0505e+04 Csoot-* 4 2.6364e-05 2.1519e-05 1.1250e+04 5.8320e+03 Csoot-* 5 1.3012e-03 1.2749e-03 1.4427e+03 7.3573e+02 Csoot-* - 6 4.7372e+00 4.7359e+00 5.8161e-01 2.9647e-01 Csoot-* - 7 6.1771e-08 3.1736e-08 - FIN 7 6.1771e-08 2.1591e-11 -- success + 6 4.7372e+00 4.7359e+00 5.8160e-01 2.9647e-01 Csoot-* + 7 6.4112e-08 3.2378e-08 + FIN 7 6.4112e-08 3.6822e-12 -- success Gas Temperature = 1.4e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -72,8 +72,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- 1 5.3218e+03 2.7005e+03 - 2 8.9325e-06 4.0777e-06 - FIN 2 8.9325e-06 6.2499e-12 -- success + 2 8.8765e-06 4.0574e-06 + FIN 2 8.8765e-06 8.4527e-11 -- success Gas Temperature = 1.4e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -124,8 +124,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- 1 2.1569e+05 9.5571e+04 - 2 1.7622e-04 2.0108e-04 - FIN 2 1.7622e-04 2.0335e-10 -- success + 2 7.8671e-04 4.6185e-04 + FIN 2 7.8671e-04 1.5306e-10 -- success Gas Temperature = 1.5e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0) @@ -175,8 +175,8 @@ Sum of coverages = 1 Iter Time Del_t Damp DelX Resid Name-Time Name-Damp ----------------------------------------------------------------------------------- - 1 2.8875e-10 1.4792e-10 - FIN 1 2.8875e-10 1.2324e-10 -- success + 1 3.0635e-10 1.5694e-10 + FIN 1 3.0635e-10 1.2314e-10 -- success Gas Temperature = 1.5e+03 Gas Pressure = 1.01e+05 Gas Phase: gas (0)