*** empty log message ***
This commit is contained in:
parent
bd4cdc2491
commit
5b7b233630
13 changed files with 282 additions and 272 deletions
|
|
@ -8,28 +8,52 @@
|
|||
#include "kernel/InterfaceKinetics.h"
|
||||
#include "kernel/importKinetics.h"
|
||||
|
||||
namespace Cantera {
|
||||
/**
|
||||
* This namespace is used for the Cantera C++ user interface.
|
||||
*/
|
||||
namespace Cantera_CXX {
|
||||
|
||||
/**
|
||||
* An interface between multiple bulk phases. This class is defined
|
||||
* mostly for convenience. It inherits both from Cantera::SurfPhase
|
||||
* and Cantera::InterfaceKinetics. It therefore represents a
|
||||
* surface phase, and also acts as the kinetics manager to manage
|
||||
* reaction occurring on the surface, possibly involving species
|
||||
* from other phases.
|
||||
*/
|
||||
class Interface :
|
||||
public SurfPhase, public InterfaceKinetics
|
||||
public Cantera::SurfPhase,
|
||||
public Cantera::InterfaceKinetics
|
||||
{
|
||||
public:
|
||||
Interface(std::string infile, std::string id, std::vector<ThermoPhase*> phases)
|
||||
|
||||
/**
|
||||
* Constructor. Construct an Interface instance from
|
||||
* a specification in an input file.
|
||||
* @param infile. Cantera input file in CTI or CTML format.
|
||||
* @param id Identification string to distinguish between
|
||||
* multiple definitions within one input file.
|
||||
* @param phases Neighboring phases that may participate in the
|
||||
* reactions on this interface.
|
||||
*/
|
||||
Interface(std::string infile, std::string id,
|
||||
std::vector<Cantera::ThermoPhase*> phases)
|
||||
: m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
m_r = Cantera::get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
|
||||
XML_Node* x = get_XML_Node("#"+id, m_r);
|
||||
|
||||
XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
|
||||
if (!x)
|
||||
throw CanteraError("Interface","error in get_XML_Node");
|
||||
throw Cantera::CanteraError("Interface","error in get_XML_Node");
|
||||
|
||||
importPhase(*x, this);
|
||||
Cantera::importPhase(*x, this);
|
||||
phases.push_back(this);
|
||||
importKinetics(*x, phases, this);
|
||||
Cantera::importKinetics(*x, phases, this);
|
||||
m_ok = true;
|
||||
}
|
||||
|
||||
/// Destructor. Does nothing.
|
||||
virtual ~Interface() {}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
|
|
@ -42,8 +66,13 @@ namespace Cantera {
|
|||
private:
|
||||
};
|
||||
|
||||
/**
|
||||
* Import an instance of class Interface from a specification in an
|
||||
* input file. This is the preferred method to create an Interface
|
||||
* instance.
|
||||
*/
|
||||
inline Interface* importInterface(std::string infile, std::string id,
|
||||
std::vector<ThermoPhase*> phases) {
|
||||
std::vector<Cantera::ThermoPhase*> phases) {
|
||||
return new Interface(infile, id, phases);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,15 @@
|
|||
* The Definitions for these functions are all located in
|
||||
* libctxx.a
|
||||
*/
|
||||
|
||||
namespace Cantera {
|
||||
ThermoPhase* importPhase(std::string infile, std::string id="");
|
||||
|
||||
// -> this is a duplicate of a src/thermo/phasereport function
|
||||
// We'll leave it here so that these are available externally
|
||||
std::string report(const ThermoPhase& th, bool show_thermo);
|
||||
|
||||
|
||||
std::string formatCompList(const Phase& mix, int xyc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,29 @@
|
|||
#!/usr/local/bin/python
|
||||
##
|
||||
# @file ctml_writer.py
|
||||
#
|
||||
# Cantera .cti input file processor
|
||||
# @defgroup pygroup Cantera Python Interface
|
||||
#
|
||||
# The functions and classes in this module process Cantera .cti input
|
||||
# files and produce CTML files. It can be imported as a module, or used
|
||||
# as a script.
|
||||
#
|
||||
# script usage:
|
||||
#
|
||||
# python ctml_writer.py infile.cti
|
||||
#
|
||||
# This will produce CTML file 'infile.xml'
|
||||
#
|
||||
#
|
||||
|
||||
# $Id$
|
||||
#
|
||||
"""
|
||||
Cantera .cti input file processor
|
||||
|
||||
The functions and classes in this module process Cantera .cti input
|
||||
files and produce CTML files. It can be imported as a module, or used
|
||||
as a script.
|
||||
|
||||
script usage:
|
||||
|
||||
python ctml_writer.py infile.cti
|
||||
|
||||
This will produce CTML file 'infile.xml'
|
||||
|
||||
"""
|
||||
import string
|
||||
|
||||
class CTI_Error:
|
||||
"""Exception raised if an error is encountered while
|
||||
parsing the input file."""
|
||||
parsing the input file.
|
||||
@ingroup pygroup"""
|
||||
def __init__(self, msg):
|
||||
print '\n\n***** Error parsing input file *****\n\n'
|
||||
print msg
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* This file is included
|
||||
* in every file that is in the Cantera Namespace.
|
||||
*
|
||||
* All physical constants are storred here.
|
||||
* All physical constants are stored here.
|
||||
* The module physConstants is defined here.
|
||||
*/
|
||||
|
||||
|
|
@ -52,11 +52,12 @@
|
|||
namespace Cantera {
|
||||
|
||||
/*!
|
||||
* All physical constants are storred here.
|
||||
* All physical constants are stored here.
|
||||
*
|
||||
* @defgroup physConstants Physical Constants
|
||||
* %Cantera uses the MKS system of units. The unit for moles
|
||||
* is defined to be the kmol.
|
||||
* is defined to be the kmol. All values of physical constants
|
||||
* are consistent with the 2006 CODATA recommendations.
|
||||
* @ingroup globalData
|
||||
* @{
|
||||
*/
|
||||
|
|
@ -154,10 +155,12 @@ namespace Cantera {
|
|||
//! largest x such that exp(x) is valid
|
||||
const doublereal MaxExp = 690.775527898;
|
||||
|
||||
//! Fairly random number to be used to initialize variables against to see if they are subsequently defined.
|
||||
//! Fairly random number to be used to initialize variables against
|
||||
//! to see if they are subsequently defined.
|
||||
const doublereal Undef = -999.1234;
|
||||
//! Small number to compare differences of mole fractions against.
|
||||
const doublereal Tiny = 1.e-20;
|
||||
|
||||
//! inline function to return the max value of two doubles.
|
||||
/*!
|
||||
* @param x double value
|
||||
|
|
|
|||
|
|
@ -23,152 +23,157 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
/*!
|
||||
* @defgroup errorhandling Error Handling
|
||||
*
|
||||
* \brief These classes and related functions are used to handle errors and
|
||||
* unknown events within Cantera.
|
||||
*
|
||||
* The general idea is that exceptions are thrown using the common
|
||||
* base class called CanteraError. Derived types of CanteraError
|
||||
* characterize what type of error is thrown. A list of all
|
||||
* of the thrown errors is kept in the Application class.
|
||||
*
|
||||
* Any exceptions which are not caught cause a fatal error exit
|
||||
* from the program.
|
||||
*
|
||||
* Below is an example of how to catch errors that throw the CanteraError class.
|
||||
* In general, all Cantera C++ programs will have this basic structure.
|
||||
*
|
||||
* \include edemo.cpp
|
||||
*
|
||||
* The function showErrors() will p//rint out the fatal error condition to standard output.
|
||||
*
|
||||
* A group of defines may be used during debugging to assert conditions which should
|
||||
* be true. These are named AssertTrace(), AssertThrow(), and AssertThrowMsg().
|
||||
* Examples of their usage is given below.
|
||||
*
|
||||
* @code
|
||||
* AssertTrace(p == OneAtm);
|
||||
* AssertThrow(p == OneAtm, "Kinetics::update");
|
||||
* AssertThrowMsg(p == OneAtm, "Kinetics::update", "Algorithm limited to atmospheric pressure");
|
||||
* @endcode
|
||||
*
|
||||
* Their first argument is a boolean. If the boolean is not true, a CanteraError is thrown, with
|
||||
* descriptive information indicating where the error occured. These functions may be eliminated
|
||||
* from the source code, if the -DNDEBUG option is specified to the compiler.
|
||||
*
|
||||
*/
|
||||
/*!
|
||||
* @defgroup errorhandling Error Handling
|
||||
*
|
||||
* \brief These classes and related functions are used to handle errors and
|
||||
* unknown events within Cantera.
|
||||
*
|
||||
* The general idea is that exceptions are thrown using the common
|
||||
* base class called CanteraError. Derived types of CanteraError
|
||||
* characterize what type of error is thrown. A list of all
|
||||
* of the thrown errors is kept in the Application class.
|
||||
*
|
||||
* Any exceptions which are not caught cause a fatal error exit
|
||||
* from the program.
|
||||
*
|
||||
* Below is an example of how to catch errors that throw the CanteraError class.
|
||||
* In general, all Cantera C++ programs will have this basic structure.
|
||||
*
|
||||
* \include edemo.cpp
|
||||
*
|
||||
* The function showErrors() will print out the fatal error
|
||||
* condition to standard output.
|
||||
*
|
||||
* A group of defines may be used during debugging to assert
|
||||
* conditions which should be true. These are named AssertTrace(),
|
||||
* AssertThrow(), and AssertThrowMsg(). Examples of their usage is
|
||||
* given below.
|
||||
*
|
||||
* @code
|
||||
* AssertTrace(p == OneAtm);
|
||||
* AssertThrow(p == OneAtm, "Kinetics::update");
|
||||
* AssertThrowMsg(p == OneAtm, "Kinetics::update",
|
||||
* "Algorithm limited to atmospheric pressure");
|
||||
* @endcode
|
||||
*
|
||||
* Their first argument is a boolean. If the boolean is not true, a
|
||||
* CanteraError is thrown, with descriptive information indicating
|
||||
* where the error occured. These functions may be eliminated from
|
||||
* the source code, if the -DNDEBUG option is specified to the
|
||||
* compiler.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//! Base class for exceptions thrown by Cantera classes.
|
||||
/*!
|
||||
* This class is the base class for exceptions thrown by Cantera.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class CanteraError {
|
||||
public:
|
||||
//! Normal Constructor for the CanteraError base class
|
||||
//! Base class for exceptions thrown by Cantera classes.
|
||||
/*!
|
||||
* This class doesn't have any storage associated with it. In its
|
||||
* constructor, a call to the Application class is made to store
|
||||
* the strings associated with the generated error condition.
|
||||
* This class is the base class for exceptions thrown by Cantera.
|
||||
*
|
||||
* @param proc String name for the function within which the error was
|
||||
* generated.
|
||||
* @param msg Descriptive string describing the type of error message.
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
CanteraError(std::string proc, std::string msg);
|
||||
class CanteraError {
|
||||
public:
|
||||
//! Normal Constructor for the CanteraError base class
|
||||
/*!
|
||||
* This class doesn't have any storage associated with it. In its
|
||||
* constructor, a call to the Application class is made to store
|
||||
* the strings associated with the generated error condition.
|
||||
*
|
||||
* @param proc String name for the function within which the error was
|
||||
* generated.
|
||||
* @param msg Descriptive string describing the type of error message.
|
||||
*/
|
||||
CanteraError(std::string proc, std::string msg);
|
||||
|
||||
//! Destructor for base class does nothing
|
||||
virtual ~CanteraError(){}
|
||||
protected:
|
||||
//! Empty base constructor is made protected so that it may be used only by
|
||||
//! inherited classes.
|
||||
/*!
|
||||
* We want to discourage throwing an error containing no information.
|
||||
*/
|
||||
CanteraError() {}
|
||||
};
|
||||
//! Destructor for base class does nothing
|
||||
virtual ~CanteraError(){}
|
||||
protected:
|
||||
//! Empty base constructor is made protected so that it may be used only by
|
||||
//! inherited classes.
|
||||
/*!
|
||||
* We want to discourage throwing an error containing no information.
|
||||
*/
|
||||
CanteraError() {}
|
||||
};
|
||||
|
||||
//! Array size error.
|
||||
/*!
|
||||
* This error is thrown if a supplied length to a vector supplied
|
||||
* to Cantera is too small.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ArraySizeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
//! Array size error.
|
||||
/*!
|
||||
* The length needed is supplied by the argument, reqd, and the
|
||||
* length supplied is given by the argument sz.
|
||||
* This error is thrown if a supplied length to a vector supplied
|
||||
* to Cantera is too small.
|
||||
*
|
||||
* @param proc String name for the function within which the error was
|
||||
* generated.
|
||||
* @param sz This is the length supplied to Cantera.
|
||||
* @param reqd This is the required length needed by Cantera
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
ArraySizeError(std::string proc, int sz, int reqd);
|
||||
};
|
||||
class ArraySizeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* The length needed is supplied by the argument, reqd, and the
|
||||
* length supplied is given by the argument sz.
|
||||
*
|
||||
* @param proc String name for the function within which the error was
|
||||
* generated.
|
||||
* @param sz This is the length supplied to Cantera.
|
||||
* @param reqd This is the required length needed by Cantera
|
||||
*/
|
||||
ArraySizeError(std::string proc, int sz, int reqd);
|
||||
};
|
||||
|
||||
//! An element index is out of range.
|
||||
/*!
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ElementRangeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
//! An element index is out of range.
|
||||
/*!
|
||||
* This class indicates an out-of-bounds index.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ElementRangeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* This class indicates an out-of-bounds index.
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param m This is the value of the out-of-bounds index.
|
||||
* @param mmax This is the maximum allowed value of the index. The
|
||||
* minimum allowed value is assumed to be 0.
|
||||
*/
|
||||
ElementRangeError(std::string func, int m, int mmax);
|
||||
};
|
||||
|
||||
//! Print a warning when a deprecated method is called.
|
||||
/*!
|
||||
* These methods are slated to go away in future releases of Cantera.
|
||||
* The developer should work towards eliminating the use of these
|
||||
* methods in the near future.
|
||||
*
|
||||
* @param classnm Class the method belongs to
|
||||
* @param oldnm Name of the deprecated method
|
||||
* @param newnm Name of the method users should use instead
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void deprecatedMethod(std::string classnm, std::string oldnm, std::string newnm);
|
||||
|
||||
//! Throw an error condition for a procedure that has been removed.
|
||||
/*!
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param m This is the value of the out-of-bounds index.
|
||||
* @param mmax This is the maximum allowed value of the index. The
|
||||
* minimum allowed value is assumed to be 0.
|
||||
* @param version Version of Cantera that first removed this function.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
ElementRangeError(std::string func, int m, int mmax);
|
||||
};
|
||||
void removeAtVersion(std::string func, std::string version);
|
||||
|
||||
//! Print a warning when a deprecated method is called.
|
||||
/*!
|
||||
* These methods are slated to go away in future releases of Cantera.
|
||||
* The developer should work towards eliminating the use of these
|
||||
* methods in the near future.
|
||||
*
|
||||
* @param classnm Class the method belongs to
|
||||
* @param oldnm Name of the deprecated method
|
||||
* @param newnm Name of the method users should use instead
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void deprecatedMethod(std::string classnm, std::string oldnm, std::string newnm);
|
||||
|
||||
//! Throw an error condition for a procedure that has been removed.
|
||||
/*!
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param version Version of Cantera that first removed this function.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void removeAtVersion(std::string func, std::string version);
|
||||
|
||||
//! Provides a line number
|
||||
//! Provides a line number
|
||||
#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
|
||||
|
||||
//! Provides a line number
|
||||
//! Provides a line number
|
||||
#define STR_TRACE_LINE(s) #s
|
||||
|
||||
//! Provides a std::string variable containing the file and line number
|
||||
/*!
|
||||
* This is a std:string containing the file name and the line number
|
||||
*/
|
||||
//! Provides a std::string variable containing the file and line number
|
||||
/*!
|
||||
* This is a std:string containing the file name and the line number
|
||||
*/
|
||||
#define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
|
@ -177,41 +182,43 @@ namespace Cantera {
|
|||
# define AssertThrowMsg(expr,proc, message) ((void) (0))
|
||||
#else
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string containing the
|
||||
* file and line number, indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string containing the
|
||||
* file and line number, indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
# define AssertTrace(expr) ((expr) ? (void) 0 : throw Cantera::CanteraError(STR_TRACE, std::string("failed assert: ") + #expr))
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param proc Character string or std:string expression indicating the procedure where the assertion failed
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param proc Character string or std:string expression indicating the procedure where the assertion failed
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
# define AssertThrow(expr, proc) ((expr) ? (void) 0 : throw Cantera::CanteraError(proc, std::string("failed assert: ") + #expr))
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param proc Character string or std:string expression indicating the procedure where the assertion failed
|
||||
* @param message Character string or std:string expression contaiing a descriptive
|
||||
* message is added to the thrown error condition.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A
|
||||
* diagnostic string indicating where the error occured is added
|
||||
* to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param proc Character string or std:string expression indicating
|
||||
* the procedure where the assertion failed
|
||||
* @param message Character string or std:string expression contaiing
|
||||
* a descriptive message is added to the thrown error condition.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
# define AssertThrowMsg(expr, proc, message) ((expr) ? (void) 0 : throw Cantera::CanteraError(proc + std::string(": at failed assert: \"") + std::string(#expr) + std::string("\""), message))
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
* This file contains definitions for utility functions and text for modules,
|
||||
* inputfiles, logs, textlogs, HTML_logs (see \ref inputfiles, \ref logs, \ref textlogs and \ref HTML_logs).
|
||||
*
|
||||
* @ingroup utils
|
||||
*
|
||||
* These functions store
|
||||
* some parameters in global storage that are accessible at all times
|
||||
* from the calling application.
|
||||
|
|
|
|||
|
|
@ -7,37 +7,28 @@
|
|||
// Copyright 2001 California Institute of Technology
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup utils Templated Utility Functions
|
||||
*
|
||||
* These are templates to perform various simple operations on arrays.
|
||||
* Note that the compiler will inline these, so using them carries no
|
||||
* performnce penalty.
|
||||
*/
|
||||
|
||||
#ifndef CT_UTILITIES_H
|
||||
#define CT_UTILITIES_H
|
||||
|
||||
#include "ct_defs.h"
|
||||
|
||||
//#ifdef DARWIN
|
||||
//#include <Accelerate.h>
|
||||
//#endif
|
||||
|
||||
//! Templated unary operator that carries out a multiplication operation
|
||||
/*!
|
||||
/**
|
||||
* Unary operator to multiply the argument by a constant. The form of
|
||||
* this operator is designed for use by std::transform. @see @ref
|
||||
* scale.
|
||||
*/
|
||||
template<class T> struct timesConstant : public std::unary_function<T, double>
|
||||
{
|
||||
//! Constructor
|
||||
/*!
|
||||
* @param c Stores the value of c as the internal constant.
|
||||
*/
|
||||
timesConstant(T c) : m_c(c) {}
|
||||
|
||||
//! Parenthesis operator that carries out a unary multiplication
|
||||
//! and returns a double
|
||||
/*!
|
||||
* @param x value of the class which is input
|
||||
*
|
||||
* @return
|
||||
* return m_c * x, which is defined as a double
|
||||
*/
|
||||
double operator()(T x) {return m_c * x;}
|
||||
|
||||
//! Internal storred value of the constant
|
||||
T m_c;
|
||||
};
|
||||
|
||||
|
|
@ -49,7 +40,6 @@ namespace Cantera {
|
|||
*
|
||||
*/
|
||||
//@{
|
||||
|
||||
|
||||
//! Maximum of two templated quantities, i and j.
|
||||
/*!
|
||||
|
|
@ -84,7 +74,7 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
|
||||
//! Tempalted Inner product of two vectors of length 4.
|
||||
//! Templated Inner product of two vectors of length 4.
|
||||
/*!
|
||||
* If either \a x
|
||||
* or \a y has length greater than 4, only the first 4 elements
|
||||
|
|
@ -160,10 +150,6 @@ namespace Cantera {
|
|||
inline doublereal dot(InputIter x_begin, InputIter x_end,
|
||||
InputIter2 y_begin) {
|
||||
return inner_product(x_begin, x_end, y_begin, 0.0);
|
||||
//doublereal sum = 0.0;
|
||||
//for(; x_begin != x_end; ++x_begin, ++y_begin)
|
||||
//sum += *x_begin * *y_begin;
|
||||
//return sum;
|
||||
}
|
||||
|
||||
//! Multiply elements of an array by a scale factor.
|
||||
|
|
@ -186,8 +172,6 @@ namespace Cantera {
|
|||
inline void scale(InputIter begin, InputIter end,
|
||||
OutputIter out, S scale_factor) {
|
||||
transform(begin, end, out, timesConstant<S>(scale_factor));
|
||||
// for (; begin != end; ++begin, ++out)
|
||||
//*out = scale_factor * *begin;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -195,7 +179,8 @@ namespace Cantera {
|
|||
* result to an existing array, x. This is essentially a templated daxpy_
|
||||
* operation.
|
||||
*
|
||||
* The template arguments are: template<class InputIter, class OutputIter, class S>
|
||||
* The template arguments are: template<class InputIter,
|
||||
* class OutputIter, class S>
|
||||
*
|
||||
* Simple Code Example of the functionality;
|
||||
* @code
|
||||
|
|
@ -582,11 +567,7 @@ namespace Cantera {
|
|||
*/
|
||||
template<class OutputIter>
|
||||
inline void scale(int N, double alpha, OutputIter x) {
|
||||
//#ifdef DARWINNNN
|
||||
//cblas_dscal(N, alpha, x, 1);
|
||||
//#else
|
||||
scale(x, x+N, x, alpha);
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -635,10 +616,10 @@ namespace Cantera {
|
|||
c[2])*x + c[1])*x + c[0]);
|
||||
}
|
||||
|
||||
//! Templated evaluation of a polynomial of order 4
|
||||
//! Evaluates a polynomial of order 4.
|
||||
/*!
|
||||
* @param x Value of the independent variable - First template parameter
|
||||
* @param c Pointer to the polynomial - Second template parameter
|
||||
* @param x Value of the independent variable.
|
||||
* @param c Pointer to the polynomial coefficient array.
|
||||
*/
|
||||
template<class D, class R>
|
||||
R poly4(D x, R* c) {
|
||||
|
|
|
|||
|
|
@ -11,14 +11,6 @@
|
|||
|
||||
// Copyright 2001 California Institute of Technology
|
||||
|
||||
/**
|
||||
* @defgroup electrochem Electrochemistry
|
||||
*
|
||||
* Support for electrochemical reaction kinetics.
|
||||
*
|
||||
* @ingroup chemkinetics
|
||||
*/
|
||||
|
||||
#ifndef CT_IFACEKINETICS_H
|
||||
#define CT_IFACEKINETICS_H
|
||||
|
||||
|
|
|
|||
|
|
@ -115,15 +115,15 @@ namespace Cantera {
|
|||
|
||||
//! Public interface for kinetics managers.
|
||||
/*!
|
||||
* This class serves as a
|
||||
* base class to derive 'kinetics managers', which are classes
|
||||
* that manage homogeneous chemistry within one phase, or
|
||||
* heterogeneous chemistry at one interface. The virtual methods
|
||||
* of this class are meant to be overloaded in subclasses. The
|
||||
* non-virtual methods perform generic functions and are
|
||||
* implemented in Kinetics. They should not be overloaded. Only
|
||||
* those methods required by a subclass need to be overloaded;
|
||||
* the rest will throw exceptions if called.
|
||||
* This class serves as a base class to derive 'kinetics
|
||||
* managers', which are classes that manage homogeneous chemistry
|
||||
* within one phase, or heterogeneous chemistry at one
|
||||
* interface. The virtual methods of this class are meant to be
|
||||
* overloaded in subclasses. The non-virtual methods perform
|
||||
* generic functions and are implemented in Kinetics. They should
|
||||
* not be overloaded. Only those methods required by a subclass
|
||||
* need to be overloaded; the rest will throw exceptions if
|
||||
* called.
|
||||
*
|
||||
* When the nomenclature "kinetics species index" is used below,
|
||||
* this means that the species index ranges over all species in
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file solveSP.h
|
||||
* Header file for implicit surface problem solver
|
||||
* (see \ref kinetics and class \link Cantera::solveSP solveSP\endlink).
|
||||
* (see \ref chemkinetics and class \link Cantera::solveSP solveSP\endlink).
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@ namespace CanteraSpectra {
|
|||
* F(x, y) = \frac{y}{\pi}\int_{-\infty}^{+\infty} \frac{e^{-z^2}}
|
||||
* {(x - z)^2 + y^2} dz
|
||||
* \f]
|
||||
* The algorithm used to cmpute this function is described in the
|
||||
* reference below. @see F. G. Lether and P. R. Wenston, "The
|
||||
* numerical computation of the %Voigt function by a corrected
|
||||
* midpoint quadrature rule for \f$ (-\infty, \infty) \f$. Journal
|
||||
* of Computational and Applied Mathematics}, 34 (1):75--92, 1991.
|
||||
*/
|
||||
doublereal Voigt::F(doublereal x) {
|
||||
|
||||
|
|
@ -98,25 +103,22 @@ namespace CanteraSpectra {
|
|||
double b = (tau + x)/y;
|
||||
double t = b*y;
|
||||
double f1, f2, f3;
|
||||
double c0 = 2.0/(Pi*m_eps); // eps or e?
|
||||
const double c0 = 2.0/(Pi*exp(0.0));
|
||||
const double c1 = 1.0/SqrtTwo;
|
||||
const double c2 = 2.0/SqrtPi;
|
||||
|
||||
if (y > c0/m_eps) {
|
||||
//cout << "returning 0.0 since y > c0/m_eps" << endl;
|
||||
return 0.0;
|
||||
}
|
||||
//{
|
||||
// throw CanteraError("Voigt::F",
|
||||
// "condition that y < c0/epsilon violated");
|
||||
//}
|
||||
double f0, ef0;
|
||||
while (1 > 0) {
|
||||
f1 = c2*y*exp(-Pi*Pi/(t*t));
|
||||
f0 = Pi*Pi/(t*t);
|
||||
ef0 = exp(-f0);
|
||||
f1 = c2*y*ef0;
|
||||
f2 = fabs(y*y - Pi*Pi/(t*t));
|
||||
f3 = 1.0 - pow(exp(-Pi*Pi/(t*t)),2);
|
||||
f3 = 1.0 - ef0*ef0;
|
||||
t *= c1;
|
||||
// cout << "t = " << t << endl;
|
||||
if ((f1/(f2*f3)) < 0.5*m_eps) break;
|
||||
if (f1/(f2*f3) < 0.5*m_eps) break;
|
||||
}
|
||||
double h = t/y;
|
||||
int N = int(0.5 + b/h);
|
||||
|
|
@ -132,11 +134,8 @@ namespace CanteraSpectra {
|
|||
C = 2.0*exp(y*y - x*x)*cos(2*x*y)/(1.0 + exp(2*Pi/h));
|
||||
}
|
||||
else {
|
||||
//cout << "returning 0, since y2 > Pi/h" << endl;
|
||||
return 0.0;
|
||||
}
|
||||
//cout << "for x = " << x << ", y = " << y << endl;
|
||||
//cout << "V(x,y) = " << Q+C << endl;
|
||||
return Q + C;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ PIC_FLAG=@PIC@
|
|||
|
||||
CXX_FLAGS = @CXXFLAGS@ $(LOCAL_DEFS) $(CXX_OPT) $(PIC_FLAG) $(DEBUG_FLAG)
|
||||
|
||||
SPECTRA_OBJ = rotor.o LineBroadener.o
|
||||
SPECTRA_OBJ = rotor.o LineBroadener.o spectralUtilities.o
|
||||
|
||||
SPECTRA_H = rotor.h LineBroadener.h
|
||||
SPECTRA_H = rotor.h LineBroadener.h Nuclei.h spectralUtilities.h
|
||||
|
||||
CXX_INCLUDES = -I. @CXX_INCLUDES@ -I../base
|
||||
LIB = @buildlib@/libctspectra.a
|
||||
|
|
|
|||
|
|
@ -1,27 +1,18 @@
|
|||
|
||||
#include "Cantera.h"
|
||||
#include "spectra.h"
|
||||
#include "kernel/Nuclei.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
using namespace CanteraSpectra;
|
||||
|
||||
int main() {
|
||||
// double B;
|
||||
// double T;
|
||||
// cout << "enter B, T: ";
|
||||
// cin >> B >> T;
|
||||
// Rotor* r = new Rotor(B);
|
||||
// double theta = wnum_to_J(B)/Boltzmann;
|
||||
// cout << "theta = " << theta << endl;
|
||||
// double pop, cpop = 0.0;
|
||||
// for (int j = 0; j < 50; j++) {
|
||||
// pop = r->population(j, T);
|
||||
// cpop += pop;
|
||||
// if (cpop > 0.999) break;
|
||||
// cout << j << ", " << r->energy_w(j) << ", "
|
||||
// << r->frequency(j, j+1) << ", "
|
||||
// << pop << ", " << cpop << ", " << r->partitionFunction(T) << ", " << T/theta << endl;
|
||||
// }
|
||||
|
||||
Nucleus* a = CanteraSpectra::HydrogenNucleus();
|
||||
Nucleus* b = HydrogenNucleus();
|
||||
if (*a == *b) {
|
||||
cout << "a and b and indistinguishable" << endl;
|
||||
}
|
||||
|
||||
// test line broading classes
|
||||
double gam = 2.0e0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue