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.
* Since the translational modes are assumed to be fully populated
* this is simply
* \f[
* C^{trans}_{v,s} \equiv \frac{\partial e^{trans}_s}{\partial T} = \frac{3}{2} R_s
* \f]
*/
virtual doublereal cv_trans() const;
/** /**
* @returns species rotational specific heat at constant volume. * @returns species translational specific heat at constant volume.
* By convention, we lump the translational/rotational components * Since the translational modes are assumed to be fully populated
* \f[ * this is simply
* C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s} * \f[
* \f] * C^{trans}_{v,s} \equiv \frac{\partial e^{trans}_s}{\partial T} = \frac{3}{2} R_s
* so then * \f]
* \f[ */
* C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s} virtual doublereal cv_trans() const;
* \f]
*/
virtual doublereal cv_rot(double atomicity) const;
/** /**
* @returns species vibrational specific heat at * @returns species rotational specific heat at constant volume.
* constant volume. This is defined as * By convention, we lump the translational/rotational components
* \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^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s}
* \f] * \f]
*/ * so then
virtual doublereal cv_vib(int k, doublereal T) const; * \f[
* C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s}
* \f]
*/
virtual doublereal cv_rot(double atomicity) const;
/**
* @returns species vibrational specific heat at
* constant volume. This is defined as
* \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}
* \f]
*/
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

@ -1,10 +1,10 @@
/** /**
* @file StatMech.h * @file StatMech.h
* Header for a single-species standard state object derived * Header for a single-species standard state object derived
* 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
*/
class StatMech : public SpeciesThermoInterpType {
public: //!
/*!
* @ingroup spthermo
*/
class StatMech : public SpeciesThermoInterpType
{
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
@ -89,7 +84,7 @@ namespace Cantera {
//! Build a series of maps for the properties needed for species //! Build a series of maps for the properties needed for species
int buildmap(); int buildmap();
//! Update the properties for this species, given a temperature polynomial //! Update the properties for this species, given a temperature polynomial
/*! /*!
* This method is called with a pointer to an array containing the functions of * This method is called with a pointer to an array containing the functions of
@ -114,10 +109,10 @@ namespace Cantera {
* @param s_R Vector of Dimensionless entropies. * @param s_R Vector of Dimensionless entropies.
* (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
/*! /*!
* Given temperature T in K, this method updates the values of * Given temperature T in K, this method updates the values of
@ -143,12 +138,12 @@ namespace Cantera {
* @param s_R Vector of Dimensionless entropies. * @param s_R Vector of Dimensionless entropies.
* (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
//! species, index. //! species, index.
/*! /*!
* All parameters are output variables * All parameters are output variables
@ -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,16 +174,16 @@ 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
doublereal m_highT; doublereal m_highT;
//! standard-state pressure //! standard-state pressure
doublereal m_Pref; doublereal m_Pref;
//! species index //! species index
int m_index; int m_index;
//! array of polynomial coefficients //! array of polynomial coefficients
vector_fp m_coeff; vector_fp m_coeff;
std::string sp_name; std::string sp_name;
@ -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,16 +298,16 @@ 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");
} }
/** /**
* @} * @}
* @name Mechanical Properties * @name Mechanical Properties

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
/*! /*!
@ -80,9 +75,9 @@ namespace Cantera {
* *
* This is computed using the lumped model, * This is computed using the lumped model,
* \f[ * \f[
* k = k^{tr} + k^{ve} * k = k^{tr} + k^{ve}
* \f] * \f]
* where, * where,
* \f[ * \f[
* k^{tr}= 5/2 \mu_s C_{v,s}^{trans} + \mu_s C_{v,s}^{rot} * k^{tr}= 5/2 \mu_s C_{v,s}^{trans} + \mu_s C_{v,s}^{rot}
* \f] * \f]
@ -90,14 +85,14 @@ namespace Cantera {
* \f[ * \f[
* k^{ve}= \mu_s C_{v,s}^{vib} + \mu_s C_{v,s}^{elec} * k^{ve}= \mu_s C_{v,s}^{vib} + \mu_s C_{v,s}^{elec}
* \f] * \f]
* *
*/ */
virtual doublereal thermalConductivity(); virtual doublereal thermalConductivity();
virtual void getBinaryDiffCoeffs(const int ld, doublereal* const d); virtual void getBinaryDiffCoeffs(const int ld, doublereal* const d);
//! 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.
@ -133,31 +128,31 @@ namespace Cantera {
virtual void update_T(); virtual void update_T();
virtual void update_C(); virtual void update_C();
//! Get the species diffusive mass fluxes wrt to //! Get the species diffusive mass fluxes wrt to
//! the mass averaged velocity, //! the mass averaged velocity,
//! given the gradients in mole fraction and temperature //! given the gradients in mole fraction and temperature
/*! /*!
* Units for the returned fluxes are kg m-2 s-1. * Units for the returned fluxes are kg m-2 s-1.
* *
* @param ndim Number of dimensions in the flux expressions * @param ndim Number of dimensions in the flux expressions
* @param grad_T Gradient of the temperature * @param grad_T Gradient of the temperature
* (length = ndim) * (length = ndim)
* @param ldx Leading dimension of the grad_X array * @param ldx Leading dimension of the grad_X array
* (usually equal to m_nsp but not always) * (usually equal to m_nsp but not always)
* @param grad_X Gradients of the mole fraction * @param grad_X Gradients of the mole fraction
* Flat vector with the m_nsp in the inner loop. * Flat vector with the m_nsp in the inner loop.
* length = ldx * ndim * length = ldx * ndim
* @param ldf Leading dimension of the fluxes array * @param ldf Leading dimension of the fluxes array
* (usually equal to m_nsp but not always) * (usually equal to m_nsp but not always)
* @param fluxes Output of the diffusive mass fluxes * @param fluxes Output of the diffusive mass fluxes
* Flat vector with the m_nsp in the inner loop. * Flat vector with the m_nsp in the inner loop.
* 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
/*! /*!
@ -167,20 +162,20 @@ namespace Cantera {
* *
* @param tr Transport parameters for all of the species * @param tr Transport parameters for all of the species
* in the phase. * in the phase.
* *
*/ */
virtual bool initGas( GasTransportParams& tr ); virtual bool initGas(GasTransportParams& tr);
/** /**
* *
* Reads the transport table specified (currently defaults to internal file) * Reads the transport table specified (currently defaults to internal file)
* *
* Reads the user-specified transport table, appending new species * Reads the user-specified transport table, appending new species
* 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;
@ -173,54 +173,57 @@ doublereal IdealGasPhase::cv_mole() const
doublereal refPressure; doublereal refPressure;
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.
*/
doublereal IdealGasPhase::cv_trans () const
{ return 1.5*GasConstant; }
/** /**
* @returns species rotational specific heat at constant volume. * @returns species translational specific heat at constant volume.
* */
*/ doublereal IdealGasPhase::cv_trans() const
doublereal IdealGasPhase::cv_rot (double atom) const {
{ return std::max(cv_tr(atom) - cv_trans(), 0.); } return 1.5*GasConstant;
}
/**
* @returns species vibrational specific heat at /**
* constant volume. * @returns species rotational specific heat at constant volume.
* *
* C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T} */
* doublereal IdealGasPhase::cv_rot(double atom) const
* The species vibration energy ($e^{vib}_{v,s}$) is: {
* return std::max(cv_tr(atom) - cv_trans(), 0.);
* 0: atom }
*
* Diatomic: /**
* \f[ * @returns species vibrational specific heat at
* \frac{R_s \theta_{v,s}}{e^{\theta_{v,s}/T}-1} * constant volume.
* \f] *
* * C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T}
* General Molecules: *
* \f[ * The species vibration energy ($e^{vib}_{v,s}$) is:
* \sum_i \frac{R_s \theta_{v,s,i}}{e^{\theta_{v,s,i}/T}-1} *
* \f] * 0: atom
* *
*/ * Diatomic:
doublereal IdealGasPhase::cv_vib (const int k, const doublereal T) const * \f[
{ * \frac{R_s \theta_{v,s}}{e^{\theta_{v,s}/T}-1}
* \f]
*
* General Molecules:
* \f[
* \sum_i \frac{R_s \theta_{v,s,i}}{e^{\theta_{v,s,i}/T}-1}
* \f]
*
*/
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;
@ -234,18 +237,17 @@ 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

@ -645,52 +645,52 @@ static void installNasa9ThermoFromXML(std::string speciesName,
} }
} }
/** /**
* Install a stat mech based property solver * Install a stat mech based property solver
* 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

@ -1,208 +1,212 @@
/** /**
* @file StatMech.cpp * @file StatMech.cpp
* \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"
#include <vector> #include <vector>
#include <map> #include <map>
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
size_t StatMech::speciesIndex() const {
return m_index;
}
int StatMech::buildmap() // Returns an integer representing the species index
{ size_t StatMech::speciesIndex() const
{
return m_index;
}
int StatMech::buildmap()
{
// build vector of strings // build vector of strings
std::vector<std::string> SS; std::vector<std::string> SS;
// now just iterate over name map to place each // now just iterate over name map to place each
// string in a key // string in a key
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
@ -220,12 +224,12 @@ namespace Cantera
name_map["Ar"]->cfs = 1.5; name_map["Ar"]->cfs = 1.5;
name_map["Ar"]->mol_weight=39.944; name_map["Ar"]->mol_weight=39.944;
name_map["Ar"]->nvib=0; name_map["Ar"]->nvib=0;
// build Ar+ // build Ar+
name_map["Ar+"]->cfs = 1.5; name_map["Ar+"]->cfs = 1.5;
name_map["Ar+"]->mol_weight=39.94345; name_map["Ar+"]->mol_weight=39.94345;
name_map["Ar+"]->nvib=0; name_map["Ar+"]->nvib=0;
// build C // build C
name_map["C"]->cfs = 1.5; name_map["C"]->cfs = 1.5;
name_map["C"]->mol_weight=12.011; name_map["C"]->mol_weight=12.011;
@ -235,7 +239,7 @@ namespace Cantera
name_map["C+"]->cfs = 1.5; name_map["C+"]->cfs = 1.5;
name_map["C+"]->mol_weight=12.01045; name_map["C+"]->mol_weight=12.01045;
name_map["C+"]->nvib=0; name_map["C+"]->nvib=0;
// C2 // C2
name_map["C2"]->cfs=2.5; name_map["C2"]->cfs=2.5;
name_map["C2"]->mol_weight=24.022; name_map["C2"]->mol_weight=24.022;
@ -322,7 +326,7 @@ namespace Cantera
name_map["CH3"]->theta[1]=8.73370e+02; name_map["CH3"]->theta[1]=8.73370e+02;
name_map["CH3"]->theta[2]=4.54960e+03; name_map["CH3"]->theta[2]=4.54960e+03;
name_map["CH3"]->theta[3]=2.01150e+03; name_map["CH3"]->theta[3]=2.01150e+03;
// CH4 // CH4
name_map["CH4"]->cfs=3; name_map["CH4"]->cfs=3;
name_map["CH4"]->mol_weight=16.04300; name_map["CH4"]->mol_weight=16.04300;
@ -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,97 +654,94 @@ 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;
double theta = 0.0; double theta = 0.0;
// 5/2 * R for molecules, 3/2 * R for atoms // 5/2 * R for molecules, 3/2 * R for atoms
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;
// ACTUNG: fix enthalpy and entropy // ACTUNG: fix enthalpy and entropy
doublereal hdivRT = 0.0; doublereal hdivRT = 0.0;
doublereal sdivR = 0.0; doublereal sdivR = 0.0;
// return the computed properties in the location in the output // return the computed properties in the location in the output
// arrays for this species // arrays for this species
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;

File diff suppressed because it is too large Load diff

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
@ -115,7 +113,7 @@ fi
# #
cp kin1_blessed.csv kin1_blessed_tmp.csv cp kin1_blessed.csv kin1_blessed_tmp.csv
if test x"$machType" = "xcygwin" ; then if test x"$machType" = "xcygwin" ; then
/bin/cp kin1_blessed_win.csv kin1_blessed_tmp.csv /bin/cp kin1_blessed_win.csv kin1_blessed_tmp.csv
fi fi
$CANTERA_BIN/csvdiff -r 3.0E-3 kin1.csv kin1_blessed_tmp.csv > kin1_test.out $CANTERA_BIN/csvdiff -r 3.0E-3 kin1.csv kin1_blessed_tmp.csv > kin1_test.out
@ -150,7 +148,7 @@ fi
# #
cp kin2_blessed.csv kin2_blessed_tmp.csv cp kin2_blessed.csv kin2_blessed_tmp.csv
if test x"$machType" = "xcygwin" ; then if test x"$machType" = "xcygwin" ; then
/bin/cp kin2_blessed_win.csv kin2_blessed_tmp.csv /bin/cp kin2_blessed_win.csv kin2_blessed_tmp.csv
fi fi
$CANTERA_BIN/csvdiff kin2.csv kin2_blessed_tmp.csv > kin2_test.out $CANTERA_BIN/csvdiff kin2.csv kin2_blessed_tmp.csv > kin2_test.out