Remove unused, deprecated code marked for removal after Cantera 2.2

This commit is contained in:
Ray Speth 2015-07-15 11:34:21 -04:00
parent ad4ed9e065
commit f1f10b6526
143 changed files with 89 additions and 17358 deletions

View file

@ -124,18 +124,6 @@ public:
m_data.resize(n*m, v);
}
//! Copy the data from one array into another without doing any checking
/*!
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
* @deprecated To be removed after Cantera 2.2.
*/
void copyData(const Array2D& y) {
warn_deprecated("Array2D::copyData", "To be removed after Cantera 2.2.");
size_t n = sizeof(doublereal) * m_nrows * m_ncols;
(void) memcpy(DATA_PTR(m_data), y.ptrColumn(0), n);
}
//! Append a column to the existing matrix using a std vector
/*!
* This operation will add a column onto the existing matrix.

View file

@ -55,37 +55,6 @@ namespace Cantera
* preprocessor symbol is defined, e.g. with the compiler option -DNDEBUG.
*/
//! Enum containing Cantera's behavior for situations where overflow or underflow of real variables
//! may occur.
/*!
* Note this frequently occurs when taking exponentials of delta Gibbs energies of reactions
* or when taking the exponentials of logs of activity coefficients.
*/
enum CT_RealNumber_Range_Behavior {
//! For this specification of range behavior, nothing is done. This is the fastest
//! behavior when all calculations are believed to be ranged well. For situations
//! where there are range errors, NaN's or INF's will be introduced.
DONOTHING_CTRB = -1,
//! For this specification of range behavior, the overflow or underflow calculation is changed.
//! Cantera will proceed by bounding the real number to maintain its viability, silently
//! changing the actual answer.
CHANGE_OVERFLOW_CTRB,
//! When an overflow or underflow occurs, Cantera will throw an error
THROWON_OVERFLOW_CTRB,
//! Cantera will use the fenv check capability introduced in C99 to check for
//! overflow and underflow conditions at crucial points.
//! It will throw an error if these conditions occur.
FENV_CHECK_CTRB,
//! Cantera will throw an error in debug mode but will not in production mode.
//! (default)
THROWON_OVERFLOW_DEBUGMODEONLY_CTRB
};
//! Base class for exceptions thrown by Cantera classes.
/*!

View file

@ -673,49 +673,6 @@ XML_Node* getByTitle(const XML_Node& node, const std::string& title);
void getString(const XML_Node& node, const std::string& titleString,
std::string& valueString, std::string& typeString);
//! This function attempts to read a named child node and returns with the
//! contents in the value string. title attribute named "titleString"
/*!
* This function will read a child node to the current XML node, with the name
* "string". It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* If the child node is not found then the empty string is returned.
*
* Example:
*
* Code snippet:
* @code
* const XML_Node &node;
* std::string valueString;
* std::string typeString;
* std::string nameString = "timeIncrement";
* getString(XML_Node& node, nameString, valueString, valueString, typeString);
* @endcode
*
* Reads the following the snippet in the XML file:
*
* <nameString type="typeString">
* valueString
* <\nameString>
*
* or alternatively as a retrofit and special case, it also reads the
* following case:
*
* <string title="nameString" type="typeString">
* valueString
* <\string>
*
* @param node Reference to the XML_Node object of the parent XML element
* @param[in] nameString Name of the XML Node
* @param[out] valueString Value string that is found in the child node.
* @param[out] typeString String type. This is an optional output variable.
* It is filled with the attribute "type" of the XML entry.
* @deprecated To be removed after Cantera 2.2.
*/
void getNamedStringValue(const XML_Node& node, const std::string& nameString, std::string& valueString,
std::string& typeString);
//! This function reads a child node with the name, nameString, and returns
//! its XML value as the return string
/*!

View file

@ -172,9 +172,6 @@ void writelogendl();
void writeline(char repeat, size_t count,
bool endl_after=true, bool endl_before=false);
//! @copydoc Application::Messages::logerror
void error(const std::string& msg);
//! @copydoc Application::warn_deprecated
void warn_deprecated(const std::string& method, const std::string& extra="");

View file

@ -95,48 +95,6 @@ std::string lowercase(const std::string& s);
compositionMap parseCompString(const std::string& ss,
const std::vector<std::string>& names=std::vector<std::string>());
//! Parse a composition string into individual key:composition pairs
/*!
* @param ss original string consisting of multiple key:composition
* pairs on multiple lines
* @param w Output vector consisting of single key:composition
* items in each index.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
void split(const std::string& ss, std::vector<std::string>& w);
//! Interpret a string as a list of floats, and convert it to a vector
//! of floats
/*!
* @param str String input vector
* @param a Output pointer to a vector of floats
* @param delim character delimiter. Defaults to a space
* @return Returns the number of floats found and converted
* @deprecated Unused. To be removed after Cantera 2.2.
*/
int fillArrayFromString(const std::string& str, doublereal* const a,
const char delim = ' ');
//! Generate a logfile name based on an input file name
/*!
* It tries to find the basename. Then, it appends a .log to it.
*
* @param infile Input file name
* @return Returns a logfile name
* @deprecated Unused function to be removed after Cantera 2.2.
*/
std::string logfileName(const std::string& infile);
//! Get the file name without the path or extension
/*!
* @param fullPath Input file name consisting
* of the full file name
*
* @return Returns the basename
* @deprecated Unused function to be removed after Cantera 2.2.
*/
std::string getBaseName(const std::string& fullPath);
//! Translate a string into one integer value
/*!
* No error checking is done on the conversion. The c stdlib function

View file

@ -90,26 +90,6 @@ inline doublereal dot5(const V& x, const V& y)
x[4]*y[4];
}
//! Templated Inner product of two vectors of length 6
/*!
* If either \a x
* or \a y has length greater than 4, only the first 4 elements
* will be used.
*
* @param x first reference to the templated class V
* @param y second reference to the templated class V
* @return
* This class returns a hard-coded type, doublereal.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class V>
inline doublereal dot6(const V& x, const V& y)
{
warn_deprecated("dot6", "To be removed after Cantera 2.2.");
return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + x[3]*y[3] +
x[4]*y[4] + x[5]*y[5];
}
//! Function that calculates a templated inner product.
/*!
* This inner product is templated twice. The output variable is hard coded
@ -161,50 +141,6 @@ inline void scale(InputIter begin, InputIter end,
std::transform(begin, end, out, timesConstant<S>(scale_factor));
}
/*!
* Multiply elements of an array, y, by a scale factor, f and add the
* result to an existing array, x. This is essentially a templated daxpy_
* operation.
*
* The template arguments are: template<class InputIter,
* class OutputIter, class S>
*
* Simple Code Example of the functionality;
* @code
* double x[10], y[10], f;
* for (i = 0; i < n; i++) {
* y[i] += f * x[i]
* }
* @endcode
* Example of the function call to implement the simple code example
* @code
* double x[10], y[10], f;
* increment_scale(x, x+10, y, f);
* @endcode
*
* It is templated with three parameters. The first template
* is the iterator, InputIter, which controls access to y[].
* The second template is the iterator OutputIter, which controls
* access to y[]. The third iterator is S, which is f.
*
* @param begin InputIter Iterator for beginning of y[]
* @param end inputIter Iterator for end of y[]
* @param out OutputIter Iterator for beginning of x[]
* @param scale_factor Scale Factor to multiply y[i] by
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class InputIter, class OutputIter, class S>
inline void increment_scale(InputIter begin, InputIter end,
OutputIter out, S scale_factor)
{
warn_deprecated("increment_scale",
"To be removed after Cantera 2.2.");
for (; begin != end; ++begin, ++out) {
*out += scale_factor * *begin;
}
}
//! Multiply each entry in x by the corresponding entry in y.
/*!
* The template arguments are: template<class InputIter, class OutputIter>
@ -239,44 +175,6 @@ inline void multiply_each(OutputIter x_begin, OutputIter x_end,
}
}
//! Invoke method 'resize' with argument \a m for a sequence of objects (templated version)
/*!
* The template arguments are: template<class InputIter>
*
* Simple code Equivalent:
* \code
* vector<vector<double> *> VV;
* for (n = 0; n < 20; n++) {
* vector<double> *vp = VV[n];
* vp->resize(m);
* }
* \endcode
* Example of function call usage to implement the simple code example:
* \code
* vector<vector<double> *> VV;
* resize_each(m, &VV[0], &VV[20]);
* \endcode
*
* @param m Integer specifying the size that each object should be resized to.
* @param begin Iterator pointing to the beginning of the sequence of object, belonging to the
* iterator class InputIter.
* @param end Iterator pointing to the end of the sequence of objects, belonging to the
* iterator class InputIter. The difference between end and begin
* determines the loop length
*
* @note This is currently unused.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class InputIter>
inline void resize_each(int m, InputIter begin, InputIter end)
{
warn_deprecated("resize_each",
"To be removed after Cantera 2.2.");
for (; begin != end; ++begin) {
begin->resize(m);
}
}
//! The maximum absolute value (templated version)
/*!
* The template arguments are: template<class InputIter>
@ -480,44 +378,6 @@ inline void scatter_mult(InputIter mult_begin, InputIter mult_end,
}
}
//! Divide selected elements in an array by a contiguous sequence of divisors.
/*!
* The template arguments are: template<class InputIter, class OutputIter, class IndexIter>
*
* Example:
* \code
* double divisors[] = {8.9, -2.0, 5.6};
* int index[] = {7, 4, 13};
* vector_fp data(20);
* ...
* // divide elements 7, 4, and 13 in data by divisors[7] divisors[4], and divisors[13]
* // respectively
* scatter_divide(divisors, divisors + 3, data.begin(), index);
* \endcode
*
* @param begin Iterator pointing to the beginning of the source vector, belonging to the
* iterator class InputIter.
* @param end Iterator pointing to the end of the source vector, belonging to the
* iterator class InputIter. The difference between end and begin
* determines the number of inner iterations.
* @param result Iterator pointing to the beginning of the output vector, belonging to the
* iterator class outputIter.
* @param index Iterator pointing to the beginning of the index vector, belonging to the
* iterator class IndexIter.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class InputIter, class OutputIter, class IndexIter>
inline void scatter_divide(InputIter begin, InputIter end,
OutputIter result, IndexIter index)
{
warn_deprecated("scatter_divide",
"To be removed after Cantera 2.2.");
for (; begin != end; ++begin, ++index) {
*(result + *index) /= *begin;
}
}
//! Compute \f[ \sum_k x_k \log x_k. \f].
/*!
* The template arguments are: template<class InputIter>
@ -571,30 +431,6 @@ inline doublereal sum_xlogQ(InputIter1 begin, InputIter1 end,
return sum;
}
//! Scale a templated vector by a constant factor.
/*!
* The template arguments are: template<class OutputIter>
*
* This function is essentially a wrapper around the stl
* function %scale(). The function is has one template
* parameter, OutputIter. OutputIter is a templated iterator
* that points to the vector to be scaled.
*
* @param N Length of the vector
* @param alpha scale factor - double
* @param x Templated Iterator to the start of the vector
* to be scaled.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class OutputIter>
inline void scale(int N, double alpha, OutputIter x)
{
warn_deprecated("scale(int N, double alpha, OutputIter x)",
"To be removed after Cantera 2.2.");
scale(x, x+N, x, alpha);
}
//! Templated evaluation of a polynomial of order 6
/*!
* @param x Value of the independent variable - First template parameter
@ -619,22 +455,6 @@ R poly8(D x, R* c)
c[2])*x + c[1])*x + c[0]);
}
//! Templated evaluation of a polynomial of order 10
/*!
* @param x Value of the independent variable - First template parameter
* @param c Pointer to the polynomial - Second template parameter
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class D, class R>
R poly10(D x, R* c)
{
warn_deprecated("poly10",
"To be removed after Cantera 2.2.");
return ((((((((((c[10]*x + c[9])*x + c[8])*x + c[7])*x
+ c[6])*x + c[5])*x + c[4])*x + c[3])*x
+ c[2])*x + c[1])*x + c[0]);
}
//! Templated evaluation of a polynomial of order 5
/*!
* @param x Value of the independent variable - First template parameter

View file

@ -1,204 +0,0 @@
/**
* @file vec_functions.h
* Templates for operations on vector-like objects.
*/
/*
* Copyright 2001 California Institute of Technology
*/
#ifndef CT_VEC_FUNCTIONS_H
#define CT_VEC_FUNCTIONS_H
#include "ct_defs.h"
#include "utilities.h"
#include <functional>
#include <iostream>
#include <cstring>
namespace Cantera
{
//! Templated function that copies the first n entries from x to y.
/*!
*
*
* The templated type is the type of x and y
*
* @param n Number of elements to copy from x to y
* @param x The object x, of templated type const T&
* @param y The object y, of templated type T&
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline void copyn(size_t n, const T& x, T& y)
{
warn_deprecated("copyn", "To be removed after Cantera 2.2.");
std::copy(x.begin(), x.begin() + n, y.begin());
}
//! 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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline void divide_each(T& x, const T& y)
{
warn_deprecated("divide_each", "To be removed after Cantera 2.2.");
std::transform(x.begin(), x.end(), y.begin(),
x.begin(), std::divides<typename T::value_type>());
}
//! 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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline void multiply_each(T& x, const T& y)
{
warn_deprecated("multiply_each", "To be removed after Cantera 2.2.");
std::transform(x.begin(), x.end(), y.begin(),
x.begin(), std::multiplies<typename T::value_type>());
}
//! 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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T, class S>
inline void scale(T& x, S scale_factor)
{
warn_deprecated("scale", "To be removed after Cantera 2.2.");
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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline doublereal dot_product(const T& x, const T& y)
{
warn_deprecated("dot_product", "To be removed after Cantera 2.2.");
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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline doublereal dot_ratio(const T& x, const T& y)
{
warn_deprecated("dot_ratio", "To be removed after Cantera 2.2.");
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
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline void add_each(T& x, const T& y)
{
warn_deprecated("add_each", "To be removed after Cantera 2.2.");
std::transform(x.begin(), x.end(), y.begin(),
x.begin(), std::plus<typename T::value_type>());
}
//! Templated dot ratio class
/*!
* Calculates the quantity:
*
* S += x[n]/y[n]
*
* The first templated type is the iterator type for x[] and y[].
* The second templated type is the type of S.
*
* @param x_begin InputIter type, indicating the address of the
* first element of x
* @param x_end InputIter type, indicating the address of the
* last element of x
* @param y_begin InputIter type, indicating the address of the
* first element of y
* @param start_value S type, indicating the type of the
* accumulation result.
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class InputIter, class S>
inline doublereal _dot_ratio(InputIter x_begin, InputIter x_end,
InputIter y_begin, S start_value)
{
warn_deprecated("_dot_ratio", "To be removed after Cantera 2.2.");
for (; x_begin != x_end; ++x_begin, ++y_begin) {
start_value += *x_begin / *y_begin;
}
return start_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,
* @deprecated Unused. To be removed after Cantera 2.2.
*/
template<class T>
inline T absmax(const std::vector<T>& v)
{
warn_deprecated("absmax", "To be removed after Cantera 2.2.");
int n = v.size();
T maxval = 0.0;
for (int i = 0; i < n; i++) {
maxval = std::max(std::abs(v[i]), maxval);
}
return maxval;
}
//! Write a vector to a stream
template <class T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
{
size_t n = v.size();
for (size_t i = 0; i < n; i++) {
os << v[i];
if (i != n-1) {
os << ", ";
}
}
return os;
}
}
#endif

View file

@ -335,21 +335,6 @@ public:
return m_temp;
}
//! Set the mixture to a state of chemical equilibrium.
/*!
* @param XY Integer flag specifying properties to hold fixed.
* @param err Error tolerance for \f$\Delta \mu/RT \f$ for all
* reactions. Also used as the relative error tolerance for
* the outer loop.
* @param maxsteps Maximum number of steps to take in solving the fixed
* TP problem.
* @param maxiter Maximum number of "outer" iterations for problems
* holding fixed something other than (T,P).
* @param loglevel Level of diagnostic output
*/
doublereal equilibrate(int XY, doublereal err = 1.0e-9,
int maxsteps = 1000, int maxiter = 200, int loglevel = -99);
//! Equilibrate a MultiPhase object
/*!
* Set this mixture to chemical equilibrium by calling one of Cantera's

View file

@ -362,9 +362,6 @@ public:
//! Returns whether the phase is an ideal solution phase
bool isIdealSoln() const;
//! Returns whether the object is using cantera calls.
bool usingCanteraCalls() const;
//! Return the index of the species that represents the
//! the voltage of the phase
size_t phiVarIndex() const;
@ -744,11 +741,6 @@ private:
*/
std::vector<vcs_SpeciesProperties*> ListSpeciesPtr;
//! If this is true, then calculations are actually performed within
//! Cantera
//! @deprecated Will be implicitly 'true' after Cantera 2.2.
bool m_useCanteraCalls;
/**
* If we are using Cantera, this is the pointer to the ThermoPhase
* object. If not, this is null.

View file

@ -108,110 +108,6 @@ typedef double(*VCS_FUNC_PTR)(double xval, double Vtarget,
int varID, void* fptrPassthrough,
int* err);
//! One dimensional root finder
/*!
* This root finder will find the root of a one dimensional equation
* \f[
* f(x) = 0
* \f]
* where x is a bounded quantity: \f$ x_{min} < x < x_max \f$
*
* The function to be minimized must have the following call structure:
*
* @code
* typedef double (*VCS_FUNC_PTR)(double xval, double Vtarget,
* int varID, void *fptrPassthrough,
* int *err); @endcode
*
* xval is the current value of the x variable. Vtarget is the requested
* value of f(x), usually 0. varID is an integer that is passed through.
* fptrPassthrough is a void pointer that is passed through. err is a return
* error indicator. err = 0 is the norm. anything else is considered a fatal
* error. The return value of the function is the current value of f(xval).
*
* @param xmin Minimum permissible value of the x variable
* @param xmax Maximum permissible value of the x parameter
* @param itmax Maximum number of iterations
* @param func function pointer, pointing to the function to be
* minimized
* @param fptrPassthrough Pointer to void that gets passed through
* the rootfinder, unchanged, to the func.
* @param FuncTargVal Target value of the function. This is usually set
* to zero.
* @param varID Variable ID. This is usually set to zero.
* @param xbest Pointer to the initial value of x on input. On output
* This contains the root value.
* @param printLvl Print level of the routine.
*
* Following is a nontrial example for vcs_root1d() in which the position of a
* cylinder floating on the water is calculated.
*
* @code
* #include <cmath>
* #include <cstdlib>
*
* #include "equil/vcs_internal.h"
*
* const double g_cgs = 980.;
* const double mass_cyl = 0.066;
* const double diam_cyl = 0.048;
* const double rad_cyl = diam_cyl / 2.0;
* const double len_cyl = 5.46;
* const double vol_cyl = Pi * diam_cyl * diam_cyl / 4 * len_cyl;
* const double rho_cyl = mass_cyl / vol_cyl;
* const double rho_gas = 0.0;
* const double rho_liq = 1.0;
* const double sigma = 72.88;
* // Contact angle in radians
* const double alpha1 = 40.0 / 180. * Pi;
*
* double func_vert(double theta1, double h_2, double rho_c) {
* double f_grav = - Pi * rad_cyl * rad_cyl * rho_c * g_cgs;
* double tmp = rad_cyl * rad_cyl * g_cgs;
* double tmp1 = theta1 + sin(theta1) * cos(theta1) - 2.0 * h_2 / rad_cyl * sin(theta1);
* double f_buoy = tmp * (Pi * rho_gas + (rho_liq - rho_gas) * tmp1);
* double f_sten = 2 * sigma * sin(theta1 + alpha1 - Pi);
* return f_grav + f_buoy + f_sten;
* }
* double calc_h2_farfield(double theta1) {
* double rhs = sigma * (1.0 + cos(alpha1 + theta1));
* rhs *= 2.0;
* rhs = rhs / (rho_liq - rho_gas) / g_cgs;
* double sign = -1.0;
* if (alpha1 + theta1 < Pi) sign = 1.0;
* double res = sign * sqrt(rhs);
* return res + rad_cyl * cos(theta1);
* }
* double funcZero(double xval, double Vtarget, int varID, void *fptrPassthrough, int *err) {
* double theta = xval;
* double h2 = calc_h2_farfield(theta);
* return func_vert(theta, h2, rho_cyl);
* }
* int main () {
* double thetamax = Pi;
* double thetamin = 0.0;
* int maxit = 1000;
* int iconv;
* double thetaR = Pi/2.0;
* int printLvl = 4;
*
* iconv = vcsUtil_root1d(thetamin, thetamax, maxit,
* funcZero,
* (void *) 0, 0.0, 0,
* &thetaR, printLvl);
* printf("theta = %g\n", thetaR);
* double h2Final = calc_h2_farfield(thetaR);
* printf("h2Final = %g\n", h2Final);
* return 0;
* }
* @endcode
* @deprecated Unused. To be removed after Cantera 2.2.
*/
int vcsUtil_root1d(double xmin, double xmax, size_t itmax, VCS_FUNC_PTR func,
void* fptrPassthrough,
double FuncTargVal, int varID, double* xbest,
int printLvl = 0);
//! determine the l2 norm of a vector of doubles
/*!
* @param vec vector of doubles
@ -232,16 +128,6 @@ double vcs_l2norm(const std::vector<double> vec);
*/
size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n);
//! Returns the maximum integer in a list
/*!
* @param vector pointer to a vector of ints
* @param length length of the integer vector
*
* @return returns the max integer value in the list
* @deprecated Unused. To be removed after Cantera 2.2.
*/
int vcs_max_int(const int* vector, int length);
//! Returns a const char string representing the type of the
//! species given by the first argument
/*!

View file

@ -1449,40 +1449,6 @@ private:
std::vector<double> m_wx;
public:
//! Calculate the rank of a matrix and return the rows and columns that
//! will generate an independent basis for that rank
/*
* Choose the optimum component species basis for the calculations,
* finding the rank and set of linearly independent rows for that
* calculation. Then find the set of linearly indepedent element columns
* that can support that rank. This is done by taking the transpose of the
* matrix and redoing the same calculation. (there may be a better way to
* do this. I don't know.)
*
* @param[in] awtmp Vector of mole numbers which will be used to
* construct a ranking for how to pick the basis species. This is
* largely ignored here.
* @param[in] numSpecies Number of species. This is the number of rows in
* the matrix.
* @param[in] matrix This is the formula matrix. Nominally, the rows are
* species, while the columns are element compositions. However,
* this routine is totally general, so that the rows and columns
* can be anything.
* @param[in] numElemConstraints Number of element constraints
*
* @param[out] usedZeroedSpecies If true, then a species with a zero
* concentration was used as a component.
* @param[out] compRes Vector of rows which are linearly independent.
* (these are the components)
* @param[out] elemComp Vector of columns which are linearly independent
* (These are the actionable element constraints).
*
* @return Returns number of components. This is the rank of the matrix
* @deprecated To be removed after Cantera 2.2.
*/
int vcs_rank(const double* awtmp, size_t numSpecies, const double* matrix, size_t numElemConstraints,
std::vector<size_t> &compRes, std::vector<size_t> &elemComp, int* const usedZeroedSpecies) const;
//! value of the number of species used to malloc data structures
size_t NSPECIES0;

View file

@ -86,10 +86,6 @@ public:
//! parameter that is used in the VCS_SSVOL_CONSTANT model.
double SSStar_Vol0;
//! If true, this object will call Cantera to do its member calculations.
//! @deprecated Will always behave as if 'true' after Cantera 2.2
bool UseCanteraCalls;
int m_VCS_UnitsFormat;
VCS_SPECIES_THERMO(size_t indexPhase, size_t indexSpeciesPhase);

View file

@ -1,129 +0,0 @@
/**
* @file ElectrodeKinetics.h
*
* @ingroup chemkinetics
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#ifndef CT_ELECTRODEKINETICS_H
#define CT_ELECTRODEKINETICS_H
#include "InterfaceKinetics.h"
namespace Cantera
{
//! A kinetics manager for heterogeneous reaction mechanisms. The
//! reactions are assumed to occur at a 2D interface between two 3D phases.
/*!
* This class is a slight addition to the InterfaceKinetics class, adding
* several concepts. First we explicitly identify the electrode and solution
* phases. We will also assume that there is an electron phase.
*
* @ingroup chemkinetics
* @deprecated Unfinished implementation to be removed after Cantera 2.2.
*/
class ElectrodeKinetics : public InterfaceKinetics
{
public:
//! Constructor
/*!
* @param thermo The optional parameter may be used to initialize
* the object with one ThermoPhase object.
* HKM Note -> Since the interface kinetics
* object will probably require multiple ThermoPhase
* objects, this is probably not a good idea
* to have this parameter.
*/
ElectrodeKinetics(thermo_t* thermo = 0);
/// Destructor.
virtual ~ElectrodeKinetics();
//! Copy Constructor
ElectrodeKinetics(const ElectrodeKinetics& right);
//! Assignment operator
ElectrodeKinetics& operator=(const ElectrodeKinetics& right);
//! Duplication function
/*!
* @param tpVector Vector of ThermoPhase pointers. These are shallow pointers to the
* ThermoPhase objects that will comprise the phases for the new object.
*
* @return Returns the duplicated object as the base class Kinetics object.
*/
virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
virtual int type() const;
//! Identify the metal phase and the electrons species
/*!
* We fill in the internal variables, metalPhaseIndex_ and kElectronIndex_ here
*/
void identifyMetalPhase();
//! Internal routine that updates the Rates of Progress of the reactions
/*!
* This is actually the guts of the functionality of the object
*/
virtual void updateROP();
double calcForwardROP_BV(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu, doublereal ioNet);
double calcForwardROP_BV_NoAct(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu, doublereal ioNet);
bool getExchangeCurrentDensityFormulation(size_t irxn, doublereal& nStoich, doublereal& OCV, doublereal& io,
doublereal& overPotential, doublereal& beta, doublereal& resistance);
//! Calculate the open circuit voltage of a given reaction
/*!
* If the reaction has no electron transport, then return 0.0
*
* @param irxn Reaction id
*/
double openCircuitVoltage(size_t irxn);
double calcCurrentDensity(double nu, double nStoich, double io, double beta, double temp, doublereal resistivity = 0.0) const;
double solveCurrentRes(doublereal nu, doublereal nStoich, doublereal ioc, doublereal beta, doublereal temp,
doublereal resistivity = 0.0, int iprob = 0) const;
//! Prepare the class for the addition of reactions
/*!
* (virtual from Kinetics)
* We determine the metal phase and solution phase here
*/
virtual void init();
virtual void finalize();
//! Vector of additional information about each reaction
/*!
* This vector contains information about the phase mole change for each reaction,
* for example.
*/
std::vector<RxnMolChange*> rmcVector;
protected:
//! Index of the metal phase in the list of phases for this kinetics object. This is the electron phase.
size_t metalPhaseIndex_;
//! Index of the solution phase in the list of phases for this surface
size_t solnPhaseIndex_;
//! Index of the electrons species in the list of species for this surface kinetics, if none set it to -1
size_t kElectronIndex_;
};
}
#endif

View file

@ -1,121 +0,0 @@
/**
* @file ReactingVolDomain.h
*
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#ifndef EXTRAGLOBALRXN_H
#define EXTRAGLOBALRXN_H
#include "cantera/kinetics/InterfaceKinetics.h"
#include <string>
#include <vector>
namespace Cantera
{
//! Class describing an extra global reaction, which is defined as
//! a linear combination of actuals reactions, global or mass-action, creating a global stoichiometric result
/*!
* This is useful for defining thermodynamics of global processes that occur
* on a surface or in a homogeneous phase.
*
* The class is set up via the function setupElemRxnVector(RxnVector, specialSpecies) which defines
* the vector of stoichiometric coefficients representing the base reaction to combine in order to
* achieve the global result that's to be calculated. specialSpecies is the index of the species
* within the kinetics object that is used to identify the global reaction. Rates of progress
* are defined in terms of the production rate of the special species.
*
* @deprecated Unfinished implementation to be removed after Cantera 2.2.
*/
class ExtraGlobalRxn
{
public:
//! Constructor takes a default kinetics pointer
/*!
* @param[in] k_ptr Pointer to a Kinetics class that will be used as the basis
* for constructing this class.
*/
ExtraGlobalRxn(Kinetics* k_ptr);
//! Destructor
virtual ~ExtraGlobalRxn() {}
void setupElemRxnVector(double* RxnVector,
int specialSpecies = -1);
std::string reactionString();
double deltaSpecValue(double* speciesVectorProperty);
std::vector<int>& reactants();
std::vector<int>& products();
bool isReversible();
double ROPValue(double* ROPKinVector);
double FwdROPValue(double* FwdROPElemKinVector, double* RevROPElemKinVector);
double RevROPValue(double* FwdROPElemKinVector, double* RevROPElemKinVector);
double reactantStoichCoeff(int kKin);
double productStoichCoeff(int kKin);
bool m_ThisIsASurfaceRxn;
double deltaRxnVecValue(double* rxnVectorProperty);
//! This kinetics operator is associated with just one
//! homogeneous phase, associated with tpList[0] phase
/*!
* Kinetics object pointer
*/
Kinetics* m_kinetics;
//! This kinetics operator is associated with multiple
//! homogeneous and surface phases.
/*!
* This object owns the Kinetics object
*/
InterfaceKinetics* m_InterfaceKinetics;
int m_nKinSpecies;
//! Number of reactants in the global reaction
int m_nReactants;
//! Vector of reactants that make up the global reaction
/*!
* This is a list of reactants using the kinetic species index
*/
std::vector<int> m_Reactants;
//! Vector of reactant stoichiometries that make up the global reaction
/*!
* This is a list of reactant stoichiometries. The species index is given in
* the member m_Reactants using the kinetic species index.
*/
std::vector<doublereal> m_ReactantStoich;
int m_nProducts;
std::vector<int> m_Products;
std::vector<doublereal> m_ProductStoich;
int m_nNetSpecies;
std::vector<int> m_NetSpecies;
std::vector<doublereal> m_netStoich;
int m_nRxns;
std::vector<doublereal> m_ElemRxnVector;
int m_SpecialSpecies;
bool m_SpecialSpeciesProduct;
int m_SS_index;
int iphaseKin;
bool m_ok;
bool m_reversible;
};
}
#endif

View file

@ -10,7 +10,6 @@
#include "cantera/thermo/mix_defs.h"
#include "Kinetics.h"
#include "cantera/kinetics/RxnMolChange.h"
#include "Reaction.h"
#include "cantera/base/utilities.h"
#include "RateCoeffMgr.h"
@ -21,34 +20,6 @@ namespace Cantera
// forward declarations
class SurfPhase;
class ImplicitSurfChem;
class RxnMolChange;
//! forward orders
//! @deprecated Incomplete implementation to be removed after Cantera 2.2.
class RxnOrders {
public:
//! constructors
RxnOrders() {}
RxnOrders(const RxnOrders &right);
~RxnOrders() {}
RxnOrders& operator=(const RxnOrders &right);
//! Fill in the structure with the array.
/*!
* @param[in] Size of length kinetic species. The entries the values of the orders
*/
int fill(const vector_fp& fullForwardOrders);
//! ID's of the kinetic species
std::vector<size_t> kinSpeciesIDs_;
//! Orders of the kinetic species
vector_fp kinSpeciesOrders_;
};
//! A kinetics manager for heterogeneous reaction mechanisms. The
//! reactions are assumed to occur at a 2D interface between two 3D phases.
@ -568,25 +539,6 @@ protected:
*/
vector_int m_ctrxn_ecdf;
//! Vector of booleans indicating whether the charge transfer reaction rate constant
//! is described by an exchange current density rate constant expression
/*!
* Length is equal to the number of reactions with charge transfer coefficients, m_ctrxn[]
*
* Some reactions have zero in this list, those that don't need special treatment.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<RxnOrders*> m_ctrxn_ROPOrdersList_;
//! Reaction Orders for the case where the forwards rate of progress is being calculated.
/*!
* Length is equal to the number of reactions with charge transfer coefficients, m_ctrxn[]
*
* Some reactions have zero in this list, indicating that the calculation isn't necessary.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<RxnOrders*> m_ctrxn_FwdOrdersList_;
vector_fp m_ctrxn_resistivity_;
//! Vector of standard concentrations

View file

@ -648,32 +648,6 @@ public:
throw NotImplementedError("Kinetics::getActivityConcentrations");
}
/**
* Returns a read-only reference to the vector of reactant
* index numbers for reaction i.
*
* @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/
virtual const std::vector<size_t>& reactants(size_t i) const {
warn_deprecated("Kinetics::reactants",
"To be removed after Cantera 2.2.");
return m_reactants[i];
}
/**
* Returns a read-only reference to the vector of product
* index numbers for reaction i.
*
* @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/
virtual const std::vector<size_t>& products(size_t i) const {
warn_deprecated("Kinetics::products",
"To be removed after Cantera 2.2.");
return m_products[i];
}
/**
* Flag specifying the type of reaction. The legal values and
* their meaning are specific to the particular kinetics
@ -969,34 +943,6 @@ protected:
//! Vector of Reaction objects represented by this Kinetics manager
std::vector<shared_ptr<Reaction> > m_reactions;
/**
* This is a vector of vectors containing the reactants for
* each reaction. The outer vector is over the number of
* reactions, m_ii. The inner vector is a list of species
* indices. If the stoichiometric coefficient for a reactant
* is greater than one, then the reactant is listed
* contiguously in the vector a number of times equal to its
* stoichiometric coefficient.
* NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<std::vector<size_t> > m_reactants;
/**
* This is a vector of vectors containing the products for
* each reaction. The outer vector is over the number of
* reactions, m_ii. The inner vector is a list of species
* indices. If the stoichiometric coefficient for a product is
* greater than one, then the reactant is listed contiguously
* in the vector a number of times equal to its stoichiometric
* coefficient.
* NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<std::vector<size_t> > m_products;
//! m_rrxn is a vector of maps, containing the reactant
//! stoichiometric coefficient information
/*!

View file

@ -1,118 +0,0 @@
/**
* @file RxnMolChange.cpp
*
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#ifndef RXNMOLCHANGE_H
#define RXNMOLCHANGE_H
#include <vector>
namespace Cantera
{
class ExtraGlobalRxn;
class Kinetics;
//! Class that includes some bookeeping entries for a reaction or a global reaction defined on a surface
/*!
* Note that all indexes refer to a specific interfacial or homogeneous kinetics object. It does not
* refer to the Phase list indexes.
* @deprecated Unfinished implementation to be removed after Cantera 2.2.
*/
class RxnMolChange
{
public:
//! Main constructor for the class
/*!
* @param kinPtr Pointer to the kinetics base class
* @param irxn Specific reaction index.
*/
RxnMolChange(Kinetics* kinPtr, int irxn);
//! Destructor
~RxnMolChange() {}
//! Constructor for the object if the object refers to a global reaction
/*!
* @param kinPtr Pointer to the kinetics base class
* @param egr Specific reaction index.
*/
RxnMolChange(Kinetics* kinPtr, ExtraGlobalRxn* egr);
//! Vector of mole changes for each phase in the Kinetics object due to the current reaction
/*!
* This is the sum of the product stoichiometric coefficient minum the reactant stoichioemtric coefficient
* for all the species in a phase.
* The index is over all the phases listed in the Kinetics object.
*/
std::vector<double> m_phaseMoleChange;
std::vector<double> m_phaseReactantMoles;
std::vector<double> m_phaseProductMoles;
//! Vector of mass changes for each phase in the Kinetics object due to the current reaction
/*!
* This is the sum of the product stoichiometric coefficient minum the reactant stoichioemtric coefficient
* index multiplied by the molecular weight for all species in a phase.
* The index is over all of the phases listed in the Kinetics object.
*/
std::vector<double> m_phaseMassChange;
//! Vector of mass changes for each phase in the Kinetics object due to the current reaction
/*!
* This is the sum of the product stoichiometric coefficient minum the reactant stoichioemtric coefficient
* index multiplied by the charg for all species in a phase.
* The index is over all of the phases listed in the Kinetics object.
*/
std::vector<double> m_phaseChargeChange;
//! Vector of phase types in the reaction
/*!
* Collection of eosTypes for all phases in the kinetics object
* The index is over all of the phases listed in the Kinetics object.
*/
std::vector<int> m_phaseTypes;
//! Vector of phase dimensions for the reaction
/*!
* Collection of nDims for all phases in the kinetics object
* The index is over all of the phases listed in the Kinetics object.
*/
std::vector<int> m_phaseDims;
//! Number of phases in the kientics object
int m_nPhases;
//! Shallow pointer pointing to the kinetics object
Kinetics* m_kinBase;
//! Reaction number within the kinetics object
/*!
* If this is neg 1, then this reaction refers to a global reaction
* specified by the m_egr pointer.
*/
int m_iRxn;
//! Maximum change in charge of any phase due to this reaction
double m_ChargeTransferInRxn;
//! Electrochemical beta parameter for the reaction
double m_beta;
//! Pointer to the specification of the global reaction
/*!
* This is 0, if the class refers to a single reaction in the kinetics object
*/
ExtraGlobalRxn* m_egr;
};
}
#endif

View file

@ -55,19 +55,6 @@ public:
void update_C(const doublereal* c) {
}
/**
* Update the value of the logarithm of the rate constant.
*
* Note, this function should never be called for negative A values.
* If it does then it will produce a negative overflow result, and
* a zero net forwards reaction rate, instead of a negative reaction
* rate constant that is the expected result.
* @deprecated. To be removed after Cantera 2.2
*/
doublereal update(doublereal logT, doublereal recipT) const {
return m_logA + m_b*logT - m_E*recipT;
}
/**
* Update the value of the natural logarithm of the rate constant.
*/
@ -86,18 +73,6 @@ public:
return m_A * std::exp(m_b*logT - m_E*recipT);
}
//! @deprecated. To be removed after Cantera 2.2
void writeUpdateRHS(std::ostream& s) const {
s << " exp(" << m_logA;
if (m_b != 0.0) {
s << " + " << m_b << " * tlog";
}
if (m_E != 0.0) {
s << " - " << m_E << " * rt";
}
s << ");" << std::endl;
}
//! Return the pre-exponential factor *A* (in m, kmol, s to powers depending
//! on the reaction order)
double preExponentialFactor() const {
@ -115,11 +90,6 @@ public:
return m_E;
}
//! @deprecated. To be removed after Cantera 2.2
static bool alwaysComputeRate() {
return false;
}
protected:
doublereal m_logA, m_b, m_E, m_A;
};
@ -177,18 +147,6 @@ public:
}
}
/**
* Update the value of the logarithm of the rate constant.
*
* This calculation is not safe for negative values of
* the preexponential.
* @deprecated. To be removed after Cantera 2.2
*/
doublereal update(doublereal logT, doublereal recipT) const {
return m_logA + m_acov + m_b*logT
- (m_E + m_ecov)*recipT + m_mcov;
}
/**
* Update the value the rate constant.
*
@ -205,11 +163,6 @@ public:
return m_E + m_ecov;
}
//! @deprecated. To be removed after Cantera 2.2
static bool alwaysComputeRate() {
return true;
}
protected:
doublereal m_logA, m_b, m_E, m_A;
doublereal m_acov, m_ecov, m_mcov;
@ -262,14 +215,6 @@ public:
rDeltaP_ = 1.0 / (logP2_ - logP1_);
}
/**
* Update the value of the logarithm of the rate constant.
* @deprecated. To be removed after Cantera 2.2
*/
doublereal update(doublereal logT, doublereal recipT) const {
return std::log(updateRC(logT, recipT));
}
/**
* Update the value the rate constant.
*
@ -300,16 +245,6 @@ public:
return std::exp(log_k1 + (log_k2-log_k1) * (logP_-logP1_) * rDeltaP_);
}
//! @deprecated. To be removed after Cantera 2.2
doublereal activationEnergy_R() const {
throw CanteraError("Plog::activationEnergy_R", "Not implemented");
}
//! @deprecated. To be removed after Cantera 2.2
static bool alwaysComputeRate() {
return false;
}
//! Check to make sure that the rate expression is finite over a range of
//! temperatures at each interpolation pressure. This is potentially an
//! issue when one of the Arrhenius expressions at a particular pressure
@ -386,14 +321,6 @@ public:
}
}
/**
* Update the value of the base-10 logarithm of the rate constant.
* @deprecated. To be removed after Cantera 2.2
*/
doublereal update(doublereal logT, doublereal recipT) const {
return std::log10(updateRC(logT, recipT));
}
/**
* Update the value the rate constant.
*
@ -414,16 +341,6 @@ public:
return std::pow(10, logk);
}
//! @deprecated. To be removed after Cantera 2.2
doublereal activationEnergy_R() const {
return 0.0;
}
//! @deprecated. To be removed after Cantera 2.2
static bool alwaysComputeRate() {
return false;
}
//! Minimum valid temperature [K]
double Tmin() const {
return Tmin_;

View file

@ -135,12 +135,6 @@ static doublereal ppow(doublereal x, doublereal order)
}
}
//! @deprecated To be removed after Cantera 2.2
inline static std::string fmt(const std::string& r, size_t n)
{
return r + "[" + int2str(n) + "]";
}
/**
* Handles one species in a reaction.
* See @ref Stoichiometry
@ -191,31 +185,6 @@ public:
return 1;
}
//! @deprecated To be removed after Cantera 2.2
void writeMultiply(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] = fmt(r, m_ic0);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " + "+fmt(r, m_ic0);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " - "+fmt(r, m_ic0);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
out[m_ic0] += " + "+fmt(r, m_rxn);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
out[m_ic0] += " - "+fmt(r, m_rxn);
}
private:
//! Reaction number
size_t m_rxn;
@ -273,35 +242,6 @@ public:
return 2;
}
//! @deprecated To be removed after Cantera 2.2
void writeMultiply(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = " + "+fmt(r, m_rxn);
out[m_ic0] += s;
out[m_ic1] += s;
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = " - "+fmt(r, m_rxn);
out[m_ic0] += s;
out[m_ic1] += s;
}
private:
//! Reaction index -> index into the ROP vector
size_t m_rxn;
@ -363,36 +303,6 @@ public:
return 3;
}
//! @deprecated To be removed after Cantera 2.2
void writeMultiply(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1) + " * " + fmt(r, m_ic2);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1)+" + "+fmt(r, m_ic2);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1)+" - "+fmt(r, m_ic2);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = " + "+fmt(r, m_rxn);
out[m_ic0] += s;
out[m_ic1] += s;
out[m_ic2] += s;
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = " - "+fmt(r, m_rxn);
out[m_ic0] += s;
out[m_ic1] += s;
out[m_ic2] += s;
}
private:
size_t m_rxn;
size_t m_ic0;
@ -484,51 +394,6 @@ public:
-= m_stoich[n]*input[m_ic[n]];
}
//! @deprecated To be removed after Cantera 2.2
void writeMultiply(const std::string& r, std::map<size_t, std::string>& out) {
out[m_rxn] = "";
for (size_t n = 0; n < m_n; n++) {
if (m_order[n] == 1.0) {
out[m_rxn] += fmt(r, m_ic[n]);
} else {
out[m_rxn] += "pow("+fmt(r, m_ic[n])+","+fp2str(m_order[n])+")";
}
if (n < m_n-1) {
out[m_rxn] += " * ";
}
}
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
for (size_t n = 0; n < m_n; n++) {
out[m_rxn] += " + "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]);
}
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
for (size_t n = 0; n < m_n; n++) {
out[m_rxn] += " - "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]);
}
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = fmt(r, m_rxn);
for (size_t n = 0; n < m_n; n++) {
out[m_ic[n]] += " + "+fp2str(m_stoich[n]) + "*" + s;
}
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
std::string s = fmt(r, m_rxn);
for (size_t n = 0; n < m_n; n++) {
out[m_ic[n]] += " - "+fp2str(m_stoich[n]) + "*" + s;
}
}
private:
//! Length of the m_ic vector
@ -616,56 +481,6 @@ inline static void _decrementReactions(InputIter begin,
}
}
//! @deprecated To be removed after Cantera 2.2
template<class InputIter>
inline static void _writeIncrementSpecies(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeIncrementSpecies(r, out);
}
}
//! @deprecated To be removed after Cantera 2.2
template<class InputIter>
inline static void _writeDecrementSpecies(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeDecrementSpecies(r, out);
}
}
//! @deprecated To be removed after Cantera 2.2
template<class InputIter>
inline static void _writeIncrementReaction(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeIncrementReaction(r, out);
}
}
//! @deprecated To be removed after Cantera 2.2
template<class InputIter>
inline static void _writeDecrementReaction(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeDecrementReaction(r, out);
}
}
//! @deprecated To be removed after Cantera 2.2
template<class InputIter>
inline static void _writeMultiply(InputIter begin, InputIter end,
const std::string& r, std::map<size_t, std::string>& out)
{
for (; begin != end; ++begin) {
begin->writeMultiply(r, out);
}
}
/*
* This class handles operations involving the stoichiometric
* coefficients on one side of a reaction (reactant or product) for
@ -840,46 +655,6 @@ public:
_decrementReactions(m_cn_list.begin(), m_cn_list.end(), input, output);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
_writeIncrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out);
_writeIncrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out);
_writeIncrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out);
_writeIncrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementSpecies(const std::string& r, std::map<size_t, std::string>& out) {
_writeDecrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out);
_writeDecrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out);
_writeDecrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out);
_writeDecrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out);
}
//! @deprecated To be removed after Cantera 2.2
void writeIncrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
_writeIncrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out);
_writeIncrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out);
_writeIncrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out);
_writeIncrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out);
}
//! @deprecated To be removed after Cantera 2.2
void writeDecrementReaction(const std::string& r, std::map<size_t, std::string>& out) {
_writeDecrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out);
_writeDecrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out);
_writeDecrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out);
_writeDecrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out);
}
//! @deprecated To be removed after Cantera 2.2
void writeMultiply(const std::string& r, std::map<size_t, std::string>& out) {
_writeMultiply(m_c1_list.begin(), m_c1_list.end(), r, out);
_writeMultiply(m_c2_list.begin(), m_c2_list.end(), r, out);
_writeMultiply(m_c3_list.begin(), m_c3_list.end(), r, out);
_writeMultiply(m_cn_list.begin(), m_cn_list.end(), r, out);
}
private:
std::vector<C1> m_c1_list;
std::vector<C2> m_c2_list;

View file

@ -19,16 +19,6 @@
namespace Cantera
{
//! Rules for parsing and installing reactions
//! @deprecated Unused. To be removed after Cantera 2.2.
struct ReactionRules {
ReactionRules();
bool skipUndeclaredSpecies;
bool skipUndeclaredThirdBodies;
bool allowNegativeA;
};
//! Install information about reactions into the kinetics object, kin.
/*!
* At this point, parent usually refers to the phase XML element.

View file

@ -11,7 +11,6 @@ int xml_get_XML_File(const char* file, int debug);
int xml_del(int i);
int xml_clear();
int xml_copy(int i);
int xml_assign(int i, int j);
int xml_build(int i, const char* file);
int xml_preprocess_and_build(int i, const char* file, int debug);
int xml_attrib(int i, const char* key, char* value);

View file

@ -1,578 +0,0 @@
/**
* @file BEulerInt.h
*/
/*
* Copyright 2004 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
* See file License.txt for licensing information.
*/
#ifndef CT_BEULERINT_H
#define CT_BEULERINT_H
#include "cantera/numerics/Integrator.h"
#include "cantera/numerics/ResidJacEval.h"
#include "cantera/numerics/GeneralMatrix.h"
#define OPT_SIZE 10
#define SUCCESS 0
#define FAILURE 1
#define STEADY 0
#define TRANSIENT 1
namespace Cantera
{
enum BEulerMethodType {
BEulerFixedStep,
BEulerVarStep
};
/**
* Exception class thrown when a BEuler error is encountered.
*/
class BEulerErr : public CanteraError
{
public:
/**
* Exception thrown when a BEuler error is encountered. We just call the
* Cantera Error handler in the initialization list.
*/
explicit BEulerErr(const std::string& msg);
};
#define BEULER_JAC_ANAL 2
#define BEULER_JAC_NUM 1
/*!
* Wrapper class for 'beuler' integrator
* We derive the class from the class Integrator
* @deprecated Unused. To be removed after Cantera 2.2.
*/
class BEulerInt : public Integrator
{
public:
/*!
* Constructor. Default settings: dense Jacobian, no user-supplied
* Jacobian function, Newton iteration.
*/
BEulerInt();
virtual ~BEulerInt();
virtual void setTolerances(double reltol, size_t n, double* abstol);
virtual void setTolerances(double reltol, double abstol);
virtual void setProblemType(int probtype);
//! Find the initial conditions for y and ydot.
virtual void initializeRJE(double t0, ResidJacEval& func);
virtual void reinitializeRJE(double t0, ResidJacEval& func);
virtual double integrateRJE(double tout, double tinit = 0.0);
// This routine advances the calculations one step using a predictor
// corrector approach. We use an implicit algorithm here.
virtual doublereal step(double tout);
//! Set the solution weights. This is a very important routine as it affects
//! quite a few operations involving convergence.
virtual void setSolnWeights();
virtual double& solution(size_t k) {
return m_y_n[k];
}
double* solution() {
return &m_y_n[0];
}
int nEquations() const {
return m_neq;
}
//! Return the total number of function evaluations
virtual int nEvals() const;
virtual void setMethodBEMT(BEulerMethodType t);
virtual void setIterator(IterType t);
virtual void setMaxStep(double hmax);
virtual void setMaxNumTimeSteps(int);
virtual void setNumInitialConstantDeltaTSteps(int);
void print_solnDelta_norm_contrib(const double* const soln0,
const char* const s0,
const double* const soln1,
const char* const s1,
const char* const title,
const double* const y0,
const double* const y1,
double damp,
int num_entries);
//! This routine controls when the solution is printed
/*!
* @param printSolnStepInterval If greater than 0, then the soln is
* printed every printSolnStepInterval steps.
* @param printSolnNumberToTout The solution is printed at regular
* invervals a total of "printSolnNumberToTout" times.
* @param printSolnFirstSteps The solution is printed out the first
* "printSolnFirstSteps" steps. After these steps the
* other parameters determine the printing. default = 0
* @param dumpJacobians Dump Jacobians to disk.
*/
virtual void setPrintSolnOptions(int printSolnStepInterval,
int printSolnNumberToTout,
int printSolnFirstSteps = 0,
bool dumpJacobians = false);
//! Set the options for the nonlinear method
/*!
* Defaults are set in the .h file. These are the defaults:
* min_newt_its = 0
* matrixConditioning = false
* colScaling = false
* rowScaling = true
*/
void setNonLinOptions(int min_newt_its = 0,
bool matrixConditioning = false,
bool colScaling = false,
bool rowScaling = true);
virtual void setPrintFlag(int print_flag);
//! Set the column scaling vector at the current time
virtual void setColumnScales();
/**
* Calculate the solution error norm. if printLargest is true, then a table
* of the largest values is printed to standard output.
*/
virtual double soln_error_norm(const double* const,
bool printLargest = false);
virtual void setInitialTimeStep(double delta_t);
/*!
* Function called by to evaluate the Jacobian matrix and the current
* residual at the current time step.
* @param J = Jacobian matrix to be filled in
* @param f = Right hand side. This routine returns the current
* value of the RHS (output), so that it does
* not have to be computed again.
*/
void beuler_jac(GeneralMatrix& J, double* const f,
double, double, double* const, double* const, int);
protected:
//! Internal routine that sets up the fixed length storage based on
//! the size of the problem to solve.
void internalMalloc();
/*!
* Function to calculate the predicted solution vector, m_y_pred_n for the
* (n+1)th time step. This routine can be used by a first order - forward
* Euler / backward Euler predictor / corrector method or for a second order
* Adams-Bashforth / Trapezoidal Rule predictor / corrector method. See
* Nachos documentation Sand86-1816 and Gresho, Lee, Sani LLNL report UCRL -
* 83282 for more information.
*
* on input:
*
* N - number of unknowns
* order - indicates order of method
* = 1 -> first order forward Euler/backward Euler
* predictor/corrector
* = 2 -> second order Adams-Bashforth/Trapezoidal Rule
* predictor/corrector
*
* delta_t_n - magnitude of time step at time n (i.e., = t_n+1 - t_n)
* delta_t_nm1 - magnitude of time step at time n - 1 (i.e., = t_n - t_n-1)
* y_n[] - solution vector at time n
* y_dot_n[] - acceleration vector from the predictor at time n
* y_dot_nm1[] - acceleration vector from the predictor at time n - 1
*
* on output:
*
* m_y_pred_n[] - predicted solution vector at time n + 1
*/
void calc_y_pred(int);
/*!
* Function to calculate the acceleration vector ydot for the first or
* second order predictor/corrector time integrator. This routine can be
* called by a first order - forward Euler / backward Euler predictor /
* corrector or for a second order Adams - Bashforth / Trapezoidal Rule
* predictor / corrector. See Nachos documentation Sand86-1816 and Gresho,
* Lee, Sani LLNL report UCRL - 83282 for more information.
*
* on input:
*
* N - number of local unknowns on the processor
* This is equal to internal plus border unknowns.
* order - indicates order of method
* = 1 -> first order forward Euler/backward Euler
* predictor/corrector
* = 2 -> second order Adams-Bashforth/Trapezoidal Rule
* predictor/corrector
*
* delta_t_n - Magnitude of the current time step at time n
* (i.e., = t_n - t_n-1)
* y_curr[] - Current Solution vector at time n
* y_nm1[] - Solution vector at time n-1
* ydot_nm1[] - Acceleration vector at time n-1
*
* on output:
*
* ydot_curr[] - Current acceleration vector at time n
*
* Note we use the current attribute to denote the possibility that
* y_curr[] may not be equal to m_y_n[] during the nonlinear solve
* because we may be using a look-ahead scheme.
*/
void calc_ydot(int, double*, double*);
/*!
* Calculates the time step truncation error estimate from a very simple
* formula based on Gresho et al. This routine can be called for a first
* order - forward Euler/backward Euler predictor/ corrector and for a
* second order Adams- Bashforth/Trapezoidal Rule predictor/corrector. See
* Nachos documentation Sand86-1816 and Gresho, Lee, LLNL report UCRL -
* 83282 for more information.
*
* on input:
*
* abs_error - Generic absolute error tolerance
* rel_error - Generic relative error tolerance
* x_coor[] - Solution vector from the implicit corrector
* x_pred_n[] - Solution vector from the explicit predictor
*
* on output:
*
* delta_t_n - Magnitude of next time step at time t_n+1
* delta_t_nm1 - Magnitude of previous time step at time t_n
*/
double time_error_norm();
/*!
* Time step control function for the selection of the time step size based on
* a desired accuracy of time integration and on an estimate of the relative
* error of the time integration process. This routine can be called for a
* first order - forward Euler/backward Euler predictor/ corrector and for a
* second order Adams- Bashforth/Trapezoidal Rule predictor/corrector. See
* Nachos documentation Sand86-1816 and Gresho, Lee, Sani LLNL report UCRL -
* 83282 for more information.
*
* on input:
*
* order - indicates order of method
* = 1 -> first order forward Euler/backward Euler
* predictor/corrector
* = 2 -> second order forward Adams-Bashforth/Trapezoidal
* rule predictor/corrector
*
* delta_t_n - Magnitude of time step at time t_n
* delta_t_nm1 - Magnitude of time step at time t_n-1
* rel_error - Generic relative error tolerance
* time_error_factor - Estimated value of the time step truncation error
* factor. This value is a ratio of the computed
* error norms. The premultiplying constants
* and the power are not yet applied to normalize the
* predictor/corrector ratio. (see output value)
*
* on output:
*
* return - delta_t for the next time step
* If delta_t is negative, then the current time step is
* rejected because the time-step truncation error is
* too large. The return value will contain the negative
* of the recommended next time step.
*
* time_error_factor - This output value is normalized so that
* values greater than one indicate the current time
* integration error is greater than the user
* specified magnitude.
*/
double time_step_control(int m_order, double time_error_factor);
//! Solve a nonlinear system
/*!
* Find the solution to F(X, xprime) = 0 by damped Newton iteration. On
* entry, y_comm[] contains an initial estimate of the solution and
* ydot_comm[] contains an estimate of the derivative.
* On successful return, y_comm[] contains the converged solution
* and ydot_comm[] contains the derivative
*
* @param y_comm[] Contains the input solution. On output y_comm[] contains
* the converged solution
* @param ydot_comm Contains the input derivative solution. On output
* y_comm[] contains the converged derivative solution
* @param CJ Inverse of the time step
* @param time_curr Current value of the time
* @param jac Jacobian
* @param num_newt_its number of Newton iterations
* @param num_linear_solves number of linear solves
* @param num_backtracks number of backtracs
* @param loglevel Log level
*/
int solve_nonlinear_problem(double* const y_comm,
double* const ydot_comm, double CJ,
double time_curr,
GeneralMatrix& jac,
int& num_newt_its,
int& num_linear_solves,
int& num_backtracks,
int loglevel);
/**
* Compute the undamped Newton step. The residual function is
* evaluated at the current time, t_n, at the current values of the
* solution vector, m_y_n, and the solution time derivative, m_ydot_n,
* but the Jacobian is not recomputed.
*/
void doNewtonSolve(double, double*, double*, double*,
GeneralMatrix&, int);
//! Bound the Newton step while relaxing the solution
/*!
* Return the factor by which the undamped Newton step 'step0'
* must be multiplied in order to keep all solution components in
* all domains between their specified lower and upper bounds.
* Other bounds may be applied here as well.
*
* Currently the bounds are hard coded into this routine:
*
* Minimum value for all variables: - 0.01 * m_ewt[i]
* Maximum value = none.
*
* Thus, this means that all solution components are expected
* to be numerical greater than zero in the limit of time step
* truncation errors going to zero.
*
* Delta bounds: The idea behind these is that the Jacobian
* couldn't possibly be representative if the
* variable is changed by a lot. (true for
* nonlinear systems, false for linear systems)
* Maximum increase in variable in any one Newton iteration: factor of 2
* Maximum decrease in variable in any one Newton iteration: factor of 5
*
* @param y Current value of the solution
* @param step0 Current raw step change in y[]
* @param loglevel Log level. This routine produces output if loglevel
* is greater than one
*
* @return Returns the damping coefficient
*/
double boundStep(const double* const y, const double* const step0, int loglevel);
/*!
* On entry, step0 must contain an undamped Newton step for the
* solution x0. This method attempts to find a damping coefficient
* such that the next undamped step would have a norm smaller than
* that of step0. If successful, the new solution after taking the
* damped step is returned in y1, and the undamped step at y1 is
* returned in step1.
*/
int dampStep(double, const double*, const double*,
const double*, double*, double*,
double*, double&, GeneralMatrix&, int&, bool, int&);
//! Compute Residual Weights
void computeResidWts(GeneralMatrix& jac);
//! Filter a new step
double filterNewStep(double, double*, double*);
//! Get the next time to print out
double getPrintTime(double time_current);
/********************** Member data ***************************/
/*********************
* METHOD FLAGS
*********************/
//! IterType is used to specify how the nonlinear equations are
//! to be relaxed at each time step.
IterType m_iter;
/**
* MethodType is used to specify how the time step is to be
* chosen. Currently, there are two choices, one is a fixed
* step method while the other is based on a predictor-corrector
* algorithm and a time-step truncation error tolerance.
*/
BEulerMethodType m_method;
/**
* m_jacFormMethod determines how a matrix is formed.
*/
int m_jacFormMethod;
/**
* m_rowScaling is a boolean. If true then row sum scaling
* of the Jacobian matrix is carried out when solving the
* linear systems.
*/
bool m_rowScaling;
/**
* m_colScaling is a boolean. If true, then column scaling
* is performed on each solution of the linear system.
*/
bool m_colScaling;
/**
* m_matrixConditioning is a boolean. If true, then the
* Jacobian and every RHS is multiplied by the inverse
* of a matrix that is suppose to reduce the condition
* number of the matrix. This is done before row scaling.
*/
bool m_matrixConditioning;
/**
* If m_itol =1 then each component has an individual
* value of atol. If m_itol = 0, the all atols are equal.
*/
int m_itol;
//! Relative time truncation error tolerances
double m_reltol;
/**
* Absolute time truncation error tolerances, when uniform
* for all variables.
*/
double m_abstols;
/**
* Vector of absolute time truncation error tolerance
* when not uniform for all variables.
*/
vector_fp m_abstol;
//! Error Weights. This is a surprisingly important quantity.
vector_fp m_ewt;
//! Maximum step size
double m_hmax;
//! Maximum integration order
int m_maxord;
//! Current integration order
int m_order;
//! Time step number
int m_time_step_num;
int m_time_step_attempts;
//! Max time steps allowed
int m_max_time_step_attempts;
/**
* Number of initial time steps to take where the time truncation error
* tolerances are not checked. Instead the delta T is uniform
*/
int m_numInitialConstantDeltaTSteps;
//! Failure Counter -> keeps track of the number of consecutive failures
int m_failure_counter;
//! Minimum Number of Newton Iterations per nonlinear step. default = 0
int m_min_newt_its;
/************************
* PRINTING OPTIONS
************************/
/**
* Step Interval at which to print out the solution
* default = 1;
* If set to zero, there is no printout
*/
int m_printSolnStepInterval;
/**
* Number of evenly spaced printouts of the solution
* If zero, there is no printout from this option
* default 1
* If set to zero there is no printout.
*/
int m_printSolnNumberToTout;
//! Number of initial steps that the solution is printed out. default = 0
int m_printSolnFirstSteps;
//! Dump Jacobians to disk. default false
bool m_dumpJacobians;
/*********************
* INTERNAL SOLUTION VALUES
*********************/
//! Number of equations in the ode integrator
int m_neq;
vector_fp m_y_n;
vector_fp m_y_nm1;
vector_fp m_y_pred_n;
vector_fp m_ydot_n;
vector_fp m_ydot_nm1;
/************************
* TIME VARIABLES
************************/
//! Initial time at the start of the integration
double m_t0;
//! Final time
double m_time_final;
double time_n;
double time_nm1;
double time_nm2;
double delta_t_n;
double delta_t_nm1;
double delta_t_nm2;
double delta_t_np1;
//! Maximum permissible time step
double delta_t_max;
vector_fp m_resid;
vector_fp m_residWts;
vector_fp m_wksp;
ResidJacEval* m_func;
vector_fp m_rowScales;
vector_fp m_colScales;
//! Pointer to the Jacobian representing the time dependent problem
GeneralMatrix* tdjac_ptr;
/**
* Determines the level of printing for each time
* step.
* 0 -> absolutely nothing is printed for
* a single time step.
* 1 -> One line summary per time step
* 2 -> short description, points of interest
* 3 -> Lots printed per time step (default)
*/
int m_print_flag;
/***************************************************************************
* COUNTERS OF VARIOUS KINDS
***************************************************************************/
//! Number of function evaluations
int m_nfe;
/**
* Number of Jacobian Evaluations and
* factorization steps (they are the same)
*/
int m_nJacEval;
//! Number of total Newton iterations
int m_numTotalNewtIts;
//! Total number of linear iterations
int m_numTotalLinearSolves;
//! Total number of convergence failures.
int m_numTotalConvFails;
//! Total Number of time truncation error failures
int m_numTotalTruncFails;
int num_failures;
};
} // namespace
#endif // CT_BEULER

View file

@ -270,14 +270,6 @@ public:
*/
virtual doublereal* const* colPts();
//! Copy the data from one array into another without doing any checking
/*!
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
* @deprecated To be removed after Cantera 2.2.
*/
virtual void copyData(const GeneralMatrix& y);
//! Check to see if we have any zero rows in the Jacobian
/*!
* This utility routine checks to see if any rows are zero.

View file

@ -174,14 +174,6 @@ public:
*/
virtual doublereal operator()(size_t i, size_t j) const = 0;
//! Copy the data from one array into another without doing any checking
/*!
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
* @deprecated To be removed after Cantera 2.2.
*/
virtual void copyData(const GeneralMatrix& y) = 0;
//! Return an iterator pointing to the first element
/*!
* We might drop this later

File diff suppressed because it is too large Load diff

View file

@ -89,9 +89,6 @@ public:
return Array2D::operator()(i, j);
}
//! @deprecated To be removed after Cantera 2.2.
virtual void copyData(const GeneralMatrix& y);
virtual doublereal operator()(size_t i, size_t j) const {
return Array2D::operator()(i, j);
}

View file

@ -1,448 +0,0 @@
/**
* @file solveProb.h Header file for implicit nonlinear solver with the option
* of a pseudotransient (see \ref numerics and class \link
* Cantera::solveProb solveProb\endlink).
*/
/*
* Copyright 2004 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
* See file License.txt for licensing information.
*/
#ifndef SOLVEPROB_H
#define SOLVEPROB_H
/**
* @defgroup solverGroup Solvers for Equation Systems
*/
#include "cantera/numerics/SquareMatrix.h"
#include "ResidEval.h"
//! Solution Methods
/*!
* Flag to specify the solution method
*
* 1: SOLVEPROB_INITIALIZE = This assumes that the initial guess supplied to the
* routine is far from the correct one. Substantial
* work plus transient time-stepping is to be expected
* to find a solution.
* 2: SOLVEPROB_RESIDUAL = Need to solve the surface problem in order to
* calculate the surface fluxes of gas-phase species.
* (Can expect a moderate change in the solution
* vector -> try to solve the system by direct
* methods
* with no damping first -> then, try time-stepping
* if the first method fails)
* A "time_scale" supplied here is used in the
* algorithm to determine when to shut off
* time-stepping.
* 3: SOLVEPROB_JACOBIAN = Calculation of the surface problem is due to the
* need for a numerical Jacobian for the gas-problem.
* The solution is expected to be very close to the
* initial guess, and accuracy is needed.
* 4: SOLVEPROB_TRANSIENT = The transient calculation is performed here for an
* amount of time specified by "time_scale". It is
* not guaranteed to be time-accurate - just stable
* and fairly fast. The solution after del_t time is
* returned, whether it's converged to a steady
* state or not.
*/
const int SOLVEPROB_INITIALIZE = 1;
const int SOLVEPROB_RESIDUAL = 2;
const int SOLVEPROB_JACOBIAN = 3;
const int SOLVEPROB_TRANSIENT = 4;
namespace Cantera
{
//! Method to solve a pseudo steady state of a nonlinear problem
/*!
* The following class handles the solution of a nonlinear problem.
*
* Res_ss(C) = - Res(C) = 0
*
* Optionally a pseudo transient algorithm may be used to relax the residual if
* it is available.
*
* Res_td(C) = dC/dt - Res(C) = 0;
*
* Res_ss(C) is the steady state residual to be solved. Res_td(C) is the
* time dependent residual which leads to the steady state residual.
*
* Solution Method
*
* This routine is typically used within a residual calculation in a large code.
* It's typically invoked millions of times for large calculations, and it must
* work every time. Therefore, requirements demand that it be robust but also
* efficient.
*
* The solution methodology is largely determined by the <TT>ifunc</TT> parameter,
* that is input to the solution object. This parameter may have the following
* 4 values:
*
* 1: SOLVEPROB_INITIALIZE = This assumes that the initial guess supplied to the
* routine is far from the correct one. Substantial
* work plus transient time-stepping is to be expected
* to find a solution.
*
* 2: SOLVEPROB_RESIDUAL = Need to solve the nonlinear problem in order to
* calculate quantities for a residual calculation
* (Can expect a moderate change in the solution
* vector -> try to solve the system by direct methods
* with no damping first -> then, try time-stepping
* if the first method fails)
* A "time_scale" supplied here is used in the
* algorithm to determine when to shut off
* time-stepping.
*
* 3: SOLVEPROB_JACOBIAN = Calculation of the surface problem is due to the
* need for a numerical Jacobian for the gas-problem.
* The solution is expected to be very close to the
* initial guess, and extra accuracy is needed because
* solution variables have been delta'd from
* nominal values to create Jacobian entries.
*
* 4: SOLVEPROB_TRANSIENT = The transient calculation is performed here for an
* amount of time specified by "time_scale". It is
* not guaranteed to be time-accurate - just stable
* and fairly fast. The solution after del_t time is
* returned, whether it's converged to a steady
* state or not. This is a poor man's time stepping
* algorithm.
*
* Pseudo time stepping algorithm:
* The time step is determined from sdot[], so that the time step
* doesn't ever change the value of a variable by more than 100%.
*
* This algorithm does use a damped Newton's method to relax the equations.
* Damping is based on a "delta damping" technique. The solution unknowns
* are not allowed to vary too much between iterations.
*
* EXTRA_ACCURACY:A constant that is the ratio of the required update norm in
* this Newton iteration compared to that in the nonlinear solver.
* A value of 0.1 is used so surface species are safely overconverged.
*
* Functions called:
*----------------------------------------------------------------------------
*
* ct_dgetrf -- First half of LAPACK direct solve of a full Matrix
*
* ct_dgetrs -- Second half of LAPACK direct solve of a full matrix. Returns
* solution vector in the right-hand-side vector, resid.
*
*----------------------------------------------------------------------------
*
* @ingroup solverGroup
* @deprecated Unused. To be removed after Cantera 2.2.
*/
class solveProb
{
public:
//! Constructor for the object
solveProb(ResidEval* resid);
virtual ~solveProb() {}
private:
//! Unimplemented private copy constructor
solveProb(const solveProb& right);
//! Unimplemented private assignment operator
solveProb& operator=(const solveProb& right);
public:
//! Main routine that actually calculates the pseudo steady state
//! of the surface problem
/*!
* The actual converged solution is returned as part of the
* internal state of the InterfaceKinetics objects.
*
* @param ifunc Determines the type of solution algorithm to be
* used. Possible values are SOLVEPROB_INITIALIZE ,
* SOLVEPROB_RESIDUAL SOLVEPROB_JACOBIAN SOLVEPROB_TRANSIENT .
*
* @param time_scale Time over which to integrate the surface equations,
* where applicable
*
* @param reltol Relative tolerance to use
*
* @return Returns 1 if the surface problem is successfully solved.
* Returns -1 if the surface problem wasn't solved successfully.
* Note the actual converged solution is returned as part of the
* internal state of the InterfaceKinetics objects.
*/
int solve(int ifunc, doublereal time_scale, doublereal reltol);
//! Report the current state of the solution
/*!
* @param[out] CSoln solution vector for the nonlinear problem
*/
virtual void reportState(doublereal* const CSoln) const;
//! Set the bottom and top bounds on the solution vector
/*!
* The default is for the bottom is 0.0, while the default for the top is 1.0
*
* @param botBounds Vector of bottom bounds
* @param topBounds vector of top bounds
*/
virtual void setBounds(const doublereal botBounds[], const doublereal topBounds[]);
void setAtol(const doublereal atol[]);
void setAtolConst(const doublereal atolconst);
private:
//! Printing routine that gets called at the start of every invocation
virtual void print_header(int ioflag, int ifunc, doublereal time_scale,
doublereal reltol,
doublereal netProdRate[]);
#ifdef DEBUG_SOLVEPROB
//! Prints out the residual and Jacobian
virtual void printResJac(int ioflag, int neq, const Array2D& Jac,
doublereal resid[], doublereal wtResid[], doublereal norm);
#endif
//! Printing routine that gets called after every iteration
virtual void printIteration(int ioflag, doublereal damp, size_t label_d, size_t label_t,
doublereal inv_t, doublereal t_real, int iter,
doublereal update_norm, doublereal resid_norm,
doublereal netProdRate[], doublereal CSolnSP[],
doublereal resid[],
doublereal wtSpecies[], size_t dim, bool do_time);
//! Print a summary of the solution
virtual void printFinal(int ioflag, doublereal damp, size_t label_d, size_t label_t,
doublereal inv_t, doublereal t_real, int iter,
doublereal update_norm, doublereal resid_norm,
doublereal netProdRateKinSpecies[], const doublereal CSolnSP[],
const doublereal resid[],
const doublereal wtSpecies[], const doublereal wtRes[],
size_t dim, bool do_time);
//! Calculate a conservative delta T to use in a pseudo-steady state
//! algorithm
/*!
* This routine calculates a pretty conservative 1/del_t based
* on MAX_i(sdot_i/(X_i*SDen0)). This probably guarantees
* diagonal dominance.
*
* Small surface fractions are allowed to intervene in the del_t
* determination, no matter how small. This may be changed.
* Now minimum changed to 1.0e-12,
*
* Maximum time step set to time_scale.
*
* @param netProdRateSolnSP Output variable. Net production rate
* of all of the species in the solution vector.
* @param Csoln output variable.
* Mole fraction of all of the species in the solution vector
* @param label Output variable. Pointer to the value of the
* species index (kindexSP) that is controlling
* the time step
* @param label_old Output variable. Pointer to the value of the
* species index (kindexSP) that controlled
* the time step at the previous iteration
* @param label_factor Output variable. Pointer to the current
* factor that is used to indicate the same species
* is controlling the time step.
*
* @param ioflag Level of the output requested.
*
* @return Returns the 1. / delta T to be used on the next step
*/
virtual doublereal calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[],
size_t* label, size_t* label_old,
doublereal* label_factor, int ioflag);
//! Calculate the solution and residual weights
/*!
* Calculate the weighting factors for norms wrt both the species
* concentration unknowns and the residual unknowns.
* @param wtSpecies Weights to use for the soln unknowns. These
* are in concentration units
* @param wtResid Weights to sue for the residual unknowns.
*
* @param CSolnSP Solution vector for the surface problem
*/
virtual void calcWeights(doublereal wtSpecies[], doublereal wtResid[],
const doublereal CSolnSP[]);
#ifdef DEBUG_SOLVEPROB
//! Utility routine to print a header for high lvls of debugging
/*!
* @param ioflag Lvl of debugging
* @param damp lvl of damping
* @param inv_t Inverse of the value of delta T
* @param t_real Value of the time
* @param iter Iteration number
* @param do_time boolean indicating whether time stepping is taking
* place
*/
virtual void printIterationHeader(int ioflag, doublereal damp,
doublereal inv_t, doublereal t_real, int iter,
bool do_time);
#endif
//! Main Function evaluation
/*!
* This calculates the net production rates of all species
*
* @param resid output Vector of residuals, length = m_neq
* @param CSolnSP Vector of species concentrations, unknowns in the
* problem, length = m_neq
* @param CSolnSPOld Old Vector of species concentrations, unknowns in the
* problem, length = m_neq
* @param do_time Calculate a time dependent residual
* @param deltaT Delta time for time dependent problem.
*/
virtual void fun_eval(doublereal* const resid, const doublereal* const CSolnSP,
const doublereal* const CSolnSPOld, const bool do_time, const doublereal deltaT);
//! Main routine that calculates the current residual and Jacobian
/*!
* @param JacCol Vector of pointers to the tops of columns of the
* Jacobian to be evaluated.
* @param resid output Vector of residuals, length = m_neq
* @param CSolnSP Vector of species concentrations, unknowns in the
* problem, length = m_neq. These are tweaked in order
* to derive the columns of the Jacobian.
* @param CSolnSPOld Old Vector of species concentrations, unknowns in the
* problem, length = m_neq
* @param do_time Calculate a time dependent residual
* @param deltaT Delta time for time dependent problem.
*/
virtual void resjac_eval(std::vector<doublereal*>& JacCol, doublereal* resid,
doublereal* CSolnSP,
const doublereal* CSolnSPOld, const bool do_time,
const doublereal deltaT);
//! This function calculates a damping factor for the Newton iteration update
//! vector, dxneg, to insure that all solution components stay within prescribed bounds
/*!
* The default for this class is that all solution components are bounded between zero and one.
* this is because the original unknowns were mole fractions and surface site fractions.
*
* dxneg[] = negative of the update vector.
*
* The constant "APPROACH" sets the fraction of the distance to the boundary
* that the step can take. If the full step would not force any fraction
* outside of the bounds, then Newton's method is mostly allowed to operate normally.
* There is also some solution damping employed.
*
* @param x Vector of the current solution components
* @param dxneg Vector of the negative of the full solution update vector.
* @param dim Size of the solution vector
* @param label return int, stating which solution component caused the most damping.
*/
virtual doublereal calc_damping(doublereal x[], doublereal dxneg[], size_t dim, size_t* label);
//! residual function pointer to be solved.
ResidEval* m_residFunc;
//! Total number of equations to solve in the implicit problem.
/*!
* Note, this can be zero, and frequently is
*/
size_t m_neq;
//! m_atol is the absolute tolerance in real units.
vector_fp m_atol;
//! m_rtol is the relative error tolerance.
doublereal m_rtol;
//! maximum value of the time step
/*!
* units = seconds
*/
doublereal m_maxstep;
//! Temporary vector with length MAX(1, m_neq)
vector_fp m_netProductionRatesSave;
//! Temporary vector with length MAX(1, m_neq)
vector_fp m_numEqn1;
//! Temporary vector with length MAX(1, m_neq)
vector_fp m_numEqn2;
//! Temporary vector with length MAX(1, m_neq)
vector_fp m_CSolnSave;
//! Solution vector
/*!
* length MAX(1, m_neq)
*/
vector_fp m_CSolnSP;
//! Saved initial solution vector
/*!
* length MAX(1, m_neq)
*/
vector_fp m_CSolnSPInit;
//! Saved solution vector at the old time step
/*!
* length MAX(1, m_neq)
*/
vector_fp m_CSolnSPOld;
//! Weights for the residual norm calculation
/*!
* length MAX(1, m_neq)
*/
vector_fp m_wtResid;
//! Weights for the species concentrations norm calculation
/*!
* length MAX(1, m_neq)
*/
vector_fp m_wtSpecies;
//! Residual for the surface problem
/*!
* The residual vector of length "dim" that, that has the value
* of "sdot" for surface species. The residuals for the bulk
* species are a function of the sdots for all species in the bulk
* phase. The last residual of each phase enforces {Sum(fractions)
* = 1}. After linear solve (dgetrf_ & dgetrs_), resid holds the
* update vector.
*
* length MAX(1, m_neq)
*/
vector_fp m_resid;
//! Vector of pointers to the top of the columns of the Jacobians
/*!
* The "dim" by "dim" computed Jacobian matrix for the
* local Newton's method.
*/
std::vector<doublereal*> m_JacCol;
//! Jacobian
/*!
* m_neq by m_neq computed Jacobian matrix for the local Newton's method.
*/
SquareMatrix m_Jac;
//! Top bounds for the solution vector
/*!
* This defaults to 1.0
*/
vector_fp m_topBounds;
//! Bottom bounds for the solution vector
/*!
* This defaults to 0.0
*/
vector_fp m_botBounds;
public:
int m_ioflag;
};
}
#endif

View file

@ -124,28 +124,11 @@ public:
m_do_energy[j] = false;
}
/*!
* Set the mass fraction fixed point for species k at grid point j, and
* disable the species equation so that the solution will be held to this
* value. Note: in practice, the species are hardly ever held fixed.
*/
void setMassFraction(size_t j, size_t k, doublereal y) {
m_fixedy(k,j) = y;
m_do_species[k] = true;
}
//! The fixed temperature value at point j.
doublereal T_fixed(size_t j) const {
return m_fixedtemp[j];
}
//! The fixed mass fraction value of species k at point j.
//! @deprecated Unused. To be removed after Cantera 2.2.
doublereal Y_fixed(size_t k, size_t j) const {
warn_deprecated("StFlow::Y_fixed", "To be removed after Cantera 2.2.");
return m_fixedy(k,j);
}
// @}
virtual std::string componentName(size_t n) const;
@ -253,44 +236,10 @@ public:
}
}
//! @deprecated Species equations are always solved. To be removed after
//! Cantera 2.2.
bool doSpecies(size_t k) {
warn_deprecated("StFlow::doSpecies", "To be removed after Cantera 2.2.");
return m_do_species[k];
}
bool doEnergy(size_t j) {
return m_do_energy[j];
}
//! @deprecated Species equations are always solved. To be removed after
//! Cantera 2.2.
void solveSpecies(size_t k=npos) {
warn_deprecated("StFlow::solveSpecies", "To be removed after Cantera 2.2.");
if (k == npos) {
for (size_t i = 0; i < m_nsp; i++) {
m_do_species[i] = true;
}
} else {
m_do_species[k] = true;
}
needJacUpdate();
}
//! @deprecated Species equations are always solved. To be removed after
//! Cantera 2.2.
void fixSpecies(size_t k=npos) {
warn_deprecated("StFlow::fixSpecies", "To be removed after Cantera 2.2.");
if (k == npos) {
for (size_t i = 0; i < m_nsp; i++) {
m_do_species[i] = false;
}
} else {
m_do_species[k] = false;
}
needJacUpdate();
}
void integrateChem(doublereal* x,doublereal dt);
//! Change the grid size. Called after grid refinement.
@ -534,7 +483,6 @@ protected:
vector_fp m_qdotRadiation;
// fixed T and Y values
Array2D m_fixedy; //!< @deprecated
vector_fp m_fixedtemp;
vector_fp m_zfix;
vector_fp m_tfix;

View file

@ -839,41 +839,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* On return uA contains the powers of the units (MKS assumed)
* of the standard concentrations and generalized concentrations
* for the kth species.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activities at
//! the current solution temperature, pressure, and solution concentration.
/*!

View file

@ -320,39 +320,6 @@ public:
*/
virtual void getStandardChemPotentials(doublereal* mu0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units:
*
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
*
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
int sizeUA = 6) const;
//@}
/// @name Partial Molar Properties of the Solution
/// These properties are handled by the parent class, SingleSpeciesTP

View file

@ -231,33 +231,6 @@ public:
*/
virtual doublereal logStandardConc(size_t k=0) const;
/**
* Returns the units of the standard and generalized
* concentrations Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activities (molality
//! based for this class and classes that derive from it) at
//! the current solution temperature, pressure, and solution concentration.

View file

@ -1644,37 +1644,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activities at
//! the current solution temperature, pressure, and solution concentration.
/*!

View file

@ -418,69 +418,6 @@ public:
*/
virtual doublereal cv_mole() const;
/**
* @returns species translational/rotational specific heat at
* constant volume. Inferred from the species gas
* constant and number of translational/rotational
* degrees of freedom. The translational/rotational
* modes are assumed to be fully populated, and are
* given by
* \f[
* C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{5}{2} R_s
* \f]
* for diatomic molecules and
* \f[
* C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{3}{2} R_s
* \f]
* for atoms.
* @deprecated To be removed after Cantera 2.2.
*/
virtual doublereal cv_tr(doublereal) const;
/**
* @returns species translational specific heat at constant volume.
* Since the translational modes are assumed to be fully populated
* this is simply
* \f[
* C^{trans}_{v,s} \equiv \frac{\partial e^{trans}_s}{\partial T} = \frac{3}{2} R_s
* \f]
* @deprecated To be removed after Cantera 2.2.
*/
virtual doublereal cv_trans() const;
/**
* @returns species rotational specific heat at constant volume.
* By convention, we lump the translational/rotational components
* \f[
* C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s}
* \f]
* so then
* \f[
* C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s}
* \f]
* @deprecated To be removed after Cantera 2.2.
*/
virtual doublereal cv_rot(double atomicity) const;
/**
* @returns species vibrational specific heat at
* constant volume,
* \f[
* C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T}
* \f]
* where the species vibration energy \f$ e^{vib}_{v,s} \f$ is
* - atom:
* 0
* - Diatomic:
* \f[ \frac{R_s \theta_{v,s}}{e^{\theta_{v,s}/T}-1} \f]
* - General Molecule:
* \f[
* \sum_i \frac{R_s \theta_{v,s,i}}{e^{\theta_{v,s,i}/T}-1}
* \f]
* @deprecated To be removed after Cantera 2.2.
*/
virtual doublereal cv_vib(int k, doublereal T) const;
//! @}
//! @name Mechanical Equation of State
//! @{

View file

@ -362,32 +362,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
/*!
* Returns the units of the standard and generalized
* concentrations Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
/*!
* Get the array of non-dimensional activities at
* the current solution temperature, pressure, and

View file

@ -412,39 +412,6 @@ public:
*/
virtual doublereal logStandardConc(size_t k) const;
/**
* Returns the units of the standard and general concentrations
* Note they have the same units, as their divisor is
* defined to be equal to the activity of the kth species
* in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* @param uA Output vector containing the units:
*
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
*
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
*
* For EOS types other than cIdealSolidSolnPhase0, the default
* kmol/m3 holds for standard concentration units. For
* cIdealSolidSolnPhase0 type, the standard concentration is
* unitless.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of species activity coefficients
/*!
* @param ac output vector of activity coefficients. Length: m_kk

View file

@ -163,37 +163,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activity coefficients at
//! the current solution temperature, pressure, and solution concentration.
/*!

View file

@ -335,37 +335,6 @@ public:
*/
virtual void getStandardChemPotentials(doublereal* mu0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
int sizeUA = 6) const;
//@}
/// @name Properties of the Standard State of the Species in the Solution
//@{

View file

@ -249,39 +249,6 @@ public:
*/
virtual void getStandardChemPotentials(doublereal* mu0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units
*
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
*
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
int sizeUA = 6) const;
//@}
/// @name Properties of the Standard State of the Species in the Solution
//@{

View file

@ -290,15 +290,6 @@ public:
*/
MixedSolventElectrolyte(XML_Node& phaseRef, const std::string& id = "");
//! Special constructor for a hard-coded problem
/*!
* @param testProb Hard-coded value. Only the value of 1 is used. It's
* for a LiKCl system -> test to predict the eutectic and
* liquidus correctly.
* @deprecated To be removed after Cantera 2.2.
*/
MixedSolventElectrolyte(int testProb);
//! Copy constructor
/*!
* @param b class to be copied

View file

@ -421,32 +421,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
/**
* Returns the units of the standard and generalized
* concentrations Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activities (molality
//! based for this class and classes that derive from it) at
//! the current solution temperature, pressure, and solution concentration.

View file

@ -644,13 +644,6 @@ public:
//! @copydoc Phase::mean_X(const doublereal* const Q) const
doublereal mean_X(const vector_fp& Q) const;
//! Evaluate the mass-fraction-weighted mean of an array Q.
//! \f[ \sum_k Y_k Q_k \f]
//! @param[in] Q Array of species property values in mass units.
//! @return The mass-fraction-weighted mean of Q.
//! @deprecated Unused. To be removed after Cantera 2.2.
doublereal mean_Y(const doublereal* const Q) const;
//! The mean molecular weight. Units: (kg/kmol)
doublereal meanMolecularWeight() const {
return m_mmw;
@ -660,11 +653,6 @@ public:
//! @return The indicated sum. Dimensionless.
doublereal sum_xlogx() const;
//! Evaluate \f$ \sum_k X_k \log Q_k \f$.
//! @param Q Vector of length m_kk to take the log average of
//! @return The indicated sum.
//! @deprecated Unused. To be removed after Cantera 2.2.
doublereal sum_xlogQ(doublereal* const Q) const;
//@}
//! @name Adding Elements and Species
@ -823,16 +811,6 @@ private:
//! Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
vector_fp m_entropy298;
public:
//! Overflow behavior of real number calculations involving this thermo object
/*!
* The default is THROWON_OVERFLOW_CTRB
* Which throws an error in debug mode, but silently changes the answer in non-debug mode
* @deprecated To be removed after Cantera 2.2.
*/
enum CT_RealNumber_Range_Behavior realNumberRangeBehavior_;
};
}

View file

@ -363,15 +363,6 @@ public:
*/
PhaseCombo_Interaction(XML_Node& phaseRef, const std::string& id = "");
//! Special constructor for a hard-coded problem
/*!
* @param testProb Hard-coded value. Only the value of 1 is used. It's
* for a LiKCl system -> test to predict the eutectic and
* liquidus correctly.
* @deprecated To be removed after Cantera 2.2.
*/
PhaseCombo_Interaction(int testProb);
//! Copy constructor
/*!
* @param b class to be copied

View file

@ -1,227 +0,0 @@
/**
* @file PseudoBinaryVPSSTP.h
* Header for intermediate ThermoPhase object for phases which
* employ Gibbs excess free energy based formulations
* (see \ref thermoprops
* and class \link Cantera::PseudoBinaryVPSSTP PseudoBinaryVPSSTP\endlink).
*
* Header file for a derived class of ThermoPhase that handles
* variable pressure standard state methods for calculating
* thermodynamic properties that are further based upon activities
* based on the molality scale. These include most of the methods for
* calculating liquid electrolyte thermodynamics.
*/
/*
* Copyright (2006) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#ifndef CT_PSEUDOBINARYVPSSTP_H
#define CT_PSEUDOBINARYVPSSTP_H
#include "GibbsExcessVPSSTP.h"
namespace Cantera
{
/**
* @ingroup thermoprops
*/
/*!
* PseudoBinaryVPSSTP is a derived class of ThermoPhase
* GibbsExcessVPSSTP that handles
* variable pressure standard state methods for calculating
* thermodynamic properties that are further based on
* expressing the Excess Gibbs free energy as a function of
* the mole fractions (or pseudo mole fractions) of constituents.
* This category is the workhorse for describing molten salts,
* solid-phase mixtures of semiconductors, and mixtures of miscible
* and semi-miscible compounds.
*
* It includes
* - regular solutions
* - Margules expansions
* - NTRL equation
* - Wilson's equation
* - UNIQUAC equation of state.
*
* This class adds additional functions onto the ThermoPhase interface
* that handles the calculation of the excess Gibbs free energy. The ThermoPhase
* class includes a member function, ThermoPhase::activityConvention()
* that indicates which convention the activities are based on. The
* default is to assume activities are based on the molar convention.
* That default is used here.
*
* All of the Excess Gibbs free energy formulations in this area employ
* symmetrical formulations.
*
* This layer will massage the mole fraction vector to implement
* cation and anion based mole numbers in an optional manner
*
* The way that it collects the cation and anion based mole numbers
* is via holding two extra ThermoPhase objects. These
* can include standard states for salts.
*
* @deprecated Incomplete and untested. To be removed after Cantera 2.2.
*/
class PseudoBinaryVPSSTP : public GibbsExcessVPSSTP
{
public:
/// Constructor
/*!
* This doesn't do much more than initialize constants with
* default values for water at 25C. Water molecular weight
* comes from the default elements.xml file. It actually
* differs slightly from the IAPWS95 value of 18.015268. However,
* density conservation and therefore element conservation
* is the more important principle to follow.
*/
PseudoBinaryVPSSTP();
//! Copy constructor
/*!
* @param b class to be copied
*/
PseudoBinaryVPSSTP(const PseudoBinaryVPSSTP& b);
/// Assignment operator
/*!
* @param b class to be copied.
*/
PseudoBinaryVPSSTP& operator=(const PseudoBinaryVPSSTP& b);
//! Duplication routine for objects which inherit from ThermoPhase.
/*!
* This virtual routine can be used to duplicate ThermoPhase objects
* inherited from ThermoPhase even if the application only has
* a pointer to ThermoPhase to work with.
*/
virtual ThermoPhase* duplMyselfAsThermoPhase() const;
/**
* @name Activities, Standard States, and Activity Concentrations
*
* The activity \f$a_k\f$ of a species in solution is
* related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
* + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
* the chemical potential at unit activity, which depends only
* on temperature and pressure.
* @{
*/
/**
* The standard concentration \f$ C^0_k \f$ used to normalize
* the generalized concentration. In many cases, this quantity
* will be the same for all species in a phase - for example,
* for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
* reason, this method returns a single value, instead of an
* array. However, for phases in which the standard
* concentration is species-specific (e.g. surface species of
* different sizes), this method may be called with an
* optional parameter indicating the species.
*
* @param k species index. Defaults to zero.
*/
virtual doublereal standardConcentration(size_t k=0) const;
//@}
/// @name Partial Molar Properties of the Solution
//@{
/**
* Get the species electrochemical potentials.
* These are partial molar quantities.
* This method adds a term \f$ Fz_k \phi_k \f$ to the
* to each chemical potential.
*
* Units: J/kmol
*
* @param mu output vector containing the species electrochemical potentials.
* Length: m_kk.
*/
void getElectrochemPotentials(doublereal* mu) const;
//@}
//! Calculate pseudo binary mole fractions
virtual void calcPseudoBinaryMoleFractions() const;
//@}
/// @name Initialization
/// The following methods are used in the process of constructing
/// the phase and setting its parameters from a specification in an
/// input file. They are not normally used in application programs.
/// To see how they are used, see importPhase().
/*!
* @internal Initialize. This method is provided to allow
* subclasses to perform any initialization required after all
* species have been added. For example, it might be used to
* resize internal work arrays that must have an entry for
* each species. The base class implementation does nothing,
* and subclasses that do not require initialization do not
* need to overload this method. When importing a CTML phase
* description, this method is called just prior to returning
* from function importPhase().
*/
virtual void initThermo();
/**
* Import and initialize a ThermoPhase object
*
* @param phaseNode This object must be the phase node of a
* complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
* @param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
void initThermoXML(XML_Node& phaseNode, const std::string& id);
virtual std::string report(bool show_thermo=true,
doublereal threshold=1e-14) const;
private:
//! Initialize lengths of local variables after all species have
//! been identified.
void initLengths();
protected:
int PBType_;
//! Number of pseudo binary species
size_t numPBSpecies_;
//! index of special species
size_t indexSpecialSpecies_;
mutable std::vector<doublereal> PBMoleFractions_;
std::vector<int> cationList_;
size_t numCationSpecies_;
std::vector<int>anionList_;
size_t numAnionSpecies_;
std::vector<int> passThroughList_;
size_t numPassThroughSpecies_;
size_t neutralPBindexStart;
ThermoPhase* cationPhase_;
ThermoPhase* anionPhase_;
mutable std::vector<doublereal> moleFractionsTmp_;
};
#define PBTYPE_PASSTHROUGH 0
#define PBTYPE_SINGLEANION 1
#define PBTYPE_SINGLECATION 2
#define PBTYPE_MULTICATIONANION 3
}
#endif

View file

@ -286,15 +286,6 @@ public:
*/
RedlichKisterVPSSTP(XML_Node& phaseRef, const std::string& id = "");
//! Special constructor for a hard-coded problem
/*!
* @param testProb Hard-coded value. Only the value of 1 is used. It's
* for a LiKCl system -> test to predict the eutectic and
* liquidus correctly.
* @deprecated To be removed after Cantera 2.2.
*/
RedlichKisterVPSSTP(int testProb);
//! Copy constructor
/*!
* @param b class to be copied

View file

@ -52,19 +52,6 @@ public:
*/
RedlichKwongMFTP(XML_Node& phaseRef, const std::string& id = "");
//! This is a special constructor, used to replicate test problems
//! during the initial verification of the object
/*!
* test problems:
* 1: Pure CO2 problem
* input file = CO2_RedlickKwongMFTP.xml
*
* @param testProb Hard -coded test problem to instantiate.
* Current valid values are 1.
* @deprecated To be removed after Cantera 2.2.
*/
RedlichKwongMFTP(int testProb);
//! Copy Constructor
/*!
* Copy constructor for the object. Constructed object will be a clone of this object, but will
@ -251,38 +238,6 @@ public:
*/
virtual doublereal standardConcentration(size_t k=0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units:
*
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
*
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0, int sizeUA = 6) const;
//! Get the array of non-dimensional activity coefficients at
//! the current solution temperature, pressure, and solution concentration.
/*!

View file

@ -1,171 +0,0 @@
/**
* @file StatMech.h
* Header for a single-species standard state object derived
* from
*/
/*
* Copyright(2006) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#ifndef CT_STATMECH_H
#define CT_STATMECH_H
#include "cantera/base/global.h"
#include "SpeciesThermoInterpType.h"
namespace Cantera
{
//! Statistical mechanics
/*!
* @ingroup spthermo
* @deprecated Incomplete stub class, to be removed after Cantera 2.2.
*/
class StatMech : public SpeciesThermoInterpType
{
public:
//! Empty constructor
StatMech();
//! constructor used in templated instantiations
/*!
* @param n Species index
* @param tlow Minimum temperature
* @param thigh Maximum temperature
* @param pref reference pressure (Pa).
* @param coeffs Vector of coefficients used to set the
* parameters for the standard state.
*/
StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref,
const doublereal* coeffs, const std::string& my_name);
//! copy constructor
/*!
* @param b object to be copied
*/
StatMech(const StatMech& b);
//! assignment operator
/*!
* @param b object to be copied
*/
StatMech& operator=(const StatMech& b);
//! duplicator
virtual SpeciesThermoInterpType*
duplMyselfAsSpeciesThermoInterpType() const;
//! Returns an integer representing the type of parameterization
virtual int reportType() const;
//! Build a series of maps for the properties needed for species
int buildmap();
//! Update the properties for this species, given a temperature polynomial
/*!
* This method is called with a pointer to an array containing the
* functions of temperature needed by this parameterization, and three
* pointers to arrays where the computed property values should be
* written. This method updates only one value in each array.
*
* \f[
* \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1
* \f]
*
* Where,
* \f[
* \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R}
* \f]
*
* Temperature Polynomial:
* tt[0] = t;
*
* @param tt vector of temperature polynomials
* @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
* @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
* @param s_R Vector of Dimensionless entropies. (length m_kk).
*/
virtual void updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const;
//! Compute the reference-state property of one species
/*!
* Given temperature T in K, this method updates the values of the non-
* dimensional heat capacity at constant pressure, enthalpy, and entropy,
* at the reference pressure, Pref of one of the species. The species
* index is used to reference into the cp_R, h_RT, and s_R arrays.
*
* @param temp Temperature (Kelvin)
* @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
* @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
* @param s_R Vector of Dimensionless entropies. (length m_kk).
*/
virtual void updatePropertiesTemp(const doublereal temp,
doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const;
//! This utility function reports back the type of parameterization and
//! all of the parameters for the species, index.
/*!
* All parameters are output variables
*
* @param n Species index
* @param type Integer type of the standard type
* @param tlow output - Minimum temperature
* @param thigh output - Maximum temperature
* @param pref output - reference pressure (Pa).
* @param coeffs Vector of coefficients used to set the
* parameters for the standard state. There are
* 12 of them, designed to be compatible
* with the multiple temperature formulation.
* coeffs[0] is equal to one.
* coeffs[1] is min temperature
* coeffs[2] is max temperature
* coeffs[3+i] from i =0,9 are the coefficients themselves
*/
virtual void reportParameters(size_t& n, int& type,
doublereal& tlow, doublereal& thigh,
doublereal& pref,
doublereal* const coeffs) const;
//! Modify parameters for the standard state
/*!
* @param coeffs Vector of coefficients used to set the
* parameters for the standard state.
*/
virtual void modifyParameters(doublereal* coeffs);
protected:
//! array of polynomial coefficients
vector_fp m_coeff;
std::string sp_name;
//*generic species struct that contains everything we need here
// achtung: add doxygen markup here
// achtung: convert doubles to realdoubles
struct species {
//Nominal T-R Degrees of freedom (cv = cfs*k*T)
doublereal cfs;
// Mol. Wt. Molecular weight (kg/kmol)
doublereal mol_weight;
// number of vibrational temperatures necessary
int nvib;
// Theta_v Characteristic vibrational temperature(s) (K)
doublereal theta[5];
};
std::map<std::string,species*> name_map;
};
}
#endif

View file

@ -165,27 +165,6 @@ public:
*/
virtual void getStandardChemPotentials(doublereal* mu0) const;
/**
* Returns the units of the standard and generalized
* concentrations. Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* uA[0] = kmol units - default = 0
* uA[1] = m units - default = 0
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//@}
/// @name Partial Molar Properties of the Solution
//@{

View file

@ -312,39 +312,6 @@ public:
*/
virtual void getStandardChemPotentials(doublereal* mu0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* @param uA Output vector containing the units
*
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
*
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
int sizeUA = 6) const;
//@}
/// @name Properties of the Standard State of the Species in the Solution
//@{

View file

@ -253,16 +253,6 @@ public:
throw NotImplementedError("ThermoPhase::cv_mole");
}
/**
* @returns species vibrational specific heat at
* constant volume.
* @deprecated To be removed after Cantera 2.2.
*/
/// Molar heat capacity at constant volume. Units: J/kmol/K.
virtual doublereal cv_vib(int, double) const {
throw NotImplementedError("ThermoPhase::cv_vib");
}
//! @}
//! @name Mechanical Properties
//! @{
@ -437,41 +427,6 @@ public:
*/
virtual doublereal logStandardConc(size_t k=0) const;
//! Returns the units of the standard and generalized concentrations.
/*!
* Note they have the same units, as their
* ratio is defined to be equal to the activity of the kth
* species in the solution, which is unitless.
*
* This routine is used in print out applications where the
* units are needed. Usually, MKS units are assumed throughout
* the program and in the XML input files.
*
* The base ThermoPhase class assigns the default quantities
* of (kmol/m3) for all species.
* Inherited classes are responsible for overriding the default
* values if necessary.
*
* On return uA contains the powers of the units (MKS assumed)
* of the standard concentrations and generalized concentrations
* for the kth species.
*
* @param uA Output vector containing the units
* uA[0] = kmol units - default = 1
* uA[1] = m units - default = -nDim(), the number of spatial
* dimensions in the Phase class.
* uA[2] = kg units - default = 0;
* uA[3] = Pa(pressure) units - default = 0;
* uA[4] = Temperature units - default = 0;
* uA[5] = time units - default = 0
* @param k species index. Defaults to 0.
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
* @deprecated To be removed after Cantera 2.2.
*/
virtual void getUnitsStandardConc(double* uA, int k = 0,
int sizeUA = 6) const;
//! Get the array of non-dimensional activities at
//! the current solution temperature, pressure, and solution concentration.
/*!

View file

@ -58,10 +58,6 @@
//! This is implemented in the class Nasa9PolyMultiTempRegion in Nasa9Poly1MultiTempRegion
#define NASA9MULTITEMP 513
//! Properties derived from theoretical considerations
//! This is implemented in the class statmech in StatMech.h
#define STAT 111
//! Surface Adsorbate Model for a species on a surface.
//! This is implemented in the class Adsorbate.
#define ADSORBATE 1024

View file

@ -1,567 +0,0 @@
/**
* @file AqueousTransport.h
* Header file defining class AqueousTransport
*/
// Copyright 2001 California Institute of Technology
#ifndef CT_AQUEOUSTRAN_H
#define CT_AQUEOUSTRAN_H
// Cantera includes
#include "TransportBase.h"
#include "cantera/numerics/DenseMatrix.h"
namespace Cantera
{
//! Class AqueousTransport implements mixture-averaged transport
//! properties for brine phases.
/*!
* The model is based on that described by Newman, Electrochemical Systems
*
* The velocity of species i may be described by the
* following equation p. 297 (12.1)
*
* \f[
* c_i \nabla \mu_i = R T \sum_j \frac{c_i c_j}{c_T D_{ij}}
* (\mathbf{v}_j - \mathbf{v}_i)
* \f]
*
* This as written is degenerate by 1 dof.
*
* To fix this we must add in the definition of the mass averaged
* velocity of the solution. We will call the simple bold-faced
* \f$\mathbf{v} \f$
* symbol the mass-averaged velocity. Then, the relation
* between \f$\mathbf{v}\f$ and the individual species velocities is
* \f$\mathbf{v}_i\f$
*
* \f[
* \rho_i \mathbf{v}_i = \rho_i \mathbf{v} + \mathbf{j}_i
* \f]
* where \f$\mathbf{j}_i\f$ are the diffusional fluxes of species i
* with respect to the mass averaged velocity and
*
* \f[
* \sum_i \mathbf{j}_i = 0
* \f]
*
* and
*
* \f[
* \sum_i \rho_i \mathbf{v}_i = \rho \mathbf{v}
* \f]
*
* Using these definitions, we can write
*
* \f[
* \mathbf{v}_i = \mathbf{v} + \frac{\mathbf{j}_i}{\rho_i}
* \f]
*
* \f[
* c_i \nabla \mu_i = R T \sum_j \frac{c_i c_j}{c_T D_{ij}}
* (\frac{\mathbf{j}_j}{\rho_j} - \frac{\mathbf{j}_i}{\rho_i})
* = R T \sum_j \frac{1}{D_{ij}}
* (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
* \f]
*
* The equations that we actually solve are
*
* \f[
* c_i \nabla \mu_i =
* = R T \sum_j \frac{1}{D_{ij}}
* (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
* \f]
* and we replace the 0th equation with the following:
*
* \f[
* \sum_i \mathbf{j}_i = 0
* \f]
*
* When there are charged species, we replace the RHS with the
* gradient of the electrochemical potential to obtain the
* modified equation
*
* \f[
* c_i \nabla \mu_i + c_i F z_i \nabla \Phi
* = R T \sum_j \frac{1}{D_{ij}}
* (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
* \f]
*
* With this formulation we may solve for the diffusion velocities, without
* having to worry about what the mass averaged velocity is.
*
* <H2> Viscosity Calculation </H2>
*
* The viscosity calculation may be broken down into two parts.
* In the first part, the viscosity of the pure species are calculated
* In the second part, a mixing rule is applied, based on the
* Wilkes correlation, to yield the mixture viscosity.
* @ingroup tranprops
* @deprecated Non-functional. To be removed after Cantera 2.2.
*/
class AqueousTransport : public Transport
{
public:
AqueousTransport();
virtual int model() const {
return cAqueousTransport;
}
//! Returns the viscosity of the solution
/*!
* The viscosity is computed using the Wilke mixture rule.
* \f[
* \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}.
* \f]
* Here \f$ \mu_k \f$ is the viscosity of pure species \e k,
* and
* \f[
* \Phi_{k,j} = \frac{\left[1
* + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2}
* {\sqrt{8}\sqrt{1 + M_k/M_j}}
* \f]
* @see updateViscosity_T();
*
* Controlling update boolean m_viscmix_ok
*/
virtual doublereal viscosity();
//! Returns the pure species viscosities
/*!
* Controlling update boolean = m_viscwt_ok
*
* @param visc Vector of species viscosities
*/
virtual void getSpeciesViscosities(doublereal* const visc);
//! Return a vector of Thermal diffusion coefficients [kg/m/sec].
/*!
* The thermal diffusion coefficient \f$ D^T_k \f$ is defined
* so that the diffusive mass flux of species <I>k</I> induced by the
* local temperature gradient is given by the following formula
*
* \f[
* M_k J_k = -D^T_k \nabla \ln T.
* \f]
*
* The thermal diffusion coefficient can be either positive or negative.
*
* In this method we set it to zero.
*
* @param dt On return, dt will contain the species thermal
* diffusion coefficients. Dimension dt at least as large as
* the number of species. Units are kg/m/s.
*/
virtual void getThermalDiffCoeffs(doublereal* const dt);
//! Return the thermal conductivity of the solution
/*!
* The thermal conductivity is computed from the following mixture rule:
* \f[
* \lambda = 0.5 \left( \sum_k X_k \lambda_k
* + \frac{1}{\sum_k X_k/\lambda_k}\right)
* \f]
*
* Controlling update boolean = m_condmix_ok
*/
virtual doublereal thermalConductivity();
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal* const d);
//! Get the Mixture diffusion coefficients
/*!
* For the single species case or the pure fluid case the routine returns
* the self-diffusion coefficient. This is need to avoid a NaN result.
* @param d vector of mixture diffusion coefficients
* units = m2 s-1. length = number of species
*/
virtual void getMixDiffCoeffs(doublereal* const d);
virtual void getMobilities(doublereal* const mobil_e);
virtual void getFluidMobilities(doublereal* const mobil_f);
//! Specify the value of the gradient of the voltage
/*!
* @param grad_V Gradient of the voltage (length num dimensions);
*/
virtual void set_Grad_V(const doublereal* const grad_V);
//! Specify the value of the gradient of the temperature
/*!
* @param grad_T Gradient of the temperature (length num dimensions);
*/
virtual void set_Grad_T(const doublereal* const grad_T);
//! Specify the value of the gradient of the MoleFractions
/*!
* @param grad_X Gradient of the mole fractions(length nsp * num dimensions);
*/
virtual void set_Grad_X(const doublereal* const grad_X);
//! Handles the effects of changes in the Temperature, internally
//! within the object.
/*!
* This is called whenever a transport property is requested. The first
* task is to check whether the temperature has changed since the last
* call to update_T(). If it hasn't then an immediate return is carried
* out.
*/
virtual void update_T();
//! Handles the effects of changes in the mixture concentration
/*!
* This is called the first time any transport property is requested from
* Mixture after the concentrations have changed.
*/
virtual void update_C();
virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
size_t ldx, const doublereal* const grad_X,
size_t ldf, doublereal* const fluxes);
//! Return the species diffusive mass fluxes wrt to the specified averaged velocity,
/*!
* This method acts similarly to getSpeciesFluxesES() but
* requires all gradients to be preset using methods set_Grad_X(), set_Grad_V(), set_Grad_T().
* See the documentation of getSpeciesFluxesES() for details.
*
* units = kg/m2/s
*
* Internally, gradients in the in mole fraction, temperature
* and electrostatic potential contribute to the diffusive flux
*
* The diffusive mass flux of species \e k is computed from the following formula
*
* \f[
* j_k = - \rho M_k D_k \nabla X_k - Y_k V_c
* \f]
*
* where V_c is the correction velocity
*
* \f[
* V_c = - \sum_j {\rho M_j D_j \nabla X_j}
* \f]
*
* @param ldf Stride of the fluxes array. Must be equal to or greater than the number of species.
* @param fluxes Output of the diffusive fluxes. Flat vector with the m_nsp in the inner loop.
* length = ldx * ndim
*/
virtual void getSpeciesFluxesExt(size_t ldf, doublereal* const fluxes);
//! Initialize the transport object
/*!
* Here we change all of the internal dimensions to be sufficient.
* We get the object ready to do property evaluations.
*
* @param tr Transport parameters for all of the species in the phase.
*/
virtual bool initLiquid(LiquidTransportParams& tr);
friend class TransportFactory;
/**
* Return a structure containing all of the pertinent parameters
* about a species that was used to construct the Transport
* properties in this object.
*
* @param k Species number to obtain the properties about.
*/
class LiquidTransportData getLiquidTransportData(int k);
//! Solve the Stefan-Maxwell equations for the diffusive fluxes.
void stefan_maxwell_solve();
private:
//! Local Copy of the molecular weights of the species
/*!
* Length is Equal to the number of species in the mechanism.
*/
vector_fp m_mw;
//! Polynomial coefficients of the viscosity
/*!
* These express the temperature dependence of the pure species viscosities.
*/
std::vector<vector_fp> m_visccoeffs;
//! Polynomial coefficients of the conductivities
/*!
* These express the temperature dependence of the pure species conductivities
*/
std::vector<vector_fp> m_condcoeffs;
//! Polynomial coefficients of the binary diffusion coefficients
/*!
* These express the temperature dependence of the binary diffusivities.
* An overall pressure dependence is then added.
*/
std::vector<vector_fp> m_diffcoeffs;
//! Internal value of the gradient of the mole fraction vector
/*!
* m_nsp is the number of species in the fluid
* k is the species index
* n is the dimensional index (x, y, or z). It has a length
* equal to m_nDim
*
* m_Grad_X[n*m_nsp + k]
*/
vector_fp m_Grad_X;
//! Internal value of the gradient of the Temperature vector
/*!
* Generally, if a transport property needs this in its evaluation it
* will look to this place to get it.
*
* No internal property is precalculated based on gradients. Gradients
* are assumed to be freshly updated before every property call.
*/
vector_fp m_Grad_T;
//! Internal value of the gradient of the Electric Voltage
/*!
* Generally, if a transport property needs this in its evaluation it
* will look to this place to get it.
*
* No internal property is precalculated based on gradients. Gradients
* are assumed to be freshly updated before every property call.
*/
vector_fp m_Grad_V;
//! Gradient of the electrochemical potential
/*!
* m_nsp is the number of species in the fluid
* k is the species index
* n is the dimensional index (x, y, or z)
*
* m_Grad_mu[n*m_nsp + k]
*/
vector_fp m_Grad_mu;
// property values
//! Array of Binary Diffusivities
/*!
* This has a size equal to nsp x nsp
* It is a symmetric matrix.
* D_ii is undefined.
*
* units m2/sec
*/
DenseMatrix m_bdiff;
//! Species viscosities
/*!
* Viscosity of the species
* Length = number of species
*
* Depends on the temperature and perhaps pressure, but
* not the species concentrations
*
* controlling update boolean -> m_spvisc_ok
*/
vector_fp m_visc;
//! Sqrt of the species viscosities
/*!
* The sqrt(visc) is used in the mixing formulas
* Length = m_nsp
*
* Depends on the temperature and perhaps pressure, but
* not the species concentrations
*
* controlling update boolean m_spvisc_ok
*/
vector_fp m_sqvisc;
//! Internal value of the species individual thermal conductivities
/*!
* Then a mixture rule is applied to get the solution conductivities
*
* Depends on the temperature and perhaps pressure, but
* not the species concentrations
*
* controlling update boolean -> m_spcond_ok
*/
vector_fp m_cond;
//! Polynomials of the log of the temperature
vector_fp m_polytempvec;
//! State of the mole fraction vector.
int m_iStateMF;
//! Local copy of the mole fractions of the species in the phase
/*!
* Update info?
* length = m_nsp
*/
vector_fp m_molefracs;
//! Local copy of the concentrations of the species in the phase
/*!
* Update info?
* length = m_nsp
*/
vector_fp m_concentrations;
//! Local copy of the charge of each species
/*!
* Contains the charge of each species (length m_nsp)
*/
vector_fp m_chargeSpecies;
//! Stefan-Maxwell Diffusion Coefficients at T, P and C
/*!
* These diffusion coefficients are considered to be
* a function of Temperature, Pressure, and Concentration.
*/
DenseMatrix m_DiffCoeff_StefMax;
//! viscosity weighting functions
DenseMatrix m_phi;
//! Matrix of the ratios of the species molecular weights
/*!
* m_wratjk(i,j) = (m_mw[j]/m_mw[k])**0.25
*/
DenseMatrix m_wratjk;
//! Matrix of the ratios of the species molecular weights
/*!
* m_wratkj1(i,j) = (1.0 + m_mw[k]/m_mw[j])**0.5
*/
DenseMatrix m_wratkj1;
//! RHS to the Stefan-Maxwell equation
Array2D m_B;
//! Matrix for the Stefan-Maxwell equation.
DenseMatrix m_A;
//! Internal storage for the species LJ well depth
vector_fp m_eps;
//! Internal storage for species polarizability
vector_fp m_alpha;
//! Current Temperature -> locally stored
/*!
* This is used to test whether new temperature computations
* should be performed.
*/
doublereal m_temp;
//! Current log(T)
doublereal m_logt;
//! Current value of kT
doublereal m_kbt;
//! Current Temperature **0.5
doublereal m_sqrt_t;
//! Current Temperature **0.25
doublereal m_t14;
//! Current Temperature **1.5
doublereal m_t32;
//! Current temperature function
/*!
* This is equal to sqrt(Boltzmann * T)
*/
doublereal m_sqrt_kbt;
//! Current value of the pressure
doublereal m_press;
//! Solution of the flux system
Array2D m_flux;
//! saved value of the mixture thermal conductivity
doublereal m_lambda;
//! Saved value of the mixture viscosity
doublereal m_viscmix;
//! work space of size m_nsp
vector_fp m_spwork;
//! Update the temperature-dependent viscosity terms.
/*!
* Updates the array of pure species viscosities, and the weighting
* functions in the viscosity mixture rule. The flag m_visc_ok is set to
* true.
*/
void updateViscosity_T();
//! Update the temperature-dependent parts of the mixture-averaged
//! thermal conductivity.
void updateCond_T();
//! Update the species viscosities
/*!
* Internal routine is run whenever the update_boolean
* m_spvisc_ok is false. This routine will calculate
* internal values for the species viscosities.
*/
void updateSpeciesViscosities();
//! Update the binary diffusion coefficients wrt T.
/*!
* These are evaluated from the polynomial fits at unit pressure (1 Pa).
*/
void updateDiff_T();
//! Boolean indicating that mixture viscosity is current
bool m_viscmix_ok;
//! Boolean indicating that weight factors wrt viscosity is current
bool m_viscwt_ok;
//! Flag to indicate that the pure species viscosities
//! are current wrt the temperature
bool m_spvisc_ok;
//! Boolean indicating that mixture diffusion coeffs are current
bool m_diffmix_ok;
//! Boolean indicating that binary diffusion coeffs are current
bool m_bindiff_ok;
//! Flag to indicate that the pure species conductivities
//! are current wrt the temperature
bool m_spcond_ok;
//! Boolean indicating that mixture conductivity is current
bool m_condmix_ok;
//! Mode for fitting the species viscosities
/*!
* Either it's CK_Mode or it's cantera mode
* in CK_Mode visc is fitted to a polynomial
* in Cantera mode sqrt(visc) is fitted.
*/
int m_mode;
//! Internal storage for the diameter - diameter
//! species interactions
DenseMatrix m_diam;
//! Debugging flags
/*!
* Turn on to get debugging information
*/
bool m_debug;
//! Number of dimensions
/*!
* Either 1, 2, or 3
*/
size_t m_nDim;
};
}
#endif

View file

@ -48,7 +48,6 @@ const int cDustyGasTransport = 400;
const int cUserTransport = 500;
const int cFtnTransport = 600;
const int cLiquidTransport = 700;
const int cAqueousTransport = 750;
const int cSimpleTransport = 770;
const int cRadiativeTransport = 800;
const int cWaterTransport = 721;

View file

@ -315,18 +315,5 @@ cdef class Mixture:
process. 0 indicates no output, while larger numbers produce
successively more verbose information.
"""
if isinstance(solver, int):
warnings.warn('Mixture.equilibrate: Using integer solver flags is '
'deprecated, and will be disabled after Cantera 2.2.')
if solver == -1:
solver = 'auto'
elif solver == 1:
solver = 'gibbs'
elif solver == 2:
solver = 'vcs'
else:
raise ValueError('Unrecognized equilibrium solver '
'specified: "{0}"'.format(solver))
self.mix.equilibrate(stringify(XY.upper()), stringify(solver), rtol,
max_steps, max_iter, estimate_equil, log_level)

View file

@ -328,21 +328,6 @@ cdef class ThermoPhase(_SolutionBase):
:param loglevel:
Set to a value > 0 to write diagnostic output.
"""
if isinstance(solver, int):
warnings.warn('ThermoPhase.equilibrate: Using integer solver '
'flags is deprecated, and will be disabled after Cantera 2.2.')
if solver == -1:
solver = 'auto'
elif solver == 0:
solver = 'element_potential'
elif solver == 1:
solver = 'gibbs'
elif solver == 2:
solver = 'vcs'
else:
raise ValueError('Invalid equilibrium solver specified: '
'"{0}"'.format(solver))
self.thermo.equilibrate(stringify(XY.upper()), stringify(solver), rtol,
maxsteps, maxiter, estimate_equil, loglevel)

View file

@ -123,12 +123,6 @@ void Application::Messages::setLogger(Logger* _logwriter)
logwriter = _logwriter;
}
void Application::Messages::logerror(const std::string& msg)
{
Cantera::warn_deprecated("Application::Messages::logerror");
logwriter->error(msg) ;
}
void Application::Messages::writelog(const std::string& msg)
{
logwriter->write(msg);

View file

@ -134,20 +134,6 @@ protected:
//! Write an end of line character to the screen and flush output
void writelogendl();
//! Write an error message and quit.
/*!
* The default behavior is to write to the standard error stream, and
* then call exit(). Note that no end-of-line character is appended
* to the message, and so if one is desired it must be included in
* the string. Note that this default behavior will terminate the
* application Cantera is invoked from (MATLAB, Excel, etc.) If this
* is not desired, then derive a class and reimplement this method.
*
* @param msg Error message to be written to cerr.
* @deprecated To be removed after Cantera 2.2
*/
void logerror(const std::string& msg) ;
//! Install a logger.
/*!
* Called by the language interfaces to install an appropriate logger.
@ -333,11 +319,6 @@ public:
pMessenger->writelogendl();
}
//! @copydoc Messages::logerror
void logerror(const std::string& msg) {
pMessenger->logerror(msg);
}
//! Print a warning indicating that *method* is deprecated. Additional
//! information (removal version, alternatives) can be specified in
//! *extra*. Deprecation warnings are printed once per method per

View file

@ -160,25 +160,6 @@ void getString(const XML_Node& node, const std::string& titleString, std::string
}
}
void getNamedStringValue(const XML_Node& node, const std::string& nameString, std::string& valueString,
std::string& typeString)
{
warn_deprecated("getNamedStringValue", "To be removed after Cantera 2.2");
valueString = "";
typeString = "";
if (node.hasChild(nameString)) {
XML_Node& xc = node.child(nameString);
valueString = xc.value();
typeString = xc["type"];
} else {
XML_Node* s = getByTitle(node, nameString);
if (s && s->name() == "string") {
valueString = s->value();
typeString = s->attrib("type");
}
}
}
void getIntegers(const XML_Node& node,
std::map<std::string, int>& v)
{

View file

@ -69,12 +69,6 @@ void writeline(char repeat, size_t count, bool endl_after, bool endl_before)
}
}
void error(const std::string& msg)
{
warn_deprecated("error", "To be removed after Cantera 2.2");
app()->logerror(msg);
}
void warn_deprecated(const std::string& method, const std::string& extra)
{
app()->warn_deprecated(method, extra);

View file

@ -164,69 +164,6 @@ compositionMap parseCompString(const std::string& ss,
return x;
}
void split(const std::string& ss, std::vector<std::string>& w)
{
warn_deprecated("split", "To be removed after Cantera 2.2.");
std::string s = ss;
std::string::size_type ibegin, iend;
std::string name, num, nm;
do {
ibegin = s.find_first_not_of(", ;\n\t");
if (ibegin != std::string::npos) {
s = s.substr(ibegin,s.size());
iend = s.find_first_of(", ;\n\t");
if (iend != std::string::npos) {
w.push_back(s.substr(0, iend));
s = s.substr(iend+1, s.size());
} else {
w.push_back(s.substr(0, s.size()));
return;
}
}
} while (s != "");
}
int fillArrayFromString(const std::string& str,
doublereal* const a, const char delim)
{
warn_deprecated("fillArrayFromString", "To be removed after Cantera 2.2.");
std::string::size_type iloc;
int count = 0;
std::string num;
std::string s = str;
while (s.size() > 0) {
iloc = s.find(delim);
if (iloc > 0) {
num = s.substr(0, iloc);
s = s.substr(iloc+1,s.size());
} else {
num = s;
s = "";
}
a[count] = fpValueCheck(num);
count++;
}
return count;
}
std::string getBaseName(const std::string& path)
{
warn_deprecated("getBaseName", "To be removed after Cantera 2.2.");
std::string file;
size_t idot = path.find_last_of('.');
size_t islash = path.find_last_of('/');
if (idot > 0 && idot < path.size()) {
if (islash > 0 && islash < idot) {
file = path.substr(islash+1, idot-islash-1);
} else {
file = path.substr(0,idot);
}
} else {
file = path;
}
return file;
}
int intValue(const std::string& val)
{
return std::atoi(stripws(val).c_str());
@ -287,14 +224,6 @@ doublereal fpValueCheck(const std::string& val)
return fpValue(str);
}
std::string logfileName(const std::string& infile)
{
warn_deprecated("logfileName", "To be removed after Cantera 2.2.");
std::string logfile = getBaseName(infile);
logfile += ".log";
return logfile;
}
std::string wrapString(const std::string& s, const int len)
{
int count=0;

View file

@ -97,26 +97,6 @@ public:
}
}
/**
* Assign one object (index j) to another (index i). This method
* is not used currently, and may be removed from the class in the
* future.
* @deprecated To be removed after Cantera 2.2
*/
static int assign(int i, int j) {
Cantera::warn_deprecated("Cabinet::assign",
"To be removed after Cantera 2.2.");
dataRef data = getData();
try {
M* src = data[j];
M* dest = data[i];
*dest = *src;
return 0;
} catch (...) {
return Cantera::handleAllExceptions(-1, -999);
}
}
/**
* Delete all objects but the first.
*/

View file

@ -122,15 +122,6 @@ extern "C" {
}
}
int func_assign(int i, int j)
{
try {
return FuncCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
double func_value(int i, double t)
{
try {

View file

@ -11,7 +11,6 @@ extern "C" {
CANTERA_CAPI int func_del(int i);
CANTERA_CAPI int func_clear();
CANTERA_CAPI int func_copy(int i);
CANTERA_CAPI int func_assign(int i, int j);
CANTERA_CAPI double func_value(int i, double t);
CANTERA_CAPI int func_derivative(int i);
CANTERA_CAPI int func_duplicate(int i);

View file

@ -55,15 +55,6 @@ extern "C" {
}
}
int mix_assign(int i, int j)
{
try {
return mixCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int mix_addPhase(int i, int j, double moles)
{
try {

View file

@ -11,7 +11,6 @@ extern "C" {
CANTERA_CAPI int mix_del(int i);
CANTERA_CAPI int mix_clear();
CANTERA_CAPI int mix_copy(int i);
CANTERA_CAPI int mix_assign(int i, int j);
CANTERA_CAPI int mix_addPhase(int i, int j, double moles);
CANTERA_CAPI int mix_init(int i);
CANTERA_CAPI size_t mix_nElements(int i);

View file

@ -454,22 +454,6 @@ extern "C" {
}
}
int stflow_solveSpeciesEqs(int i, int flag)
{
try {
if (flag > 0) {
DomainCabinet::get<StFlow>(i).solveSpecies(npos);
} else {
DomainCabinet::get<StFlow>(i).fixSpecies(npos);
}
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int stflow_solveEnergyEqn(int i, int flag)
{
try {

View file

@ -57,7 +57,6 @@ extern "C" {
CANTERA_CAPI double stflow_pressure(int i);
CANTERA_CAPI int stflow_setFixedTempProfile(int i, size_t n, double* pos,
size_t m, double* temp);
CANTERA_CAPI int stflow_solveSpeciesEqs(int i, int flag);
CANTERA_CAPI int stflow_solveEnergyEqn(int i, int flag);
CANTERA_CAPI int sim1D_clear();

View file

@ -62,15 +62,6 @@ extern "C" {
}
}
int reactor_assign(int i, int j)
{
try {
return ReactorCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int reactor_setInitialVolume(int i, double v)
{
try {
@ -249,15 +240,6 @@ extern "C" {
}
}
int reactornet_assign(int i, int j)
{
try {
return NetworkCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int reactornet_setInitialTime(int i, double t)
{
try {
@ -504,15 +486,6 @@ extern "C" {
}
}
int wall_assign(int i, int j)
{
try {
return WallCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int wall_install(int i, int n, int m)
{
try {

View file

@ -10,7 +10,6 @@ extern "C" {
CANTERA_CAPI int reactor_new(int type);
CANTERA_CAPI int reactor_del(int i);
CANTERA_CAPI int reactor_copy(int i);
CANTERA_CAPI int reactor_assign(int i, int j);
CANTERA_CAPI int reactor_setInitialVolume(int i, double v);
CANTERA_CAPI int reactor_setEnergy(int i, int eflag);
CANTERA_CAPI int reactor_setThermoMgr(int i, int n);
@ -30,7 +29,6 @@ extern "C" {
CANTERA_CAPI int reactornet_new();
CANTERA_CAPI int reactornet_del(int i);
CANTERA_CAPI int reactornet_copy(int i);
CANTERA_CAPI int reactornet_assign(int i, int j);
CANTERA_CAPI int reactornet_setInitialTime(int i, double t);
CANTERA_CAPI int reactornet_setMaxTimeStep(int i, double maxstep);
CANTERA_CAPI int reactornet_setTolerances(int i, double rtol, double atol);
@ -56,7 +54,6 @@ extern "C" {
CANTERA_CAPI int wall_new(int type);
CANTERA_CAPI int wall_del(int i);
CANTERA_CAPI int wall_copy(int i);
CANTERA_CAPI int wall_assign(int i, int j);
CANTERA_CAPI int wall_install(int i, int n, int m);
CANTERA_CAPI int wall_setkinetics(int i, int n, int m);
CANTERA_CAPI double wall_vdot(int i, double t);

View file

@ -51,15 +51,6 @@ extern "C" {
}
}
int rdiag_assign(int i, int j)
{
try {
return DiagramCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int rdiag_detailed(int i)
{
try {

View file

@ -84,15 +84,6 @@ extern "C" {
}
}
int xml_assign(int i, int j)
{
try {
return XmlCabinet::assign(i,j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int xml_build(int i, const char* file)
{
try {

View file

@ -18,7 +18,6 @@ extern "C" {
CANTERA_CAPI int xml_del(int i);
CANTERA_CAPI int xml_clear();
CANTERA_CAPI int xml_copy(int i);
CANTERA_CAPI int xml_assign(int i, int j);
CANTERA_CAPI int xml_build(int i, const char* file);
CANTERA_CAPI int xml_preprocess_and_build(int i, const char* file, int debug);
CANTERA_CAPI int xml_attrib(int i, const char* key, char* value);

View file

@ -558,15 +558,6 @@ doublereal MultiPhase::volume() const
return sum;
}
double MultiPhase::equilibrate(int XY, doublereal err, int maxsteps,
int maxiter, int loglevel)
{
warn_deprecated("MultiPhase::equilibrate(int XY, ...)",
"Use MultiPhase::equilibrate(string XY, ...) instead. To be removed "
"after Cantera 2.2.");
return equilibrate_MultiPhaseEquil(XY, err, maxsteps, maxiter, loglevel);
}
double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
int maxsteps, int maxiter,
int loglevel)

View file

@ -868,10 +868,6 @@ int vcs_Cantera_to_vprob(MultiPhase* mphase, VCS_PROB* vprob)
plogf("Unknown Cantera EOS to VCSnonideal: %d\n", eos);
}
VolPhase->m_eqnState = VCS_EOS_UNK_CANTERA;
if (!VolPhase->usingCanteraCalls()) {
throw CanteraError("vcs_Cantera_to_vprob",
"vcs functions asked for, but unimplemented");
}
break;
}
@ -982,7 +978,6 @@ int vcs_Cantera_to_vprob(MultiPhase* mphase, VCS_PROB* vprob)
* Transfer the thermo specification of the species
* vprob->SpeciesThermo[]
*/
ts_ptr->UseCanteraCalls = VolPhase->usingCanteraCalls();
ts_ptr->m_VCS_UnitsFormat = VolPhase->p_VCS_UnitsFormat;
/*
* Add lookback connectivity into the thermo object first
@ -1020,10 +1015,6 @@ int vcs_Cantera_to_vprob(MultiPhase* mphase, VCS_PROB* vprob)
}
ts_ptr->SS0_Model = VCS_SS0_NOTHANDLED;
ts_ptr->SSStar_Model = VCS_SSSTAR_NOTHANDLED;
if (!(ts_ptr->UseCanteraCalls)) {
throw CanteraError("vcs_Cantera_to_vprob",
"Cantera calls not being used -> aborting");
}
}
/*

View file

@ -37,7 +37,6 @@ vcs_VolPhase::vcs_VolPhase(VCS_SOLVE* owningSolverObject) :
m_existence(VCS_PHASE_EXIST_NO),
m_MFStartIndex(0),
IndSpecies(0),
m_useCanteraCalls(false),
TP_ptr(0),
v_totalMoles(0.0),
m_phiVarIndex(npos),
@ -80,7 +79,6 @@ vcs_VolPhase::vcs_VolPhase(const vcs_VolPhase& b) :
m_isIdealSoln(b.m_isIdealSoln),
m_existence(b.m_existence),
m_MFStartIndex(b.m_MFStartIndex),
m_useCanteraCalls(b.m_useCanteraCalls),
TP_ptr(b.TP_ptr),
v_totalMoles(b.v_totalMoles),
creationMoleNumbers_(0),
@ -152,7 +150,6 @@ vcs_VolPhase& vcs_VolPhase::operator=(const vcs_VolPhase& b)
ListSpeciesPtr[k] =
new vcs_SpeciesProperties(*(b.ListSpeciesPtr[k]));
}
m_useCanteraCalls = b.m_useCanteraCalls;
/*
* Do a shallow copy of the ThermoPhase object pointer.
* We don't duplicate the object.
@ -302,12 +299,7 @@ void vcs_VolPhase::_updateActCoeff() const
m_UpToDate_AC = true;
return;
}
if (m_useCanteraCalls) {
TP_ptr->getActivityCoefficients(VCS_DATA_PTR(ActCoeff));
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
}
TP_ptr->getActivityCoefficients(VCS_DATA_PTR(ActCoeff));
m_UpToDate_AC = true;
}
@ -321,20 +313,7 @@ double vcs_VolPhase::AC_calc_one(size_t kspec) const
void vcs_VolPhase::_updateG0() const
{
if (m_useCanteraCalls) {
TP_ptr->getGibbs_ref(VCS_DATA_PTR(SS0ChemicalPotential));
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
double R = vcsUtil_gasConstant(p_VCS_UnitsFormat);
for (size_t k = 0; k < m_numSpecies; k++) {
size_t kglob = IndSpecies[k];
vcs_SpeciesProperties* sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO* sTherm = sProp->SpeciesThermo;
SS0ChemicalPotential[k] =
R * (sTherm->G0_R_calc(kglob, Temp_));
}
}
TP_ptr->getGibbs_ref(VCS_DATA_PTR(SS0ChemicalPotential));
m_UpToDate_G0 = true;
}
@ -348,20 +327,7 @@ double vcs_VolPhase::G0_calc_one(size_t kspec) const
void vcs_VolPhase::_updateGStar() const
{
if (m_useCanteraCalls) {
TP_ptr->getStandardChemPotentials(VCS_DATA_PTR(StarChemicalPotential));
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
double R = vcsUtil_gasConstant(p_VCS_UnitsFormat);
for (size_t k = 0; k < m_numSpecies; k++) {
size_t kglob = IndSpecies[k];
vcs_SpeciesProperties* sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO* sTherm = sProp->SpeciesThermo;
StarChemicalPotential[k] =
R * (sTherm->GStar_R_calc(kglob, Temp_, Pres_));
}
}
TP_ptr->getStandardChemPotentials(VCS_DATA_PTR(StarChemicalPotential));
m_UpToDate_GStar = true;
}
@ -392,13 +358,8 @@ void vcs_VolPhase::setMoleFractions(const double* const xmol)
void vcs_VolPhase::_updateMoleFractionDependencies()
{
if (m_useCanteraCalls) {
if (TP_ptr) {
TP_ptr->setState_PX(Pres_, &(Xmol_[m_MFStartIndex]));
}
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
if (TP_ptr) {
TP_ptr->setState_PX(Pres_, &(Xmol_[m_MFStartIndex]));
}
if (!m_isIdealSoln) {
m_UpToDate_AC = false;
@ -625,12 +586,7 @@ void vcs_VolPhase::sendToVCS_GStar(double* const gstar) const
void vcs_VolPhase::setElectricPotential(const double phi)
{
m_phi = phi;
if (m_useCanteraCalls) {
TP_ptr->setElectricPotential(m_phi);
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
}
TP_ptr->setElectricPotential(m_phi);
// We have changed the state variable. Set uptodate flags to false
m_UpToDate_AC = false;
m_UpToDate_VolStar = false;
@ -650,13 +606,8 @@ void vcs_VolPhase::setState_TP(const double temp, const double pres)
return;
}
}
if (m_useCanteraCalls) {
TP_ptr->setElectricPotential(m_phi);
TP_ptr->setState_TP(temp, pres);
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
}
TP_ptr->setElectricPotential(m_phi);
TP_ptr->setState_TP(temp, pres);
Temp_ = temp;
Pres_ = pres;
m_UpToDate_AC = false;
@ -673,18 +624,7 @@ void vcs_VolPhase::setState_T(const double temp)
void vcs_VolPhase::_updateVolStar() const
{
if (m_useCanteraCalls) {
TP_ptr->getStandardVolumes(VCS_DATA_PTR(StarMolarVol));
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
for (size_t k = 0; k < m_numSpecies; k++) {
size_t kglob = IndSpecies[k];
vcs_SpeciesProperties* sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO* sTherm = sProp->SpeciesThermo;
StarMolarVol[k] = (sTherm->VolStar_calc(kglob, Temp_, Pres_));
}
}
TP_ptr->getStandardVolumes(VCS_DATA_PTR(StarMolarVol));
m_UpToDate_VolStar = true;
}
@ -698,22 +638,7 @@ double vcs_VolPhase::VolStar_calc_one(size_t kspec) const
double vcs_VolPhase::_updateVolPM() const
{
if (m_useCanteraCalls) {
TP_ptr->getPartialMolarVolumes(VCS_DATA_PTR(PartialMolarVol));
} else {
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
for (size_t k = 0; k < m_numSpecies; k++) {
size_t kglob = IndSpecies[k];
vcs_SpeciesProperties* sProp = ListSpeciesPtr[k];
VCS_SPECIES_THERMO* sTherm = sProp->SpeciesThermo;
StarMolarVol[k] = (sTherm->VolStar_calc(kglob, Temp_, Pres_));
}
for (size_t k = 0; k < m_numSpecies; k++) {
PartialMolarVol[k] = StarMolarVol[k];
}
}
TP_ptr->getPartialMolarVolumes(VCS_DATA_PTR(PartialMolarVol));
m_totalVol = 0.0;
for (size_t k = 0; k < m_numSpecies; k++) {
m_totalVol += PartialMolarVol[k] * Xmol_[k];
@ -834,54 +759,46 @@ void vcs_VolPhase::sendToVCS_LnActCoeffJac(Array2D& np_LnACJac_VCS)
void vcs_VolPhase::setPtrThermoPhase(ThermoPhase* tp_ptr)
{
TP_ptr = tp_ptr;
if (TP_ptr) {
m_useCanteraCalls = true;
Temp_ = TP_ptr->temperature();
Pres_ = TP_ptr->pressure();
setState_TP(Temp_, Pres_);
p_VCS_UnitsFormat = VCS_UNITS_MKS;
m_phi = TP_ptr->electricPotential();
size_t nsp = TP_ptr->nSpecies();
size_t nelem = TP_ptr->nElements();
if (nsp != m_numSpecies) {
if (m_numSpecies != 0) {
plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, m_numSpecies);
}
resize(VP_ID_, nsp, nelem, PhaseName.c_str());
Temp_ = TP_ptr->temperature();
Pres_ = TP_ptr->pressure();
setState_TP(Temp_, Pres_);
p_VCS_UnitsFormat = VCS_UNITS_MKS;
m_phi = TP_ptr->electricPotential();
size_t nsp = TP_ptr->nSpecies();
size_t nelem = TP_ptr->nElements();
if (nsp != m_numSpecies) {
if (m_numSpecies != 0) {
plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, m_numSpecies);
}
TP_ptr->getMoleFractions(VCS_DATA_PTR(Xmol_));
creationMoleNumbers_ = Xmol_;
_updateMoleFractionDependencies();
resize(VP_ID_, nsp, nelem, PhaseName.c_str());
}
TP_ptr->getMoleFractions(VCS_DATA_PTR(Xmol_));
creationMoleNumbers_ = Xmol_;
_updateMoleFractionDependencies();
/*
* figure out ideal solution tag
*/
if (nsp == 1) {
m_isIdealSoln = true;
} else {
int eos = TP_ptr->eosType();
switch (eos) {
case cIdealGas:
case cIncompressible:
case cSurf:
case cMetal:
case cStoichSubstance:
case cSemiconductor:
case cLatticeSolid:
case cLattice:
case cEdge:
case cIdealSolidSolnPhase:
m_isIdealSoln = true;
break;
default:
m_isIdealSoln = false;
};
}
/*
* figure out ideal solution tag
*/
if (nsp == 1) {
m_isIdealSoln = true;
} else {
m_useCanteraCalls = false;
warn_deprecated("m_useCanteraCalls", "Setting this flag to 'false' is "
"deprecated and will not work after Cantera 2.2.");
int eos = TP_ptr->eosType();
switch (eos) {
case cIdealGas:
case cIncompressible:
case cSurf:
case cMetal:
case cStoichSubstance:
case cSemiconductor:
case cLatticeSolid:
case cLattice:
case cEdge:
case cIdealSolidSolnPhase:
m_isIdealSoln = true;
break;
default:
m_isIdealSoln = false;
};
}
}
@ -990,11 +907,6 @@ bool vcs_VolPhase::isIdealSoln() const
return m_isIdealSoln;
}
bool vcs_VolPhase::usingCanteraCalls() const
{
return m_useCanteraCalls;
}
size_t vcs_VolPhase::phiVarIndex() const
{
return m_phiVarIndex;

View file

@ -1,289 +0,0 @@
/*!
* @file vcs_rank.cpp
* Header file for the internal class that holds the problem.
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#include "cantera/equil/vcs_solve.h"
#include "cantera/base/ctexceptions.h"
#include <cstdio>
using namespace std;
namespace Cantera {
static int basisOptMax1(const double * const molNum,
const int n) {
// int largest = 0;
for (int i = 0; i < n; ++i) {
if (molNum[i] > -1.0E200 && fabs(molNum[i]) > 1.0E-13) {
return i;
}
}
for (int i = 0; i < n; ++i) {
if (molNum[i] > -1.0E200) {
return i;
}
}
return n-1;
}
int VCS_SOLVE::vcs_rank(const double * awtmp, size_t numSpecies, const double matrix[], size_t numElemConstraints,
std::vector<size_t> &compRes, std::vector<size_t>& elemComp, int * const usedZeroedSpecies) const
{
warn_deprecated("VCS_SOLVE::vcs_rank", "To be removed after Cantera 2.2");
int lindep;
size_t j, k, jl, i, l, ml;
int numComponents = 0;
compRes.clear();
elemComp.clear();
vector<double> sm(numElemConstraints*numSpecies);
vector<double> sa(numSpecies);
vector<double> ss(numSpecies);
double test = -0.2512345E298;
if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
plogf(" "); for(i=0; i<77; i++) plogf("-"); plogf("\n");
plogf(" --- Subroutine vcs_rank called to ");
plogf("calculate the rank and independent rows /colums of the following matrix\n");
if (m_debug_print_lvl >= 5) {
plogf(" --- Species | ");
for (j = 0; j < numElemConstraints; j++) {
plogf(" ");
plogf(" %3d ", j);
}
plogf("\n");
plogf(" --- -----------");
for (j = 0; j < numElemConstraints; j++) {
plogf("---------");
}
plogf("\n");
for (k = 0; k < numSpecies; k++) {
plogf(" --- ");
plogf(" %3d ", k);
plogf(" |");
for (j = 0; j < numElemConstraints; j++) {
plogf(" %8.2g", matrix[j*numSpecies + k]);
}
plogf("\n");
}
plogf(" ---");
plogendl();
}
}
/*
* Calculate the maximum value of the number of components possible
* It's equal to the minimum of the number of elements and the
* number of total species.
*/
int ncTrial = static_cast<int>(std::min(numElemConstraints, numSpecies));
numComponents = ncTrial;
*usedZeroedSpecies = false;
/*
* Use a temporary work array for the mole numbers, aw[]
*/
std::vector<double> aw(numSpecies);
for (j = 0; j < numSpecies; j++) {
aw[j] = awtmp[j];
}
int jr = -1;
/*
* Top of a loop of some sort based on the index JR. JR is the
* current number of component species found.
*/
do {
++jr;
/* - Top of another loop point based on finding a linearly */
/* - independent species */
do {
/*
* Search the remaining part of the mole number vector, AW,
* for the largest remaining species. Return its identity in K.
* The first search criteria is always the largest positive
* magnitude of the mole number.
*/
k = basisOptMax1(VCS_DATA_PTR(aw), static_cast<int>(numSpecies));
if ((aw[k] != test) && fabs(aw[k]) == 0.0) {
*usedZeroedSpecies = true;
}
if (aw[k] == test) {
numComponents = jr;
goto L_CLEANUP;
}
/*
* Assign a small negative number to the component that we have
* just found, in order to take it out of further consideration.
*/
aw[k] = test;
/* *********************************************************** */
/* **** CHECK LINEAR INDEPENDENCE WITH PREVIOUS SPECIES ****** */
/* *********************************************************** */
/*
* Modified Gram-Schmidt Method, p. 202 Dalquist
* QR factorization of a matrix without row pivoting.
*/
jl = jr;
for (j = 0; j < numElemConstraints; ++j) {
sm[j + jr*numElemConstraints] = matrix[j*numSpecies + k];
}
if (jl > 0) {
/*
* Compute the coefficients of JA column of the
* the upper triangular R matrix, SS(J) = R_J_JR
* (this is slightly different than Dalquist)
* R_JA_JA = 1
*/
for (j = 0; j < jl; ++j) {
ss[j] = 0.0;
for (i = 0; i < numElemConstraints; ++i) {
ss[j] += sm[i + jr* numElemConstraints] * sm[i + j* numElemConstraints];
}
ss[j] /= sa[j];
}
/*
* Now make the new column, (*,JR), orthogonal to the
* previous columns
*/
for (j = 0; j < jl; ++j) {
for (l = 0; l < numElemConstraints; ++l) {
sm[l + jr*numElemConstraints] -= ss[j] * sm[l + j*numElemConstraints];
}
}
}
/*
* Find the new length of the new column in Q.
* It will be used in the denominator in future row calcs.
*/
sa[jr] = 0.0;
for (ml = 0; ml < numElemConstraints; ++ml) {
sa[jr] += pow(sm[ml + jr * numElemConstraints], 2);
}
/* **************************************************** */
/* **** IF NORM OF NEW ROW .LT. 1E-3 REJECT ********** */
/* **************************************************** */
if (sa[jr] < 1.0e-6) lindep = true;
else lindep = false;
} while(lindep);
/* ****************************************** */
/* **** REARRANGE THE DATA ****************** */
/* ****************************************** */
compRes.push_back(k);
elemComp.push_back(jr);
} while (jr < (ncTrial-1));
L_CLEANUP: ;
if (numComponents == ncTrial && numElemConstraints == numSpecies) {
return numComponents;
}
int numComponentsR = numComponents;
ss.resize(numElemConstraints);
sa.resize(numElemConstraints);
elemComp.clear();
aw.resize(numElemConstraints);
for (j = 0; j < numSpecies; j++) {
aw[j] = 1.0;
}
jr = -1;
do {
++jr;
do {
k = basisOptMax1(VCS_DATA_PTR(aw), static_cast<int>(numElemConstraints));
if (aw[k] == test) {
numComponents = jr;
goto LE_CLEANUP;
}
aw[k] = test;
jl = jr;
for (j = 0; j < numSpecies; ++j) {
sm[j + jr*numSpecies] = matrix[k*numSpecies + j];
}
if (jl > 0) {
for (j = 0; j < jl; ++j) {
ss[j] = 0.0;
for (i = 0; i < numSpecies; ++i) {
ss[j] += sm[i + jr* numSpecies] * sm[i + j* numSpecies];
}
ss[j] /= sa[j];
}
for (j = 0; j < jl; ++j) {
for (l = 0; l < numSpecies; ++l) {
sm[l + jr*numSpecies] -= ss[j] * sm[l + j*numSpecies];
}
}
}
sa[jr] = 0.0;
for (ml = 0; ml < numSpecies; ++ml) {
sa[jr] += pow(sm[ml + jr * numSpecies], 2);
}
if (sa[jr] < 1.0e-6) lindep = true;
else lindep = false;
} while(lindep);
elemComp.push_back(k);
} while (jr < (ncTrial-1));
numComponents = jr;
LE_CLEANUP: ;
if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
plogf(" --- vcs_rank found rank %d\n", numComponents);
if (m_debug_print_lvl >= 5) {
if (compRes.size() == elemComp.size()) {
printf(" --- compRes elemComp\n");
for (int i = 0; i < (int) compRes.size(); i++) {
printf(" --- %d %d \n", (int) compRes[i], (int) elemComp[i]);
}
} else {
for (int i = 0; i < (int) compRes.size(); i++) {
printf(" --- compRes[%d] = %d \n", (int) i, (int) compRes[i]);
}
for (int i = 0; i < (int) elemComp.size(); i++) {
printf(" --- elemComp[%d] = %d \n", (int) i, (int) elemComp[i]);
}
}
}
}
if (numComponentsR != numComponents) {
printf("vcs_rank ERROR: number of components are different: %d %d\n", numComponentsR, numComponents);
throw CanteraError("vcs_rank ERROR:",
" logical inconsistency");
exit(-1);
}
return numComponents;
}
}

View file

@ -1,393 +0,0 @@
/**
* @file vcs_root1d.cpp
* Code for a one dimensional root finder program.
*/
/*
* Copyright (2006) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#include "cantera/equil/vcs_internal.h"
#include "cantera/equil/vcs_defs.h"
#include "cantera/numerics/ctlapack.h"
#include <cstdio>
namespace Cantera
{
#define TOL_CONV 1.0E-5
static void print_funcEval(FILE* fp, double xval, double fval, int its)
{
fprintf(fp,"\n");
fprintf(fp,"...............................................................\n");
fprintf(fp,".................. vcs_root1d Function Evaluation .............\n");
fprintf(fp,".................. iteration = %5d ........................\n", its);
fprintf(fp,".................. value = %12.5g ......................\n", xval);
fprintf(fp,".................. funct = %12.5g ......................\n", fval);
fprintf(fp,"...............................................................\n");
fprintf(fp,"\n");
}
int vcsUtil_root1d(double xmin, double xmax, size_t itmax,
VCS_FUNC_PTR func, void* fptrPassthrough,
double FuncTargVal, int varID,
double* xbest, int printLvl)
{
warn_deprecated("vcsUtil_root1d", "To be removed after Cantera 2.2.");
static int callNum = 0;
const char* stre = "vcs_root1d ERROR: ";
const char* strw = "vcs_root1d WARNING: ";
bool converged = false;
int err = 0;
#ifdef DEBUG_MODE
char fileName[80];
#else
char* fileName;
#endif
FILE* fp = 0;
double x1, x2, xnew, f1, f2, fnew, slope;
size_t its = 0;
int posStraddle = 0;
int retn = VCS_SUCCESS;
bool foundPosF = false;
bool foundNegF = false;
bool foundStraddle = false;
double xPosF = 0.0;
double xNegF = 0.0;
double fnorm; /* A valid norm for the making the function value
* dimensionless */
double c[9], f[3], xn1, xn2, x0 = 0.0, f0 = 0.0, root, theta, xquad;
callNum++;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
sprintf(fileName, "rootfd_%d.log", callNum);
fp = fopen(fileName, "w");
fprintf(fp, " Iter TP_its xval Func_val | Reasoning\n");
fprintf(fp, "-----------------------------------------------------"
"-------------------------------\n");
} else if (printLvl >= 3) {
plogf("WARNING: vcsUtil_root1d: printlvl >= 3, but debug mode not turned on\n");
}
if (xmax <= xmin) {
plogf("%sxmin and xmax are bad: %g %g\n", stre, xmin, xmax);
return VCS_PUB_BAD;
}
x1 = *xbest;
if (x1 < xmin || x1 > xmax) {
x1 = (xmin + xmax) / 2.0;
}
f1 = func(x1, FuncTargVal, varID, fptrPassthrough, &err);
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
print_funcEval(fp, x1, f1, static_cast<int>(its));
fprintf(fp, "%-5d %-5d %-15.5E %-15.5E\n", -2, 0, x1, f1);
}
if (f1 == 0.0) {
*xbest = x1;
return VCS_SUCCESS;
} else if (f1 > 0.0) {
foundPosF = true;
xPosF = x1;
} else {
foundNegF = true;
xNegF = x1;
}
x2 = x1 * 1.1;
if (x2 > xmax) {
x2 = x1 - (xmax - xmin) / 100.;
}
f2 = func(x2, FuncTargVal, varID, fptrPassthrough, &err);
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
print_funcEval(fp, x2, f2, static_cast<int>(its));
fprintf(fp, "%-5d %-5d %-15.5E %-15.5E", -1, 0, x2, f2);
}
if (FuncTargVal != 0.0) {
fnorm = fabs(FuncTargVal) + 1.0E-13;
} else {
fnorm = 0.5*(fabs(f1) + fabs(f2)) + fabs(FuncTargVal);
}
if (f2 == 0.0) {
return retn;
} else if (f2 > 0.0) {
if (!foundPosF) {
foundPosF = true;
xPosF = x2;
}
} else {
if (!foundNegF) {
foundNegF = true;
xNegF = x2;
}
}
foundStraddle = foundPosF && foundNegF;
if (foundStraddle) {
if (xPosF > xNegF) {
posStraddle = true;
} else {
posStraddle = false;
}
}
int ipiv[3];
int info;
do {
/*
* Find an estimate of the next point to try based on
* a linear approximation.
*/
slope = (f2 - f1) / (x2 - x1);
if (slope == 0.0) {
plogf("%s functions evals produced the same result, %g, at %g and %g\n",
strw, f2, x1, x2);
xnew = 2*x2 - x1 + 1.0E-3;
} else {
xnew = x2 - f2 / slope;
}
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | xlin = %-9.4g", xnew);
}
/*
* Do a quadratic fit -> Note this algorithm seems
* to work OK. The quadratic approximation doesn't kick in until
* the end of the run, when it becomes reliable.
*/
if (its > 0) {
c[0] = 1.;
c[1] = 1.;
c[2] = 1.;
c[3] = x0;
c[4] = x1;
c[5] = x2;
c[6] = pow(x0, 2);
c[7] = pow(x1, 2);
c[8] = pow(x2, 2);
f[0] = f0;
f[1] = f1;
f[2] = f2;
ct_dgetrf(3, 3, c, 3, ipiv, info);
if (info) {
goto QUAD_BAIL;
}
ct_dgetrs(ctlapack::NoTranspose, 3, 1, c, 3, ipiv, f, 3, info);
root = f[1]* f[1] - 4.0 * f[0] * f[2];
if (root >= 0.0) {
xn1 = (- f[1] + sqrt(root)) / (2.0 * f[2]);
xn2 = (- f[1] - sqrt(root)) / (2.0 * f[2]);
if (fabs(xn2 - x2) < fabs(xn1 - x2) && xn2 > 0.0) {
xquad = xn2;
} else {
xquad = xn1;
}
theta = fabs(xquad - xnew) / fabs(xnew - x2);
theta = std::min(1.0, theta);
xnew = theta * xnew + (1.0 - theta) * xquad;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
if (theta != 1.0) {
fprintf(fp, " | xquad = %-9.4g", xnew);
}
}
} else {
/*
* Pick out situations where the convergence may be
* accelerated.
*/
if ((sign(xnew - x2) == sign(x2 - x1)) &&
(sign(x2 - x1) == sign(x1 - x0))) {
xnew += xnew - x2;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | xquada = %-9.4g", xnew);
}
}
}
}
QUAD_BAIL:
;
/*
*
* Put heuristic bounds on the step jump
*/
if ((xnew > x1 && xnew < x2) || (xnew < x1 && xnew > x2)) {
/*
*
* If we are doing a jump in between two points, make sure
* the new trial is between 10% and 90% of the distance
* between the old points.
*/
slope = fabs(x2 - x1) / 10.;
if (fabs(xnew - x1) < slope) {
xnew = x1 + sign(xnew-x1) * slope;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | x10%% = %-9.4g", xnew);
}
}
if (fabs(xnew - x2) < slope) {
xnew = x2 + sign(xnew-x2) * slope;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | x10%% = %-9.4g", xnew);
}
}
} else {
/*
* If we are venturing into new ground, only allow the step jump
* to increase by 100% at each iteration
*/
slope = 2.0 * fabs(x2 - x1);
if (fabs(slope) < fabs(xnew - x2)) {
xnew = x2 + sign(xnew-x2) * slope;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | xlimitsize = %-9.4g", xnew);
}
}
}
if (xnew > xmax) {
xnew = x2 + (xmax - x2) / 2.0;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | xlimitmax = %-9.4g", xnew);
}
}
if (xnew < xmin) {
xnew = x2 + (x2 - xmin) / 2.0;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | xlimitmin = %-9.4g", xnew);
}
}
if (foundStraddle) {
#ifdef DEBUG_MODE
slope = xnew;
#endif
if (posStraddle) {
if (f2 > 0.0) {
if (xnew > x2) {
xnew = (xNegF + x2)/2;
}
if (xnew < xNegF) {
xnew = (xNegF + x2)/2;
}
} else {
if (xnew < x2) {
xnew = (xPosF + x2)/2;
}
if (xnew > xPosF) {
xnew = (xPosF + x2)/2;
}
}
} else {
if (f2 > 0.0) {
if (xnew < x2) {
xnew = (xNegF + x2)/2;
}
if (xnew > xNegF) {
xnew = (xNegF + x2)/2;
}
} else {
if (xnew > x2) {
xnew = (xPosF + x2)/2;
}
if (xnew < xPosF) {
xnew = (xPosF + x2)/2;
}
}
}
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
if (slope != xnew) {
fprintf(fp, " | xstraddle = %-9.4g", xnew);
}
}
}
fnew = func(xnew, FuncTargVal, varID, fptrPassthrough, &err);
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp,"\n");
print_funcEval(fp, xnew, fnew, static_cast<int>(its));
fprintf(fp, "%-5d %-5d %-15.5E %-15.5E", (int) its, 0, xnew, fnew);
}
if (foundStraddle) {
if (posStraddle) {
if (fnew > 0.0) {
if (xnew < xPosF) {
xPosF = xnew;
}
} else {
if (xnew > xNegF) {
xNegF = xnew;
}
}
} else {
if (fnew > 0.0) {
if (xnew > xPosF) {
xPosF = xnew;
}
} else {
if (xnew < xNegF) {
xNegF = xnew;
}
}
}
}
if (! foundStraddle) {
if (fnew > 0.0) {
if (!foundPosF) {
foundPosF = true;
xPosF = xnew;
foundStraddle = true;
posStraddle = (xPosF > xNegF);
}
} else {
if (!foundNegF) {
foundNegF = true;
xNegF = xnew;
foundStraddle = true;
posStraddle = (xPosF > xNegF);
}
}
}
x0 = x1;
f0 = f1;
x1 = x2;
f1 = f2;
x2 = xnew;
f2 = fnew;
if (fabs(fnew / fnorm) < 1.0E-5) {
converged = true;
}
its++;
} while (! converged && its < itmax);
if (converged) {
if (printLvl >= 1) {
plogf("vcs_root1d success: convergence achieved\n");
}
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, " | vcs_root1d success in %d its, fnorm = %g\n", (int) its, fnorm);
}
} else {
retn = VCS_FAILED_CONVERGENCE;
if (printLvl >= 1) {
plogf("vcs_root1d ERROR: maximum iterations exceeded without convergence\n");
}
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fprintf(fp, "\nvcs_root1d failure in %lu its\n", its);
}
}
*xbest = x2;
if (DEBUG_MODE_ENABLED && printLvl >= 3) {
fclose(fp);
}
return retn;
}
}

View file

@ -35,7 +35,6 @@ VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(size_t indexPhase,
SSStar_Model(VCS_SSSTAR_CONSTANT),
SSStar_Vol_Model(VCS_SSVOL_IDEALGAS),
SSStar_Vol0(-1.0),
UseCanteraCalls(false),
m_VCS_UnitsFormat(VCS_UNITS_UNITLESS)
{
SS0_Pref = 1.01325E5;
@ -56,7 +55,6 @@ VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(const VCS_SPECIES_THERMO& b) :
SSStar_Model(b.SSStar_Model),
SSStar_Vol_Model(b.SSStar_Vol_Model),
SSStar_Vol0(b.SSStar_Vol0),
UseCanteraCalls(b.UseCanteraCalls),
m_VCS_UnitsFormat(b.m_VCS_UnitsFormat)
{
}
@ -79,7 +77,6 @@ VCS_SPECIES_THERMO::operator=(const VCS_SPECIES_THERMO& b)
SSStar_Model = b.SSStar_Model;
SSStar_Vol_Model = b.SSStar_Vol_Model;
SSStar_Vol0 = b.SSStar_Vol0;
UseCanteraCalls = b.UseCanteraCalls;
m_VCS_UnitsFormat = b.m_VCS_UnitsFormat;
}
return *this;
@ -94,30 +91,15 @@ double VCS_SPECIES_THERMO::GStar_R_calc(size_t kglob, double TKelvin,
double pres)
{
double fe = G0_R_calc(kglob, TKelvin);
double T = TKelvin;
if (UseCanteraCalls) {
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::GStar_R_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_TP(TKelvin, pres);
fe = OwningPhase->GStar_calc_one(kspec);
double R = vcsUtil_gasConstant(m_VCS_UnitsFormat);
fe /= R;
} else {
double pref = SS0_Pref;
switch (SSStar_Model) {
case VCS_SSSTAR_CONSTANT:
break;
case VCS_SSSTAR_IDEAL_GAS:
fe += T * log(pres/ pref);
break;
default:
throw CanteraError("VCS_SPECIES_THERMO::GStar_R_calc",
"unknown SSStar model");
}
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::GStar_R_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_TP(TKelvin, pres);
fe = OwningPhase->GStar_calc_one(kspec);
double R = vcsUtil_gasConstant(m_VCS_UnitsFormat);
fe /= R;
return fe;
}
@ -125,66 +107,33 @@ double VCS_SPECIES_THERMO::VolStar_calc(size_t kglob, double TKelvin,
double presPA)
{
double vol;
double T = TKelvin;
if (UseCanteraCalls) {
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::VolStar_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_TP(TKelvin, presPA);
vol = OwningPhase->VolStar_calc_one(kspec);
} else {
switch (SSStar_Vol_Model) {
case VCS_SSVOL_CONSTANT:
vol = SSStar_Vol0;
break;
case VCS_SSVOL_IDEALGAS:
vol= GasConstant * T / presPA;
break;
default:
throw CanteraError("VCS_SPECIES_THERMO::VolStar_calc",
"unknown SSVol model");
}
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::VolStar_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_TP(TKelvin, presPA);
vol = OwningPhase->VolStar_calc_one(kspec);
return vol;
}
double VCS_SPECIES_THERMO::G0_R_calc(size_t kglob, double TKelvin)
{
double fe, H, S;
if (SS0_Model == VCS_SS0_CONSTANT) {
return SS0_feSave;
}
if (TKelvin == SS0_TSave) {
return SS0_feSave;
}
if (UseCanteraCalls) {
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::G0_R_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_T(TKelvin);
fe = OwningPhase->G0_calc_one(kspec);
double R = vcsUtil_gasConstant(m_VCS_UnitsFormat);
fe /= R;
} else {
switch (SS0_Model) {
case VCS_SS0_CONSTANT:
fe = SS0_feSave;
break;
case VCS_SS0_CONSTANT_CP:
H = SS0_H0 + (TKelvin - SS0_T0) * SS0_Cp0;
S = SS0_Cp0 + SS0_Cp0 * log((TKelvin / SS0_T0));
fe = H - TKelvin * S;
break;
default:
throw CanteraError("VCS_SPECIES_THERMO::G0_R_calc",
"unknown model");
}
if (m_VCS_UnitsFormat != VCS_UNITS_MKS) {
throw CanteraError("VCS_SPECIES_THERMO::G0_R_calc",
"Possible inconsistency");
}
size_t kspec = IndexSpeciesPhase;
OwningPhase->setState_T(TKelvin);
double fe = OwningPhase->G0_calc_one(kspec);
double R = vcsUtil_gasConstant(m_VCS_UnitsFormat);
fe /= R;
SS0_feSave = fe;
SS0_TSave = TKelvin;
return fe;
@ -192,19 +141,14 @@ double VCS_SPECIES_THERMO::G0_R_calc(size_t kglob, double TKelvin)
double VCS_SPECIES_THERMO::eval_ac(size_t kglob)
{
double ac;
/*
* Activity coefficients are frequently evaluated on a per phase
* basis. If they are, then the currPhAC[] boolean may be used
* to reduce repeated work. Just set currPhAC[iph], when the
* activity coefficients for all species in the phase are reevaluated.
*/
if (UseCanteraCalls) {
size_t kspec = IndexSpeciesPhase;
ac = OwningPhase->AC_calc_one(kspec);
} else {
ac = 1.0;
}
size_t kspec = IndexSpeciesPhase;
double ac = OwningPhase->AC_calc_one(kspec);
return ac;
}

View file

@ -59,20 +59,6 @@ size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n)
return largest;
}
int vcs_max_int(const int* vector, int length)
{
warn_deprecated("vcs_max_int", "Unused. To be removed after Cantera 2.2.");
int retn;
if (vector == NULL || length <= 0) {
return 0;
}
retn = vector[0];
for (int i = 1; i < length; i++) {
retn = std::max(retn, vector[i]);
}
return retn;
}
double vcsUtil_gasConstant(int mu_units)
{
switch (mu_units) {

View file

@ -97,15 +97,6 @@ extern "C" {
}
}
status_t fxml_assign_(const integer* i, const integer* j)
{
try {
return XmlCabinet::assign(*i,*j);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
status_t fxml_attrib_(const integer* i, const char* key, char* value,
ftnlen keylen, ftnlen valuelen)
{

View file

@ -24,11 +24,6 @@ interface
integer, intent(in) :: i
end function fxml_copy
integer function fxml_assign(i, j)
integer, intent(in) :: i
integer, intent(in) :: j
end function fxml_assign
integer function fxml_preprocess_and_build(i, file)
integer, intent(in) :: i
character*(*), intent(in) :: file

View file

@ -12,7 +12,6 @@
#include "cantera/kinetics/AqueousKinetics.h"
#include "cantera/kinetics/Reaction.h"
#include "cantera/base/vec_functions.h"
using namespace std;

View file

@ -1,929 +0,0 @@
/**
* @file ElectrodeKinetics.cpp
*/
#include "cantera/kinetics/ElectrodeKinetics.h"
#include "cantera/thermo/SurfPhase.h"
#include "cantera/base/utilities.h"
#include "cantera/base/global.h"
#include <cstdio>
using namespace std;
namespace Cantera
{
//============================================================================================================================
ElectrodeKinetics::ElectrodeKinetics(thermo_t* thermo) :
InterfaceKinetics(thermo),
metalPhaseIndex_(npos),
solnPhaseIndex_(npos),
kElectronIndex_(npos)
{
warn_deprecated("class ElectrodeKinetics",
"To be removed after Cantera 2.2.");
}
//============================================================================================================================
ElectrodeKinetics::~ElectrodeKinetics()
{
for (size_t i = 0; i < rmcVector.size(); i++) {
delete rmcVector[i];
}
}
//============================================================================================================================
ElectrodeKinetics::ElectrodeKinetics(const ElectrodeKinetics& right) :
InterfaceKinetics()
{
/*
* Call the assignment operator
*/
ElectrodeKinetics::operator=(right);
}
//============================================================================================================================
ElectrodeKinetics& ElectrodeKinetics::operator=(const ElectrodeKinetics& right)
{
/*
* Check for self assignment.
*/
if (this == &right) {
return *this;
}
InterfaceKinetics::operator=(right);
metalPhaseIndex_ = right.metalPhaseIndex_;
solnPhaseIndex_ = right.solnPhaseIndex_;
kElectronIndex_ = right.kElectronIndex_;
for (size_t i = 0; i < rmcVector.size(); i++) {
delete rmcVector[i];
}
rmcVector.resize(m_ii, 0);
for (size_t i = 0; i < m_ii; i++) {
if (right.rmcVector[i]) {
rmcVector[i] = new RxnMolChange(*(right.rmcVector[i]));
}
}
return *this;
}
//============================================================================================================================
int ElectrodeKinetics::type() const
{
return cInterfaceKinetics;
}
//============================================================================================================================
Kinetics* ElectrodeKinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const
{
ElectrodeKinetics* iK = new ElectrodeKinetics(*this);
iK->assignShallowPointers(tpVector);
return iK;
}
//============================================================================================================================
// Identify the metal phase and the electron species
void ElectrodeKinetics::identifyMetalPhase()
{
metalPhaseIndex_ = npos;
kElectronIndex_ = npos;
solnPhaseIndex_ = npos;
size_t np = nPhases();
//
// Identify the metal phase as the phase with the electron species (element index of 1 for element E
// Should probably also stipulate a charge of -1.
//
for (size_t iph = 0; iph < np; iph++) {
ThermoPhase* tp = m_thermo[iph];
size_t nSpecies = tp->nSpecies();
size_t nElements = tp->nElements();
size_t eElectron = tp->elementIndex("E");
if (eElectron != npos) {
for (size_t k = 0; k < nSpecies; k++) {
if (tp->nAtoms(k,eElectron) == 1) {
int ifound = 1;
for (size_t e = 0; e < nElements; e++) {
if (tp->nAtoms(k,e) != 0.0) {
if (e != eElectron) {
ifound = 0;
}
}
}
if (ifound == 1) {
metalPhaseIndex_ = iph;
kElectronIndex_ = m_start[iph] + k;
}
}
}
}
//
// Identify the solution phase as a 3D phase, with nonzero phase charge change
// in at least one reaction
//
/*
* Haven't filled in reactions yet when this is called, unlike previous treatment.
if (iph != metalPhaseIndex_) {
for (size_t i = 0; i < m_ii; i++) {
RxnMolChange* rmc = rmcVector[i];
if (rmc->m_phaseChargeChange[iph] != 0) {
if (rmc->m_phaseDims[iph] == 3) {
solnPhaseIndex_ = iph;
break;
}
}
}
}
*/
//
// New method is to find the first multispecies 3D phase with charged species as the solution phase
//
if (iph != metalPhaseIndex_) {
ThermoPhase& tp =*( m_thermo[iph]);
size_t nsp = tp.nSpecies();
size_t nd = tp.nDim();
if (nd == 3 && nsp > 1) {
for (size_t k = 0; k < nsp; k++) {
if (tp.charge(k) != 0.0) {
solnPhaseIndex_ = iph;
string ss = tp.name();
// cout << "solution phase = "<< ss << endl;
break;
}
}
}
}
}
//
// Right now, if we don't find an electron phase, we will not error exit. Some functions will
// be turned off and the object will behave as an InterfaceKinetics object. This is needed
// because downstream electrode objects have internal reaction surfaces that don't have
// electrons.
//
/*
if (metalPhaseIndex_ == npos) {
throw CanteraError("ElectrodeKinetics::identifyMetalPhase()",
"Can't find electron phase -> treating this as an error right now");
}
if (solnPhaseIndex_ == npos) {
throw CanteraError("ElectrodeKinetics::identifyMetalPhase()",
"Can't find solution phase -> treating this as an error right now");
}
*/
}
//============================================================================================================================
// virtual from InterfaceKinetics
void ElectrodeKinetics::updateROP()
{
// evaluate rate constants and equilibrium constants at temperature and phi (electric potential)
_update_rates_T();
// get updated activities (rates updated below)
_update_rates_C();
double TT = m_surf->temperature();
double rtdf = GasConstant * TT / Faraday;
if (m_ROP_ok) {
return;
}
//
// Copy the reaction rate coefficients, m_rfn, into m_ropf
//
copy(m_rfn.begin(), m_rfn.end(), m_ropf.begin());
//
// Multiply by the perturbation factor
//
multiply_each(m_ropf.begin(), m_ropf.end(), m_perturb.begin());
//
// Copy the forward rate constants to the reverse rate constants
//
copy(m_ropf.begin(), m_ropf.end(), m_ropr.begin());
//
// For reverse rates computed from thermochemistry, multiply
// the forward rates copied into m_ropr by the reciprocals of
// the equilibrium constants
//
multiply_each(m_ropr.begin(), m_ropr.end(), m_rkcn.begin());
//
// multiply ropf by the activity concentration reaction orders to obtain
// the forward rates of progress.
//
m_reactantStoich.multiply(DATA_PTR(m_actConc), DATA_PTR(m_ropf));
//
// For reversible reactions, multiply ropr by the activity concentration products
//
m_revProductStoich.multiply(DATA_PTR(m_actConc), DATA_PTR(m_ropr));
//
// Fix up these calculations for cases where the above formalism doesn't hold
//
double OCV = 0.0;
for (size_t iBeta = 0; iBeta < m_beta.size(); iBeta++) {
size_t irxn = m_ctrxn[iBeta];
int reactionType = m_rxntype[irxn];
if (reactionType == BUTLERVOLMER_RXN) {
//
// Get the beta value
//
double beta = m_beta[iBeta];
//
// OK, the reaction rate constant contains the current density rate constant calculation
// the rxnstoich calculation contained the dependence of the current density on the activity concentrations
// We finish up with the ROP calculation
//
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (iECDFormulation == 0) {
throw CanteraError(" ElectrodeKinetics::updateROP()",
"Straight kfwrd with BUTLERVOLMER_RXN not handled yet");
}
//
// Get the phase mole change structure
//
RxnMolChange* rmc = rmcVector[irxn];
//
// Calculate the stoichiometric eletrons for the reaction
// This is the number of electrons that are the net products of the reaction
//
AssertThrow(metalPhaseIndex_ != npos, "ElectrodeKinetics::updateROP()");
double nStoichElectrons = - rmc->m_phaseChargeChange[metalPhaseIndex_];
//
// Calculate the open circuit voltage of the reaction
//
getDeltaGibbs(0);
if (nStoichElectrons != 0.0) {
OCV = m_deltaG[irxn]/Faraday/ nStoichElectrons;
} else {
OCV = 0.0;
}
//
// Calculate the voltage of the electrode.
//
double voltage = m_phi[metalPhaseIndex_] - m_phi[solnPhaseIndex_];
//
// Calculate the overpotential
//
double nu = voltage - OCV;
//
// Find the product of the standard concentrations for ROP orders that we used above
//
const RxnOrders* ro_rop = m_ctrxn_ROPOrdersList_[iBeta];
if (ro_rop == 0) {
throw CanteraError("ElectrodeKinetics::", "ROP orders pointer is zero ?!?");
}
double tmp2 = 1.0;
const std::vector<size_t>& kinSpeciesIDs = ro_rop->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_rop->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t k = kinSpeciesIDs[j];
double oo = kinSpeciesOrders[j];
tmp2 *= pow(m_StandardConc[k], oo);
}
//
// Now have to divide this to get rid of standard concentrations. We should
// have used just the activities in the m_rxnstoich.multiplyReactants(DATA_PTR(m_actConc), DATA_PTR(m_ropf));
// calculation above!
// That is because the exchange current density rate constants have the correct units in the first place.
//
m_ropf[irxn] /= tmp2;
//
// Calculate the exchange current density
// m_ropf contains the exchange current reaction rate
//
double ioc = m_ropf[irxn] * nStoichElectrons;
//
// Add in the film resistance here
//
double resist = m_ctrxn_resistivity_[iBeta];
double exp1 = nu * nStoichElectrons * beta / rtdf;
double exp2 = - nu * nStoichElectrons * (1.0 - beta) / (rtdf);
double io = ioc * (exp(exp1) - exp(exp2));
if (resist != 0.0) {
io = solveCurrentRes(nu, nStoichElectrons, ioc, beta, TT, resist, 0);
}
m_ropnet[irxn] = io / (Faraday * nStoichElectrons);
//
// Need to resurrect the forwards rate of progress -> there is some need to
// calculate each direction individually
//
m_ropf[irxn] = calcForwardROP_BV(irxn, iBeta, ioc, nStoichElectrons, nu, io);
//
// Calculate the reverse rate of progress from the difference
//
m_ropr[irxn] = m_ropf[irxn] - m_ropnet[irxn];
} else if (reactionType == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN) {
//
// Get the beta value
//
double beta = m_beta[iBeta];
//
// OK, the reaction rate constant contains the current density rate constant calculation
// the rxnstoich calculation contained the dependence of the current density on the activity concentrations
// We finish up with the ROP calculation
//
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (iECDFormulation == 0) {
throw CanteraError("ElectrodeKinetics::updateROP()",
"Straight kfwrd with BUTLERVOLMER_NOACTIVITYCOEFFS_RXN not handled yet");
}
//
// Get the phase mole change structure
//
RxnMolChange* rmc = rmcVector[irxn];
//
// Calculate the stoichiometric eletrons for the reaction
// This is the number of electrons that are the net products of the reaction
//
double nStoichElectrons = - rmc->m_phaseChargeChange[metalPhaseIndex_];
//
// Calculate the open circuit voltage of the reaction
//
getDeltaGibbs(0);
if (nStoichElectrons != 0.0) {
OCV = m_deltaG[irxn]/Faraday/ nStoichElectrons;
} else {
OCV = 0.0;
}
//
// Calculate the voltage of the electrode.
//
double voltage = m_phi[metalPhaseIndex_] - m_phi[solnPhaseIndex_];
//
// Calculate the overpotential
//
double nu = voltage - OCV;
//
// Unfortunately, we really need to recalculate everything from almost scratch
// for this case, since it widely diverges from the thermo norm.
//
// Start with the exchange current reaction rate constant, which should
// be located in m_rfn[].
//
double ioc = m_rfn[irxn] * nStoichElectrons * m_perturb[irxn];
//
// Now we need th mole fraction vector and we need the RxnOrders vector.
//
const RxnOrders* ro_fwd = m_ctrxn_ROPOrdersList_[iBeta];
if (ro_fwd == 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV()", "forward orders pointer is zero ?!?");
}
double tmp = 1.0;
double mfS = 0.0;
const std::vector<size_t>& kinSpeciesIDs = ro_fwd->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_fwd->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t ks = kinSpeciesIDs[j];
thermo_t& th = speciesPhase(ks);
size_t n = speciesPhaseIndex(ks);
size_t klocal = ks - m_start[n];
mfS = th.moleFraction(klocal);
double oo = kinSpeciesOrders[j];
tmp *= pow(mfS, oo);
}
ioc *= tmp;
//
// Add in the film resistance here, later
//
double resist = m_ctrxn_resistivity_[iBeta];
double exp1 = nu * nStoichElectrons * beta / rtdf;
double exp2 = - nu * nStoichElectrons * (1.0 - beta) / (rtdf);
double io = ioc * (exp(exp1) - exp(exp2));
if (resist != 0.0) {
io = solveCurrentRes(nu, nStoichElectrons, ioc, beta, TT, resist, 0);
}
m_ropnet[irxn] = io / (Faraday * nStoichElectrons);
//
// Need to resurrect the forwards rate of progress -> there is some need to
// calculate each direction individually
//
m_ropf[irxn] = calcForwardROP_BV_NoAct(irxn, iBeta, ioc, nStoichElectrons, nu, io);
//
// Calculate the reverse rate of progress from the difference
//
m_ropr[irxn] = m_ropf[irxn] - m_ropnet[irxn];
}
}
for (size_t j = 0; j != m_ii; ++j) {
m_ropnet[j] = m_ropf[j] - m_ropr[j];
}
/*
* For reactions involving multiple phases, we must check that the phase
* being consumed actually exists. This is particularly important for
* phases that are stoichiometric phases containing one species with a unity activity
*/
if (m_phaseExistsCheck) {
for (size_t j = 0; j != m_ii; ++j) {
if ((m_ropr[j] > m_ropf[j]) && (m_ropr[j] > 0.0)) {
for (size_t p = 0; p < nPhases(); p++) {
if (m_rxnPhaseIsProduct[j][p]) {
if (! m_phaseExists[p]) {
m_ropnet[j] = 0.0;
m_ropr[j] = m_ropf[j];
if (m_ropf[j] > 0.0) {
for (size_t rp = 0; rp < nPhases(); rp++) {
if (m_rxnPhaseIsReactant[j][rp]) {
if (! m_phaseExists[rp]) {
m_ropnet[j] = 0.0;
m_ropr[j] = m_ropf[j] = 0.0;
}
}
}
}
}
}
if (m_rxnPhaseIsReactant[j][p]) {
if (! m_phaseIsStable[p]) {
m_ropnet[j] = 0.0;
m_ropr[j] = m_ropf[j];
}
}
}
} else if ((m_ropf[j] > m_ropr[j]) && (m_ropf[j] > 0.0)) {
for (size_t p = 0; p < nPhases(); p++) {
if (m_rxnPhaseIsReactant[j][p]) {
if (! m_phaseExists[p]) {
m_ropnet[j] = 0.0;
m_ropf[j] = m_ropr[j];
if (m_ropf[j] > 0.0) {
for (size_t rp = 0; rp < nPhases(); rp++) {
if (m_rxnPhaseIsProduct[j][rp]) {
if (! m_phaseExists[rp]) {
m_ropnet[j] = 0.0;
m_ropf[j] = m_ropr[j] = 0.0;
}
}
}
}
}
}
if (m_rxnPhaseIsProduct[j][p]) {
if (! m_phaseIsStable[p]) {
m_ropnet[j] = 0.0;
m_ropf[j] = m_ropr[j];
}
}
}
}
}
}
m_ROP_ok = true;
}
//==================================================================================================================
//
// When the BV form is used we still need to go backwards to calculate the forward rate of progress.
// This routine does that
//
double ElectrodeKinetics::calcForwardROP_BV(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu, doublereal ioNet)
{
double ropf;
doublereal rt = GasConstant * thermo(0).temperature();
//
// Calculate gather the exchange current reaction rate constant (where does n_s appear?)
//
doublereal beta = m_beta[iBeta];
#ifdef DEBUG_MODE
//
// Determine whether the reaction rate constant is in an exchange current density formulation format.
//
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (!iECDFormulation) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV", "not handled yet");
}
//
// Calculate the forward chemical and modify the forward reaction rate coefficient
//
const RxnOrders* ro_fwd = m_ctrxn_FwdOrdersList_[iBeta];
if (ro_fwd == 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV()", "forward orders pointer is zero ?!?");
}
double tmp = exp(- m_beta[iBeta] * m_deltaG0[irxn] / rt);
double tmp2 = 1.0;
const std::vector<size_t>& kinSpeciesIDs = ro_fwd->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_fwd->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t k = kinSpeciesIDs[j];
double oo = kinSpeciesOrders[j];
tmp2 *= pow(m_StandardConc[k], oo);
}
//double tmp2 = m_ProdStanConcReac[irxn];
tmp *= 1.0 / tmp2 / Faraday;
//
// Calculate the chemical reaction rate constant
//
double iorc = m_rfn[irxn] * m_perturb[irxn];
double kf = iorc * tmp;
//
// Calculate the electrochemical factor
//
double eamod = m_beta[iBeta] * deltaElectricEnergy_[irxn];
kf *= exp(- eamod / rt);
//
// Calculate the forward rate of progress
// -> get the pointer for the orders
//
tmp = 1.0;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t k = kinSpeciesIDs[j];
double oo = kinSpeciesOrders[j];
tmp *= pow(m_actConc[k], oo);
}
ropf = kf * tmp;
#endif
//
// Now calculate ropf in a separate but equivalent way.
// totally equivalent way if resistivity is zero, should be equal (HKM -> Proved exactly in one case)
//
double iof = ioc;
double resistivity = m_ctrxn_resistivity_[iBeta];
if (fabs(resistivity * ioNet) > fabs(nu)) {
ioNet = nu / resistivity;
}
if (nStoich > 0.0) {
double exp1 = nStoich * Faraday * beta * (nu - resistivity * ioNet)/ (rt);
iof *= exp(exp1);
} else {
#ifdef DEBUG_MODE
if (ioc > 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV", "ioc should be less than zero here");
}
#endif
double exp2 = -nu * nStoich * Faraday * (1.0 - beta) / (rt);
iof = ioc * ( - exp(exp2));
}
ropf = iof / ( Faraday * nStoich);
return ropf;
}
//==================================================================================================================
//
// When the BV form is used we still need to go backwards to calculate the forward rate of progress.
// This routine does that
//
double ElectrodeKinetics::calcForwardROP_BV_NoAct(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu,
doublereal ioNet)
{
doublereal TT = thermo(0).temperature();
doublereal rt = GasConstant * TT;
//doublereal rrt = 1.0/rt;
doublereal beta = m_beta[iBeta];
/*
//
// Calculate gather the exchange current reaction rate constant (where does n_s appear?)
//
double iorc = m_rfn[irxn] * m_perturb[irxn];
//
// Determine whether the reaction rate constant is in an exchange current density formulation format.
//
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (!iECDFormulation) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV_NoAct", "not handled yet");
}
//
// Calculate the forward chemical and modify the forward reaction rate coefficient
// (we don't use standard concentrations at all here);
//
double tmp = exp(- m_beta[iBeta] * m_deltaG0[irxn] * rrt);
double tmp2 = 1.0;
tmp *= 1.0 / tmp2 / Faraday;
//
// Calculate the chemical reaction rate constant
//
double kf = iorc * tmp;
//
// Calculate the electrochemical factor
//
double eamod = m_beta[iBeta] * deltaElectricEnergy_[irxn];
kf *= exp(- eamod * rrt);
//
// Calculate the forward rate of progress
// -> get the pointer for the orders
//
const RxnOrders* ro_fwd = m_ctrxn_FwdOrdersList_[iBeta];
if (ro_fwd == 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV()", "forward orders pointer is zero ?!?");
}
tmp = 1.0;
const std::vector<size_t>& kinSpeciesIDs = ro_fwd->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_fwd->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t ks = kinSpeciesIDs[j];
thermo_t& th = speciesPhase(ks);
size_t n = speciesPhaseIndex(ks);
size_t klocal = ks - m_start[n];
double mfS = th.moleFraction(klocal);
double oo = kinSpeciesOrders[j];
tmp *= pow(mfS, oo);
}
double ropf = kf * tmp;
*/
/*
if (nStoich > 0) {
double ropf = ioc / ( Faraday * nStoich);
double exp1 = nu * nStoich * Faraday * beta / (rt);
ropf *= exp(exp1);
} else {
double ropf = ioc / ( Faraday * nStoich);
double exp1 = nu * nStoich * Faraday * beta / (rt);
ropf *= exp(exp1);
}
*/
//
// With all of the thermo issues, I'm thinking this is the best we can do
// (it certainly maintains the forward and reverse rates of progress as being positive)
//
double iof = ioc;
double resistivity = m_ctrxn_resistivity_[iBeta];
if (fabs(resistivity * ioNet) > fabs(nu)) {
ioNet = nu / resistivity;
}
if (nStoich > 0) {
double exp1 = nStoich * Faraday * beta * (nu - resistivity * ioNet)/ (rt);
iof *= exp(exp1);
} else {
#ifdef DEBUG_MODE
if (ioc > 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV_NoAct", "ioc should be less than zero here");
}
#endif
double exp2 = -nu * nStoich * Faraday * (1.0 - beta) / (rt);
iof = ioc * ( - exp(exp2));
}
double ropf = iof / ( Faraday * nStoich);
return ropf;
}
//==================================================================================================================
double ElectrodeKinetics::openCircuitVoltage(size_t irxn)
{
//
// Calculate deltaG for all reactions
//
getDeltaGibbs(0);
//
// Look up the net number of electrons that are products.
//
RxnMolChange* rmc = rmcVector[irxn];
double nStoichElectrons = - rmc->m_phaseChargeChange[metalPhaseIndex_];
double OCV = 0.0;
if (nStoichElectrons != 0.0) {
OCV = m_deltaG[irxn] / Faraday / nStoichElectrons;
}
return OCV;
}
//==================================================================================================================
//
// Returns the local exchange current density formulation parameters
//
bool ElectrodeKinetics::
getExchangeCurrentDensityFormulation(size_t irxn,
doublereal& nStoichElectrons, doublereal& OCV, doublereal& io,
doublereal& overPotential, doublereal& beta,
doublereal& resistivity)
{
size_t iBeta = npos;
beta = 0.0;
//
// Add logic to handle other reaction types -> return 0 if formulation isn't compatible
//
// evaluate rate constants and equilibrium constants at temperature and phi (electric potential)
_update_rates_T();
// get updated activities (rates updated below)
_update_rates_C();
updateExchangeCurrentQuantities();
RxnMolChange* rmc = rmcVector[irxn];
// could also get this from reactant and product stoichiometry, maybe
if (metalPhaseIndex_ == npos) {
nStoichElectrons = 0;
OCV = 0.0;
return false;
} else {
nStoichElectrons = - rmc->m_phaseChargeChange[metalPhaseIndex_];
}
getDeltaGibbs(0);
if (nStoichElectrons != 0.0) {
OCV = m_deltaG[irxn] / Faraday / nStoichElectrons;
}
for (size_t i = 0; i < m_ctrxn.size(); i++) {
if (m_ctrxn[i] == irxn) {
iBeta = i;
break;
}
}
beta = m_beta[iBeta];
doublereal rt = GasConstant*thermo(0).temperature();
double mG0 = m_deltaG0[irxn];
int reactionType = m_rxntype[irxn];
//
// Start with the forward reaction rate
//
double iO = m_rfn[irxn] * m_perturb[irxn];
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (! iECDFormulation) {
iO = m_rfn[irxn] * Faraday * nStoichElectrons;
if (beta > 0.0) {
double fac = exp(mG0 / (rt));
iO *= pow(fac, beta);
// Need this step because m_rfn includes the inverse of this term, while the formulas
// only use the chemical reaction rate constant.
fac = exp( beta * deltaElectricEnergy_[irxn] / (rt));
iO *= fac;
}
} else {
iO *= nStoichElectrons;
}
double omb = 1.0 - beta;
if (reactionType == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN) {
const RxnOrders* ro_fwd = m_ctrxn_ROPOrdersList_[iBeta];
if (ro_fwd == 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV()", "forward orders pointer is zero ?!?");
}
double tmp = 1.0;
const std::vector<size_t>& kinSpeciesIDs = ro_fwd->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_fwd->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t ks = kinSpeciesIDs[j];
thermo_t& th = speciesPhase(ks);
size_t n = speciesPhaseIndex(ks);
size_t klocal = ks - m_start[n];
double mfS = th.moleFraction(klocal);
double oo = kinSpeciesOrders[j];
tmp *= pow(mfS, oo);
}
iO *= tmp;
} else if (reactionType == BUTLERVOLMER_RXN) {
const RxnOrders* ro_fwd = m_ctrxn_ROPOrdersList_[iBeta];
if (ro_fwd == 0) {
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV()", "forward orders pointer is zero ?!?");
}
double tmp = 1.0;
const std::vector<size_t>& kinSpeciesIDs = ro_fwd->kinSpeciesIDs_;
const std::vector<doublereal>& kinSpeciesOrders = ro_fwd->kinSpeciesOrders_;
for (size_t j = 0; j < kinSpeciesIDs.size(); j++) {
size_t ks = kinSpeciesIDs[j];
double oo = kinSpeciesOrders[j];
tmp *= pow((m_actConc[ks]/m_StandardConc[ks]), oo);
}
iO *= tmp;
} else {
for (size_t k = 0; k < m_kk; k++) {
doublereal reactCoeff = reactantStoichCoeff(k, irxn);
doublereal prodCoeff = productStoichCoeff(k, irxn);
if (reactCoeff != 0.0) {
iO *= pow(m_actConc[k], reactCoeff*omb);
iO *= pow(m_StandardConc[k], reactCoeff*beta);
}
if (prodCoeff != 0.0) {
iO *= pow(m_actConc[k], prodCoeff*beta);
iO /= pow(m_StandardConc[k], prodCoeff*omb);
}
}
}
io = iO;
resistivity = m_ctrxn_resistivity_[iBeta];
double phiMetal = m_thermo[metalPhaseIndex_]->electricPotential();
double phiSoln = m_thermo[solnPhaseIndex_]->electricPotential();
double E = phiMetal - phiSoln;
overPotential = E - OCV;
return true;
}
//====================================================================================================================
double ElectrodeKinetics::calcCurrentDensity(double nu, double nStoich, double ioc, double beta, double temp,
doublereal resistivity) const
{
double exp1 = nu * nStoich * Faraday * beta / (GasConstant * temp);
double exp2 = -nu * nStoich * Faraday * (1.0 - beta) / (GasConstant * temp);
double val = ioc * (exp(exp1) - exp(exp2));
if (resistivity > 0.0) {
val = solveCurrentRes(nu, nStoich, ioc, beta, temp, resistivity, 0);
}
return val;
}
//==================================================================================================================
void ElectrodeKinetics::init()
{
InterfaceKinetics::init();
identifyMetalPhase();
}
void ElectrodeKinetics::finalize()
{
InterfaceKinetics::finalize();
// Malloc and calculate all of the quantities that go into the extra description of reactions
rmcVector.resize(m_ii, 0);
for (size_t i = 0; i < m_ii; i++) {
rmcVector[i] = new RxnMolChange(this, static_cast<int>(i));
}
}
//==================================================================================================================
double ElectrodeKinetics::solveCurrentRes(double nu, double nStoich, doublereal ioc, doublereal beta, doublereal temp,
doublereal resistivity, int iprob) const
{
// int nits = 0;
doublereal f, dfdi, deltai, eexp1, eexp2, exp1, exp2, icurr, deltai_damp;
doublereal nFRT = nStoich * Faraday / (GasConstant * temp);
if (iprob == 0) {
eexp1 = exp(nu * nFRT * beta);
eexp2 = exp(-nu * nFRT * (1.0 - beta)) ;
} else {
eexp1 = exp(nu * nFRT * beta);
eexp2 = 0.0;
}
icurr = ioc * (eexp1 - eexp2);
double icurrDamp = icurr;
if (fabs(resistivity * icurr) > 0.9 * fabs(nu)) {
icurrDamp = 0.9 * nu / resistivity;
}
if (iprob == 0) {
eexp1 = exp( nFRT * beta * (nu - resistivity * icurrDamp));
eexp2 = exp(- nFRT * (1.0 - beta) * (nu - resistivity * icurrDamp));
} else {
eexp1 = exp( nFRT * beta * (nu - resistivity * icurrDamp));
eexp2 = 0.0;
}
icurr = ioc * (eexp1 - eexp2);
if (fabs(resistivity * icurr) > 0.99 * fabs(nu)) {
icurr = 0.99 * nu / resistivity;
}
do {
// nits++;
if (iprob == 0) {
exp1 = nFRT * beta * (nu - resistivity * icurr);
exp2 = - nFRT * (1.0 - beta) * (nu - resistivity * icurr);
eexp1 = exp(exp1);
eexp2 = exp(exp2);
f = icurr - ioc * (eexp1 - eexp2);
dfdi = 1.0 - ioc * eexp1 * ( - beta * nFRT * resistivity ) +
ioc * eexp2 * ( (1.0 - beta) * nFRT * resistivity );
} else {
exp1 = nFRT * beta * (nu - resistivity * icurr);
eexp1 = exp(exp1);
f = icurr - ioc * (eexp1);
dfdi = 1.0 - ioc * eexp1 * ( - beta * nFRT * resistivity );
}
deltai = - f / dfdi;
if (fabs(deltai) > 0.1 * fabs(icurr)) {
deltai_damp = 0.1 * deltai;
if (fabs(deltai_damp) > 0.1 * fabs(icurr)) {
deltai_damp = 0.1 * icurr * (deltai_damp / fabs(deltai_damp));
}
} else if (fabs(deltai) > 0.01 * fabs(icurr)) {
deltai_damp = 0.3 * deltai;
} else if (fabs(deltai) > 0.001 * fabs(icurr)) {
deltai_damp = 0.5 * deltai;
} else {
deltai_damp = deltai;
}
icurr += deltai_damp;
if (fabs(resistivity * icurr) > fabs(nu)) {
icurr = 0.999 * nu / resistivity;
}
} while((fabs(deltai/icurr)> 1.0E-14) && (fabs(deltai) > 1.0E-20));
// printf(" its = %d\n", nits);
return icurr;
}
//==================================================================================================================
}

View file

@ -1,391 +0,0 @@
/**
* @file example2.cpp
*
*/
/*
* $Id: ExtraGlobalRxn.cpp 571 2013-03-26 16:44:21Z hkmoffa $
*
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
// Example 2
//
// Read a mechanism, and print to the standard output stream a
// well-formatted Chemkin ELEMENT section.
//
#include "cantera/kinetics/ExtraGlobalRxn.h"
#include "cantera/numerics/DenseMatrix.h"
// Kinetics includes
#include "cantera/kinetics.h"
#include "cantera/kinetics/InterfaceKinetics.h"
#include "cantera/thermo/SurfPhase.h"
#include "cantera/kinetics/KineticsFactory.h"
#include <iostream>
#include <new>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
namespace Cantera {
//============================================================================================================
static void erase_vd(std::vector<doublereal>& m_vec, int index)
{
std::vector<double>::iterator ipos;
ipos = m_vec.begin();
ipos += index;
m_vec.erase(ipos);
}
//============================================================================================================
static void erase_vi(std::vector<int>& m_vec, int index)
{
std::vector<int>::iterator ipos;
ipos = m_vec.begin();
ipos += index;
m_vec.erase(ipos);
}
//============================================================================================================
//! add the species into the list of products or reactants
/*!
* Note this function gets called for both the product and reactant sides. However, it's only
* called for one side or another.
*
* @param kkinspec kinetic species index of the product
* @param
*/
static void addV(int kkinspec, double ps, std::vector<int>& m_Products,
std::vector<doublereal>& m_ProductStoich)
{
int nsize = static_cast<int>(m_Products.size());
for (int i = 0; i < nsize; i++) {
if (m_Products[i] == kkinspec) {
m_ProductStoich[i] += ps;
return;
}
}
m_Products.push_back(kkinspec);
m_ProductStoich.push_back(ps);
}
//============================================================================================================
ExtraGlobalRxn::ExtraGlobalRxn(Kinetics* k_ptr) :
m_ThisIsASurfaceRxn(false),
m_kinetics(k_ptr),
m_InterfaceKinetics(0),
m_nKinSpecies(0),
m_nReactants(0),
m_nProducts(0),
m_nNetSpecies(0),
m_nRxns(0),
m_SpecialSpecies(-1),
m_SpecialSpeciesProduct(true),
iphaseKin(0),
m_ok(false),
m_reversible(true)
{
warn_deprecated("class ExtraGlobalRxn",
"Unfinished implementation to be removed after Cantera 2.2.");
m_InterfaceKinetics = dynamic_cast<InterfaceKinetics*>(k_ptr);
if (m_InterfaceKinetics) {
m_ThisIsASurfaceRxn = true;
}
m_nRxns = static_cast<int>(m_kinetics->nReactions());
m_ElemRxnVector.resize(m_nRxns,0.0);
m_nKinSpecies = static_cast<int>(m_kinetics->nTotalSpecies());
}
//============================================================================================================
void ExtraGlobalRxn::setupElemRxnVector(double* RxnVector,
int specialSpecies)
{
int i;
int kkinspec;
for (size_t i = 0; i < (size_t) m_nRxns; i++) {
m_ElemRxnVector[i] = RxnVector[i];
}
for (size_t i = 0; i < (size_t) m_nRxns; i++) {
if (RxnVector[i] > 0.0) {
for (kkinspec = 0; kkinspec < m_nKinSpecies; kkinspec++) {
double ps = m_kinetics->productStoichCoeff(kkinspec, i);
if (ps > 0.0) {
addV(kkinspec, RxnVector[i]* ps, m_Products, m_ProductStoich);
addV(kkinspec, RxnVector[i]* ps, m_NetSpecies, m_netStoich);
}
double rs = m_kinetics->reactantStoichCoeff(kkinspec, i);
if (rs > 0.0) {
addV(kkinspec, RxnVector[i] * rs, m_Reactants, m_ReactantStoich);
addV(kkinspec, -RxnVector[i] * rs, m_NetSpecies, m_netStoich);
}
}
} else if (RxnVector[i] < 0.0) {
for (kkinspec = 0; kkinspec < m_nKinSpecies; kkinspec++) {
double ps = m_kinetics->productStoichCoeff(kkinspec, i);
if (ps > 0.0) {
addV(kkinspec,- RxnVector[i]* ps, m_Reactants, m_ReactantStoich);
addV(kkinspec, RxnVector[i]* ps, m_NetSpecies, m_netStoich);
}
double rs = m_kinetics->reactantStoichCoeff(kkinspec, i);
if (rs > 0.0) {
addV(kkinspec, -RxnVector[i] * rs, m_Products, m_ProductStoich);
addV(kkinspec, -RxnVector[i] * rs, m_NetSpecies, m_netStoich);
}
}
}
}
Recheck:
for (i = 0; i < static_cast<int>(m_Products.size()); i++) {
if (m_ProductStoich[i] == 0.0) {
erase_vi(m_Products, i);
erase_vd(m_ProductStoich, i);
goto Recheck ;
}
}
for (i = 0; i < static_cast<int>(m_Reactants.size()); i++) {
if (m_ReactantStoich[i] == 0.0) {
erase_vi(m_Reactants, i);
erase_vd(m_ReactantStoich, i);
goto Recheck ;
}
}
for (i = 0; i < static_cast<int>(m_NetSpecies.size()); i++) {
if (m_netStoich[i] == 0.0) {
erase_vi(m_NetSpecies, i);
erase_vd(m_netStoich, i);
goto Recheck ;
}
}
for (i = 0; i < static_cast<int>(m_Products.size()); i++) {
int ik = m_Products[i];
for (int j = 0; j < static_cast<int>(m_Reactants.size()); j++) {
int jk = m_Reactants[j];
if (ik == jk) {
if (m_ProductStoich[i] == m_ReactantStoich[j]) {
erase_vi(m_Products, i);
erase_vd(m_ProductStoich, i);
erase_vi(m_Reactants, j);
erase_vd(m_ReactantStoich, j);
} else if (m_ProductStoich[i] > m_ReactantStoich[j]) {
m_ProductStoich[i] -= m_ReactantStoich[j];
erase_vi(m_Reactants, j);
erase_vd(m_ReactantStoich, j);
} else {
m_ReactantStoich[j] -= m_ProductStoich[i];
erase_vi(m_Products, i);
erase_vd(m_ProductStoich, i);
}
// We just screwed up the indexing -> restart.
goto Recheck ;
}
}
}
m_nProducts = static_cast<int>(m_Products.size());
m_nReactants = static_cast<int>(m_Reactants.size());
m_nNetSpecies = static_cast<int>(m_NetSpecies.size());
/*
* Section to assign the special species
*/
m_SpecialSpecies = specialSpecies;
if (specialSpecies == -1) {
m_SpecialSpecies = m_Products[0];
}
bool ifound = false;
for (i = 0; i < (int) m_NetSpecies.size(); i++) {
int ik = m_NetSpecies[i];
if (ik == m_SpecialSpecies) {
if (m_netStoich[i] > 0.0) {
m_SpecialSpeciesProduct = true;
} else {
m_SpecialSpeciesProduct = false;
}
m_SS_index = i;
ifound = true;
break;
}
}
if (!ifound) {
throw CanteraError(":setupElemRxnVector",
"Special species not a reactant or product: "
+ int2str(m_SpecialSpecies));
}
m_ok = true;
}
//============================================================================================================
std::string ExtraGlobalRxn::reactionString()
{
string rs;
int k, istoich;
for (k = 0; k < m_nReactants; k++) {
int kkinspecies = m_Reactants[k];
double stoich = m_ReactantStoich[k];
if (stoich != 1.0) {
istoich = (int) stoich;
if (fabs((double)istoich - stoich) < 0.00001) {
rs += int2str(istoich) + " ";
} else {
rs += fp2str(stoich) + " ";
}
}
string sName = m_kinetics->kineticsSpeciesName(kkinspecies);
rs += sName;
if (k < (m_nReactants-1)) {
rs += " + ";
}
}
rs += " = ";
for (k = 0; k < m_nProducts; k++) {
int kkinspecies = m_Products[k];
double stoich = m_ProductStoich[k];
if (stoich != 1.0) {
istoich = (int) stoich;
if (fabs((double)istoich - stoich) < 0.00001) {
rs += int2str(istoich) + " ";
} else {
rs += fp2str(stoich) + " ";
}
}
string sName = m_kinetics->kineticsSpeciesName(kkinspecies);
rs += sName;
if (k < (m_nProducts-1)) {
rs += " + ";
}
}
return rs;
}
//============================================================================================================
std::vector<int>& ExtraGlobalRxn::reactants()
{
return m_Reactants;
}
//============================================================================================================
std::vector<int>& ExtraGlobalRxn::products()
{
return m_Products;
}
//============================================================================================================
bool ExtraGlobalRxn::isReversible()
{
return m_reversible;
}
//============================================================================================================
double ExtraGlobalRxn::reactantStoichCoeff(int kKin)
{
for (int k = 0; k < m_nReactants; k++) {
int kkinspec = m_Reactants[k];
if (kkinspec == kKin) {
return m_ReactantStoich[k];
}
}
return 0.0;
}
//============================================================================================================
double ExtraGlobalRxn::productStoichCoeff(int kKin)
{
for (int k = 0; k < m_nProducts; k++) {
int kkinspec = m_Products[k];
if (kkinspec == kKin) {
return m_ProductStoich[k];
}
}
return 0.0;
}
//============================================================================================================
double ExtraGlobalRxn::deltaSpecValue(double* speciesVectorProperty)
{
int k;
double val = 0;
for (k = 0; k < m_nNetSpecies; k++) {
int kkinspec = m_NetSpecies[k];
val += speciesVectorProperty[kkinspec] * m_netStoich[k];
}
return val;
}
//============================================================================================================
double ExtraGlobalRxn::deltaRxnVecValue(double* rxnVectorProperty)
{
double val = 0;
for (int i = 0; i < m_nRxns; i++) {
val += m_ElemRxnVector[i] * rxnVectorProperty[i];
}
return val;
}
//============================================================================================================
double ExtraGlobalRxn::ROPValue(double* ROPElemKinVector)
{
double val = 0.0;
for (int i = 0; i < m_nRxns; i++) {
double kstoich = m_kinetics->productStoichCoeff(m_SpecialSpecies, i) - m_kinetics->reactantStoichCoeff(m_SpecialSpecies, i);
if (m_ElemRxnVector[i] > 0.0) {
val += ROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
} else {
val -= ROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
}
}
if (!m_SpecialSpeciesProduct) {
val = -val;
}
return val;
}
//============================================================================================================
double ExtraGlobalRxn::FwdROPValue(double* FwdROPElemKinVector,
double* RevROPElemKinVector)
{
double val = 0.0;
for (int i = 0; i < m_nRxns; i++) {
double kstoich = m_kinetics->productStoichCoeff(m_SpecialSpecies, i) - m_kinetics->reactantStoichCoeff(m_SpecialSpecies, i);
if (m_ElemRxnVector[i] > 0.0) {
val += FwdROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
}
if (m_ElemRxnVector[i] < 0.0) {
val += RevROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
}
}
if (!m_SpecialSpeciesProduct) {
val = -val;
}
return val;
}
//============================================================================================================
double ExtraGlobalRxn::RevROPValue(double* FwdROPElemKinVector,
double* RevROPElemKinVector)
{
double val = 0.0;
for (int i = 0; i < m_nRxns; i++) {
double kstoich = m_kinetics->productStoichCoeff(m_SpecialSpecies, i)- m_kinetics->reactantStoichCoeff(m_SpecialSpecies, i);
if (m_ElemRxnVector[i] > 0.0) {
val += RevROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
}
if (m_ElemRxnVector[i] < 0.0) {
val += FwdROPElemKinVector[i] * kstoich * m_ElemRxnVector[i];
}
}
if (!m_SpecialSpeciesProduct) {
val = -val;
}
return val;
}
//============================================================================================================
}

View file

@ -43,13 +43,6 @@ InterfaceKinetics::InterfaceKinetics(thermo_t* thermo) :
InterfaceKinetics::~InterfaceKinetics()
{
delete m_integrator;
for (size_t i = 0; i < m_ctrxn_ROPOrdersList_.size(); i++) {
delete m_ctrxn_ROPOrdersList_[i];
}
for (size_t i = 0; i < m_ctrxn_FwdOrdersList_.size(); i++) {
delete m_ctrxn_FwdOrdersList_[i];
}
}
InterfaceKinetics::InterfaceKinetics(const InterfaceKinetics& right)
@ -113,24 +106,6 @@ InterfaceKinetics& InterfaceKinetics::operator=(const InterfaceKinetics& right)
m_rxnPhaseIsProduct = right.m_rxnPhaseIsProduct;
m_ioFlag = right.m_ioFlag;
for (size_t i = 0; i < m_ctrxn_ROPOrdersList_.size(); i++) {
delete m_ctrxn_ROPOrdersList_[i];
}
m_ctrxn_ROPOrdersList_ = right.m_ctrxn_ROPOrdersList_;
for (size_t i = 0; i < m_ctrxn_ROPOrdersList_.size(); i++) {
RxnOrders* ro = right.m_ctrxn_ROPOrdersList_[i];
m_ctrxn_ROPOrdersList_[i] = new RxnOrders(*ro);
}
for (size_t i = 0; i < m_ctrxn_FwdOrdersList_.size(); i++) {
delete m_ctrxn_FwdOrdersList_[i];
}
m_ctrxn_FwdOrdersList_ = right.m_ctrxn_FwdOrdersList_;
for (size_t i = 0; i < m_ctrxn_FwdOrdersList_.size(); i++) {
RxnOrders* ro = right.m_ctrxn_FwdOrdersList_[i];
m_ctrxn_FwdOrdersList_[i] = new RxnOrders(*ro);
}
return *this;
}
@ -816,29 +791,10 @@ bool InterfaceKinetics::addReaction(shared_ptr<Reaction> r_base)
++iter) {
orders[kineticsSpeciesIndex(iter->first)] = iter->second;
}
RxnOrders* ro = new RxnOrders();
ro->fill(orders);
m_ctrxn_ROPOrdersList_.push_back(ro);
m_ctrxn_FwdOrdersList_.push_back(0);
// Fill in the Fwd Orders dependence here for B-V reactions
if (r.reaction_type == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN ||
r.reaction_type == BUTLERVOLMER_RXN) {
vector_fp fwdFullorders(m_kk, 0.0);
determineFwdOrdersBV(*re, fwdFullorders);
RxnOrders* ro = new RxnOrders();
ro->fill(fwdFullorders);
m_ctrxn_FwdOrdersList_[i] = ro;
}
} else {
m_ctrxn_ROPOrdersList_.push_back(0);
m_ctrxn_FwdOrdersList_.push_back(0);
}
} else {
m_ctrxn_BVform.push_back(0);
m_ctrxn_ROPOrdersList_.push_back(0);
m_ctrxn_FwdOrdersList_.push_back(0);
if (re->film_resistivity > 0.0) {
throw CanteraError("InterfaceKinetics::addReaction()",
"film resistivity set for elementary reaction");
@ -1250,35 +1206,4 @@ void EdgeKinetics::finalize()
m_finalized = true;
}
RxnOrders::RxnOrders(const RxnOrders& right) :
kinSpeciesIDs_(right.kinSpeciesIDs_),
kinSpeciesOrders_(right.kinSpeciesOrders_)
{
}
RxnOrders& RxnOrders::operator=(const RxnOrders& right)
{
if (this == &right) {
return *this;
}
kinSpeciesIDs_ = right.kinSpeciesIDs_;
kinSpeciesOrders_ = right.kinSpeciesOrders_;
return *this;
}
int RxnOrders::fill(const std::vector<doublereal>& fullForwardOrders)
{
int nzeroes = 0;
kinSpeciesIDs_.clear();
kinSpeciesOrders_.clear();
for (size_t k = 0; k < fullForwardOrders.size(); ++k) {
if (fullForwardOrders[k] != 0.0) {
kinSpeciesIDs_.push_back(k);
kinSpeciesOrders_.push_back(fullForwardOrders[k]);
++nzeroes;
}
}
return nzeroes;
}
}

View file

@ -53,8 +53,6 @@ Kinetics& Kinetics::operator=(const Kinetics& right)
m_kk = right.m_kk;
m_perturb = right.m_perturb;
m_reactions = right.m_reactions;
m_reactants = right.m_reactants;
m_products = right.m_products;
m_rrxn = right.m_rrxn;
m_prxn = right.m_prxn;
m_rxntype = right.m_rxntype;
@ -613,7 +611,6 @@ bool Kinetics::addReaction(shared_ptr<Reaction> r)
rstoich.push_back(iter->second);
m_rrxn[k][irxn] = iter->second;
}
m_reactants.push_back(rk);
for (Composition::const_iterator iter = r->products.begin();
iter != r->products.end();
@ -623,7 +620,6 @@ bool Kinetics::addReaction(shared_ptr<Reaction> r)
pstoich.push_back(iter->second);
m_prxn[k][irxn] = iter->second;
}
m_products.push_back(pk);
// The default order for each reactant is its stoichiometric coefficient,
// which can be overridden by entries in the Reaction.orders map. rorder[i]

View file

@ -1,157 +0,0 @@
/**
* @file example2.cpp
*
* $Id: RxnMolChange.cpp 571 2013-03-26 16:44:21Z hkmoffa $
*
*/
/*
* Copyright (2005) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software.
*/
#include "cantera/kinetics/RxnMolChange.h"
#include "cantera/thermo.h"
#include "cantera/kinetics.h"
#include "cantera/kinetics/InterfaceKinetics.h"
#include "cantera/kinetics/ExtraGlobalRxn.h"
#include <iostream>
#include <new>
using namespace std;
namespace Cantera {
RxnMolChange::RxnMolChange(Kinetics* kinPtr, int irxn) :
m_nPhases(0),
m_kinBase(kinPtr),
m_iRxn(irxn),
m_ChargeTransferInRxn(0.0),
m_beta(0.0),
m_egr(0)
{
warn_deprecated("class RxnMolChange", "To be removed after Cantera 2.2.");
int iph;
AssertTrace(irxn >= 0);
AssertTrace(irxn < static_cast<int>(kinPtr->nReactions()));
m_nPhases = static_cast<int>(kinPtr->nPhases());
m_phaseMoleChange.resize(m_nPhases, 0.0);
m_phaseReactantMoles.resize(m_nPhases, 0.0);
m_phaseProductMoles.resize(m_nPhases, 0.0);
m_phaseMassChange.resize(m_nPhases, 0.0);
m_phaseChargeChange.resize(m_nPhases, 0.0);
m_phaseTypes.resize(m_nPhases, 0);
m_phaseDims.resize(m_nPhases, 0);
int m_kk = static_cast<int>(kinPtr->nTotalSpecies());
for (int kKin = 0; kKin < m_kk; kKin++) {
iph = static_cast<int>(m_kinBase->speciesPhaseIndex(kKin));
ThermoPhase& tpRef = m_kinBase->thermo(iph);
int kLoc = kKin - static_cast<int>(m_kinBase->kineticsSpeciesIndex(0, iph));
double rsc = m_kinBase->reactantStoichCoeff(kKin, irxn);
double psc = m_kinBase->productStoichCoeff(kKin, irxn);
double nsc = psc - rsc;
m_phaseMoleChange[iph] += (nsc);
m_phaseReactantMoles[iph] += rsc;
m_phaseProductMoles[iph] += psc;
double mw = tpRef.molecularWeight(kLoc);
m_phaseMassChange[iph] += (nsc) * mw;
double chg = tpRef.charge(kLoc);
m_phaseChargeChange[iph] += nsc * chg;
}
for (iph = 0; iph < m_nPhases; iph++) {
ThermoPhase& tpRef = m_kinBase->thermo(iph);
m_phaseDims[iph] = static_cast<int>(tpRef.nDim());
m_phaseTypes[iph] = tpRef.eosType();
if (m_phaseChargeChange[iph] != 0.0) {
double tmp = fabs(m_phaseChargeChange[iph]);
if (tmp > m_ChargeTransferInRxn) {
m_ChargeTransferInRxn = tmp;
}
}
}
if (m_ChargeTransferInRxn) {
InterfaceKinetics* iK = dynamic_cast<InterfaceKinetics*>(kinPtr);
if (iK) {
m_beta = iK->electrochem_beta(irxn);
} else {
throw CanteraError("RxnMolChange", "unknown condition on charge");
}
}
}
RxnMolChange::RxnMolChange(Kinetics* kinPtr, ExtraGlobalRxn* egr) :
m_nPhases(0),
m_kinBase(kinPtr),
m_iRxn(-1),
m_ChargeTransferInRxn(0.0),
m_beta(0.0),
m_egr(egr)
{
int iph;
AssertTrace(egr != 0);
m_nPhases = static_cast<int>(kinPtr->nPhases());
m_phaseMoleChange.resize(m_nPhases, 0.0);
m_phaseReactantMoles.resize(m_nPhases, 0.0);
m_phaseProductMoles.resize(m_nPhases, 0.0);
m_phaseMassChange.resize(m_nPhases, 0.0);
m_phaseChargeChange.resize(m_nPhases, 0.0);
m_phaseTypes.resize(m_nPhases, 0);
m_phaseDims.resize(m_nPhases, 0);
int m_kk = static_cast<int>(kinPtr->nTotalSpecies());
for (int kKin = 0; kKin < m_kk; kKin++) {
iph = static_cast<int>(m_kinBase->speciesPhaseIndex(kKin));
ThermoPhase& tpRef = m_kinBase->thermo(iph);
int kLoc = kKin - static_cast<int>(m_kinBase->kineticsSpeciesIndex(0, iph));
double rsc = egr->reactantStoichCoeff(kKin);
double psc = egr->productStoichCoeff(kKin);
double nsc = psc - rsc;
m_phaseMoleChange[iph] += (nsc);
m_phaseReactantMoles[iph] += rsc;
m_phaseProductMoles[iph] += psc;
double mw = tpRef.molecularWeight(kLoc);
m_phaseMassChange[iph] += (nsc) * mw;
double chg = tpRef.charge(kLoc);
m_phaseChargeChange[iph] += nsc * chg;
}
for (iph = 0; iph < m_nPhases; iph++) {
ThermoPhase& tpRef = m_kinBase->thermo(iph);
m_phaseDims[iph] = static_cast<int>(tpRef.nDim());
m_phaseTypes[iph] = tpRef.eosType();
if (m_phaseChargeChange[iph] != 0.0) {
double tmp = fabs(m_phaseChargeChange[iph]);
if (tmp > m_ChargeTransferInRxn) {
m_ChargeTransferInRxn = tmp;
}
}
}
if (m_ChargeTransferInRxn) {
InterfaceKinetics* iK = dynamic_cast<InterfaceKinetics*>(kinPtr);
if (iK) {
m_beta = 0.0;
} else {
throw CanteraError("RxnMolChange", "unknown condition on charge");
}
}
}
}

View file

@ -24,14 +24,6 @@ using namespace std;
namespace Cantera
{
ReactionRules::ReactionRules() :
skipUndeclaredSpecies(false),
skipUndeclaredThirdBodies(false),
allowNegativeA(false)
{
}
bool installReactionArrays(const XML_Node& p, Kinetics& kin,
std::string default_phase, bool check_for_duplicates)
{

View file

@ -46,9 +46,6 @@ void mixturemethods(int nlhs, mxArray* plhs[],
case 2:
iok = mix_copy(i);
break;
case 3:
iok = mix_assign(i, int(v));
break;
case 4:
checkNArgs(5, nrhs);
moles = getDouble(prhs[4]);

View file

@ -279,11 +279,6 @@ void onedimmethods(int nlhs, mxArray* plhs[],
nv = mxGetM(prhs[4])*mxGetN(prhs[4]);
iok = stflow_setFixedTempProfile(dom, np, pos, nv, temp);
break;
case 65:
checkNArgs(4, nrhs);
flag = getInt(prhs[3]);
iok = stflow_solveSpeciesEqs(dom, flag);
break;
case 66:
checkNArgs(4, nrhs);
flag = getInt(prhs[3]);

View file

@ -42,9 +42,6 @@ void reactormethods(int nlhs, mxArray* plhs[],
case 2:
iok = reactor_copy(i);
break;
case 3:
iok = reactor_assign(i,int(v));
break;
case 4:
iok = reactor_setInitialVolume(i, v);
break;

View file

@ -46,9 +46,6 @@ void reactornetmethods(int nlhs, mxArray* plhs[],
case 2:
iok = reactornet_copy(i);
break;
case 3:
iok = reactornet_assign(i,int(v));
break;
case 4:
iok = reactornet_addreactor(i, int(v));
break;

View file

@ -40,9 +40,6 @@ void wallmethods(int nlhs, mxArray* plhs[],
case 2:
iok = wall_copy(i);
break;
case 3:
iok = wall_assign(i,int(v));
break;
case 4:
m = getInt(prhs[4]);
iok = wall_install(i, int(v), m);

View file

@ -66,10 +66,6 @@ void xmlmethods(int nlhs, mxArray* plhs[],
case 2:
iok = xml_copy(i);
break;
case 3:
j = getInt(prhs[3]);
iok = xml_assign(i,j);
break;
case 4:
file = getString(prhs[3]);
iok = xml_build(i, file);

File diff suppressed because it is too large Load diff

View file

@ -423,15 +423,6 @@ doublereal* const* BandMatrix::colPts()
return &(m_colPtrs[0]);
}
void BandMatrix::copyData(const GeneralMatrix& y)
{
warn_deprecated("BandMatrix::copyData", "To be removed after Cantera 2.2.");
m_factored = false;
size_t n = sizeof(doublereal) * m_n * (2 *m_kl + m_ku + 1);
GeneralMatrix* yyPtr = const_cast<GeneralMatrix*>(&y);
(void) memcpy(DATA_PTR(data), yyPtr->ptrColumn(0), n);
}
void BandMatrix::useFactorAlgorithm(int fAlgorithm)
{
// useQR_ = fAlgorithm;

File diff suppressed because it is too large Load diff

View file

@ -306,12 +306,6 @@ doublereal* SquareMatrix::ptrColumn(size_t j)
return Array2D::ptrColumn(j);
}
void SquareMatrix::copyData(const GeneralMatrix& y)
{
const SquareMatrix* yy_ptr = dynamic_cast<const SquareMatrix*>(& y);
Array2D::copyData(*yy_ptr);
}
size_t SquareMatrix::nRows() const
{
return m_nrows;

View file

@ -1,915 +0,0 @@
/**
* @file: solveProb.cpp Implicit solver for nonlinear problems
*/
/*
* Copyright 2004 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
* See file License.txt for licensing information.
*/
#include "cantera/numerics/solveProb.h"
#include "cantera/base/clockWC.h"
#include "cantera/base/stringUtils.h"
#include "cantera/base/global.h"
using namespace std;
namespace Cantera
{
/***************************************************************************
* STATIC ROUTINES DEFINED IN THIS FILE
***************************************************************************/
static doublereal calcWeightedNorm(const doublereal [], const doublereal dx[], size_t);
solveProb::solveProb(ResidEval* resid) :
m_residFunc(resid),
m_neq(0),
m_atol(0),
m_rtol(1.0E-4),
m_maxstep(1000),
m_ioflag(0)
{
warn_deprecated("class solveProb", "To be removed after Cantera 2.2.");
m_neq = m_residFunc->nEquations();
// Dimension solution vector
size_t dim1 = std::max<size_t>(1, m_neq);
m_atol.resize(dim1, 1.0E-9);
m_netProductionRatesSave.resize(dim1, 0.0);
m_numEqn1.resize(dim1, 0.0);
m_numEqn2.resize(dim1, 0.0);
m_CSolnSave.resize(dim1, 0.0);
m_CSolnSP.resize(dim1, 0.0);
m_CSolnSPInit.resize(dim1, 0.0);
m_CSolnSPOld.resize(dim1, 0.0);
m_wtResid.resize(dim1, 0.0);
m_wtSpecies.resize(dim1, 0.0);
m_resid.resize(dim1, 0.0);
m_topBounds.resize(dim1, 1.0);
m_botBounds.resize(dim1, 0.0);
m_Jac.resize(dim1, dim1, 0.0);
m_JacCol.resize(dim1, 0);
for (size_t k = 0; k < dim1; k++) {
m_JacCol[k] = m_Jac.ptrColumn(k);
}
}
int solveProb::solve(int ifunc, doublereal time_scale,
doublereal reltol)
{
/*
* The following calculation is a Newton's method to get the surface fractions
* of the surface and bulk species by requiring that the surface species
* production rate = 0 and that the bulk fractions are proportional to their
* production rates.
*/
doublereal EXTRA_ACCURACY = 0.001;
if (ifunc == SOLVEPROB_JACOBIAN) {
EXTRA_ACCURACY *= 0.001;
}
int info = 0;
size_t label_t = npos; /* Species IDs for time control */
size_t label_d; /* Species IDs for damping control */
size_t label_t_old = npos;
doublereal label_factor = 1.0;
int iter=0; // iteration number on numlinear solver
int iter_max=1000; // maximum number of nonlinear iterations
doublereal deltaT = 1.0E-10; // Delta time step
doublereal damp=1.0, tmp;
// Weighted L2 norm of the residual. Currently, this is only
// used for IO purposes. It doesn't control convergence.
// Therefore, it is turned off when DEBUG_SOLVEPROB isn't defined.
doublereal resid_norm;
doublereal inv_t = 0.0;
doublereal t_real = 0.0, update_norm = 1.0E6;
bool do_time = false, not_converged = true;
#ifdef DEBUG_SOLVEPROB
#ifdef DEBUG_SOLVEPROB_TIME
doublereal t1;
#endif
#else
if (m_ioflag > 1) {
m_ioflag = 1;
}
#endif
#ifdef DEBUG_SOLVEPROB
#ifdef DEBUG_SOLVEPROB_TIME
clockWC wc;
if (m_ioflag) {
t1 = wc.secondsWC();
}
#endif
#endif
/*
* Set the initial value of the do_time parameter
*/
if (ifunc == SOLVEPROB_INITIALIZE || ifunc == SOLVEPROB_TRANSIENT) {
do_time = true;
}
/*
* upload the initial conditions
*/
m_residFunc->getInitialConditions(t_real, DATA_PTR(m_CSolnSP), DATA_PTR(m_numEqn1));
/*
* Store the initial guess in the soln vector,
* CSolnSP, and in an separate vector CSolnSPInit.
*/
std::copy(m_CSolnSP.begin(), m_CSolnSP.end(), m_CSolnSPInit.begin());
if (m_ioflag) {
print_header(m_ioflag, ifunc, time_scale, reltol,
DATA_PTR(m_netProductionRatesSave));
}
/*
* Quick return when there isn't a surface problem to solve
*/
if (m_neq == 0) {
not_converged = false;
update_norm = 0.0;
}
/* ------------------------------------------------------------------
* Start of Newton's method
* ------------------------------------------------------------------
*/
while (not_converged && iter < iter_max) {
iter++;
/*
* Store previous iteration's solution in the old solution vector
*/
std::copy(m_CSolnSP.begin(), m_CSolnSP.end(), m_CSolnSPOld.begin());
/*
* Calculate the value of the time step
* - heuristics to stop large oscillations in deltaT
*/
if (do_time) {
/* don't hurry increase in time step at the same time as damping */
if (damp < 1.0) {
label_factor = 1.0;
}
tmp = calc_t(DATA_PTR(m_netProductionRatesSave), DATA_PTR(m_CSolnSP),
&label_t, &label_t_old, &label_factor, m_ioflag);
if (iter < 10) {
inv_t = tmp;
} else if (tmp > 2.0*inv_t) {
inv_t = 2.0*inv_t;
} else {
inv_t = tmp;
}
/*
* Check end condition
*/
if (ifunc == SOLVEPROB_TRANSIENT) {
tmp = t_real + 1.0/inv_t;
if (tmp > time_scale) {
inv_t = 1.0/(time_scale - t_real);
}
}
} else {
/* make steady state calc a step of 1 million seconds to
prevent singular Jacobians for some pathological cases */
inv_t = 1.0e-6;
}
deltaT = 1.0/inv_t;
/*
* Call the routine to numerically evaluation the Jacobian
* and residual for the current iteration.
*/
resjac_eval(m_JacCol, DATA_PTR(m_resid), DATA_PTR(m_CSolnSP),
DATA_PTR(m_CSolnSPOld), do_time, deltaT);
/*
* Calculate the weights. Make sure the calculation is carried
* out on the first iteration.
*/
if (iter%4 == 1) {
calcWeights(DATA_PTR(m_wtSpecies), DATA_PTR(m_wtResid),
DATA_PTR(m_CSolnSP));
}
/*
* Find the weighted norm of the residual
*/
resid_norm = calcWeightedNorm(DATA_PTR(m_wtResid), DATA_PTR(m_resid), m_neq);
#ifdef DEBUG_SOLVEPROB
if (m_ioflag > 1) {
printIterationHeader(m_ioflag, damp, inv_t, t_real, iter, do_time);
/*
* Print out the residual and Jacobian
*/
printResJac(m_ioflag, m_neq, m_Jac, DATA_PTR(m_resid),
DATA_PTR(m_wtResid), resid_norm);
}
#endif
/*
* Solve Linear system (with LAPACK). The solution is in resid[]
*/
info = m_Jac.factor();
if (info==0) {
m_Jac.solve(&m_resid[0]);
}
/*
* Force convergence if residual is small to avoid
* "nan" results from the linear solve.
*/
else {
if (m_ioflag) {
printf("solveSurfSS: Zero pivot, assuming converged: %g (%d)\n",
resid_norm, info);
}
for (size_t jcol = 0; jcol < m_neq; jcol++) {
m_resid[jcol] = 0.0;
}
/* print out some helpful info */
if (m_ioflag > 1) {
printf("-----\n");
printf("solveSurfProb: iter %d t_real %g delta_t %g\n\n",
iter,t_real, 1.0/inv_t);
printf("solveSurfProb: init guess, current concentration,"
"and prod rate:\n");
printf("-----\n");
}
if (do_time) {
t_real += time_scale;
}
#ifdef DEBUG_SOLVEPROB
if (m_ioflag) {
printf("\nResidual is small, forcing convergence!\n");
}
#endif
}
/*
* Calculate the Damping factor needed to keep all unknowns
* between 0 and 1, and not allow too large a change (factor of 2)
* in any unknown.
*/
damp = calc_damping(DATA_PTR(m_CSolnSP), DATA_PTR(m_resid), m_neq, &label_d);
/*
* Calculate the weighted norm of the update vector
* Here, resid is the delta of the solution, in concentration
* units.
*/
update_norm = calcWeightedNorm(DATA_PTR(m_wtSpecies),
DATA_PTR(m_resid), m_neq);
/*
* Update the solution vector and real time
* Crop the concentrations to zero.
*/
for (size_t irow = 0; irow < m_neq; irow++) {
m_CSolnSP[irow] -= damp * m_resid[irow];
}
if (do_time) {
t_real += damp/inv_t;
}
if (m_ioflag) {
printIteration(m_ioflag, damp, label_d, label_t, inv_t, t_real, iter,
update_norm, resid_norm,
DATA_PTR(m_netProductionRatesSave),
DATA_PTR(m_CSolnSP), DATA_PTR(m_resid),
DATA_PTR(m_wtSpecies), m_neq, do_time);
}
if (ifunc == SOLVEPROB_TRANSIENT) {
not_converged = (t_real < time_scale);
} else {
if (do_time) {
if (t_real > time_scale ||
(resid_norm < 1.0e-7 &&
update_norm*time_scale/t_real < EXTRA_ACCURACY)) {
do_time = false;
#ifdef DEBUG_SOLVEPROB
if (m_ioflag > 1) {
printf("\t\tSwitching to steady solve.\n");
}
#endif
}
} else {
not_converged = ((update_norm > EXTRA_ACCURACY) ||
(resid_norm > EXTRA_ACCURACY));
}
}
} /* End of Newton's Method while statement */
/*
* End Newton's method. If not converged, print error message and
* recalculate sdot's at equal site fractions.
*/
if (not_converged) {
if (m_ioflag) {
printf("#$#$#$# Error in solveProb $#$#$#$ \n");
printf("Newton iter on surface species did not converge, "
"update_norm = %e \n", update_norm);
printf("Continuing anyway\n");
}
}
#ifdef DEBUG_SOLVEPROB
#ifdef DEBUG_SOLVEPROB_TIME
if (m_ioflag) {
printf("\nEnd of solve, time used: %e\n", wc.secondsWC()-t1);
}
#endif
#endif
/*
* Decide on what to return in the solution vector
* - right now, will always return the last solution
* no matter how bad
*/
if (m_ioflag) {
fun_eval(DATA_PTR(m_resid), DATA_PTR(m_CSolnSP), DATA_PTR(m_CSolnSPOld),
false, deltaT);
resid_norm = calcWeightedNorm(DATA_PTR(m_wtResid),
DATA_PTR(m_resid), m_neq);
printFinal(m_ioflag, damp, label_d, label_t, inv_t, t_real, iter,
update_norm, resid_norm, DATA_PTR(m_netProductionRatesSave),
DATA_PTR(m_CSolnSP), DATA_PTR(m_resid),
DATA_PTR(m_wtSpecies),
DATA_PTR(m_wtResid), m_neq, do_time);
}
/*
* Return with the appropriate flag
*/
if (update_norm > 1.0) {
return -1;
}
return 0;
}
void solveProb::reportState(doublereal* const CSolnSP) const
{
std::copy(m_CSolnSP.begin(), m_CSolnSP.end(), CSolnSP);
}
void solveProb::fun_eval(doublereal* const resid, const doublereal* const CSoln,
const doublereal* const CSolnOld, const bool do_time,
const doublereal deltaT)
{
/*
* This routine uses the m_numEqn1 and m_netProductionRatesSave vectors
* as temporary internal storage.
*/
if (do_time) {
m_residFunc->evalSimpleTD(0.0, CSoln, CSolnOld, deltaT, resid);
} else {
m_residFunc->evalSS(0.0, CSoln, resid);
}
}
void solveProb::resjac_eval(std::vector<doublereal*> &JacCol,
doublereal resid[], doublereal CSoln[],
const doublereal CSolnOld[], const bool do_time,
const doublereal deltaT)
{
doublereal dc, cSave, sd;
doublereal* col_j;
/*
* Calculate the residual
*/
fun_eval(resid, CSoln, CSolnOld, do_time, deltaT);
/*
* Now we will look over the columns perturbing each unknown.
*/
for (size_t kCol = 0; kCol < m_neq; kCol++) {
cSave = CSoln[kCol];
sd = fabs(cSave) + fabs(CSoln[kCol]) + m_atol[kCol] * 1.0E6;
if (sd < 1.0E-200) {
sd = 1.0E-4;
}
dc = std::max(1.0E-11 * sd, fabs(cSave) * 1.0E-6);
CSoln[kCol] += dc;
// Use the m_numEqn2 vector as temporary internal storage.
fun_eval(DATA_PTR(m_numEqn2), CSoln, CSolnOld, do_time, deltaT);
col_j = JacCol[kCol];
for (size_t i = 0; i < m_neq; i++) {
col_j[i] = (m_numEqn2[i] - resid[i])/dc;
}
CSoln[kCol] = cSave;
}
}
doublereal solveProb::calc_damping(doublereal x[], doublereal dxneg[], size_t dim, size_t* label)
{
const doublereal APPROACH = 0.50;
doublereal damp = 1.0, xnew, xtop, xbot;
static doublereal damp_old = 1.0;
*label = npos;
for (size_t i = 0; i < dim; i++) {
doublereal topBounds = m_topBounds[i];
doublereal botBounds = m_botBounds[i];
/*
* Calculate the new suggested new value of x[i]
*/
double delta_x = - dxneg[i];
xnew = x[i] - damp * dxneg[i];
/*
* Calculate the allowed maximum and minimum values of x[i]
* - Only going to allow x[i] to converge to the top and bottom bounds by a
* single order of magnitude at one time
*/
bool canCrossOrigin = false;
if (topBounds > 0.0 && botBounds < 0.0) {
canCrossOrigin = true;
}
xtop = topBounds - 0.1 * fabs(topBounds - x[i]);
xbot = botBounds + 0.1 * fabs(x[i] - botBounds);
if (xnew > xtop) {
damp = - APPROACH * (xtop - x[i]) / dxneg[i];
*label = i;
} else if (xnew < xbot) {
damp = APPROACH * (x[i] - xbot) / dxneg[i];
*label = i;
}
double denom = fabs(x[i]) + 1.0E5 * m_atol[i];
if ((fabs(delta_x) / denom) > 0.3) {
double newdamp = 0.3 * denom / fabs(delta_x);
if (canCrossOrigin) {
if (xnew * x[i] < 0.0) {
if (fabs(x[i]) < 1.0E8 * m_atol[i]) {
newdamp = 2.0 * fabs(x[i]) / fabs(delta_x);
}
}
}
damp = std::min(damp, newdamp);
}
}
/*
* Only allow the damping parameter to increase by a factor of three each
* iteration. Heuristic to avoid oscillations in the value of damp
*/
if (damp > damp_old*3) {
damp = damp_old*3;
*label = npos;
}
/*
* Save old value of the damping parameter for use
* in subsequent calls.
*/
damp_old = damp;
return damp;
}
/*
* This function calculates the norm of an update, dx[],
* based on the weighted values of x.
*/
static doublereal calcWeightedNorm(const doublereal wtX[], const doublereal dx[], size_t dim)
{
doublereal norm = 0.0;
doublereal tmp;
if (dim == 0) {
return 0.0;
}
for (size_t i = 0; i < dim; i++) {
tmp = dx[i] / wtX[i];
norm += tmp * tmp;
}
return sqrt(norm/dim);
}
void solveProb::calcWeights(doublereal wtSpecies[], doublereal wtResid[],
const doublereal CSoln[])
{
/*
* First calculate the weighting factor
*/
for (size_t k = 0; k < m_neq; k++) {
wtSpecies[k] = m_atol[k] + m_rtol * fabs(CSoln[k]);
}
/*
* Now do the residual Weights. Since we have the Jacobian, we
* will use it to generate a number based on the what a significant
* change in a solution variable does to each residual.
* This is a row sum scale operation.
*/
for (size_t k = 0; k < m_neq; k++) {
wtResid[k] = 0.0;
for (size_t jcol = 0; jcol < m_neq; jcol++) {
wtResid[k] += fabs(m_Jac(k,jcol) * wtSpecies[jcol]);
}
}
}
doublereal solveProb::calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[],
size_t* label, size_t* label_old,
doublereal* label_factor, int ioflag)
{
doublereal tmp, inv_timeScale=0.0;
for (size_t k = 0; k < m_neq; k++) {
if (Csoln[k] <= 1.0E-10) {
tmp = 1.0E-10;
} else {
tmp = Csoln[k];
}
tmp = fabs(netProdRateSolnSP[k]/ tmp);
if (netProdRateSolnSP[k]> 0.0) {
tmp /= 100.;
}
if (tmp > inv_timeScale) {
inv_timeScale = tmp;
*label = k;
}
}
/*
* Increase time step exponentially as same species repeatedly
* controls time step
*/
if (*label == *label_old) {
*label_factor *= 1.5;
} else {
*label_old = *label;
*label_factor = 1.0;
}
inv_timeScale = inv_timeScale / *label_factor;
#ifdef DEBUG_SOLVEPROB
if (ioflag > 1) {
if (*label_factor > 1.0) {
printf("Delta_t increase due to repeated controlling species = %e\n",
*label_factor);
}
int kkin = m_kinSpecIndex[*label];
string sn = " "
printf("calc_t: spec=%d(%s) sf=%e pr=%e dt=%e\n",
*label, sn.c_str(), XMolSolnSP[*label],
netProdRateSolnSP[*label], 1.0/inv_timeScale);
}
#endif
return inv_timeScale;
}
void solveProb::setBounds(const doublereal botBounds[], const doublereal topBounds[])
{
for (size_t k = 0; k < m_neq; k++) {
m_botBounds[k] = botBounds[k];
m_topBounds[k] = topBounds[k];
}
}
#ifdef DEBUG_SOLVEPROB
void solveProb::printResJac(int ioflag, int neq, const Array2D& Jac,
doublereal resid[], doublereal wtRes[],
doublereal norm)
{
}
#endif
void solveProb::print_header(int ioflag, int ifunc, doublereal time_scale,
doublereal reltol,
doublereal netProdRate[])
{
int damping = 1;
if (ioflag) {
printf("\n================================ SOLVEPROB CALL SETUP "
"========================================\n");
if (ifunc == SOLVEPROB_INITIALIZE) {
printf("\n SOLVEPROB Called with Initialization turned on\n");
printf(" Time scale input = %9.3e\n", time_scale);
} else if (ifunc == SOLVEPROB_RESIDUAL) {
printf("\n SOLVEPROB Called to calculate steady state residual\n");
printf(" from a good initial guess\n");
} else if (ifunc == SOLVEPROB_JACOBIAN) {
printf("\n SOLVEPROB Called to calculate steady state Jacobian\n");
printf(" from a good initial guess\n");
} else if (ifunc == SOLVEPROB_TRANSIENT) {
printf("\n SOLVEPROB Called to integrate surface in time\n");
printf(" for a total of %9.3e sec\n", time_scale);
} else {
throw CanteraError("solveProb::print_header",
"Unknown ifunc flag = " + int2str(ifunc));
}
if (damping) {
printf(" Damping is ON \n");
} else {
printf(" Damping is OFF \n");
}
printf(" Reltol = %9.3e, Abstol = %9.3e\n", reltol, m_atol[0]);
}
/*
* Print out the initial guess
*/
#ifdef DEBUG_SOLVEPROB
if (ioflag > 1) {
printf("\n================================ INITIAL GUESS "
"========================================\n");
int kindexSP = 0;
for (int isp = 0; isp < m_numSurfPhases; isp++) {
InterfaceKinetics* m_kin = m_objects[isp];
int surfIndex = m_kin->surfacePhaseIndex();
int nPhases = m_kin->nPhases();
m_kin->getNetProductionRates(netProdRate);
updateMFKinSpecies(XMolKinSpecies, isp);
printf("\n IntefaceKinetics Object # %d\n\n", isp);
printf("\t Number of Phases = %d\n", nPhases);
printf("\t Phase:SpecName Prod_Rate MoleFraction kindexSP\n");
printf("\t -------------------------------------------------------"
"----------\n");
int kspindex = 0;
bool inSurfacePhase = false;
for (int ip = 0; ip < nPhases; ip++) {
if (ip == surfIndex) {
inSurfacePhase = true;
} else {
inSurfacePhase = false;
}
ThermoPhase& THref = m_kin->thermo(ip);
int nsp = THref.nSpecies();
string pname = THref.id();
for (int k = 0; k < nsp; k++) {
string sname = THref.speciesName(k);
string cname = pname + ":" + sname;
if (inSurfacePhase) {
printf("\t %-24s %10.3e %10.3e %d\n", cname.c_str(),
netProdRate[kspindex], XMolKinSpecies[kspindex],
kindexSP);
kindexSP++;
} else {
printf("\t %-24s %10.3e %10.3e\n", cname.c_str(),
netProdRate[kspindex], XMolKinSpecies[kspindex]);
}
kspindex++;
}
}
printf("=========================================================="
"=================================\n");
}
}
#endif
if (ioflag == 1) {
printf("\n\n\t Iter Time Del_t Damp DelX "
" Resid Name-Time Name-Damp\n");
printf("\t -----------------------------------------------"
"------------------------------------\n");
}
}
void solveProb::printIteration(int ioflag, doublereal damp, size_t label_d,
size_t label_t,
doublereal inv_t, doublereal t_real, int iter,
doublereal update_norm, doublereal resid_norm,
doublereal netProdRate[], doublereal CSolnSP[],
doublereal resid[],
doublereal wtSpecies[], size_t dim, bool do_time)
{
size_t i, k;
string nm;
if (ioflag == 1) {
printf("\t%6d ", iter);
if (do_time) {
printf("%9.4e %9.4e ", t_real, 1.0/inv_t);
} else
for (i = 0; i < 22; i++) {
printf(" ");
}
if (damp < 1.0) {
printf("%9.4e ", damp);
} else
for (i = 0; i < 11; i++) {
printf(" ");
}
printf("%9.4e %9.4e", update_norm, resid_norm);
if (do_time) {
k = label_t;
printf(" %s", int2str(k).c_str());
} else {
for (i = 0; i < 16; i++) {
printf(" ");
}
}
if (label_d != npos) {
k = label_d;
printf(" %s", int2str(k).c_str());
}
printf("\n");
}
#ifdef DEBUG_SOLVEPROB
else if (ioflag > 1) {
updateMFSolnSP(XMolSolnSP);
printf("\n\t Weighted norm of update = %10.4e\n", update_norm);
printf("\t Name Prod_Rate XMol Conc "
" Conc_Old wtConc");
if (damp < 1.0) {
printf(" UnDamped_Conc");
}
printf("\n");
printf("\t---------------------------------------------------------"
"-----------------------------\n");
int kindexSP = 0;
for (int isp = 0; isp < m_numSurfPhases; isp++) {
int nsp = m_nSpeciesSurfPhase[isp];
InterfaceKinetics* m_kin = m_objects[isp];
m_kin->getNetProductionRates(DATA_PTR(m_numEqn1));
for (int k = 0; k < nsp; k++, kindexSP++) {
int kspIndex = m_kinSpecIndex[kindexSP];
nm = m_kin->kineticsSpeciesName(kspIndex);
printf("\t%-16s %10.3e %10.3e %10.3e %10.3e %10.3e ",
nm.c_str(),
m_numEqn1[kspIndex],
XMolSolnSP[kindexSP],
CSolnSP[kindexSP], CSolnSP[kindexSP]+damp*resid[kindexSP],
wtSpecies[kindexSP]);
if (damp < 1.0) {
printf("%10.4e ", CSolnSP[kindexSP]+(damp-1.0)*resid[kindexSP]);
if (label_d == kindexSP) {
printf(" Damp ");
}
}
if (label_t == kindexSP) {
printf(" Tctrl");
}
printf("\n");
}
}
printf("\t--------------------------------------------------------"
"------------------------------\n");
}
#endif
}
void solveProb::printFinal(int ioflag, doublereal damp, size_t label_d, size_t label_t,
doublereal inv_t, doublereal t_real, int iter,
doublereal update_norm, doublereal resid_norm,
doublereal netProdRateKinSpecies[], const doublereal CSolnSP[],
const doublereal resid[],
const doublereal wtSpecies[], const doublereal wtRes[],
size_t dim, bool do_time)
{
size_t i, k;
string nm;
if (ioflag == 1) {
printf("\tFIN%3d ", iter);
if (do_time) {
printf("%9.4e %9.4e ", t_real, 1.0/inv_t);
} else
for (i = 0; i < 22; i++) {
printf(" ");
}
if (damp < 1.0) {
printf("%9.4e ", damp);
} else
for (i = 0; i < 11; i++) {
printf(" ");
}
printf("%9.4e %9.4e", update_norm, resid_norm);
if (do_time) {
k = label_t;
printf(" %s", int2str(k).c_str());
} else {
for (i = 0; i < 16; i++) {
printf(" ");
}
}
if (label_d != npos) {
k = label_d;
printf(" %s", int2str(k).c_str());
}
printf(" -- success\n");
}
#ifdef DEBUG_SOLVEPROB
else if (ioflag > 1) {
printf("\n================================== FINAL RESULT ========="
"==================================================\n");
printf("\n Weighted norm of solution update = %10.4e\n", update_norm);
printf(" Weighted norm of residual update = %10.4e\n\n", resid_norm);
printf(" Name Prod_Rate XMol Conc "
" wtConc Resid Resid/wtResid wtResid");
if (damp < 1.0) {
printf(" UnDamped_Conc");
}
printf("\n");
printf("---------------------------------------------------------------"
"---------------------------------------------\n");
for (int k = 0; k < m_neq; k++, k++) {
printf("%-16s %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e",
nm.c_str(),
m_numEqn1[k],
XMolSolnSP[k],
CSolnSP[k],
wtSpecies[k],
resid[k],
resid[k]/wtRes[k], wtRes[k]);
if (damp < 1.0) {
printf("%10.4e ", CSolnSP[k]+(damp-1.0)*resid[k]);
if (label_d == k) {
printf(" Damp ");
}
}
if (label_t == k) {
printf(" Tctrl");
}
printf("\n");
}
printf("\n");
printf("==============================================================="
"============================================\n\n");
}
#endif
}
#ifdef DEBUG_SOLVEPROB
void solveProb::printIterationHeader(int ioflag, doublereal damp,
doublereal inv_t, doublereal t_real,
int iter, bool do_time)
{
if (ioflag > 1) {
printf("\n===============================Iteration %5d "
"=================================\n", iter);
if (do_time) {
printf(" Transient step with: Real Time_n-1 = %10.4e sec,", t_real);
printf(" Time_n = %10.4e sec\n", t_real + 1.0/inv_t);
printf(" Delta t = %10.4e sec", 1.0/inv_t);
} else {
printf(" Steady Solve ");
}
if (damp < 1.0) {
printf(", Damping value = %10.4e\n", damp);
} else {
printf("\n");
}
}
}
#endif
void solveProb::setAtol(const doublereal atol[])
{
for (size_t k = 0; k < m_neq; k++, k++) {
m_atol[k] = atol[k];
}
}
void solveProb::setAtolConst(const doublereal atolconst)
{
for (size_t k = 0; k < m_neq; k++, k++) {
m_atol[k] = atolconst;
}
}
}

View file

@ -7,7 +7,7 @@
*/
#include "cantera/oneD/MultiNewton.h"
#include "cantera/base/vec_functions.h"
#include "cantera/base/utilities.h"
#include <cstdio>
#include <ctime>

View file

@ -123,8 +123,6 @@ void StFlow::resize(size_t ncomponents, size_t points)
m_wdot.resize(m_nsp,m_points, 0.0);
m_do_energy.resize(m_points,false);
m_qdotRadiation.resize(m_points, 0.0);
m_fixedy.resize(m_nsp, m_points);
m_fixedtemp.resize(m_points);
m_dz.resize(m_points-1);
@ -203,7 +201,7 @@ void StFlow::setGasAtMidpoint(const doublereal* x, size_t j)
void StFlow::_finalize(const doublereal* x)
{
size_t k, j;
size_t j;
doublereal zz, tt;
size_t nz = m_zfix.size();
bool e = m_do_energy[0];
@ -215,9 +213,6 @@ void StFlow::_finalize(const doublereal* x)
tt = linearInterp(zz, m_zfix, m_tfix);
m_fixedtemp[j] = tt;
}
for (k = 0; k < m_nsp; k++) {
setMassFraction(j, k, Y(x, k, j));
}
}
if (e) {
solveEnergyEqn();

Some files were not shown because too many files have changed in this diff Show more