Fixed code formatting

This commit is contained in:
Ray Speth 2012-07-18 18:32:29 +00:00
parent e77990ab24
commit 3ce3da1fa2
53 changed files with 1417 additions and 1414 deletions

View file

@ -14,7 +14,8 @@
#endif #endif
namespace Cantera { namespace Cantera
{
#ifdef THREAD_SAFE_CANTERA #ifdef THREAD_SAFE_CANTERA
@ -42,7 +43,8 @@ typedef boost::mutex::scoped_lock ScopedLock;
#else #else
typedef int mutex_t; typedef int mutex_t;
class ScopedLock { class ScopedLock
{
public: public:
explicit ScopedLock(const int m) : m_(m) {} explicit ScopedLock(const int m) : m_(m) {}
private: private:

View file

@ -94,7 +94,9 @@ public:
virtual std::string getMessage() const; virtual std::string getMessage() const;
//! Method overridden by derived classes to indicate their type //! Method overridden by derived classes to indicate their type
virtual std::string getClass() const { return "CanteraError"; } virtual std::string getClass() const {
return "CanteraError";
}
protected: protected:
//! Protected default constructor discourages throwing errors containing no information. //! Protected default constructor discourages throwing errors containing no information.
@ -137,7 +139,9 @@ public:
CanteraError(procedure), sz_(sz), reqd_(reqd) {} CanteraError(procedure), sz_(sz), reqd_(reqd) {}
virtual std::string getMessage() const; virtual std::string getMessage() const;
virtual std::string getClass() const { return "ArraySizeError"; } virtual std::string getClass() const {
return "ArraySizeError";
}
private: private:
size_t sz_, reqd_; size_t sz_, reqd_;
@ -166,7 +170,9 @@ public:
virtual ~IndexError() throw() {}; virtual ~IndexError() throw() {};
virtual std::string getMessage() const; virtual std::string getMessage() const;
virtual std::string getClass() const { return "IndexError"; } virtual std::string getClass() const {
return "IndexError";
}
private: private:
std::string arrayName_; std::string arrayName_;

View file

@ -28,8 +28,7 @@ class SpeciesThermoFactory;
class XML_Node; class XML_Node;
//! Rules for parsing and installing reactions //! Rules for parsing and installing reactions
struct ReactionRules struct ReactionRules {
{
ReactionRules(); ReactionRules();
bool skipUndeclaredSpecies; bool skipUndeclaredSpecies;
bool skipUndeclaredThirdBodies; bool skipUndeclaredThirdBodies;

View file

@ -20,20 +20,20 @@
namespace Cantera namespace Cantera
{ {
//! A species thermodynamic property manager for a phase. //! A species thermodynamic property manager for a phase.
/*! /*!
* This is a general manager that can handle a wide variety * This is a general manager that can handle a wide variety
* of species thermodynamic polynomials for individual species. * of species thermodynamic polynomials for individual species.
* It is slow, however, because it recomputes the functions of * It is slow, however, because it recomputes the functions of
* temperature needed for each species. What it does is to create * temperature needed for each species. What it does is to create
* a vector of SpeciesThermoInterpType objects. * a vector of SpeciesThermoInterpType objects.
* *
* @ingroup mgrsrefcalc * @ingroup mgrsrefcalc
*/ */
class GeneralSpeciesThermo : public SpeciesThermo class GeneralSpeciesThermo : public SpeciesThermo
{ {
public: public:
//! Constructor //! Constructor
GeneralSpeciesThermo(); GeneralSpeciesThermo();
@ -214,7 +214,7 @@ namespace Cantera
#endif #endif
private: private:
//! Provide the SpeciesthermoInterpType object //! Provide the SpeciesthermoInterpType object
/*! /*!
* provide access to the SpeciesThermoInterpType object. * provide access to the SpeciesThermoInterpType object.
@ -226,7 +226,7 @@ namespace Cantera
*/ */
SpeciesThermoInterpType* provideSTIT(size_t k); SpeciesThermoInterpType* provideSTIT(size_t k);
protected: protected:
/** /**
* This is the main unknown in the object. It is * This is the main unknown in the object. It is
@ -261,7 +261,7 @@ namespace Cantera
friend class VPSSMgr; friend class VPSSMgr;
}; };
} }

View file

@ -424,64 +424,64 @@ public:
* property manager. * property manager.
* @see SpeciesThermo * @see SpeciesThermo
*/ */
virtual doublereal cp_mole() const; virtual doublereal cp_mole() const;
/** /**
* Molar heat capacity at constant volume. Units: J/kmol/K. * Molar heat capacity at constant volume. Units: J/kmol/K.
* For an ideal gas mixture, * For an ideal gas mixture,
* \f[ \hat c_v = \hat c_p - \hat R. \f] * \f[ \hat c_v = \hat c_p - \hat R. \f]
*/ */
virtual doublereal cv_mole() const; virtual doublereal cv_mole() const;
/** /**
* @returns species translational/rotational specific heat at * @returns species translational/rotational specific heat at
* constant volume. Inferred from the species gas * constant volume. Inferred from the species gas
* constant and number of translational/rotational * constant and number of translational/rotational
* degrees of freedom. The translational/rotational * degrees of freedom. The translational/rotational
* modes are assumed to be fully populated, and are * modes are assumed to be fully populated, and are
* given by * given by
* \f[ * \f[
* C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{5}{2} R_s * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{5}{2} R_s
* \f] * \f]
* for diatomic molecules and * for diatomic molecules and
* \f[ * \f[
* C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{3}{2} R_s * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{3}{2} R_s
* \f] * \f]
* for atoms. * for atoms.
*/ */
virtual doublereal cv_tr(doublereal ) const; virtual doublereal cv_tr(doublereal) const;
/** /**
* @returns species translational specific heat at constant volume. * @returns species translational specific heat at constant volume.
* Since the translational modes are assumed to be fully populated * Since the translational modes are assumed to be fully populated
* this is simply * this is simply
* \f[ * \f[
* C^{trans}_{v,s} \equiv \frac{\partial e^{trans}_s}{\partial T} = \frac{3}{2} R_s * C^{trans}_{v,s} \equiv \frac{\partial e^{trans}_s}{\partial T} = \frac{3}{2} R_s
* \f] * \f]
*/ */
virtual doublereal cv_trans() const; virtual doublereal cv_trans() const;
/** /**
* @returns species rotational specific heat at constant volume. * @returns species rotational specific heat at constant volume.
* By convention, we lump the translational/rotational components * By convention, we lump the translational/rotational components
* \f[ * \f[
* C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s} * C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s}
* \f] * \f]
* so then * so then
* \f[ * \f[
* C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s} * C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s}
* \f] * \f]
*/ */
virtual doublereal cv_rot(double atomicity) const; virtual doublereal cv_rot(double atomicity) const;
/** /**
* @returns species vibrational specific heat at * @returns species vibrational specific heat at
* constant volume. This is defined as * constant volume. This is defined as
* \f[ * \f[
* C^{vib}_{v,s} \equiv \frac{\partial e^{vib}_s}{\partial T_V} = \frac{R_s \theta_{vs}^2 \exp\left(\theta_{vs}/T_V\right)}{\left[\left(\exp\left(\theta_{vs}/T_V\right)-1\right)T_V\right]^2} * C^{vib}_{v,s} \equiv \frac{\partial e^{vib}_s}{\partial T_V} = \frac{R_s \theta_{vs}^2 \exp\left(\theta_{vs}/T_V\right)}{\left[\left(\exp\left(\theta_{vs}/T_V\right)-1\right)T_V\right]^2}
* \f] * \f]
*/ */
virtual doublereal cv_vib(int k, doublereal T) const; virtual doublereal cv_vib(int k, doublereal T) const;
//@} //@}

View file

@ -254,11 +254,11 @@ public:
} }
} }
//! Modify parameters for the standard state //! Modify parameters for the standard state
/*! /*!
* @param coeffs Vector of coefficients used to set the * @param coeffs Vector of coefficients used to set the
* parameters for the standard state. * parameters for the standard state.
*/ */
virtual void modifyParameters(doublereal* coeffs) { virtual void modifyParameters(doublereal* coeffs) {
m_coeff[0] = coeffs[5]; m_coeff[0] = coeffs[5];
m_coeff[1] = coeffs[6]; m_coeff[1] = coeffs[6];

View file

@ -106,8 +106,8 @@ public:
//! @param right Reference to the class to be used in the copy //! @param right Reference to the class to be used in the copy
Phase(const Phase& right); Phase(const Phase& right);
//! Assignment operator //! Assignment operator
//! @param right Reference to the class to be used in the copy //! @param right Reference to the class to be used in the copy
Phase& operator=(const Phase& right); Phase& operator=(const Phase& right);
//! Returns a reference to the XML_Node stored for the phase. //! Returns a reference to the XML_Node stored for the phase.

View file

@ -74,8 +74,7 @@ public:
/*! /*!
* @param right Object to be copied * @param right Object to be copied
*/ */
SpeciesThermoDuo(const SpeciesThermoDuo& right) SpeciesThermoDuo(const SpeciesThermoDuo& right) {
{
*this = operator=(right); *this = operator=(right);
} }
@ -128,8 +127,7 @@ public:
* @param stit_ptr Pointer to the SpeciesThermoInterpType object * @param stit_ptr Pointer to the SpeciesThermoInterpType object
* This will set up the thermo for one species * This will set up the thermo for one species
*/ */
virtual void install_STIT(SpeciesThermoInterpType* stit_ptr) virtual void install_STIT(SpeciesThermoInterpType* stit_ptr) {
{
throw CanteraError("install_STIT", "not implemented"); throw CanteraError("install_STIT", "not implemented");
} }
@ -161,8 +159,7 @@ public:
* *
* @param k Species index * @param k Species index
*/ */
virtual doublereal minTemp(size_t k = npos) const virtual doublereal minTemp(size_t k = npos) const {
{
return std::max(m_thermo1.minTemp(),m_thermo2.minTemp()); return std::max(m_thermo1.minTemp(),m_thermo2.minTemp());
} }
@ -176,8 +173,7 @@ public:
* *
* @param k index for parameterization k * @param k index for parameterization k
*/ */
virtual doublereal maxTemp(size_t k = npos) const virtual doublereal maxTemp(size_t k = npos) const {
{
return std::min(m_thermo1.maxTemp(), m_thermo2.maxTemp()); return std::min(m_thermo1.maxTemp(), m_thermo2.maxTemp());
} }
@ -194,8 +190,7 @@ public:
* *
* @param k index for parameterization k * @param k index for parameterization k
*/ */
virtual doublereal refPressure(size_t k = npos) const virtual doublereal refPressure(size_t k = npos) const {
{
return m_p0; return m_p0;
} }

View file

@ -4,7 +4,7 @@
* from * from
*/ */
/* /*
* Copywrite (2006) Sandia Corporation. Under the terms of * Copyright(2006) Sandia Corporation. Under the terms of
* Contract DE-AC04-94AL85000 with Sandia Corporation, the * Contract DE-AC04-94AL85000 with Sandia Corporation, the
* U.S. Government retains certain rights in this software. * U.S. Government retains certain rights in this software.
*/ */
@ -12,28 +12,23 @@
#ifndef CT_STATMECH_H #ifndef CT_STATMECH_H
#define CT_STATMECH_H #define CT_STATMECH_H
/*
* $Revision: 279 $
* $Date: 2009-12-05 13:08:43 -0600 (Sat, 05 Dec 2009) $
*/
#include "cantera/base/global.h" #include "cantera/base/global.h"
#include "SpeciesThermoInterpType.h" #include "SpeciesThermoInterpType.h"
#include "SpeciesThermoMgr.h" #include "SpeciesThermoMgr.h"
#include <string> #include <string>
#include <map> #include <map>
namespace Cantera { namespace Cantera
{
//! //!
/*! /*!
* @ingroup spthermo * @ingroup spthermo
*/ */
class StatMech : public SpeciesThermoInterpType { class StatMech : public SpeciesThermoInterpType
{
public: public:
//! Empty constructor //! Empty constructor
StatMech(); StatMech();
@ -49,7 +44,7 @@ namespace Cantera {
* parameters for the standard state. * parameters for the standard state.
*/ */
StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref, StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref,
const doublereal* coeffs, std::string my_name); const doublereal* coeffs, std::string my_name);
//! copy constructor //! copy constructor
/*! /*!
@ -67,7 +62,7 @@ namespace Cantera {
virtual ~StatMech(); virtual ~StatMech();
//! duplicator //! duplicator
virtual SpeciesThermoInterpType * virtual SpeciesThermoInterpType*
duplMyselfAsSpeciesThermoInterpType() const; duplMyselfAsSpeciesThermoInterpType() const;
//! Returns the minimum temperature that the thermo //! Returns the minimum temperature that the thermo
@ -115,7 +110,7 @@ namespace Cantera {
* (length m_kk). * (length m_kk).
*/ */
virtual void updateProperties(const doublereal* tt, virtual void updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const;
//! Compute the reference-state property of one species //! Compute the reference-state property of one species
@ -144,8 +139,8 @@ namespace Cantera {
* (length m_kk). * (length m_kk).
*/ */
virtual void updatePropertiesTemp(const doublereal temp, virtual void updatePropertiesTemp(const doublereal temp,
doublereal* cp_R, doublereal* h_RT, doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const; doublereal* s_R) const;
//!This utility function reports back the type of //!This utility function reports back the type of
//! parameterization and all of the parameters for the //! parameterization and all of the parameters for the
@ -167,10 +162,10 @@ namespace Cantera {
* coeffs[2] is max temperature * coeffs[2] is max temperature
* coeffs[3+i] from i =0,9 are the coefficients themselves * coeffs[3+i] from i =0,9 are the coefficients themselves
*/ */
virtual void reportParameters(size_t& n, int &type, virtual void reportParameters(size_t& n, int& type,
doublereal &tlow, doublereal &thigh, doublereal& tlow, doublereal& thigh,
doublereal &pref, doublereal& pref,
doublereal* const coeffs) const; doublereal* const coeffs) const;
//! Modify parameters for the standard state //! Modify parameters for the standard state
/*! /*!
@ -179,7 +174,7 @@ namespace Cantera {
*/ */
virtual void modifyParameters(doublereal* coeffs); virtual void modifyParameters(doublereal* coeffs);
protected: protected:
//! lowest valid temperature //! lowest valid temperature
doublereal m_lowT; doublereal m_lowT;
//! highest valid temperature //! highest valid temperature
@ -196,24 +191,23 @@ namespace Cantera {
//*generic species struct that contains everything we need here //*generic species struct that contains everything we need here
// achtung: add doxygen markup here // achtung: add doxygen markup here
// achtung: convert doubles to realdoubles // achtung: convert doubles to realdoubles
struct species struct species {
{ //Nominal T-R Degrees of freedom (cv = cfs*k*T)
//Nominal T-R Degrees of freedom (cv = cfs*k*T) doublereal cfs;
doublereal cfs;
// Mol. Wt. Molecular weight (kg/kmol) // Mol. Wt. Molecular weight (kg/kmol)
doublereal mol_weight; doublereal mol_weight;
// number of vibrational temperatures necessary // number of vibrational temperatures necessary
int nvib; int nvib;
// Theta_v Characteristic vibrational temperature(s) (K) // Theta_v Characteristic vibrational temperature(s) (K)
doublereal theta[5]; doublereal theta[5];
}; };
std::map<std::string,species*> name_map; std::map<std::string,species*> name_map;
}; };
} }
#endif #endif

View file

@ -298,15 +298,15 @@ public:
return err("cv_mole"); return err("cv_mole");
} }
/** /**
* @returns species vibrational specific heat at * @returns species vibrational specific heat at
* constant volume. * constant volume.
* *
*/ */
/// Molar heat capacity at constant volume. Units: J/kmol/K. /// Molar heat capacity at constant volume. Units: J/kmol/K.
virtual doublereal cv_vib(int, double) const { virtual doublereal cv_vib(int, double) const {
return err("cv_vib"); return err("cv_vib");
} }
/** /**
* @} * @}

View file

@ -7,7 +7,8 @@
#include "TransportBase.h" #include "TransportBase.h"
namespace Cantera { namespace Cantera
{
//! Class GasTransport implements some functions and properties that are //! Class GasTransport implements some functions and properties that are
//! shared by the MixTransport and MultiTransport classes. //! shared by the MixTransport and MultiTransport classes.

View file

@ -3,24 +3,12 @@
* Header file defining class PecosTransport * Header file defining class PecosTransport
*/ */
/* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology // Copyright 2001 California Institute of Technology
#ifndef CT_PECOSTRAN_H #ifndef CT_PECOSTRAN_H
#define CT_PECOSTRAN_H #define CT_PECOSTRAN_H
// turn off warnings under Windows
#ifdef WIN32
#pragma warning(disable:4786)
#pragma warning(disable:4503)
#endif
// STL includes // STL includes
#include <vector> #include <vector>
#include <string> #include <string>
@ -42,24 +30,28 @@ using namespace std;
#include "TransportBase.h" #include "TransportBase.h"
#include "cantera/numerics/DenseMatrix.h" #include "cantera/numerics/DenseMatrix.h"
namespace Cantera { namespace Cantera
{
class GasTransportParams; class GasTransportParams;
/** /**
* *
* Class PecosTransport implements mixture-averaged transport * Class PecosTransport implements mixture-averaged transport
* properties for ideal gas mixtures. * properties for ideal gas mixtures.
* *
*/ */
class PecosTransport : public Transport { class PecosTransport : public Transport
{
public: public:
virtual ~PecosTransport() {} virtual ~PecosTransport() {}
virtual int model() const { return cPecosTransport; } virtual int model() const {
return cPecosTransport;
}
//! Viscosity of the mixture //! Viscosity of the mixture
/*! /*!
@ -67,8 +59,11 @@ namespace Cantera {
*/ */
virtual doublereal viscosity(); virtual doublereal viscosity();
virtual void getSpeciesViscosities(doublereal* visc) virtual void getSpeciesViscosities(doublereal* visc) {
{ update_T(); updateViscosity_T(); copy(m_visc.begin(), m_visc.end(), visc); } update_T();
updateViscosity_T();
copy(m_visc.begin(), m_visc.end(), visc);
}
//! Return the thermal diffusion coefficients //! Return the thermal diffusion coefficients
/*! /*!
@ -154,10 +149,10 @@ namespace Cantera {
* length = ldx * ndim * length = ldx * ndim
*/ */
virtual void getSpeciesFluxes(int ndim, virtual void getSpeciesFluxes(int ndim,
const doublereal* grad_T, const doublereal* grad_T,
int ldx, int ldx,
const doublereal* grad_X, const doublereal* grad_X,
int ldf, doublereal* fluxes); int ldf, doublereal* fluxes);
//! Initialize the transport object //! Initialize the transport object
/*! /*!
@ -169,7 +164,7 @@ namespace Cantera {
* in the phase. * in the phase.
* *
*/ */
virtual bool initGas( GasTransportParams& tr ); virtual bool initGas(GasTransportParams& tr);
/** /**
@ -180,7 +175,7 @@ namespace Cantera {
* data and/or replacing default species data. * data and/or replacing default species data.
* *
*/ */
void read_blottner_transport_table (); void read_blottner_transport_table();
friend class TransportFactory; friend class TransportFactory;
@ -193,17 +188,17 @@ namespace Cantera {
*/ */
struct GasTransportData getGasTransportData(int); struct GasTransportData getGasTransportData(int);
protected: protected:
/// default constructor /// default constructor
PecosTransport(); PecosTransport();
private: private:
//! Calculate the pressure from the ideal gas law //! Calculate the pressure from the ideal gas law
doublereal pressure_ig() const { doublereal pressure_ig() const {
return (m_thermo->molarDensity() * GasConstant * return (m_thermo->molarDensity() * GasConstant *
m_thermo->temperature()); m_thermo->temperature());
} }
// mixture attributes // mixture attributes
@ -290,6 +285,6 @@ namespace Cantera {
vector_fp cp_R; vector_fp cp_R;
vector_fp cv_int; vector_fp cv_int;
}; };
} }
#endif #endif

View file

@ -21,7 +21,8 @@ using std::endl;
#pragma comment(lib, "advapi32") #pragma comment(lib, "advapi32")
#endif #endif
namespace Cantera { namespace Cantera
{
// If running multiple threads in a cpp application, the Application class // If running multiple threads in a cpp application, the Application class
// is the only internal object that is single instance with static data. // is the only internal object that is single instance with static data.
@ -82,7 +83,8 @@ Application::Messages::Messages(const Messages& r) :
logwriter = new Logger(*(r.logwriter)); logwriter = new Logger(*(r.logwriter));
} }
Application::Messages& Application::Messages::operator=(const Messages& r) { Application::Messages& Application::Messages::operator=(const Messages& r)
{
if (this == &r) { if (this == &r) {
return *this; return *this;
} }
@ -99,7 +101,8 @@ Application::Messages& Application::Messages::operator=(const Messages& r) {
return *this; return *this;
} }
Application::Messages::~Messages() { Application::Messages::~Messages()
{
delete logwriter; delete logwriter;
#ifdef WITH_HTML_LOGS #ifdef WITH_HTML_LOGS
if (xmllog) { if (xmllog) {
@ -329,7 +332,8 @@ Application::Application() :
stop_on_error(false), stop_on_error(false),
options(), options(),
xmlfiles(), xmlfiles(),
pMessenger() { pMessenger()
{
#if !defined( THREAD_SAFE_CANTERA ) #if !defined( THREAD_SAFE_CANTERA )
pMessenger = std::auto_ptr<Messages>(new Messages()); pMessenger = std::auto_ptr<Messages>(new Messages());
#endif #endif
@ -349,7 +353,8 @@ Application::Application() :
#endif #endif
} }
Application* Application::Instance() { Application* Application::Instance()
{
ScopedLock appLock(app_mutex); ScopedLock appLock(app_mutex);
if (Application::s_app == 0) { if (Application::s_app == 0) {
Application::s_app = new Application(); Application::s_app = new Application();
@ -367,7 +372,8 @@ Application::~Application()
} }
} }
void Application::ApplicationDestroy() { void Application::ApplicationDestroy()
{
ScopedLock appLock(app_mutex); ScopedLock appLock(app_mutex);
if (Application::s_app != 0) { if (Application::s_app != 0) {
delete Application::s_app; delete Application::s_app;
@ -435,11 +441,11 @@ XML_Node* Application::get_XML_File(std::string file, int debug)
* the processed xml tree. * the processed xml tree.
*/ */
if (xmlfiles.find(ff) != xmlfiles.end()) { if (xmlfiles.find(ff) != xmlfiles.end()) {
if (debug > 0) { if (debug > 0) {
writelog("get_XML_File(): File, " + ff + writelog("get_XML_File(): File, " + ff +
", was previously read." + ", was previously read." +
" Retrieving the stored xml tree.\n"); " Retrieving the stored xml tree.\n");
} }
return xmlfiles[ff]; return xmlfiles[ff];
} }
/* /*

View file

@ -10,7 +10,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace Cantera { namespace Cantera
{
class XML_Node; class XML_Node;

View file

@ -83,13 +83,13 @@ void ct2ctml(const char* file, const int debug)
python.start(pypath(), "-i"); python.start(pypath(), "-i");
stringstream output_stream; stringstream output_stream;
python.in() << python.in() <<
"if True:\n" << // Use this so that the rest is a single block "if True:\n" << // Use this so that the rest is a single block
" import sys\n" << " import sys\n" <<
" sys.stderr = sys.stdout\n" << " sys.stderr = sys.stdout\n" <<
" import ctml_writer\n" << " import ctml_writer\n" <<
" ctml_writer.convert(r'" << file << "')\n" << " ctml_writer.convert(r'" << file << "')\n" <<
" sys.exit(0)\n\n" " sys.exit(0)\n\n"
"sys.exit(7)\n"; "sys.exit(7)\n";
python.close_in(); python.close_in();
std::string line; std::string line;
while (python.out().good()) { while (python.out().good()) {

View file

@ -7,7 +7,8 @@
#include <sstream> #include <sstream>
#include <typeinfo> #include <typeinfo>
namespace Cantera { namespace Cantera
{
// *** Exceptions *** // *** Exceptions ***
@ -38,7 +39,8 @@ void CanteraError::save()
} }
} }
const char* CanteraError::what() const throw() { const char* CanteraError::what() const throw()
{
try { try {
formattedMessage_ = "\n"; formattedMessage_ = "\n";
formattedMessage_ += stars; formattedMessage_ += stars;
@ -51,22 +53,25 @@ const char* CanteraError::what() const throw() {
// Something went terribly wrong and we couldn't even format the message. // Something went terribly wrong and we couldn't even format the message.
} }
return formattedMessage_.c_str(); return formattedMessage_.c_str();
} }
std::string CanteraError::getMessage() const { std::string CanteraError::getMessage() const
{
return msg_; return msg_;
} }
std::string ArraySizeError::getMessage() const { std::string ArraySizeError::getMessage() const
{
std::stringstream ss; std::stringstream ss;
ss << "Array size (" << sz_ << ") too small. Must be at least " << reqd_ << "."; ss << "Array size (" << sz_ << ") too small. Must be at least " << reqd_ << ".";
return ss.str(); return ss.str();
} }
std::string IndexError::getMessage() const { std::string IndexError::getMessage() const
{
std::stringstream ss; std::stringstream ss;
ss << "IndexError: " << arrayName_ << "[" << m_ << "]" << ss << "IndexError: " << arrayName_ << "[" << m_ << "]" <<
" outside valid range of 0 to " << (mmax_) << "."; " outside valid range of 0 to " << (mmax_) << ".";
return ss.str(); return ss.str();
} }

View file

@ -1132,7 +1132,7 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
} }
//==================================================================================================================== //====================================================================================================================
size_t getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector<doublereal> & v, size_t getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector<doublereal> & v,
const bool convert, const std::string unitsString) const bool convert, const std::string unitsString)
{ {
std::string::size_type icom; std::string::size_type icom;
std::string numstr; std::string numstr;

View file

@ -11,7 +11,8 @@
using namespace std; using namespace std;
namespace Cantera { namespace Cantera
{
//! Return a pointer to the application object //! Return a pointer to the application object
static Application* app() static Application* app()

View file

@ -102,7 +102,7 @@ void outputExcel(std::ostream& s, const std::string& title,
s << ","; s << ",";
} }
} }
s << endl; s << endl;
for (i = 0; i < npts; i++) { for (i = 0; i < npts; i++) {
for (j = 0; j < nv; j++) { for (j = 0; j < nv; j++) {
s << data(j,i); s << data(j,i);

View file

@ -899,7 +899,7 @@ const std::vector<XML_Node*>& XML_Node::children() const
size_t XML_Node::nChildren(const bool discardComments) const size_t XML_Node::nChildren(const bool discardComments) const
{ {
if (discardComments) { if (discardComments) {
size_t count = 0; size_t count = 0;
for (size_t i = 0; i < m_nchildren; i++) { for (size_t i = 0; i < m_nchildren; i++) {
XML_Node* xc = m_children[i]; XML_Node* xc = m_children[i];
if (!(xc->isComment())) { if (!(xc->isComment())) {

View file

@ -33,7 +33,8 @@
# define DERR -999.999 # define DERR -999.999
#endif #endif
namespace Cantera { namespace Cantera
{
//! Exception handler used at language interface boundaries. //! Exception handler used at language interface boundaries.
/*! /*!
@ -56,12 +57,12 @@ T handleAllExceptions(T ctErrorCode, T otherErrorCode)
return ctErrorCode; return ctErrorCode;
} catch (std::exception& err) { } catch (std::exception& err) {
std::cerr << "Cantera: caught an instance of " std::cerr << "Cantera: caught an instance of "
<< err.what() << std::endl; << err.what() << std::endl;
setError("handleAllExceptions", err.what()); setError("handleAllExceptions", err.what());
return otherErrorCode; return otherErrorCode;
} catch (...) { } catch (...) {
std::cerr << "Cantera: caught an instance of " std::cerr << "Cantera: caught an instance of "
"an unknown exception type" << std::endl; "an unknown exception type" << std::endl;
setError("handleAllExceptions", "unknown exception"); setError("handleAllExceptions", "unknown exception");
return otherErrorCode; return otherErrorCode;
} }

View file

@ -252,7 +252,7 @@ extern "C" {
} }
int phase_setMassFractions(int n, size_t leny, int phase_setMassFractions(int n, size_t leny,
double* y, int norm) double* y, int norm)
{ {
try { try {
ThermoPhase& p = ThermoCabinet::item(n); ThermoPhase& p = ThermoCabinet::item(n);
@ -628,7 +628,7 @@ extern "C" {
} }
int th_equil(int n, char* XY, int solver, int th_equil(int n, char* XY, int solver,
double rtol, int maxsteps, int maxiter, int loglevel) double rtol, int maxsteps, int maxiter, int loglevel)
{ {
try { try {
equilibrate(ThermoCabinet::item(n), XY, solver, rtol, maxsteps, equilibrate(ThermoCabinet::item(n), XY, solver, rtol, maxsteps,
@ -804,8 +804,8 @@ extern "C" {
//-------------- Kinetics ------------------// //-------------- Kinetics ------------------//
size_t newKineticsFromXML(int mxml, int iphase, size_t newKineticsFromXML(int mxml, int iphase,
int neighbor1, int neighbor2, int neighbor3, int neighbor1, int neighbor2, int neighbor3,
int neighbor4) int neighbor4)
{ {
try { try {
XML_Node& x = XmlCabinet::item(mxml); XML_Node& x = XmlCabinet::item(mxml);
@ -835,7 +835,7 @@ extern "C" {
} }
int installRxnArrays(int pxml, int ikin, int installRxnArrays(int pxml, int ikin,
char* default_phase) char* default_phase)
{ {
try { try {
XML_Node& p = XmlCabinet::item(pxml); XML_Node& p = XmlCabinet::item(pxml);
@ -871,7 +871,7 @@ extern "C" {
{ {
try { try {
return KineticsCabinet::item(n).kineticsSpeciesIndex(string(nm), return KineticsCabinet::item(n).kineticsSpeciesIndex(string(nm),
string(ph)); string(ph));
} catch (...) { } catch (...) {
return handleAllExceptions(npos, npos); return handleAllExceptions(npos, npos);
} }
@ -1309,7 +1309,7 @@ extern "C" {
} }
int trans_getMolarFluxes(int n, const double* state1, int trans_getMolarFluxes(int n, const double* state1,
const double* state2, double delta, double* fluxes) const double* state2, double delta, double* fluxes)
{ {
try { try {
TransportCabinet::item(n).getMolarFluxes(state1, state2, delta, fluxes); TransportCabinet::item(n).getMolarFluxes(state1, state2, delta, fluxes);
@ -1320,7 +1320,7 @@ extern "C" {
} }
int trans_getMassFluxes(int n, const double* state1, int trans_getMassFluxes(int n, const double* state1,
const double* state2, double delta, double* fluxes) const double* state2, double delta, double* fluxes)
{ {
try { try {
TransportCabinet::item(n).getMassFluxes(state1, state2, delta, fluxes); TransportCabinet::item(n).getMassFluxes(state1, state2, delta, fluxes);
@ -1511,7 +1511,7 @@ extern "C" {
} }
int buildSolutionFromXML(char* src, int ixml, char* id, int buildSolutionFromXML(char* src, int ixml, char* id,
int ith, int ikin) int ith, int ikin)
{ {
try { try {
XML_Node* root = 0; XML_Node* root = 0;

View file

@ -76,7 +76,7 @@ extern "C" {
CANTERA_CAPI int th_set_SV(int n, double* vals); CANTERA_CAPI int th_set_SV(int n, double* vals);
CANTERA_CAPI int th_set_SP(int n, double* vals); CANTERA_CAPI int th_set_SP(int n, double* vals);
CANTERA_CAPI int th_equil(int n, char* XY, int solver, CANTERA_CAPI int th_equil(int n, char* XY, int solver,
double rtol, int maxsteps, int maxiter, int loglevel); double rtol, int maxsteps, int maxiter, int loglevel);
CANTERA_CAPI double th_critTemperature(int n); CANTERA_CAPI double th_critTemperature(int n);
CANTERA_CAPI double th_critPressure(int n); CANTERA_CAPI double th_critPressure(int n);
@ -88,10 +88,10 @@ extern "C" {
CANTERA_CAPI int th_setState_Tsat(int n, double t, double x); CANTERA_CAPI int th_setState_Tsat(int n, double t, double x);
CANTERA_CAPI size_t newKineticsFromXML(int mxml, int iphase, CANTERA_CAPI size_t newKineticsFromXML(int mxml, int iphase,
int neighbor1=-1, int neighbor2=-1, int neighbor3=-1, int neighbor1=-1, int neighbor2=-1, int neighbor3=-1,
int neighbor4=-1); int neighbor4=-1);
CANTERA_CAPI int installRxnArrays(int pxml, int ikin, CANTERA_CAPI int installRxnArrays(int pxml, int ikin,
char* default_phase); char* default_phase);
CANTERA_CAPI size_t kin_nSpecies(int n); CANTERA_CAPI size_t kin_nSpecies(int n);
CANTERA_CAPI size_t kin_nReactions(int n); CANTERA_CAPI size_t kin_nReactions(int n);
CANTERA_CAPI size_t kin_nPhases(int n); CANTERA_CAPI size_t kin_nPhases(int n);
@ -125,7 +125,7 @@ extern "C" {
CANTERA_CAPI size_t kin_phase(int n, size_t i); CANTERA_CAPI size_t kin_phase(int n, size_t i);
CANTERA_CAPI size_t newTransport(char* model, CANTERA_CAPI size_t newTransport(char* model,
int th, int loglevel); int th, int loglevel);
CANTERA_CAPI double trans_viscosity(int n); CANTERA_CAPI double trans_viscosity(int n);
CANTERA_CAPI double trans_thermalConductivity(int n); CANTERA_CAPI double trans_thermalConductivity(int n);
CANTERA_CAPI int trans_getThermalDiffCoeffs(int n, int ldt, double* dt); CANTERA_CAPI int trans_getThermalDiffCoeffs(int n, int ldt, double* dt);
@ -134,13 +134,13 @@ extern "C" {
CANTERA_CAPI int trans_getMultiDiffCoeffs(int n, int ld, double* d); CANTERA_CAPI int trans_getMultiDiffCoeffs(int n, int ld, double* d);
CANTERA_CAPI int trans_setParameters(int n, int type, int k, double* d); CANTERA_CAPI int trans_setParameters(int n, int type, int k, double* d);
CANTERA_CAPI int trans_getMolarFluxes(int n, const double* state1, CANTERA_CAPI int trans_getMolarFluxes(int n, const double* state1,
const double* state2, double delta, double* fluxes); const double* state2, double delta, double* fluxes);
CANTERA_CAPI int trans_getMassFluxes(int n, const double* state1, CANTERA_CAPI int trans_getMassFluxes(int n, const double* state1,
const double* state2, double delta, double* fluxes); const double* state2, double delta, double* fluxes);
CANTERA_CAPI int import_phase(int nth, int nxml, char* id); CANTERA_CAPI int import_phase(int nth, int nxml, char* id);
CANTERA_CAPI int import_kinetics(int nxml, char* id, CANTERA_CAPI int import_kinetics(int nxml, char* id,
int nphases, int* ith, int nkin); int nphases, int* ith, int nkin);
CANTERA_CAPI int getCanteraError(int buflen, char* buf); CANTERA_CAPI int getCanteraError(int buflen, char* buf);
CANTERA_CAPI int showCanteraErrors(); CANTERA_CAPI int showCanteraErrors();
CANTERA_CAPI int write_HTML_log(const char* file); CANTERA_CAPI int write_HTML_log(const char* file);
@ -152,10 +152,10 @@ extern "C" {
CANTERA_CAPI int delTransport(int n); CANTERA_CAPI int delTransport(int n);
CANTERA_CAPI int readlog(int n, char* buf); CANTERA_CAPI int readlog(int n, char* buf);
CANTERA_CAPI int buildSolutionFromXML(char* src, int ixml, char* id, CANTERA_CAPI int buildSolutionFromXML(char* src, int ixml, char* id,
int ith, int ikin); int ith, int ikin);
CANTERA_CAPI int ck_to_cti(char* in_file, char* db_file, CANTERA_CAPI int ck_to_cti(char* in_file, char* db_file,
char* tr_file, char* id_tag, int debug, int validate); char* tr_file, char* id_tag, int debug, int validate);
CANTERA_CAPI int writelogfile(char* logfile); CANTERA_CAPI int writelogfile(char* logfile);
} }

View file

@ -41,8 +41,8 @@ extern "C" {
int maxiter, int loglevel); int maxiter, int loglevel);
CANTERA_CAPI int mix_getChemPotentials(int i, size_t lenmu, double* mu); CANTERA_CAPI int mix_getChemPotentials(int i, size_t lenmu, double* mu);
CANTERA_CAPI int mix_getValidChemPotentials(int i, double bad_mu, CANTERA_CAPI int mix_getValidChemPotentials(int i, double bad_mu,
int standard, size_t lenmu, int standard, size_t lenmu,
double* mu); double* mu);
CANTERA_CAPI double mix_enthalpy(int i); CANTERA_CAPI double mix_enthalpy(int i);
CANTERA_CAPI double mix_entropy(int i); CANTERA_CAPI double mix_entropy(int i);
CANTERA_CAPI double mix_gibbs(int i); CANTERA_CAPI double mix_gibbs(int i);

View file

@ -173,7 +173,7 @@ extern "C" {
} }
int domain_setTolerances(int i, int n, double rtol, int domain_setTolerances(int i, int n, double rtol,
double atol, int itime) double atol, int itime)
{ {
try { try {
Domain1D& dom = DomainCabinet::item(i); Domain1D& dom = DomainCabinet::item(i);
@ -457,7 +457,7 @@ extern "C" {
} }
int stflow_setFixedTempProfile(int i, size_t n, double* pos, int stflow_setFixedTempProfile(int i, size_t n, double* pos,
size_t m, double* temp) size_t m, double* temp)
{ {
try { try {
vector_fp vpos(n), vtemp(n); vector_fp vpos(n), vtemp(n);

View file

@ -17,11 +17,11 @@ extern "C" {
CANTERA_CAPI int domain_componentName(int i, int n, int sz, char* nameout); CANTERA_CAPI int domain_componentName(int i, int n, int sz, char* nameout);
CANTERA_CAPI size_t domain_componentIndex(int i, char* name); CANTERA_CAPI size_t domain_componentIndex(int i, char* name);
CANTERA_CAPI int domain_setBounds(int i, int n, double lower, CANTERA_CAPI int domain_setBounds(int i, int n, double lower,
double upper); double upper);
CANTERA_CAPI double domain_lowerBound(int i, int n); CANTERA_CAPI double domain_lowerBound(int i, int n);
CANTERA_CAPI double domain_upperBound(int i, int n); CANTERA_CAPI double domain_upperBound(int i, int n);
CANTERA_CAPI int domain_setTolerances(int i, int n, double rtol, CANTERA_CAPI int domain_setTolerances(int i, int n, double rtol,
double atol, int itime); double atol, int itime);
CANTERA_CAPI double domain_rtol(int i, int n); CANTERA_CAPI double domain_rtol(int i, int n);
CANTERA_CAPI double domain_atol(int i, int n); CANTERA_CAPI double domain_atol(int i, int n);
CANTERA_CAPI int domain_setupGrid(int i, size_t npts, double* grid); CANTERA_CAPI int domain_setupGrid(int i, size_t npts, double* grid);
@ -62,7 +62,7 @@ extern "C" {
CANTERA_CAPI int sim1D_del(int i); CANTERA_CAPI int sim1D_del(int i);
CANTERA_CAPI int sim1D_setValue(int i, int dom, int comp, int localPoint, double value); CANTERA_CAPI int sim1D_setValue(int i, int dom, int comp, int localPoint, double value);
CANTERA_CAPI int sim1D_setProfile(int i, int dom, int comp, CANTERA_CAPI int sim1D_setProfile(int i, int dom, int comp,
size_t np, double* pos, size_t nv, double* v); size_t np, double* pos, size_t nv, double* v);
CANTERA_CAPI int sim1D_setFlatProfile(int i, int dom, int comp, double v); CANTERA_CAPI int sim1D_setFlatProfile(int i, int dom, int comp, double v);
CANTERA_CAPI int sim1D_showSolution(int i, char* fname); CANTERA_CAPI int sim1D_showSolution(int i, char* fname);
CANTERA_CAPI int sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps); CANTERA_CAPI int sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps);
@ -72,13 +72,13 @@ extern "C" {
CANTERA_CAPI int sim1D_setRefineCriteria(int i, int dom, double ratio, CANTERA_CAPI int sim1D_setRefineCriteria(int i, int dom, double ratio,
double slope, double curve, double prune); double slope, double curve, double prune);
CANTERA_CAPI int sim1D_save(int i, char* fname, char* id, CANTERA_CAPI int sim1D_save(int i, char* fname, char* id,
char* desc); char* desc);
CANTERA_CAPI int sim1D_restore(int i, char* fname, char* id); CANTERA_CAPI int sim1D_restore(int i, char* fname, char* id);
CANTERA_CAPI int sim1D_writeStats(int i, int printTime = 1); CANTERA_CAPI int sim1D_writeStats(int i, int printTime = 1);
CANTERA_CAPI int sim1D_domainIndex(int i, char* name); CANTERA_CAPI int sim1D_domainIndex(int i, char* name);
CANTERA_CAPI double sim1D_value(int i, int idom, int icomp, int localPoint); CANTERA_CAPI double sim1D_value(int i, int idom, int icomp, int localPoint);
CANTERA_CAPI double sim1D_workValue(int i, int idom, CANTERA_CAPI double sim1D_workValue(int i, int idom,
int icomp, int localPoint); int icomp, int localPoint);
CANTERA_CAPI int sim1D_eval(int i, double rdt, int count); CANTERA_CAPI int sim1D_eval(int i, double rdt, int count);
CANTERA_CAPI int sim1D_setMaxJacAge(int i, int ss_age, int ts_age); CANTERA_CAPI int sim1D_setMaxJacAge(int i, int ss_age, int ts_age);
CANTERA_CAPI int sim1D_timeStepFactor(int i, double tfactor); CANTERA_CAPI int sim1D_timeStepFactor(int i, double tfactor);

View file

@ -467,7 +467,7 @@ extern "C" {
{ {
try { try {
bool ok = FlowDeviceCabinet::item(i).install(ReactorCabinet::item(n), bool ok = FlowDeviceCabinet::item(i).install(ReactorCabinet::item(n),
ReactorCabinet::item(m)); ReactorCabinet::item(m));
if (!ok) { if (!ok) {
throw CanteraError("install","Could not install flow device."); throw CanteraError("install","Could not install flow device.");
} }

View file

@ -225,7 +225,7 @@ extern "C" {
} }
int rdiag_findMajor(int i, double threshold, int rdiag_findMajor(int i, double threshold,
size_t lda, double* a) size_t lda, double* a)
{ {
try { try {
DiagramCabinet::item(i).findMajorPaths(threshold, lda, a); DiagramCabinet::item(i).findMajorPaths(threshold, lda, a);
@ -293,7 +293,7 @@ extern "C" {
} }
int rbuild_build(int i, int k, char* el, char* dotfile, int rbuild_build(int i, int k, char* el, char* dotfile,
int idiag, int iquiet) int idiag, int iquiet)
{ {
try { try {
ofstream fdot(dotfile); ofstream fdot(dotfile);

View file

@ -33,7 +33,7 @@ extern "C" {
CANTERA_CAPI int rbuild_del(int i); CANTERA_CAPI int rbuild_del(int i);
CANTERA_CAPI int rbuild_init(int i, char* logfile, int k); CANTERA_CAPI int rbuild_init(int i, char* logfile, int k);
CANTERA_CAPI int rbuild_build(int i, int k, char* el, char* dotfile, CANTERA_CAPI int rbuild_build(int i, int k, char* el, char* dotfile,
int idiag, int iquiet); int idiag, int iquiet);
} }
#endif #endif

View file

@ -61,17 +61,17 @@ extern "C" {
_surfphase(i).setCoveragesByName(string(c)); _surfphase(i).setCoveragesByName(string(c));
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int surf_getcoverages(int i, double* c) int surf_getcoverages(int i, double* c)
{ {
try { try {
_surfphase(i).getCoverages(c); _surfphase(i).getCoverages(c);
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
@ -81,7 +81,7 @@ extern "C" {
_surfphase(i).setConcentrations(c); _surfphase(i).setConcentrations(c);
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
@ -91,7 +91,7 @@ extern "C" {
_surfphase(i).getConcentrations(c); _surfphase(i).getConcentrations(c);
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
} }

View file

@ -31,8 +31,8 @@ extern "C" {
} }
return XmlCabinet::add(x); return XmlCabinet::add(x);
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_get_XML_File(const char* file, int debug) int xml_get_XML_File(const char* file, int debug)
@ -62,8 +62,8 @@ extern "C" {
XmlCabinet::del(i); XmlCabinet::del(i);
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_removeChild(int i, int j) int xml_removeChild(int i, int j)
@ -72,8 +72,8 @@ extern "C" {
XmlCabinet::item(i).removeChild(&XmlCabinet::item(j)); XmlCabinet::item(i).removeChild(&XmlCabinet::item(j));
return 0; return 0;
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_copy(int i) int xml_copy(int i)
@ -81,8 +81,8 @@ extern "C" {
try { try {
return XmlCabinet::newCopy(i); return XmlCabinet::newCopy(i);
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_assign(int i, int j) int xml_assign(int i, int j)
@ -90,8 +90,8 @@ extern "C" {
try { try {
return XmlCabinet::assign(i,j); return XmlCabinet::assign(i,j);
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_build(int i, const char* file) int xml_build(int i, const char* file)
@ -250,8 +250,8 @@ extern "C" {
XML_Node& node = XmlCabinet::item(i); XML_Node& node = XmlCabinet::item(i);
return (int) node.nChildren(); return (int) node.nChildren();
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
int xml_addChild(int i, const char* name, const char* value) int xml_addChild(int i, const char* name, const char* value)

View file

@ -887,7 +887,7 @@ double VCS_SOLVE::vcs_phaseStabilityTest(const size_t iph)
for (k = 0; k < Vphase->nSpecies(); k++) { for (k = 0; k < Vphase->nSpecies(); k++) {
if (fabs(damp * delFrac[k]) > 0.3*fabs(fracDelta_old[k])) { if (fabs(damp * delFrac[k]) > 0.3*fabs(fracDelta_old[k])) {
damp = std::max(0.3*fabs(fracDelta_old[k]) / fabs(delFrac[k]), damp = std::max(0.3*fabs(fracDelta_old[k]) / fabs(delFrac[k]),
1.0E-8/fabs(delFrac[k])); 1.0E-8/fabs(delFrac[k]));
} }
if (delFrac[k] < 0.0) { if (delFrac[k] < 0.0) {
if (2.0 * damp * (-delFrac[k]) > fracDelta_old[k]) { if (2.0 * damp * (-delFrac[k]) > fracDelta_old[k]) {

View file

@ -126,9 +126,9 @@ int VCS_SOLVE::vcs_prep_oneTime(int printLvl)
* equal to nspecies - nelements. This may be changed below * equal to nspecies - nelements. This may be changed below
*/ */
if (m_numElemConstraints > m_numSpeciesTot) { if (m_numElemConstraints > m_numSpeciesTot) {
m_numRxnTot = 0; m_numRxnTot = 0;
} else { } else {
m_numRxnTot = m_numSpeciesTot - m_numElemConstraints; m_numRxnTot = m_numSpeciesTot - m_numElemConstraints;
} }
m_numRxnRdc = m_numRxnTot; m_numRxnRdc = m_numRxnTot;
m_numSpeciesRdc = m_numSpeciesTot; m_numSpeciesRdc = m_numSpeciesTot;

View file

@ -88,7 +88,7 @@ extern "C" {
//--------------- Phase ---------------------// //--------------- Phase ---------------------//
status_t phase_getname_(const integer* n, char* nm, status_t phase_getname_(const integer* n, char* nm,
ftnlen lennm) ftnlen lennm)
{ {
try { try {
std::string pnm = _fph(n)->name(); std::string pnm = _fph(n)->name();
@ -108,7 +108,7 @@ extern "C" {
try { try {
return _fph(n)->nElements(); return _fph(n)->nElements();
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
} }
@ -225,7 +225,7 @@ extern "C" {
} catch (...) { } catch (...) {
return handleAllExceptions(-1, ERR); return handleAllExceptions(-1, ERR);
} }
return 0; return 0;
} }
doublereal phase_massfraction_(const integer* n, integer* k) doublereal phase_massfraction_(const integer* n, integer* k)
@ -649,8 +649,8 @@ extern "C" {
//-------------- Kinetics ------------------// //-------------- Kinetics ------------------//
integer newkineticsfromxml_(integer* mxml, integer* iphase, integer newkineticsfromxml_(integer* mxml, integer* iphase,
const integer* neighbor1, const integer* neighbor2, const integer* neighbor3, const integer* neighbor1, const integer* neighbor2, const integer* neighbor3,
const integer* neighbor4) const integer* neighbor4)
{ {
try { try {
XML_Node* x = _xml(mxml); XML_Node* x = _xml(mxml);
@ -700,7 +700,7 @@ extern "C" {
} }
integer kin_speciesindex_(const integer* n, const char* nm, const char* ph, integer kin_speciesindex_(const integer* n, const char* nm, const char* ph,
ftnlen lennm, ftnlen lenph) ftnlen lennm, ftnlen lenph)
{ {
try { try {
return _fkin(n)->kineticsSpeciesIndex(f2string(nm, lennm), return _fkin(n)->kineticsSpeciesIndex(f2string(nm, lennm),
@ -1018,7 +1018,7 @@ extern "C" {
//-------------------- Functions --------------------------- //-------------------- Functions ---------------------------
status_t ctphase_report_(const integer* nth, status_t ctphase_report_(const integer* nth,
char* buf, integer* show_thermo, ftnlen buflen) char* buf, integer* show_thermo, ftnlen buflen)
{ {
try { try {
bool stherm = (*show_thermo != 0); bool stherm = (*show_thermo != 0);
@ -1065,7 +1065,7 @@ extern "C" {
status_t ctbuildsolutionfromxml(char* src, integer* ixml, char* id, status_t ctbuildsolutionfromxml(char* src, integer* ixml, char* id,
integer* ith, integer* ikin, ftnlen lensrc, ftnlen lenid) integer* ith, integer* ikin, ftnlen lensrc, ftnlen lenid)
{ {
try { try {
XML_Node* root = 0; XML_Node* root = 0;

View file

@ -1115,10 +1115,10 @@ void InterfaceKinetics::addElementaryReaction(ReactionData& r)
*/ */
int reactionRateCoeffType_orig = r.rateCoeffType; int reactionRateCoeffType_orig = r.rateCoeffType;
if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) { if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) {
r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE; r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
} }
if (r.rateCoeffType == ARRHENIUS_REACTION_RATECOEFF_TYPE) { if (r.rateCoeffType == ARRHENIUS_REACTION_RATECOEFF_TYPE) {
r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE; r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE;
} }
/* /*
* Install the reaction rate into the vector of reactions handled by this class * Install the reaction rate into the vector of reactions handled by this class

View file

@ -489,8 +489,8 @@ static void getEfficiencies(const XML_Node& eff, Kinetics& kin,
rdata.thirdBodyEfficiencies[k] = fpValue(val[n]); // bb->second; rdata.thirdBodyEfficiencies[k] = fpValue(val[n]); // bb->second;
} else if (!rules.skipUndeclaredThirdBodies) { } else if (!rules.skipUndeclaredThirdBodies) {
throw CanteraError("getEfficiencies", "Encountered third-body " throw CanteraError("getEfficiencies", "Encountered third-body "
"efficiency for undefined species \"" + nm + "\"\n" "efficiency for undefined species \"" + nm + "\"\n"
"while adding reaction " + int2str(rdata.number+1) + "."); "while adding reaction " + int2str(rdata.number+1) + ".");
} }
} }
} }
@ -512,7 +512,7 @@ void getRateCoefficient(const XML_Node& kf, Kinetics& kin,
const XML_Node& node = kf.child(m); const XML_Node& node = kf.child(m);
double p = getFloat(node, "P", "toSI"); double p = getFloat(node, "P", "toSI");
vector_fp& rate = rdata.plogParameters.insert( vector_fp& rate = rdata.plogParameters.insert(
std::make_pair(p, vector_fp()))->second; std::make_pair(p, vector_fp()))->second;
rate.resize(3); rate.resize(3);
rate[0] = getFloat(node, "A", "toSI"); rate[0] = getFloat(node, "A", "toSI");
rate[1] = getFloat(node, "b"); rate[1] = getFloat(node, "b");
@ -853,8 +853,8 @@ bool rxninfo::installReaction(int iRxn, const XML_Node& r, Kinetics& kin,
rdata.number = iRxn; rdata.number = iRxn;
rdata.rxn_number = iRxn; rdata.rxn_number = iRxn;
// Read the rate coefficient data from the XML file. Trigger an // Read the rate coefficient data from the XML file. Trigger an
// exception for negative A unless specifically authorized. // exception for negative A unless specifically authorized.
getRateCoefficient(r.child("rateCoeff"), kin, rdata, rules); getRateCoefficient(r.child("rateCoeff"), kin, rdata, rules);
// Check to see that the elements balance in the reaction. // Check to see that the elements balance in the reaction.

View file

@ -86,8 +86,9 @@ void phasemethods(int nlhs, mxArray* plhs[],
buflen = (mwSize)(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; buflen = (mwSize)(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1;
input_buf = (char*)mxCalloc(buflen, sizeof(char)); input_buf = (char*)mxCalloc(buflen, sizeof(char));
status = mxGetString(prhs[3], input_buf, buflen); status = mxGetString(prhs[3], input_buf, buflen);
if (status != 0) if (status != 0) {
mexWarnMsgTxt("Not enough space. " "String is truncated."); mexWarnMsgTxt("Not enough space. " "String is truncated.");
}
switch (mjob) { switch (mjob) {
case 30: case 30:

View file

@ -18,22 +18,23 @@
#define DAE_DEVEL #define DAE_DEVEL
#ifdef DAE_DEVEL #ifdef DAE_DEVEL
namespace Cantera { namespace Cantera
DAE_Solver* newDAE_Solver(std::string itype, ResidJacEval& f) { {
if (itype == "IDA") { DAE_Solver* newDAE_Solver(std::string itype, ResidJacEval& f)
{
if (itype == "IDA") {
#ifdef HAS_SUNDIALS #ifdef HAS_SUNDIALS
return new IDA_Solver(f); return new IDA_Solver(f);
#else #else
throw CanteraError("newDAE_Solver","IDA solver requires sundials" throw CanteraError("newDAE_Solver","IDA solver requires sundials"
" package, but Cantera was not built with sundials."); " package, but Cantera was not built with sundials.");
#endif #endif
} } else {
else { throw CanteraError("newDAE_Solver",
throw CanteraError("newDAE_Solver", "unknown DAE solver: "+itype);
"unknown DAE solver: "+itype);
}
} }
} }
}
# #
#endif #endif

View file

@ -3738,8 +3738,8 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f,
if (s_print_NumJac) { if (s_print_NumJac) {
if (m_print_flag >= 7) { if (m_print_flag >= 7) {
if (retn != 1) { if (retn != 1) {
printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n");
printf("\t\t We will bail after calculating the Jacobian\n"); printf("\t\t We will bail after calculating the Jacobian\n");
} }
if (neq_ < 20) { if (neq_ < 20) {
printf("\t\tUnk m_ewt y dyVector ResN\n"); printf("\t\tUnk m_ewt y dyVector ResN\n");
@ -3835,8 +3835,8 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f,
if (s_print_NumJac) { if (s_print_NumJac) {
if (m_print_flag >= 7) { if (m_print_flag >= 7) {
if (retn != 1) { if (retn != 1) {
printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n");
printf("\t\t We will bail after calculating the Jacobian\n"); printf("\t\t We will bail after calculating the Jacobian\n");
} }
if (neq_ < 20) { if (neq_ < 20) {
printf("\t\tUnk m_ewt y dyVector ResN\n"); printf("\t\tUnk m_ewt y dyVector ResN\n");
@ -3865,8 +3865,8 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f,
} }
info = m_func->evalResidNJ(time_curr, delta_t_n, y, ydot, info = m_func->evalResidNJ(time_curr, delta_t_n, y, ydot,
DATA_PTR(m_wksp), JacDelta_ResidEval, DATA_PTR(m_wksp), JacDelta_ResidEval,
static_cast<int>(j), dy); static_cast<int>(j), dy);
m_nfe++; m_nfe++;
if (info != 1) { if (info != 1) {
mdp::mdp_safe_free((void**) &dyVector); mdp::mdp_safe_free((void**) &dyVector);
@ -3875,7 +3875,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f,
doublereal diff; doublereal diff;
int ileft = (int) j - (int) ku; int ileft = (int) j - (int) ku;
int iright = static_cast<int>(j + kl); int iright = static_cast<int>(j + kl);
for (int i = ileft; i <= iright; i++) { for (int i = ileft; i <= iright; i++) {
if (i >= 0 && i < (int) neq_) { if (i >= 0 && i < (int) neq_) {
@ -3885,14 +3885,14 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f,
col_j[index] = diff / dy; col_j[index] = diff / dy;
} }
} }
/* /*
for (size_t i = j - ku; i <= j + kl; i++) { for (size_t i = j - ku; i <= j + kl; i++) {
if (i < neq_) { if (i < neq_) {
diff = subtractRD(m_wksp[i], f[i]); diff = subtractRD(m_wksp[i], f[i]);
col_j[kl + ku + i - j] = diff / dy; col_j[kl + ku + i - j] = diff / dy;
} }
} }
*/ */
y[j] = ysave; y[j] = ysave;
if (solnType_ != NSOLN_TYPE_STEADY_STATE) { if (solnType_ != NSOLN_TYPE_STEADY_STATE) {
ydot[j] = ydotsave; ydot[j] = ydotsave;

View file

@ -176,8 +176,8 @@ doublereal MultiNewton::boundStep(const doublereal* x0,
doublereal fbound = 1.0; doublereal fbound = 1.0;
for (size_t i = 0; i < r.nDomains(); i++) { for (size_t i = 0; i < r.nDomains(); i++) {
fbound = std::min(fbound, fbound = std::min(fbound,
bound_step(x0 + r.start(i), step0 + r.start(i), bound_step(x0 + r.start(i), step0 + r.start(i),
r.domain(i), loglevel)); r.domain(i), loglevel));
} }
return fbound; return fbound;
} }

View file

@ -260,7 +260,7 @@ int Sim1D::newtonSolve(int loglevel)
return -1; return -1;
} else { } else {
throw CanteraError("Sim1D::newtonSolve", throw CanteraError("Sim1D::newtonSolve",
"ERROR: OneDim::solve returned m = " + int2str(m) + "\n"); "ERROR: OneDim::solve returned m = " + int2str(m) + "\n");
} }
} }

View file

@ -22,110 +22,109 @@ namespace Cantera
{ {
/* /*
* Constructors * Constructors
*/ */
GeneralSpeciesThermo::GeneralSpeciesThermo() : GeneralSpeciesThermo::GeneralSpeciesThermo() :
SpeciesThermo(), SpeciesThermo(),
m_tlow_max(0.0), m_tlow_max(0.0),
m_thigh_min(1.0E30), m_thigh_min(1.0E30),
m_p0(OneAtm), m_p0(OneAtm),
m_kk(0) m_kk(0)
{ {
m_tlow_max = 0.0; m_tlow_max = 0.0;
m_thigh_min = 1.0E30; m_thigh_min = 1.0E30;
} }
GeneralSpeciesThermo:: GeneralSpeciesThermo::
GeneralSpeciesThermo(const GeneralSpeciesThermo& b) : GeneralSpeciesThermo(const GeneralSpeciesThermo& b) :
m_tlow_max(b.m_tlow_max), m_tlow_max(b.m_tlow_max),
m_thigh_min(b.m_thigh_min), m_thigh_min(b.m_thigh_min),
m_kk(b.m_kk) m_kk(b.m_kk)
{ {
m_sp.resize(m_kk, 0); m_sp.resize(m_kk, 0);
for (size_t k = 0; k < m_kk; k++) { for (size_t k = 0; k < m_kk; k++) {
SpeciesThermoInterpType* bk = b.m_sp[k]; SpeciesThermoInterpType* bk = b.m_sp[k];
if (bk) { if (bk) {
m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType();
} }
} }
} }
GeneralSpeciesThermo& GeneralSpeciesThermo&
GeneralSpeciesThermo::operator=(const GeneralSpeciesThermo& b) GeneralSpeciesThermo::operator=(const GeneralSpeciesThermo& b)
{ {
if (&b != this) { if (&b != this) {
m_tlow_max = b.m_tlow_max; m_tlow_max = b.m_tlow_max;
m_thigh_min = b.m_thigh_min; m_thigh_min = b.m_thigh_min;
for (size_t k = 0; k < m_kk; k++) { for (size_t k = 0; k < m_kk; k++) {
SpeciesThermoInterpType* sp = m_sp[k]; SpeciesThermoInterpType* sp = m_sp[k];
if (sp) { if (sp) {
delete sp; delete sp;
m_sp[k] = 0; m_sp[k] = 0;
} }
} }
m_kk = b.m_kk; m_kk = b.m_kk;
m_sp.resize(m_kk, 0); m_sp.resize(m_kk, 0);
for (size_t k = 0; k < m_kk; k++) { for (size_t k = 0; k < m_kk; k++) {
SpeciesThermoInterpType* bk = b.m_sp[k]; SpeciesThermoInterpType* bk = b.m_sp[k];
if (bk) { if (bk) {
m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType();
} }
} }
} }
return *this; return *this;
} }
GeneralSpeciesThermo::~GeneralSpeciesThermo() GeneralSpeciesThermo::~GeneralSpeciesThermo()
{ {
for (size_t k = 0; k < m_kk; k++) { for (size_t k = 0; k < m_kk; k++) {
SpeciesThermoInterpType* sp = m_sp[k]; SpeciesThermoInterpType* sp = m_sp[k];
if (sp) { if (sp) {
delete sp; delete sp;
m_sp[k] = 0; m_sp[k] = 0;
} }
} }
} }
SpeciesThermo* SpeciesThermo*
GeneralSpeciesThermo::duplMyselfAsSpeciesThermo() const GeneralSpeciesThermo::duplMyselfAsSpeciesThermo() const
{ {
GeneralSpeciesThermo* gsth = new GeneralSpeciesThermo(*this); GeneralSpeciesThermo* gsth = new GeneralSpeciesThermo(*this);
return (SpeciesThermo*) gsth; return (SpeciesThermo*) gsth;
} }
/* /*
* Install parameterization for a species. * Install parameterization for a species.
* @param index Species index * @param index Species index
* @param type parameterization type * @param type parameterization type
* @param c coefficients. The meaning of these depends on * @param c coefficients. The meaning of these depends on
* the parameterization. * the parameterization.
*/ */
void GeneralSpeciesThermo::install(std::string name, void GeneralSpeciesThermo::install(std::string name,
size_t index, size_t index,
int type, int type,
const doublereal* c, const doublereal* c,
doublereal minTemp, doublereal minTemp,
doublereal maxTemp, doublereal maxTemp,
doublereal refPressure) doublereal refPressure)
{ {
/* /*
* Resize the arrays if necessary, filling the empty * Resize the arrays if necessary, filling the empty
* slots with the zero pointer. * slots with the zero pointer.
*/ */
if(minTemp <= 0.0) if (minTemp <= 0.0) {
{ throw CanteraError("Error in GeneralSpeciesThermo.cpp",
throw CanteraError("Error in GeneralSpeciesThermo.cpp", " Cannot take 0 tmin as input. \n\n");
" Cannot take 0 tmin as input. \n\n"); }
}
if (index >= m_kk) { if (index >= m_kk) {
m_sp.resize(index+1, 0); m_sp.resize(index+1, 0);
m_kk = index+1; m_kk = index+1;
} }
//int nfreq = 3; //int nfreq = 3;
@ -135,74 +134,74 @@ namespace Cantera
switch (type) { switch (type) {
case NASA1: case NASA1:
m_sp[index] = new NasaPoly1(index, minTemp, maxTemp, m_sp[index] = new NasaPoly1(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case SHOMATE1: case SHOMATE1:
m_sp[index] = new ShomatePoly(index, minTemp, maxTemp, m_sp[index] = new ShomatePoly(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case CONSTANT_CP: case CONSTANT_CP:
case SIMPLE: case SIMPLE:
m_sp[index] = new ConstCpPoly(index, minTemp, maxTemp, m_sp[index] = new ConstCpPoly(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case MU0_INTERP: case MU0_INTERP:
m_sp[index] = new Mu0Poly(index, minTemp, maxTemp, m_sp[index] = new Mu0Poly(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case SHOMATE2: case SHOMATE2:
m_sp[index] = new ShomatePoly2(index, minTemp, maxTemp, m_sp[index] = new ShomatePoly2(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case NASA2: case NASA2:
m_sp[index] = new NasaPoly2(index, minTemp, maxTemp, m_sp[index] = new NasaPoly2(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
case STAT: case STAT:
m_sp[index] = new StatMech(index, minTemp, maxTemp, m_sp[index] = new StatMech(index, minTemp, maxTemp,
refPressure, c, name); refPressure, c, name);
break; break;
case ADSORBATE: case ADSORBATE:
m_sp[index] = new Adsorbate(index, minTemp, maxTemp, m_sp[index] = new Adsorbate(index, minTemp, maxTemp,
refPressure, c); refPressure, c);
break; break;
default: default:
throw UnknownSpeciesThermoModel( throw UnknownSpeciesThermoModel(
"GeneralSpeciesThermo::install", "GeneralSpeciesThermo::install",
"unknown species type", int2str(type)); "unknown species type", int2str(type));
break; break;
} }
if (!m_sp[index]) { if (!m_sp[index]) {
cout << "Null m_sp... index = " << index << endl; cout << "Null m_sp... index = " << index << endl;
cout << "type = " << type << endl; cout << "type = " << type << endl;
} }
m_tlow_max = max(minTemp, m_tlow_max); m_tlow_max = max(minTemp, m_tlow_max);
m_thigh_min = min(maxTemp, m_thigh_min); m_thigh_min = min(maxTemp, m_thigh_min);
} }
// Install a new species thermodynamic property // Install a new species thermodynamic property
// parameterization for one species. // parameterization for one species.
/* /*
* @param stit_ptr Pointer to the SpeciesThermoInterpType object * @param stit_ptr Pointer to the SpeciesThermoInterpType object
* This will set up the thermo for one species * This will set up the thermo for one species
*/ */
void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr) void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr)
{ {
/* /*
* Resize the arrays if necessary, filling the empty * Resize the arrays if necessary, filling the empty
* slots with the zero pointer. * slots with the zero pointer.
*/ */
if (!stit_ptr) { if (!stit_ptr) {
throw CanteraError("GeneralSpeciesThermo::install_STIT", throw CanteraError("GeneralSpeciesThermo::install_STIT",
"zero pointer"); "zero pointer");
} }
size_t index = stit_ptr->speciesIndex(); size_t index = stit_ptr->speciesIndex();
if (index >= m_kk) { if (index >= m_kk) {
m_sp.resize(index+1, 0); m_sp.resize(index+1, 0);
m_kk = index+1; m_kk = index+1;
} }
AssertThrow(m_sp[index] == 0, AssertThrow(m_sp[index] == 0,
"Index position isn't null, duplication of assignment: " + int2str(index)); "Index position isn't null, duplication of assignment: " + int2str(index));
@ -219,177 +218,177 @@ namespace Cantera
m_tlow_max = max(minTemp, m_tlow_max); m_tlow_max = max(minTemp, m_tlow_max);
m_thigh_min = min(maxTemp, m_thigh_min); m_thigh_min = min(maxTemp, m_thigh_min);
} }
void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr,
VPSSMgr* vpssmgr_ptr) VPSSMgr* vpssmgr_ptr)
{ {
STITbyPDSS* stit_ptr = new STITbyPDSS(k, vpssmgr_ptr, PDSS_ptr); STITbyPDSS* stit_ptr = new STITbyPDSS(k, vpssmgr_ptr, PDSS_ptr);
install_STIT(stit_ptr); install_STIT(stit_ptr);
} }
/** /**
* Update the properties for one species. * Update the properties for one species.
*/ */
void GeneralSpeciesThermo:: void GeneralSpeciesThermo::
update_one(size_t k, doublereal t, doublereal* cp_R, update_one(size_t k, doublereal t, doublereal* cp_R,
doublereal* h_RT, doublereal* s_R) const doublereal* h_RT, doublereal* s_R) const
{ {
SpeciesThermoInterpType* sp_ptr = m_sp[k]; SpeciesThermoInterpType* sp_ptr = m_sp[k];
if (sp_ptr) { if (sp_ptr) {
sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R); sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R);
} }
} }
/** /**
* Update the properties for all species. * Update the properties for all species.
*/ */
void GeneralSpeciesThermo:: void GeneralSpeciesThermo::
update(doublereal t, doublereal* cp_R, update(doublereal t, doublereal* cp_R,
doublereal* h_RT, doublereal* s_R) const doublereal* h_RT, doublereal* s_R) const
{ {
vector<SpeciesThermoInterpType*>::const_iterator _begin, _end; vector<SpeciesThermoInterpType*>::const_iterator _begin, _end;
_begin = m_sp.begin(); _begin = m_sp.begin();
_end = m_sp.end(); _end = m_sp.end();
SpeciesThermoInterpType* sp_ptr = 0; SpeciesThermoInterpType* sp_ptr = 0;
for (; _begin != _end; ++_begin) { for (; _begin != _end; ++_begin) {
sp_ptr = *(_begin); sp_ptr = *(_begin);
if (sp_ptr) { if (sp_ptr) {
sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R); sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R);
} }
// else { // else {
// writelog("General::update: sp_ptr is NULL!\n"); // writelog("General::update: sp_ptr is NULL!\n");
//} //}
} }
} }
/** /**
* This utility function reports the type of parameterization * This utility function reports the type of parameterization
* used for the species, index. * used for the species, index.
*/ */
int GeneralSpeciesThermo::reportType(size_t index) const int GeneralSpeciesThermo::reportType(size_t index) const
{ {
SpeciesThermoInterpType* sp = m_sp[index]; SpeciesThermoInterpType* sp = m_sp[index];
if (sp) { if (sp) {
return sp->reportType(); return sp->reportType();
} }
return -1; return -1;
} }
/** /**
* This utility function reports back the type of * This utility function reports back the type of
* parameterization and all of the parameters for the * parameterization and all of the parameters for the
* species, index. * species, index.
* For the NASA object, there are 15 coefficients. * For the NASA object, there are 15 coefficients.
*/ */
void GeneralSpeciesThermo:: void GeneralSpeciesThermo::
reportParams(size_t index, int& type, doublereal* const c, reportParams(size_t index, int& type, doublereal* const c,
doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure) const doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure) const
{ {
SpeciesThermoInterpType* sp = m_sp[index]; SpeciesThermoInterpType* sp = m_sp[index];
size_t n; size_t n;
if (sp) { if (sp) {
sp->reportParameters(n, type, minTemp, maxTemp, sp->reportParameters(n, type, minTemp, maxTemp,
refPressure, c); refPressure, c);
if (n != index) { if (n != index) {
throw CanteraError("GeneralSpeciesThermo::reportParams", throw CanteraError("GeneralSpeciesThermo::reportParams",
"Internal error encountered"); "Internal error encountered");
} }
} else { } else {
type = -1; type = -1;
} }
} }
// //! Modify parameters for the standard state // //! Modify parameters for the standard state
// /*! // /*!
// * @param index Species index // * @param index Species index
// * @param c Vector of coefficients used to set the // * @param c Vector of coefficients used to set the
// * parameters for the standard state. // * parameters for the standard state.
// */ // */
// void GeneralSpeciesThermo:: // void GeneralSpeciesThermo::
// modifyParams(size_t index, doublereal* c) // modifyParams(size_t index, doublereal* c)
// { // {
// SpeciesThermoInterpType* sp = m_sp[index]; // SpeciesThermoInterpType* sp = m_sp[index];
// if (sp) { // if (sp) {
// sp->modifyParameters(c); // sp->modifyParameters(c);
// } // }
// } // }
/** /**
* Return the lowest temperature at which the thermodynamic * Return the lowest temperature at which the thermodynamic
* parameterization is valid. If no argument is supplied, the * parameterization is valid. If no argument is supplied, the
* value is the one for which all species parameterizations * value is the one for which all species parameterizations
* are valid. Otherwise, if an integer argument is given, the * are valid. Otherwise, if an integer argument is given, the
* value applies only to the species with that index. * value applies only to the species with that index.
*/ */
doublereal GeneralSpeciesThermo::minTemp(size_t k) const doublereal GeneralSpeciesThermo::minTemp(size_t k) const
{ {
if (k == npos) { if (k == npos) {
return m_tlow_max; return m_tlow_max;
} else { } else {
SpeciesThermoInterpType* sp = m_sp[k]; SpeciesThermoInterpType* sp = m_sp[k];
if (sp) { if (sp) {
return sp->minTemp(); return sp->minTemp();
} }
} }
return m_tlow_max; return m_tlow_max;
} }
doublereal GeneralSpeciesThermo::maxTemp(size_t k) const doublereal GeneralSpeciesThermo::maxTemp(size_t k) const
{ {
if (k == npos) { if (k == npos) {
return m_thigh_min; return m_thigh_min;
} else { } else {
SpeciesThermoInterpType* sp = m_sp[k]; SpeciesThermoInterpType* sp = m_sp[k];
if (sp) { if (sp) {
return sp->maxTemp(); return sp->maxTemp();
} }
} }
return m_thigh_min; return m_thigh_min;
} }
doublereal GeneralSpeciesThermo::refPressure(size_t k) const doublereal GeneralSpeciesThermo::refPressure(size_t k) const
{ {
if (k == npos) { if (k == npos) {
return m_p0; return m_p0;
} else { } else {
SpeciesThermoInterpType* sp = m_sp[k]; SpeciesThermoInterpType* sp = m_sp[k];
if (sp) { if (sp) {
return sp->refPressure(); return sp->refPressure();
} }
} }
return m_p0; return m_p0;
} }
SpeciesThermoInterpType* GeneralSpeciesThermo::provideSTIT(size_t k) SpeciesThermoInterpType* GeneralSpeciesThermo::provideSTIT(size_t k)
{ {
return (m_sp[k]); return (m_sp[k]);
} }
#ifdef H298MODIFY_CAPABILITY #ifdef H298MODIFY_CAPABILITY
doublereal GeneralSpeciesThermo::reportOneHf298(int k) const doublereal GeneralSpeciesThermo::reportOneHf298(int k) const
{ {
SpeciesThermoInterpType* sp_ptr = m_sp[k]; SpeciesThermoInterpType* sp_ptr = m_sp[k];
doublereal h = -1.0; doublereal h = -1.0;
if (sp_ptr) { if (sp_ptr) {
h = sp_ptr->reportHf298(0); h = sp_ptr->reportHf298(0);
} }
return h; return h;
} }
void GeneralSpeciesThermo::modifyOneHf298(const int k, const doublereal Hf298New) void GeneralSpeciesThermo::modifyOneHf298(const int k, const doublereal Hf298New)
{ {
SpeciesThermoInterpType* sp_ptr = m_sp[k]; SpeciesThermoInterpType* sp_ptr = m_sp[k];
if (sp_ptr) { if (sp_ptr) {
sp_ptr->modifyOneHf298(k, Hf298New); sp_ptr->modifyOneHf298(k, Hf298New);
} }
} }
#endif #endif

View file

@ -155,15 +155,15 @@ doublereal IdealGasPhase::cv_mole() const
return cp_mole() - GasConstant; return cp_mole() - GasConstant;
} }
/** /**
* @returns species translational/rotational specific heat at * @returns species translational/rotational specific heat at
* constant volume. * constant volume.
* *
* Either: $5/2 R_s$ or $3/2 R_s$ for molecules/atoms. * Either: $5/2 R_s$ or $3/2 R_s$ for molecules/atoms.
* *
*/ */
doublereal IdealGasPhase::cv_tr (doublereal atomicity) const doublereal IdealGasPhase::cv_tr(doublereal atomicity) const
{ {
// k is the species number // k is the species number
int dum = 0; int dum = 0;
int type = 0; int type = 0;
@ -174,53 +174,56 @@ doublereal IdealGasPhase::cv_mole() const
m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure); m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure);
if(type != 111) if (type != 111) {
{ throw CanteraError("Error in IdealGasPhase.cpp",
throw CanteraError("Error in IdealGasPhase.cpp", "cv_tr only supported for StatMech!. \n\n");
"cv_tr only supported for StatMech!. \n\n");
} }
// see reportParameters for specific details // see reportParameters for specific details
return c[3]; return c[3];
} }
/** /**
* @returns species translational specific heat at constant volume. * @returns species translational specific heat at constant volume.
*/ */
doublereal IdealGasPhase::cv_trans () const doublereal IdealGasPhase::cv_trans() const
{ return 1.5*GasConstant; } {
return 1.5*GasConstant;
}
/** /**
* @returns species rotational specific heat at constant volume. * @returns species rotational specific heat at constant volume.
* *
*/ */
doublereal IdealGasPhase::cv_rot (double atom) const doublereal IdealGasPhase::cv_rot(double atom) const
{ return std::max(cv_tr(atom) - cv_trans(), 0.); } {
return std::max(cv_tr(atom) - cv_trans(), 0.);
}
/** /**
* @returns species vibrational specific heat at * @returns species vibrational specific heat at
* constant volume. * constant volume.
* *
* C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T} * C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T}
* *
* The species vibration energy ($e^{vib}_{v,s}$) is: * The species vibration energy ($e^{vib}_{v,s}$) is:
* *
* 0: atom * 0: atom
* *
* Diatomic: * Diatomic:
* \f[ * \f[
* \frac{R_s \theta_{v,s}}{e^{\theta_{v,s}/T}-1} * \frac{R_s \theta_{v,s}}{e^{\theta_{v,s}/T}-1}
* \f] * \f]
* *
* General Molecules: * General Molecules:
* \f[ * \f[
* \sum_i \frac{R_s \theta_{v,s,i}}{e^{\theta_{v,s,i}/T}-1} * \sum_i \frac{R_s \theta_{v,s,i}}{e^{\theta_{v,s,i}/T}-1}
* \f] * \f]
* *
*/ */
doublereal IdealGasPhase::cv_vib (const int k, const doublereal T) const doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
{ {
// k is the species number // k is the species number
int dum = 0; int dum = 0;
@ -235,17 +238,16 @@ doublereal IdealGasPhase::cv_mole() const
m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure); m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure);
// basic sanity check // basic sanity check
if(type != 111) if (type != 111) {
{ throw CanteraError("Error in IdealGasPhase.cpp",
throw CanteraError("Error in IdealGasPhase.cpp", "cv_vib only supported for StatMech!. \n\n");
"cv_vib only supported for StatMech!. \n\n");
} }
// see reportParameters for specific details // see reportParameters for specific details
return c[4]; return c[4];
} }
// Mechanical Equation of State ---------------------------- // Mechanical Equation of State ----------------------------
// Chemical Potentials and Activities ---------------------- // Chemical Potentials and Activities ----------------------

View file

@ -721,7 +721,7 @@ void Phase::addUniqueElement(const std::string& symbol, doublereal weight,
} else { } else {
if (m_atomicWeights[i] != weight) { if (m_atomicWeights[i] != weight) {
throw CanteraError("AddUniqueElement", throw CanteraError("AddUniqueElement",
"Duplicate Elements (" + symbol + ") have different weights"); "Duplicate Elements (" + symbol + ") have different weights");
} }
} }
} }
@ -756,7 +756,7 @@ void Phase::addElementsFromXML(const XML_Node& phase)
// get the declared element names // get the declared element names
if (! phase.hasChild("elementArray")) { if (! phase.hasChild("elementArray")) {
throw CanteraError("Elements::addElementsFromXML", throw CanteraError("Elements::addElementsFromXML",
"phase xml node doesn't have \"elementArray\" XML Node"); "phase xml node doesn't have \"elementArray\" XML Node");
} }
XML_Node& elements = phase.child("elementArray"); XML_Node& elements = phase.child("elementArray");
vector<string> enames; vector<string> enames;
@ -865,8 +865,8 @@ void Phase::addSpecies(const std::string& name, const doublereal* comp,
if (fabs(charge + ecomp) > 0.001) { if (fabs(charge + ecomp) > 0.001) {
if (ecomp != 0.0) { if (ecomp != 0.0) {
throw CanteraError("Phase::addSpecies", throw CanteraError("Phase::addSpecies",
"Input charge and element E compositions differ " "Input charge and element E compositions differ "
"for species " + name); "for species " + name);
} else { } else {
// Just fix up the element E composition based on the input // Just fix up the element E composition based on the input
// species charge // species charge

View file

@ -650,47 +650,47 @@ static void installNasa9ThermoFromXML(std::string speciesName,
* for species k into a SpeciesThermo instance. * for species k into a SpeciesThermo instance.
*/ */
static void installStatMechThermoFromXML(std::string speciesName, static void installStatMechThermoFromXML(std::string speciesName,
SpeciesThermo& sp, int k, SpeciesThermo& sp, int k,
const std::vector<XML_Node*>& tp) const std::vector<XML_Node*>& tp)
{ {
const XML_Node * fptr = tp[0]; const XML_Node* fptr = tp[0];
int nRegTmp = tp.size(); int nRegTmp = tp.size();
int nRegions = 0; int nRegions = 0;
vector_fp cPoly; vector_fp cPoly;
StatMech *np_ptr = 0; StatMech* np_ptr = 0;
std::vector<StatMech *> regionPtrs; std::vector<StatMech*> regionPtrs;
doublereal tmin, tmax, pref = OneAtm; doublereal tmin, tmax, pref = OneAtm;
// Loop over all of the possible temperature regions // Loop over all of the possible temperature regions
for (int i = 0; i < nRegTmp; i++) { for (int i = 0; i < nRegTmp; i++) {
fptr = tp[i]; fptr = tp[i];
if (fptr) { if (fptr) {
if (fptr->name() == "StatMech") { if (fptr->name() == "StatMech") {
if (fptr->hasChild("floatArray")) { if (fptr->hasChild("floatArray")) {
tmin = fpValue((*fptr)["Tmin"]); tmin = fpValue((*fptr)["Tmin"]);
tmax = fpValue((*fptr)["Tmax"]); tmax = fpValue((*fptr)["Tmax"]);
if ((*fptr).hasAttrib("P0")) { if ((*fptr).hasAttrib("P0")) {
pref = fpValue((*fptr)["P0"]); pref = fpValue((*fptr)["P0"]);
} }
if ((*fptr).hasAttrib("Pref")) { if ((*fptr).hasAttrib("Pref")) {
pref = fpValue((*fptr)["Pref"]); pref = fpValue((*fptr)["Pref"]);
} }
getFloatArray(fptr->child("floatArray"), cPoly, false); getFloatArray(fptr->child("floatArray"), cPoly, false);
if (cPoly.size() != 0) { if (cPoly.size() != 0) {
throw CanteraError("installStatMechThermoFromXML", throw CanteraError("installStatMechThermoFromXML",
"Expected no coeff: this is not a polynomial representation"); "Expected no coeff: this is not a polynomial representation");
} }
} }
} }
}
} }
} // set properties
// set properties tmin = 0.1;
tmin = 0.1; vector_fp coeffs(1);
vector_fp coeffs(1); coeffs[0] = 0.0;
coeffs[0] = 0.0; (&sp)->install(speciesName, k, STAT, &coeffs[0], tmin, tmax, pref);
(&sp)->install(speciesName, k, STAT, &coeffs[0], tmin, tmax, pref);
} }
//! Install a Adsorbate polynomial thermodynamic property parameterization for species k into a SpeciesThermo instance. //! Install a Adsorbate polynomial thermodynamic property parameterization for species k into a SpeciesThermo instance.
@ -794,15 +794,12 @@ void SpeciesThermoFactory::installThermoForSpecies
} else if (f->name() == "Mu0") { } else if (f->name() == "Mu0") {
installMu0ThermoFromXML(speciesNode["name"], spthermo, k, f); installMu0ThermoFromXML(speciesNode["name"], spthermo, k, f);
} else if (f->name() == "NASA9") { } else if (f->name() == "NASA9") {
installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp);
} } else if (f->name() == "StatMech") {
else if (f->name() == "StatMech") { installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp);
installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); } else if (f->name() == "adsorbate") {
}
else if (f->name() == "adsorbate") {
installAdsorbateThermoFromXML(speciesNode["name"], spthermo, k, *f); installAdsorbateThermoFromXML(speciesNode["name"], spthermo, k, *f);
} } else {
else {
throw UnknownSpeciesThermoModel("installThermoForSpecies", throw UnknownSpeciesThermoModel("installThermoForSpecies",
speciesNode["name"], f->name()); speciesNode["name"], f->name());
} }
@ -813,11 +810,9 @@ void SpeciesThermoFactory::installThermoForSpecies
installNasaThermoFromXML(speciesNode["name"], spthermo, k, f0, f1); installNasaThermoFromXML(speciesNode["name"], spthermo, k, f0, f1);
} else if (f0->name() == "Shomate" && f1->name() == "Shomate") { } else if (f0->name() == "Shomate" && f1->name() == "Shomate") {
installShomateThermoFromXML(speciesNode["name"], spthermo, k, f0, f1); installShomateThermoFromXML(speciesNode["name"], spthermo, k, f0, f1);
} } else if (f0->name() == "StatMech") {
else if (f0->name() == "StatMech") { installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp);
installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); } else if (f0->name() == "NASA9" && f1->name() == "NASA9") {
}
else if (f0->name() == "NASA9" && f1->name() == "NASA9") {
installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp);
} else { } else {
throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"],
@ -827,17 +822,15 @@ void SpeciesThermoFactory::installThermoForSpecies
const XML_Node* f0 = tp[0]; const XML_Node* f0 = tp[0];
if (f0->name() == "NASA9") { if (f0->name() == "NASA9") {
installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp);
} } else if (f0->name() == "StatMech") {
else if (f0->name() == "StatMech") { installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp);
installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); } else {
} throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"],
else { "multiple");
throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"],
"multiple");
} }
} else { } else {
throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"],
"multiple"); "multiple");
} }
} }
} }

View file

@ -3,10 +3,6 @@
* \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink * \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink
*/ */
/* $Author: hkmoffa $
* $Revision: 279 $
* $Date: 2009-12-05 13:08:43 -0600 (Sat, 05 Dec 2009) $
*/
// Copyright 2007 Sandia National Laboratories // Copyright 2007 Sandia National Laboratories
#include "cantera/thermo/StatMech.h" #include "cantera/thermo/StatMech.h"
@ -16,110 +12,119 @@
namespace Cantera namespace Cantera
{ {
// Statistical mechanics // Statistical mechanics
/* /*
* @ingroup spthermo * @ingroup spthermo
*/ */
//! Empty constructor //! Empty constructor
StatMech::StatMech() StatMech::StatMech()
: m_lowT(0.1), m_highT (1.0), : m_lowT(0.1), m_highT(1.0),
m_Pref(1.0E5), m_index (0) {} m_Pref(1.0E5), m_index(0) {}
// constructor used in templated instantiations // constructor used in templated instantiations
/* /*
* @param n Species index * @param n Species index
* @param tlow Minimum temperature * @param tlow Minimum temperature
* @param thigh Maximum temperature * @param thigh Maximum temperature
* @param pref reference pressure (Pa). * @param pref reference pressure (Pa).
* @param coeffs Vector of coefficients used to set the * @param coeffs Vector of coefficients used to set the
* parameters for the standard state. * parameters for the standard state.
*/ */
StatMech::StatMech(int n, doublereal tlow, doublereal thigh, StatMech::StatMech(int n, doublereal tlow, doublereal thigh,
doublereal pref, doublereal pref,
const doublereal* coeffs, const doublereal* coeffs,
std::string my_name) : std::string my_name) :
m_lowT (tlow), m_lowT(tlow),
m_highT (thigh), m_highT(thigh),
m_Pref (pref), m_Pref(pref),
m_index (n), m_index(n),
sp_name (my_name) sp_name(my_name)
{ {
// should error on zero -- cannot take ln(0) // should error on zero -- cannot take ln(0)
if(m_lowT <= 0.0){ if (m_lowT <= 0.0) {
throw CanteraError("Error in StatMech.cpp", throw CanteraError("Error in StatMech.cpp",
" Cannot take 0 tmin as input. \n\n"); " Cannot take 0 tmin as input. \n\n");
} }
buildmap(); buildmap();
} }
// copy constructor // copy constructor
/* /*
* @param b object to be copied * @param b object to be copied
*/ */
StatMech::StatMech(const StatMech& b) : StatMech::StatMech(const StatMech& b) :
m_lowT (b.m_lowT), m_lowT(b.m_lowT),
m_highT (b.m_highT), m_highT(b.m_highT),
m_Pref (b.m_Pref), m_Pref(b.m_Pref),
m_index (b.m_index) m_index(b.m_index)
{ {
} }
// assignment operator // assignment operator
/* /*
* @param b object to be copied * @param b object to be copied
*/ */
StatMech& StatMech::operator=(const StatMech& b) { StatMech& StatMech::operator=(const StatMech& b)
{
if (&b != this) { if (&b != this) {
m_lowT = b.m_lowT; m_lowT = b.m_lowT;
m_highT = b.m_highT; m_highT = b.m_highT;
m_Pref = b.m_Pref; m_Pref = b.m_Pref;
m_index = b.m_index; m_index = b.m_index;
} }
return *this; return *this;
} }
// Destructor // Destructor
StatMech::~StatMech() { StatMech::~StatMech()
} {
}
// duplicator // duplicator
SpeciesThermoInterpType * SpeciesThermoInterpType*
StatMech::duplMyselfAsSpeciesThermoInterpType() const { StatMech::duplMyselfAsSpeciesThermoInterpType() const
{
StatMech* np = new StatMech(*this); StatMech* np = new StatMech(*this);
return (SpeciesThermoInterpType *) np; return (SpeciesThermoInterpType*) np;
} }
// Returns the minimum temperature that the thermo // Returns the minimum temperature that the thermo
// parameterization is valid // parameterization is valid
doublereal StatMech::minTemp() const doublereal StatMech::minTemp() const
{ {
return m_lowT; return m_lowT;
} }
// Returns the maximum temperature that the thermo // Returns the maximum temperature that the thermo
// parameterization is valid // parameterization is valid
doublereal StatMech::maxTemp() const { doublereal StatMech::maxTemp() const
{
return m_highT; return m_highT;
} }
// Returns the reference pressure (Pa) // Returns the reference pressure (Pa)
doublereal StatMech::refPressure() const { return m_Pref; } doublereal StatMech::refPressure() const
{
return m_Pref;
}
// Returns an integer representing the type of parameterization // Returns an integer representing the type of parameterization
int StatMech::reportType() const { int StatMech::reportType() const
{
return STAT; return STAT;
} }
// Returns an integer representing the species index // Returns an integer representing the species index
size_t StatMech::speciesIndex() const { size_t StatMech::speciesIndex() const
{
return m_index; return m_index;
} }
int StatMech::buildmap() int StatMech::buildmap()
{ {
// build vector of strings // build vector of strings
std::vector<std::string> SS; std::vector<std::string> SS;
@ -129,80 +134,79 @@ namespace Cantera
SS.push_back("Air"); SS.push_back("Air");
SS.push_back("CPAir"); SS.push_back("CPAir");
SS.push_back("Ar" ); SS.push_back("Ar");
SS.push_back("Ar+" ); SS.push_back("Ar+");
SS.push_back("C" ); SS.push_back("C");
SS.push_back("C+" ); SS.push_back("C+");
SS.push_back("C2" ); SS.push_back("C2");
SS.push_back("C2H" ); SS.push_back("C2H");
SS.push_back("C2H2" ); SS.push_back("C2H2");
SS.push_back("C3" ); SS.push_back("C3");
SS.push_back("CF" ); SS.push_back("CF");
SS.push_back("CF2" ); SS.push_back("CF2");
SS.push_back("CF3" ); SS.push_back("CF3");
SS.push_back("CF4" ); SS.push_back("CF4");
SS.push_back("CH" ); SS.push_back("CH");
SS.push_back("CH2" ); SS.push_back("CH2");
SS.push_back("CH3" ); SS.push_back("CH3");
SS.push_back("CH4" ); SS.push_back("CH4");
SS.push_back("Cl" ); SS.push_back("Cl");
SS.push_back("Cl2" ); SS.push_back("Cl2");
SS.push_back("CN" ); SS.push_back("CN");
SS.push_back("CN+" ); SS.push_back("CN+");
SS.push_back("CO" ); SS.push_back("CO");
SS.push_back("CO+" ); SS.push_back("CO+");
SS.push_back("CO2" ); SS.push_back("CO2");
SS.push_back("F" ); SS.push_back("F");
SS.push_back("F2" ); SS.push_back("F2");
SS.push_back("H" ); SS.push_back("H");
SS.push_back("H+" ); SS.push_back("H+");
SS.push_back("H2" ); SS.push_back("H2");
SS.push_back("H2+" ); SS.push_back("H2+");
SS.push_back("H2O" ); SS.push_back("H2O");
SS.push_back("HCl" ); SS.push_back("HCl");
SS.push_back("HCN" ); SS.push_back("HCN");
SS.push_back("He" ); SS.push_back("He");
SS.push_back("He+" ); SS.push_back("He+");
SS.push_back("N" ); SS.push_back("N");
SS.push_back("N+" ); SS.push_back("N+");
SS.push_back("N2" ); SS.push_back("N2");
SS.push_back("CPN2" ); SS.push_back("CPN2");
SS.push_back("N2+" ); SS.push_back("N2+");
SS.push_back("Ne" ); SS.push_back("Ne");
SS.push_back("NCO" ); SS.push_back("NCO");
SS.push_back("NH" ); SS.push_back("NH");
SS.push_back("NH+" ); SS.push_back("NH+");
SS.push_back("NH2" ); SS.push_back("NH2");
SS.push_back("NH3" ); SS.push_back("NH3");
SS.push_back("NO" ); SS.push_back("NO");
SS.push_back("NO+" ); SS.push_back("NO+");
SS.push_back("NO2" ); SS.push_back("NO2");
SS.push_back("O" ); SS.push_back("O");
SS.push_back("O+" ); SS.push_back("O+");
SS.push_back("O2" ); SS.push_back("O2");
SS.push_back("O2+" ); SS.push_back("O2+");
SS.push_back("OH" ); SS.push_back("OH");
SS.push_back("Si" ); SS.push_back("Si");
SS.push_back("SiO" ); SS.push_back("SiO");
SS.push_back("e"); SS.push_back("e");
// now place each species in a map // now place each species in a map
int ii; int ii;
for(ii=0; ii < SS.size(); ii++) for (ii=0; ii < SS.size(); ii++) {
{ name_map[SS[ii]]=(new species);
name_map[SS[ii]]=(new species);
// init to crazy defaults // init to crazy defaults
name_map[SS[ii]]->nvib = -1; name_map[SS[ii]]->nvib = -1;
name_map[SS[ii]]->cfs = -1; name_map[SS[ii]]->cfs = -1;
name_map[SS[ii]]->mol_weight = -1; name_map[SS[ii]]->mol_weight = -1;
name_map[SS[ii]]->theta[0] =0.0; name_map[SS[ii]]->theta[0] =0.0;
name_map[SS[ii]]->theta[1] =0.0; name_map[SS[ii]]->theta[1] =0.0;
name_map[SS[ii]]->theta[2] =0.0; name_map[SS[ii]]->theta[2] =0.0;
name_map[SS[ii]]->theta[3] =0.0; name_map[SS[ii]]->theta[3] =0.0;
name_map[SS[ii]]->theta[4] =0.0; name_map[SS[ii]]->theta[4] =0.0;
} }
// now set all species information // now set all species information
@ -570,88 +574,79 @@ namespace Cantera
name_map["e"]->nvib=0; name_map["e"]->nvib=0;
int dum = 0; int dum = 0;
for(ii=0; ii < SS.size(); ii++) for (ii=0; ii < SS.size(); ii++) {
{ // check nvib was initalized for all species
// check nvib was initalized for all species if (name_map[SS[ii]]->nvib == -1) {
if(name_map[SS[ii]]->nvib == -1) std::cout << name_map[SS[ii]]->nvib << std::endl;
{ throw CanteraError("Error in StatMech.cpp",
std::cout << name_map[SS[ii]]->nvib << std::endl; "nvib not initialized!. \n\n");
throw CanteraError("Error in StatMech.cpp",
"nvib not initialized!. \n\n");
} } else {
else // check that theta is initalized
{ for (int i=0; i<name_map[SS[ii]]->nvib; i++) {
// check that theta is initalized if (name_map[SS[ii]]->theta[i] <= 0.0) {
for(int i=0;i<name_map[SS[ii]]->nvib;i++) throw CanteraError("Error in StatMech.cpp",
{ "theta not initalized!. \n\n");
if(name_map[SS[ii]]->theta[i] <= 0.0) }
{ }
throw CanteraError("Error in StatMech.cpp",
"theta not initalized!. \n\n");
}
}
// check that no non-zero theta exist // check that no non-zero theta exist
// for any theta larger than nvib! // for any theta larger than nvib!
for(int i=name_map[SS[ii]]->nvib;i<5;i++) for (int i=name_map[SS[ii]]->nvib; i<5; i++) {
{ if (name_map[SS[ii]]->theta[i] != 0.0) {
if(name_map[SS[ii]]->theta[i] != 0.0) std::string err = "bad theta value for "+SS[ii]+"\n";
{ throw CanteraError("StatMech.cpp",err);
std::string err = "bad theta value for "+SS[ii]+"\n"; }
throw CanteraError("StatMech.cpp",err); } // done with for loop
} }
} // done with for loop
}
// check mol weight was initialized for all species // check mol weight was initialized for all species
if(name_map[SS[ii]]->mol_weight == -1) if (name_map[SS[ii]]->mol_weight == -1) {
{ std::cout << name_map[SS[ii]]->mol_weight << std::endl;
std::cout << name_map[SS[ii]]->mol_weight << std::endl; throw CanteraError("Error in StatMech.cpp",
throw CanteraError("Error in StatMech.cpp", "mol_weight not initialized!. \n\n");
"mol_weight not initialized!. \n\n");
} }
// cfs was initialized for all species // cfs was initialized for all species
if(name_map[SS[ii]]->cfs == -1) if (name_map[SS[ii]]->cfs == -1) {
{ std::cout << name_map[SS[ii]]->cfs << std::endl;
std::cout << name_map[SS[ii]]->cfs << std::endl; throw CanteraError("Error in StatMech.cpp",
throw CanteraError("Error in StatMech.cpp", "cfs not initialized!. \n\n");
"cfs not initialized!. \n\n");
} }
} // done with sanity checks } // done with sanity checks
// mark it zero, dude // mark it zero, dude
return 0; return 0;
} }
// Update the properties for this species // Update the properties for this species
/** /**
* *
* \f[ * \f[
* \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1 * \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1
* \f] * \f]
* *
* Where, * Where,
* \f[ * \f[
* \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R} * \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R}
* \f] * \f]
* *
* *
* @param tt vector of temperature polynomials * @param tt vector of temperature polynomials
* @param cp_R Vector of Dimensionless heat capacities. * @param cp_R Vector of Dimensionless heat capacities.
* (length m_kk). * (length m_kk).
* @param h_RT Vector of Dimensionless enthalpies. * @param h_RT Vector of Dimensionless enthalpies.
* (length m_kk). * (length m_kk).
* @param s_R Vector of Dimensionless entropies. * @param s_R Vector of Dimensionless entropies.
* (length m_kk). * (length m_kk).
*/ */
void StatMech::updateProperties(const doublereal* tt, void StatMech::updateProperties(const doublereal* tt,
doublereal* cp_R, doublereal* h_RT, doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const { doublereal* s_R) const
{
std::map<std::string,species*>::iterator it; std::map<std::string,species*>::iterator it;
@ -659,16 +654,13 @@ namespace Cantera
species* s; species* s;
// pointer to map location of particular species // pointer to map location of particular species
if(name_map.find(sp_name) != name_map.end()) if (name_map.find(sp_name) != name_map.end()) {
{ s = name_map.find(sp_name)->second;
s = name_map.find(sp_name)->second; } else {
} //std::cout << sp_name << std::endl;
else throw CanteraError("StatMech.cpp",
{ "species properties not found!. \n\n");
//std::cout << sp_name << std::endl; }
throw CanteraError("StatMech.cpp",
"species properties not found!. \n\n");
}
// translational + rotational specific heat // translational + rotational specific heat
doublereal ctr = 0.0; doublereal ctr = 0.0;
@ -678,11 +670,10 @@ namespace Cantera
ctr += GasConstant * s->cfs; ctr += GasConstant * s->cfs;
// vibrational energy // vibrational energy
for(int i=0; i< s->nvib; i++) for (int i=0; i< s->nvib; i++) {
{ theta = s->theta[i];
theta = s->theta[i]; ctr += GasConstant * theta * (theta* exp(theta/tt[0])/(tt[0]*tt[0]))/((exp(theta/tt[0])-1) * (exp(theta/tt[0])-1));
ctr += GasConstant * theta * (theta* exp(theta/tt[0])/(tt[0]*tt[0]))/((exp(theta/tt[0])-1) * (exp(theta/tt[0])-1)); }
}
// Cp = Cv + R // Cp = Cv + R
doublereal cpdivR = ctr/GasConstant + 1; doublereal cpdivR = ctr/GasConstant + 1;
@ -696,60 +687,61 @@ namespace Cantera
cp_R[m_index] = cpdivR; cp_R[m_index] = cpdivR;
h_RT[m_index] = hdivRT; h_RT[m_index] = hdivRT;
s_R [m_index] = sdivR; s_R [m_index] = sdivR;
} }
// Compute the reference-state property of one species // Compute the reference-state property of one species
/* /*
* Given temperature T in K, this method updates the values of * Given temperature T in K, this method updates the values of
* the non-dimensional heat capacity at constant pressure, * the non-dimensional heat capacity at constant pressure,
* enthalpy, and entropy, at the reference pressure, Pref * enthalpy, and entropy, at the reference pressure, Pref
* of one of the species. The species index is used * of one of the species. The species index is used
* to reference into the cp_R, h_RT, and s_R arrays. * to reference into the cp_R, h_RT, and s_R arrays.
* *
* Temperature Polynomial: * Temperature Polynomial:
* tt[0] = t; * tt[0] = t;
* tt[1] = t*t; * tt[1] = t*t;
* tt[2] = t*t*t; * tt[2] = t*t*t;
* tt[3] = t*t*t*t; * tt[3] = t*t*t*t;
* tt[4] = 1.0/t; * tt[4] = 1.0/t;
* tt[5] = 1.0/(t*t); * tt[5] = 1.0/(t*t);
* tt[6] = std::log(t); * tt[6] = std::log(t);
* *
* @param temp Temperature (Kelvin) * @param temp Temperature (Kelvin)
* @param cp_R Vector of Dimensionless heat capacities. * @param cp_R Vector of Dimensionless heat capacities.
* (length m_kk). * (length m_kk).
* @param h_RT Vector of Dimensionless enthalpies. * @param h_RT Vector of Dimensionless enthalpies.
* (length m_kk). * (length m_kk).
* @param s_R Vector of Dimensionless entropies. * @param s_R Vector of Dimensionless entropies.
* (length m_kk). * (length m_kk).
*/ */
void StatMech::updatePropertiesTemp(const doublereal temp, void StatMech::updatePropertiesTemp(const doublereal temp,
doublereal* cp_R, doublereal* h_RT, doublereal* cp_R, doublereal* h_RT,
doublereal* s_R) const { doublereal* s_R) const
{
double tPoly[1]; double tPoly[1];
tPoly[0] = temp; tPoly[0] = temp;
updateProperties(tPoly, cp_R, h_RT, s_R); updateProperties(tPoly, cp_R, h_RT, s_R);
} }
//This utility function reports back the type of //This utility function reports back the type of
// parameterization and all of the parameters for the // parameterization and all of the parameters for the
// species, index. // species, index.
/* /*
* All parameters are output variables * All parameters are output variables
* *
* @param n Species index * @param n Species index
* @param type Integer type of the standard type * @param type Integer type of the standard type
* @param tlow output - Minimum temperature * @param tlow output - Minimum temperature
* @param thigh output - Maximum temperature * @param thigh output - Maximum temperature
* @param pref output - reference pressure (Pa). * @param pref output - reference pressure (Pa).
* @param coeffs Vector of species state data * @param coeffs Vector of species state data
*/ */
void StatMech::reportParameters(size_t &n, int &type, void StatMech::reportParameters(size_t& n, int& type,
doublereal &tlow, doublereal &thigh, doublereal& tlow, doublereal& thigh,
doublereal &pref, doublereal& pref,
doublereal* const coeffs) const doublereal* const coeffs) const
{ {
species* s; species* s;
n = m_index; n = m_index;
@ -757,55 +749,50 @@ namespace Cantera
tlow = m_lowT; tlow = m_lowT;
thigh = m_highT; thigh = m_highT;
pref = m_Pref; pref = m_Pref;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++) {
{ coeffs[i] = 0.0;
coeffs[i] = 0.0; }
}
doublereal temp = coeffs[0]; doublereal temp = coeffs[0];
coeffs[1] = m_lowT; coeffs[1] = m_lowT;
coeffs[2] = m_highT; coeffs[2] = m_highT;
// get species name, to gather species properties // get species name, to gather species properties
// pointer to map location of particular species // pointer to map location of particular species
if(name_map.find(sp_name) != name_map.end()) if (name_map.find(sp_name) != name_map.end()) {
{ s = name_map.find(sp_name)->second;
s = name_map.find(sp_name)->second; } else {
} //std::cout << sp_name << std::endl;
else throw CanteraError("StatMech.cpp",
{ "species properties not found!. \n\n");
//std::cout << sp_name << std::endl; }
throw CanteraError("StatMech.cpp",
"species properties not found!. \n\n");
}
double theta = 0.0; double theta = 0.0;
doublereal cvib = 0; doublereal cvib = 0;
// vibrational energy // vibrational energy
for(int i=0; i< s->nvib; i++) for (int i=0; i< s->nvib; i++) {
{ theta = s->theta[i];
theta = s->theta[i]; cvib += GasConstant * theta * (theta* exp(theta/temp)/(temp*temp))/((exp(theta/temp)-1) * (exp(theta/temp)-1));
cvib += GasConstant * theta * (theta* exp(theta/temp)/(temp*temp))/((exp(theta/temp)-1) * (exp(theta/temp)-1)); }
}
// load vibrational energy // load vibrational energy
coeffs[3] = GasConstant * s->cfs; coeffs[3] = GasConstant * s->cfs;
coeffs[4] = cvib; coeffs[4] = cvib;
} }
// Modify parameters for the standard state // Modify parameters for the standard state
/* /*
* @param coeffs Vector of coefficients used to set the * @param coeffs Vector of coefficients used to set the
* parameters for the standard state. * parameters for the standard state.
*/ */
void StatMech::modifyParameters(doublereal* coeffs) void StatMech::modifyParameters(doublereal* coeffs)
{ {
} }
} }

View file

@ -249,16 +249,13 @@ ThermoPhase* newPhase(XML_Node& xmlphase)
ThermoPhase* t = newThermoPhase(model); ThermoPhase* t = newThermoPhase(model);
if (model == "singing cows") { if (model == "singing cows") {
throw CanteraError(" newPhase", "Cows don't sing"); throw CanteraError(" newPhase", "Cows don't sing");
} } else if (model == "HMW") {
else if (model == "HMW") {
HMWSoln* p = dynamic_cast<HMWSoln*>(t); HMWSoln* p = dynamic_cast<HMWSoln*>(t);
p->constructPhaseXML(xmlphase,""); p->constructPhaseXML(xmlphase,"");
} } else if (model == "IonsFromNeutralMolecule") {
else if (model == "IonsFromNeutralMolecule") {
IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t); IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t);
p->constructPhaseXML(xmlphase,""); p->constructPhaseXML(xmlphase,"");
} } else {
else {
importPhase(xmlphase, t); importPhase(xmlphase, t);
} }
return t; return t;

View file

@ -294,7 +294,7 @@ doublereal WaterProps::ADebye(doublereal T, doublereal P_input, int ifunc)
doublereal dw = density_IAPWS(T, P); doublereal dw = density_IAPWS(T, P);
doublereal tmp = sqrt(2.0 * Avogadro * dw / 1000.); doublereal tmp = sqrt(2.0 * Avogadro * dw / 1000.);
doublereal tmp2 = ElectronCharge * ElectronCharge * Avogadro / doublereal tmp2 = ElectronCharge * ElectronCharge * Avogadro /
(epsilon * GasConstant * T); (epsilon * GasConstant * T);
doublereal tmp3 = tmp2 * sqrt(tmp2); doublereal tmp3 = tmp2 * sqrt(tmp2);
doublereal A_Debye = tmp * tmp3 / (8.0 * Pi); doublereal A_Debye = tmp * tmp3 / (8.0 * Pi);

View file

@ -687,7 +687,7 @@ void Substance::set_TPp(double Temp, double Pressure)
// loop // loop
while (P_here = Pp(), while (P_here = Pp(),
fabs(Pressure - P_here) >= ErrP*Pressure || LoopCount == 0) { fabs(Pressure - P_here) >= ErrP* Pressure || LoopCount == 0) {
if (P_here < 0.0) { if (P_here < 0.0) {
BracketSlope(Pressure); BracketSlope(Pressure);
} else { } else {

View file

@ -1,7 +1,8 @@
#include "cantera/transport/GasTransport.h" #include "cantera/transport/GasTransport.h"
#include "cantera/transport/TransportParams.h" #include "cantera/transport/TransportParams.h"
namespace Cantera { namespace Cantera
{
GasTransport::GasTransport(ThermoPhase* thermo) : GasTransport::GasTransport(ThermoPhase* thermo) :
Transport(thermo), Transport(thermo),
@ -135,7 +136,8 @@ bool GasTransport::initGas(GasTransportParams& tr)
return true; return true;
} }
void GasTransport::update_T(void) { void GasTransport::update_T(void)
{
double T = m_thermo->temperature(); double T = m_thermo->temperature();
if (T == m_temp) { if (T == m_temp) {
return; return;

View file

@ -4,11 +4,6 @@
* *
*/ */
/* $Author$
* $Revision$
* $Date$
*/
#include "cantera/thermo/ThermoPhase.h" #include "cantera/thermo/ThermoPhase.h"
#include "cantera/transport/PecosTransport.h" #include "cantera/transport/PecosTransport.h"
@ -28,22 +23,24 @@ using namespace std;
*/ */
#define MIN_X 1.e-20 #define MIN_X 1.e-20
namespace Cantera { namespace Cantera
{
//////////////////// class PecosTransport methods ////////////// //////////////////// class PecosTransport methods //////////////
PecosTransport::PecosTransport() : PecosTransport::PecosTransport() :
m_nsp(0), m_nsp(0),
m_tmin(-1.0), m_tmin(-1.0),
m_tmax(100000.), m_tmax(100000.),
m_temp(-1.0), m_temp(-1.0),
m_logt(0.0) m_logt(0.0)
{ {
} }
bool PecosTransport::initGas( GasTransportParams& tr ) { bool PecosTransport::initGas(GasTransportParams& tr)
{
// constant substance attributes // constant substance attributes
m_thermo = tr.thermo; m_thermo = tr.thermo;
@ -54,7 +51,7 @@ namespace Cantera {
// make a local copy of the molecular weights // make a local copy of the molecular weights
m_mw.resize(m_nsp); m_mw.resize(m_nsp);
copy(m_thermo->molecularWeights().begin(), copy(m_thermo->molecularWeights().begin(),
m_thermo->molecularWeights().end(), m_mw.begin()); m_thermo->molecularWeights().end(), m_mw.begin());
// copy polynomials and parameters into local storage // copy polynomials and parameters into local storage
m_poly = tr.poly; m_poly = tr.poly;
@ -71,7 +68,7 @@ namespace Cantera {
m_alpha = tr.alpha; m_alpha = tr.alpha;
m_dipoleDiag.resize(m_nsp); m_dipoleDiag.resize(m_nsp);
for (int i = 0; i < m_nsp; i++) { for (int i = 0; i < m_nsp; i++) {
m_dipoleDiag[i] = tr.dipole(i,i); m_dipoleDiag[i] = tr.dipole(i,i);
} }
m_phi.resize(m_nsp, m_nsp, 0.0); m_phi.resize(m_nsp, m_nsp, 0.0);
@ -79,11 +76,11 @@ namespace Cantera {
m_wratkj1.resize(m_nsp, m_nsp, 0.0); m_wratkj1.resize(m_nsp, m_nsp, 0.0);
int j, k; int j, k;
for (j = 0; j < m_nsp; j++) for (j = 0; j < m_nsp; j++)
for (k = j; k < m_nsp; k++) { for (k = j; k < m_nsp; k++) {
m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]); m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]);
m_wratjk(k,j) = sqrt(m_wratjk(j,k)); m_wratjk(k,j) = sqrt(m_wratjk(j,k));
m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]); m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]);
} }
m_polytempvec.resize(5); m_polytempvec.resize(5);
m_visc.resize(m_nsp); m_visc.resize(m_nsp);
@ -109,113 +106,123 @@ namespace Cantera {
// set specific heats // set specific heats
cv_rot.resize(m_nsp); cv_rot.resize(m_nsp);
cp_R.resize(m_nsp); cp_R.resize(m_nsp);
cv_int.resize(m_nsp); cv_int.resize(m_nsp);
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
cv_rot[k] = tr.crot[k]; cv_rot[k] = tr.crot[k];
cp_R[k] = ((IdealGasPhase*)tr.thermo)->cp_R_ref()[k]; cp_R[k] = ((IdealGasPhase*)tr.thermo)->cp_R_ref()[k];
cv_int[k] = cp_R[k] - 2.5 - cv_rot[k]; cv_int[k] = cp_R[k] - 2.5 - cv_rot[k];
} }
return true; return true;
} }
/********************************************************* /*********************************************************
* *
* Public methods * Public methods
* *
*********************************************************/ *********************************************************/
/****************** viscosity ******************************/ /****************** viscosity ******************************/
/** /**
* The viscosity is computed using the Wilke mixture rule. * The viscosity is computed using the Wilke mixture rule.
* \f[ * \f[
* \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}. * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}.
* \f] * \f]
* Here \f$ \mu_k \f$ is the viscosity of pure species \e k, * Here \f$ \mu_k \f$ is the viscosity of pure species \e k,
* and * and
* \f[ * \f[
* \Phi_{k,j} = \frac{\left[1 * \Phi_{k,j} = \frac{\left[1
* + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2} * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2}
* {\sqrt{8}\sqrt{1 + M_k/M_j}} * {\sqrt{8}\sqrt{1 + M_k/M_j}}
* \f] * \f]
* @see updateViscosity_T(); * @see updateViscosity_T();
*/ */
doublereal PecosTransport::viscosity() { doublereal PecosTransport::viscosity()
{
update_T(); update_T();
update_C(); update_C();
if (m_viscmix_ok) return m_viscmix; if (m_viscmix_ok) {
return m_viscmix;
}
doublereal vismix = 0.0; doublereal vismix = 0.0;
int k; int k;
// update m_visc and m_phi if necessary // update m_visc and m_phi if necessary
if (!m_viscwt_ok) updateViscosity_T(); if (!m_viscwt_ok) {
updateViscosity_T();
}
multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork));
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
vismix += m_molefracs[k] * m_visc[k]/m_spwork[k]; //denom; vismix += m_molefracs[k] * m_visc[k]/m_spwork[k]; //denom;
} }
m_viscmix = vismix; m_viscmix = vismix;
return vismix; return vismix;
} }
/******************* binary diffusion coefficients **************/ /******************* binary diffusion coefficients **************/
/* /*
* *
* Using Ramshaw's self-consistent Effective Binary Diffusion * Using Ramshaw's self-consistent Effective Binary Diffusion
* (1990, J. Non-Equilib. Thermo) * (1990, J. Non-Equilib. Thermo)
* Adding more doxygen would be good here * Adding more doxygen would be good here
*/ */
void PecosTransport::getBinaryDiffCoeffs(const int ld, doublereal* const d) { void PecosTransport::getBinaryDiffCoeffs(const int ld, doublereal* const d)
{
int i,j; int i,j;
update_T(); update_T();
// if necessary, evaluate the binary diffusion coefficents // if necessary, evaluate the binary diffusion coefficents
if (!m_bindiff_ok) updateDiff_T(); if (!m_bindiff_ok) {
updateDiff_T();
}
doublereal rp = 1.0/pressure_ig(); doublereal rp = 1.0/pressure_ig();
for (i = 0; i < m_nsp; i++) for (i = 0; i < m_nsp; i++)
for (j = 0; j < m_nsp; j++) { for (j = 0; j < m_nsp; j++) {
d[ld*j + i] = rp * m_bdiff(i,j); d[ld*j + i] = rp * m_bdiff(i,j);
} }
} }
void PecosTransport::getMobilities(doublereal* const mobil) { void PecosTransport::getMobilities(doublereal* const mobil)
{
int k; int k;
getMixDiffCoeffs(DATA_PTR(m_spwork)); getMixDiffCoeffs(DATA_PTR(m_spwork));
doublereal c1 = ElectronCharge / (Boltzmann * m_temp); doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k); mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k);
} }
} }
/****************** thermal conductivity **********************/ /****************** thermal conductivity **********************/
/** /**
* The thermal conductivity is computed using the Wilke mixture rule. * The thermal conductivity is computed using the Wilke mixture rule.
* \f[ * \f[
* \k = \sum_s \frac{k_s X_s}{\sum_j \Phi_{s,j} X_j}. * \k = \sum_s \frac{k_s X_s}{\sum_j \Phi_{s,j} X_j}.
* \f] * \f]
* Here \f$ \k_s \f$ is the conductivity of pure species \e s, * Here \f$ \k_s \f$ is the conductivity of pure species \e s,
* and * and
* \f[ * \f[
* \Phi_{s,j} = \frac{\left[1 * \Phi_{s,j} = \frac{\left[1
* + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_s}}\right)}\right]^2} * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_s}}\right)}\right]^2}
* {\sqrt{8}\sqrt{1 + M_s/M_j}} * {\sqrt{8}\sqrt{1 + M_s/M_j}}
* \f] * \f]
* @see updateCond_T(); * @see updateCond_T();
*/ */
doublereal PecosTransport::thermalConductivity() { doublereal PecosTransport::thermalConductivity()
{
int k; int k;
doublereal lambda = 0.0; doublereal lambda = 0.0;
@ -223,52 +230,56 @@ namespace Cantera {
update_C(); update_C();
// update m_cond and m_phi if necessary // update m_cond and m_phi if necessary
if (!m_spcond_ok) updateCond_T(); if (!m_spcond_ok) {
updateCond_T();
}
if (!m_condmix_ok) { if (!m_condmix_ok) {
multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork));
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
lambda += m_molefracs[k] * m_cond[k]/m_spwork[k]; //denom; lambda += m_molefracs[k] * m_cond[k]/m_spwork[k]; //denom;
} }
} }
m_lambda = lambda; m_lambda = lambda;
return m_lambda; return m_lambda;
} }
/****************** thermal diffusion coefficients ************/ /****************** thermal diffusion coefficients ************/
/** /**
* Thermal diffusion is not considered in this pecos * Thermal diffusion is not considered in this pecos
* model. To include thermal diffusion, use transport manager * model. To include thermal diffusion, use transport manager
* MultiTransport instead. This methods fills out array dt with * MultiTransport instead. This methods fills out array dt with
* zeros. * zeros.
*/ */
void PecosTransport::getThermalDiffCoeffs(doublereal* const dt) { void PecosTransport::getThermalDiffCoeffs(doublereal* const dt)
{
int k; int k;
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
dt[k] = 0.0; dt[k] = 0.0;
} }
} }
/** /**
* @param ndim The number of spatial dimensions (1, 2, or 3). * @param ndim The number of spatial dimensions (1, 2, or 3).
* @param grad_T The temperature gradient (ignored in this model). * @param grad_T The temperature gradient (ignored in this model).
* @param ldx Leading dimension of the grad_X array. * @param ldx Leading dimension of the grad_X array.
* The diffusive mass flux of species \e k is computed from * The diffusive mass flux of species \e k is computed from
* \f[ * \f[
* \vec{j}_k = -n M_k D_k \nabla X_k + \frac{\rho_k}{\rho} \sum_r n M_r D_r \nabla X_r * \vec{j}_k = -n M_k D_k \nabla X_k + \frac{\rho_k}{\rho} \sum_r n M_r D_r \nabla X_r
* \f] * \f]
* *
* This is neglective pressure, forced and thermal diffusion. * This is neglective pressure, forced and thermal diffusion.
* *
*/ */
void PecosTransport::getSpeciesFluxes(int ndim, void PecosTransport::getSpeciesFluxes(int ndim,
const doublereal* grad_T, int ldx, const doublereal* grad_X, const doublereal* grad_T, int ldx, const doublereal* grad_X,
int ldf, doublereal* fluxes) { int ldf, doublereal* fluxes)
{
int n, k; int n, k;
update_T(); update_T();
@ -284,140 +295,146 @@ namespace Cantera {
doublereal correction=0.0; doublereal correction=0.0;
// grab 2nd (summation) term -- still need to multiply by mass fraction (\rho_s / \rho) // grab 2nd (summation) term -- still need to multiply by mass fraction (\rho_s / \rho)
for (k = 0; k < m_nsp; k++) for (k = 0; k < m_nsp; k++) {
{ correction += rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k];
correction += rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k]; }
}
for (n = 0; n < ndim; n++) { for (n = 0; n < ndim; n++) {
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k] + y[k]*correction; fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k] + y[k]*correction;
sum[n] += fluxes[n*ldf + k]; sum[n] += fluxes[n*ldf + k];
} }
} }
// add correction flux to enforce sum to zero // add correction flux to enforce sum to zero
for (n = 0; n < ndim; n++) { for (n = 0; n < ndim; n++) {
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
fluxes[n*ldf + k] -= y[k]*sum[n]; fluxes[n*ldf + k] -= y[k]*sum[n];
} }
} }
} }
/** /**
* Mixture-averaged diffusion coefficients [m^2/s]. * Mixture-averaged diffusion coefficients [m^2/s].
* *
* For the single species case or the pure fluid case * For the single species case or the pure fluid case
* the routine returns the self-diffusion coefficient. * the routine returns the self-diffusion coefficient.
* This is need to avoid a Nan result in the formula * This is need to avoid a Nan result in the formula
* below. * below.
*/ */
void PecosTransport::getMixDiffCoeffs(doublereal* const d) { void PecosTransport::getMixDiffCoeffs(doublereal* const d)
{
update_T(); update_T();
update_C(); update_C();
// update the binary diffusion coefficients if necessary // update the binary diffusion coefficients if necessary
if (!m_bindiff_ok) updateDiff_T(); if (!m_bindiff_ok) {
updateDiff_T();
}
int k, j; int k, j;
doublereal mmw = m_thermo->meanMolecularWeight(); doublereal mmw = m_thermo->meanMolecularWeight();
doublereal sumxw = 0.0, sum2; doublereal sumxw = 0.0, sum2;
doublereal p = pressure_ig(); doublereal p = pressure_ig();
if (m_nsp == 1) { if (m_nsp == 1) {
d[0] = m_bdiff(0,0) / p; d[0] = m_bdiff(0,0) / p;
} else { } else {
for (k = 0; k < m_nsp; k++) sumxw += m_molefracs[k] * m_mw[k]; for (k = 0; k < m_nsp; k++) {
for (k = 0; k < m_nsp; k++) { sumxw += m_molefracs[k] * m_mw[k];
sum2 = 0.0; }
for (j = 0; j < m_nsp; j++) { for (k = 0; k < m_nsp; k++) {
if (j != k) { sum2 = 0.0;
sum2 += m_molefracs[j] / m_bdiff(j,k); for (j = 0; j < m_nsp; j++) {
} if (j != k) {
} sum2 += m_molefracs[j] / m_bdiff(j,k);
if (sum2 <= 0.0) { }
d[k] = m_bdiff(k,k) / p; }
} else { if (sum2 <= 0.0) {
d[k] = (sumxw - m_molefracs[k] * m_mw[k])/(p * mmw * sum2); d[k] = m_bdiff(k,k) / p;
} } else {
} d[k] = (sumxw - m_molefracs[k] * m_mw[k])/(p * mmw * sum2);
}
}
} }
} }
void PecosTransport::getMixDiffCoeffsMole(doublereal* const d) void PecosTransport::getMixDiffCoeffsMole(doublereal* const d)
{ {
update_T(); update_T();
update_C(); update_C();
// update the binary diffusion coefficients if necessary // update the binary diffusion coefficients if necessary
if (!m_bindiff_ok) { if (!m_bindiff_ok) {
updateDiff_T(); updateDiff_T();
} }
doublereal p = m_thermo->pressure(); doublereal p = m_thermo->pressure();
if (m_nsp == 1) { if (m_nsp == 1) {
d[0] = m_bdiff(0,0) / p; d[0] = m_bdiff(0,0) / p;
} else { } else {
for (size_t k = 0; k < m_nsp; k++) { for (size_t k = 0; k < m_nsp; k++) {
double sum2 = 0.0; double sum2 = 0.0;
for (size_t j = 0; j < m_nsp; j++) { for (size_t j = 0; j < m_nsp; j++) {
if (j != k) { if (j != k) {
sum2 += m_molefracs[j] / m_bdiff(j,k); sum2 += m_molefracs[j] / m_bdiff(j,k);
} }
} }
if (sum2 <= 0.0) { if (sum2 <= 0.0) {
d[k] = m_bdiff(k,k) / p; d[k] = m_bdiff(k,k) / p;
} else { } else {
d[k] = (1 - m_molefracs[k]) / (p * sum2); d[k] = (1 - m_molefracs[k]) / (p * sum2);
} }
} }
} }
} }
void PecosTransport::getMixDiffCoeffsMass(doublereal* const d) void PecosTransport::getMixDiffCoeffsMass(doublereal* const d)
{ {
update_T(); update_T();
update_C(); update_C();
// update the binary diffusion coefficients if necessary // update the binary diffusion coefficients if necessary
if (!m_bindiff_ok) { if (!m_bindiff_ok) {
updateDiff_T(); updateDiff_T();
} }
doublereal mmw = m_thermo->meanMolecularWeight(); doublereal mmw = m_thermo->meanMolecularWeight();
doublereal p = m_thermo->pressure(); doublereal p = m_thermo->pressure();
if (m_nsp == 1) { if (m_nsp == 1) {
d[0] = m_bdiff(0,0) / p; d[0] = m_bdiff(0,0) / p;
} else { } else {
for (size_t k=0; k<m_nsp; k++) { for (size_t k=0; k<m_nsp; k++) {
double sum1 = 0.0; double sum1 = 0.0;
double sum2 = 0.0; double sum2 = 0.0;
for (size_t i=0; i<m_nsp; i++) { for (size_t i=0; i<m_nsp; i++) {
if (i==k) { if (i==k) {
continue; continue;
} }
sum1 += m_molefracs[i] / m_bdiff(k,i); sum1 += m_molefracs[i] / m_bdiff(k,i);
sum2 += m_molefracs[i] * m_mw[i] / m_bdiff(k,i); sum2 += m_molefracs[i] * m_mw[i] / m_bdiff(k,i);
} }
sum1 *= p; sum1 *= p;
sum2 *= p * m_molefracs[k] / (mmw - m_mw[k]*m_molefracs[k]); sum2 *= p * m_molefracs[k] / (mmw - m_mw[k]*m_molefracs[k]);
d[k] = 1.0 / (sum1 + sum2); d[k] = 1.0 / (sum1 + sum2);
} }
} }
} }
/** /**
* @internal This is called whenever a transport property is * @internal This is called whenever a transport property is
* requested from ThermoSubstance if the temperature has changed * requested from ThermoSubstance if the temperature has changed
* since the last call to update_T. * since the last call to update_T.
*/ */
void PecosTransport::update_T() void PecosTransport::update_T()
{ {
doublereal t = m_thermo->temperature(); doublereal t = m_thermo->temperature();
if (t == m_temp) return; if (t == m_temp) {
return;
}
if (t <= 0.0) { if (t <= 0.0) {
throw CanteraError("PecosTransport::update_T", throw CanteraError("PecosTransport::update_T",
"negative temperature "+fp2str(t)); "negative temperature "+fp2str(t));
} }
m_temp = t; m_temp = t;
m_logt = log(m_temp); m_logt = log(m_temp);
@ -444,15 +461,15 @@ namespace Cantera {
m_bindiff_ok = false; m_bindiff_ok = false;
m_abc_ok = false; m_abc_ok = false;
m_condmix_ok = false; m_condmix_ok = false;
} }
/** /**
* @internal This is called the first time any transport property * @internal This is called the first time any transport property
* is requested from Mixture after the concentrations * is requested from Mixture after the concentrations
* have changed. * have changed.
*/ */
void PecosTransport::update_C() void PecosTransport::update_C()
{ {
// signal that concentration-dependent quantities will need to // signal that concentration-dependent quantities will need to
// be recomputed before use, and update the local mole // be recomputed before use, and update the local mole
// fractions. // fractions.
@ -466,88 +483,90 @@ namespace Cantera {
// add an offset to avoid a pure species condition // add an offset to avoid a pure species condition
int k; int k;
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
m_molefracs[k] = std::max(MIN_X, m_molefracs[k]); m_molefracs[k] = std::max(MIN_X, m_molefracs[k]);
} }
} }
/************************************************************************* /*************************************************************************
* *
* methods to update temperature-dependent properties * methods to update temperature-dependent properties
* *
*************************************************************************/ *************************************************************************/
/** /**
* *
* Update the temperature-dependent parts of the mixture-averaged * Update the temperature-dependent parts of the mixture-averaged
* thermal conductivity. * thermal conductivity.
* *
* Calculated as, * Calculated as,
* \f[ * \f[
* k= \mu_s (5/2 * C_{v,s}^{trans} + C_{v,s}^{rot} + C_{v,s}^{vib} * k= \mu_s (5/2 * C_{v,s}^{trans} + C_{v,s}^{rot} + C_{v,s}^{vib}
* \f] * \f]
* *
* *
*/ */
void PecosTransport::updateCond_T() { void PecosTransport::updateCond_T()
{
int k; int k;
doublereal fivehalves = 5/2; doublereal fivehalves = 5/2;
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
// need to add cv_elec in the future // need to add cv_elec in the future
m_cond[k] = m_visc[k] * ( fivehalves * cv_int[k] + cv_rot[k] + m_thermo->cv_vib(k,m_temp) ); m_cond[k] = m_visc[k] * (fivehalves * cv_int[k] + cv_rot[k] + m_thermo->cv_vib(k,m_temp));
} }
m_spcond_ok = true; m_spcond_ok = true;
m_condmix_ok = false; m_condmix_ok = false;
} }
/** /**
* Update the binary diffusion coefficients. These are evaluated * Update the binary diffusion coefficients. These are evaluated
* from the polynomial fits at unit pressure (1 Pa). * from the polynomial fits at unit pressure (1 Pa).
*/ */
void PecosTransport::updateDiff_T() { void PecosTransport::updateDiff_T()
{
// evaluate binary diffusion coefficients at unit pressure // evaluate binary diffusion coefficients at unit pressure
int i,j; int i,j;
int ic = 0; int ic = 0;
if (m_mode == CK_Mode) { if (m_mode == CK_Mode) {
for (i = 0; i < m_nsp; i++) { for (i = 0; i < m_nsp; i++) {
for (j = i; j < m_nsp; j++) { for (j = i; j < m_nsp; j++) {
m_bdiff(i,j) = exp(dot4(m_polytempvec, m_diffcoeffs[ic])); m_bdiff(i,j) = exp(dot4(m_polytempvec, m_diffcoeffs[ic]));
m_bdiff(j,i) = m_bdiff(i,j); m_bdiff(j,i) = m_bdiff(i,j);
ic++; ic++;
} }
} }
} } else {
else { for (i = 0; i < m_nsp; i++) {
for (i = 0; i < m_nsp; i++) { for (j = i; j < m_nsp; j++) {
for (j = i; j < m_nsp; j++) { m_bdiff(i,j) = m_temp * m_sqrt_t*dot5(m_polytempvec,
m_bdiff(i,j) = m_temp * m_sqrt_t*dot5(m_polytempvec, m_diffcoeffs[ic]);
m_diffcoeffs[ic]); m_bdiff(j,i) = m_bdiff(i,j);
m_bdiff(j,i) = m_bdiff(i,j); ic++;
ic++; }
} }
}
} }
m_bindiff_ok = true; m_bindiff_ok = true;
m_diffmix_ok = false; m_diffmix_ok = false;
} }
/** /**
* *
* Update the pure-species viscosities. (Pa-s) = (kg/m/sec) * Update the pure-species viscosities. (Pa-s) = (kg/m/sec)
* *
* Using Blottner fit for viscosity. Defines kinematic viscosity * Using Blottner fit for viscosity. Defines kinematic viscosity
* of the form * of the form
* \f[ * \f[
* \mu_s\left(T\right) = 0.10 \exp\left(A_s\left(\log T\right)^2 + B_s\log T + C_s\right) * \mu_s\left(T\right) = 0.10 \exp\left(A_s\left(\log T\right)^2 + B_s\log T + C_s\right)
* \f] * \f]
* where \f$ A_s \f$, \f$ B_s \f$, and \f$ C_s \f$ are constants. * where \f$ A_s \f$, \f$ B_s \f$, and \f$ C_s \f$ are constants.
* *
*/ */
void PecosTransport::updateSpeciesViscosities() { void PecosTransport::updateSpeciesViscosities()
{
// blottner // blottner
// return 0.10*std::exp(_a*(logT*logT) + _b*logT + _c); // return 0.10*std::exp(_a*(logT*logT) + _b*logT + _c);
@ -555,22 +574,22 @@ namespace Cantera {
int k; int k;
// iterate over species, update pure-species viscosity // iterate over species, update pure-species viscosity
for (k = 0; k < m_nsp; k++) { for (k = 0; k < m_nsp; k++) {
m_visc[k] = 0.10*std::exp(a[k]*(m_logt*m_logt) + b[k]*m_logt + c[k]); m_visc[k] = 0.10*std::exp(a[k]*(m_logt*m_logt) + b[k]*m_logt + c[k]);
m_sqvisc[k] = sqrt(m_visc[k]); m_sqvisc[k] = sqrt(m_visc[k]);
} }
// time to update mixing // time to update mixing
m_spvisc_ok = true; m_spvisc_ok = true;
} }
/* /*
* read_blottner_transport_table() * read_blottner_transport_table()
* loads up A B and C for blottner fits * loads up A B and C for blottner fits
* hardcoded for air, will need to generalize later * hardcoded for air, will need to generalize later
*/ */
void PecosTransport::read_blottner_transport_table() void PecosTransport::read_blottner_transport_table()
{ {
// istringstream blot // istringstream blot
// ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" // ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
// "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" // "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
@ -615,25 +634,25 @@ namespace Cantera {
// # e -- Sandia Report SC-RR-70-754 // # e -- Sandia Report SC-RR-70-754
istringstream blot istringstream blot
("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
"CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
"N 1.15572000000e-02 6.03167900000e-01 -1.24327495000e+01\n" "N 1.15572000000e-02 6.03167900000e-01 -1.24327495000e+01\n"
"N2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" "N2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
"CPN2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" "CPN2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n"
"NO 4.36378000000e-02 -3.35511000000e-02 -9.57674300000e+00\n" "NO 4.36378000000e-02 -3.35511000000e-02 -9.57674300000e+00\n"
"O 2.03144000000e-02 4.29440400000e-01 -1.16031403000e+01\n" "O 2.03144000000e-02 4.29440400000e-01 -1.16031403000e+01\n"
"O2 4.49290000000e-02 -8.26158000000e-02 -9.20194750000e+00\n" "O2 4.49290000000e-02 -8.26158000000e-02 -9.20194750000e+00\n"
"C -8.3285e-3 0.7703240 -12.7378000\n" "C -8.3285e-3 0.7703240 -12.7378000\n"
"C2 -8.4311e-3 0.7876060 -13.0268000\n" "C2 -8.4311e-3 0.7876060 -13.0268000\n"
"C3 -8.4312e-3 0.7876090 -12.8240000\n" "C3 -8.4312e-3 0.7876090 -12.8240000\n"
"C2H -2.4241e-2 1.0946550 -14.5835500\n" "C2H -2.4241e-2 1.0946550 -14.5835500\n"
"CN -8.3811e-3 0.7860330 -12.9406000\n" "CN -8.3811e-3 0.7860330 -12.9406000\n"
"CO -0.019527394 1.013295 -13.97873\n" "CO -0.019527394 1.013295 -13.97873\n"
"CO2 -0.019527387 1.047818 -14.32212\n" "CO2 -0.019527387 1.047818 -14.32212\n"
"HCN -2.4241e-2 1.0946550 -14.5835500\n" "HCN -2.4241e-2 1.0946550 -14.5835500\n"
"H -8.3912e-3 0.7743270 -13.6653000\n" "H -8.3912e-3 0.7743270 -13.6653000\n"
"H2 -8.3346e-3 0.7815380 -13.5351000\n" "H2 -8.3346e-3 0.7815380 -13.5351000\n"
"e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n"); "e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n");
string line; string line;
string name; string name;
@ -641,51 +660,46 @@ namespace Cantera {
int k; int k;
int i = 0; int i = 0;
while (std::getline(blot, line)) while (std::getline(blot, line)) {
{
istringstream ss(line); istringstream ss(line);
std::getline(ss, ss1, ' '); std::getline(ss, ss1, ' ');
std::getline(ss, ss2, ' '); std::getline(ss, ss2, ' ');
std::getline(ss, ss3, ' '); std::getline(ss, ss3, ' ');
std::getline(ss, ss4, ' '); std::getline(ss, ss4, ' ');
name = ss1; name = ss1;
// now put coefficients in correct species // now put coefficients in correct species
for (k = 0; k < m_nsp; k++) for (k = 0; k < m_nsp; k++) {
{ string sss = m_thermo->speciesName(k);
string sss = m_thermo->speciesName(k);
// this is the right species index // this is the right species index
if(sss.compare(ss1) == 0) if (sss.compare(ss1) == 0) {
{ a[k] = atof(ss2.c_str());
a[k] = atof(ss2.c_str()); b[k] = atof(ss3.c_str());
b[k] = atof(ss3.c_str()); c[k] = atof(ss4.c_str());
c[k] = atof(ss4.c_str());
// index // index
i++; i++;
} } else { // default to air
else // default to air
{
a[k] = 0.026; a[k] = 0.026;
b[k] = 0.3; b[k] = 0.3;
c[k] = -11.3; c[k] = -11.3;
} }
} // done with for loop } // done with for loop
} }
// for (k = 0; k < m_nsp; k++) // for (k = 0; k < m_nsp; k++)
// { // {
// string sss = m_thermo->speciesName(k); // string sss = m_thermo->speciesName(k);
// cout << sss << endl; // cout << sss << endl;
// cout << a[k] << endl; // cout << a[k] << endl;
// cout << b[k] << endl; // cout << b[k] << endl;
// cout << c[k] << endl; // cout << c[k] << endl;
// } // }
// simple sanity check // simple sanity check
// if(i != m_nsp-1) // if(i != m_nsp-1)
@ -693,38 +707,41 @@ namespace Cantera {
// std::cout << "error\n" << i << std::endl; // std::cout << "error\n" << i << std::endl;
// } // }
} }
/** /**
* *
* Update the temperature-dependent viscosity terms. * Update the temperature-dependent viscosity terms.
* Updates the array of pure species viscosities, and the * Updates the array of pure species viscosities, and the
* weighting functions in the viscosity mixture rule. * weighting functions in the viscosity mixture rule.
* The flag m_visc_ok is set to true. * The flag m_visc_ok is set to true.
* *
*/ */
void PecosTransport::updateViscosity_T() { void PecosTransport::updateViscosity_T()
{
doublereal vratiokj, wratiojk, factor1; doublereal vratiokj, wratiojk, factor1;
if (!m_spvisc_ok) updateSpeciesViscosities(); if (!m_spvisc_ok) {
updateSpeciesViscosities();
}
// see Eq. (9-5.15) of Reid, Prausnitz, and Poling // see Eq. (9-5.15) of Reid, Prausnitz, and Poling
int j, k; int j, k;
for (j = 0; j < m_nsp; j++) { for (j = 0; j < m_nsp; j++) {
for (k = j; k < m_nsp; k++) { for (k = j; k < m_nsp; k++) {
vratiokj = m_visc[k]/m_visc[j]; vratiokj = m_visc[k]/m_visc[j];
wratiojk = m_mw[j]/m_mw[k]; wratiojk = m_mw[j]/m_mw[k];
// Note that m_wratjk(k,j) holds the square root of // Note that m_wratjk(k,j) holds the square root of
// m_wratjk(j,k)! // m_wratjk(j,k)!
factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j); factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j);
m_phi(k,j) = factor1*factor1 / m_phi(k,j) = factor1*factor1 /
(SqrtEight * m_wratkj1(j,k)); (SqrtEight * m_wratkj1(j,k));
m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk); m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk);
} }
} }
m_viscwt_ok = true; m_viscwt_ok = true;
} }
} }

View file

@ -373,7 +373,7 @@ Transport* TransportFactory::newTransport(std::string transportModel,
tr = new MixTransport; tr = new MixTransport;
initTransport(tr, phase, CK_Mode, log_level); initTransport(tr, phase, CK_Mode, log_level);
break; break;
// adding pecos transport model 2/13/12 // adding pecos transport model 2/13/12
case cPecosTransport: case cPecosTransport:
tr = new PecosTransport; tr = new PecosTransport;
initTransport(tr, phase, 0, log_level); initTransport(tr, phase, 0, log_level);
@ -712,8 +712,8 @@ void TransportFactory::initLiquidTransport(Transport* tran,
} }
void TransportFactory::fitCollisionIntegrals(ostream& logfile, void TransportFactory::fitCollisionIntegrals(ostream& logfile,
GasTransportParams& tr, GasTransportParams& tr,
MMCollisionInt& integrals) MMCollisionInt& integrals)
{ {
vector_fp::iterator dptr; vector_fp::iterator dptr;
doublereal dstar; doublereal dstar;
@ -1145,7 +1145,7 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
*********************************************************/ *********************************************************/
void TransportFactory::fitProperties(GasTransportParams& tr, void TransportFactory::fitProperties(GasTransportParams& tr,
MMCollisionInt& integrals, std::ostream& logfile) MMCollisionInt& integrals, std::ostream& logfile)
{ {
doublereal tstar; doublereal tstar;
int ndeg = 0; int ndeg = 0;

View file

@ -1,7 +1,5 @@
#!/bin/sh #!/bin/sh
# #
# $Id: runtest,v 1.8 2006/08/14 19:32:55 hkmoffa Exp $
#
temp_success="1" temp_success="1"
/bin/rm -f eq1.csv tr1.csv tr2.csv kin1.csv kin2.csv \ /bin/rm -f eq1.csv tr1.csv tr2.csv kin1.csv kin2.csv \
kin1_blessed_tmp.csv kin2_blessed_tmp.csv kin1_blessed_tmp.csv kin2_blessed_tmp.csv