From 3ce3da1fa2498cb5680b8eb4e1c7af9426be06bd Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 18 Jul 2012 18:32:29 +0000 Subject: [PATCH] Fixed code formatting --- include/cantera/base/ct_thread.h | 6 +- include/cantera/base/ctexceptions.h | 12 +- include/cantera/kinetics/importKinetics.h | 3 +- include/cantera/thermo/GeneralSpeciesThermo.h | 32 +- include/cantera/thermo/IdealGasPhase.h | 108 +-- include/cantera/thermo/NasaPoly1.h | 10 +- include/cantera/thermo/Phase.h | 4 +- include/cantera/thermo/SpeciesThermoMgr.h | 15 +- include/cantera/thermo/StatMech.h | 98 ++- include/cantera/thermo/ThermoPhase.h | 20 +- include/cantera/transport/GasTransport.h | 3 +- include/cantera/transport/PecosTransport.h | 99 ++- src/base/application.cpp | 28 +- src/base/application.h | 3 +- src/base/ct2ctml.cpp | 14 +- src/base/ctexceptions.cpp | 19 +- src/base/ctml.cpp | 2 +- src/base/global.cpp | 3 +- src/base/plots.cpp | 2 +- src/base/xml.cpp | 2 +- src/clib/clib_defs.h | 7 +- src/clib/ct.cpp | 18 +- src/clib/ct.h | 20 +- src/clib/ctmultiphase.h | 4 +- src/clib/ctonedim.cpp | 4 +- src/clib/ctonedim.h | 10 +- src/clib/ctreactor.cpp | 2 +- src/clib/ctrpath.cpp | 4 +- src/clib/ctrpath.h | 2 +- src/clib/ctsurf.cpp | 12 +- src/clib/ctxml.cpp | 24 +- src/equil/vcs_phaseStability.cpp | 2 +- src/equil/vcs_prep.cpp | 4 +- src/fortran/fct.cpp | 16 +- src/kinetics/InterfaceKinetics.cpp | 4 +- src/kinetics/importKinetics.cpp | 10 +- src/matlab/phasemethods.cpp | 3 +- src/numerics/DAE_solvers.cpp | 23 +- src/numerics/NonlinearSolver.cpp | 30 +- src/oneD/MultiNewton.cpp | 4 +- src/oneD/Sim1D.cpp | 2 +- src/thermo/GeneralSpeciesThermo.cpp | 449 ++++++----- src/thermo/IdealGasPhase.cpp | 124 +-- src/thermo/Phase.cpp | 8 +- src/thermo/SpeciesThermoFactory.cpp | 113 ++- src/thermo/StatMech.cpp | 659 ++++++++------- src/thermo/ThermoFactory.cpp | 9 +- src/thermo/WaterProps.cpp | 2 +- src/tpx/Sub.cpp | 2 +- src/transport/GasTransport.cpp | 6 +- src/transport/PecosTransport.cpp | 757 +++++++++--------- src/transport/TransportFactory.cpp | 8 +- test_problems/cxx_ex/runtest | 6 +- 53 files changed, 1417 insertions(+), 1414 deletions(-) diff --git a/include/cantera/base/ct_thread.h b/include/cantera/base/ct_thread.h index 176b3a063..d97000368 100644 --- a/include/cantera/base/ct_thread.h +++ b/include/cantera/base/ct_thread.h @@ -14,7 +14,8 @@ #endif -namespace Cantera { +namespace Cantera +{ #ifdef THREAD_SAFE_CANTERA @@ -42,7 +43,8 @@ typedef boost::mutex::scoped_lock ScopedLock; #else typedef int mutex_t; -class ScopedLock { +class ScopedLock +{ public: explicit ScopedLock(const int m) : m_(m) {} private: diff --git a/include/cantera/base/ctexceptions.h b/include/cantera/base/ctexceptions.h index 6b95cc4bf..bb417b70a 100644 --- a/include/cantera/base/ctexceptions.h +++ b/include/cantera/base/ctexceptions.h @@ -94,7 +94,9 @@ public: virtual std::string getMessage() const; //! 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 default constructor discourages throwing errors containing no information. @@ -137,7 +139,9 @@ public: CanteraError(procedure), sz_(sz), reqd_(reqd) {} virtual std::string getMessage() const; - virtual std::string getClass() const { return "ArraySizeError"; } + virtual std::string getClass() const { + return "ArraySizeError"; + } private: size_t sz_, reqd_; @@ -166,7 +170,9 @@ public: virtual ~IndexError() throw() {}; virtual std::string getMessage() const; - virtual std::string getClass() const { return "IndexError"; } + virtual std::string getClass() const { + return "IndexError"; + } private: std::string arrayName_; diff --git a/include/cantera/kinetics/importKinetics.h b/include/cantera/kinetics/importKinetics.h index f9c9ae333..aabd2d09d 100644 --- a/include/cantera/kinetics/importKinetics.h +++ b/include/cantera/kinetics/importKinetics.h @@ -28,8 +28,7 @@ class SpeciesThermoFactory; class XML_Node; //! Rules for parsing and installing reactions -struct ReactionRules -{ +struct ReactionRules { ReactionRules(); bool skipUndeclaredSpecies; bool skipUndeclaredThirdBodies; diff --git a/include/cantera/thermo/GeneralSpeciesThermo.h b/include/cantera/thermo/GeneralSpeciesThermo.h index 68054ba53..6234e3514 100644 --- a/include/cantera/thermo/GeneralSpeciesThermo.h +++ b/include/cantera/thermo/GeneralSpeciesThermo.h @@ -20,20 +20,20 @@ namespace Cantera { - //! A species thermodynamic property manager for a phase. - /*! - * This is a general manager that can handle a wide variety - * of species thermodynamic polynomials for individual species. - * It is slow, however, because it recomputes the functions of - * temperature needed for each species. What it does is to create - * a vector of SpeciesThermoInterpType objects. - * - * @ingroup mgrsrefcalc - */ - class GeneralSpeciesThermo : public SpeciesThermo - { +//! A species thermodynamic property manager for a phase. +/*! + * This is a general manager that can handle a wide variety + * of species thermodynamic polynomials for individual species. + * It is slow, however, because it recomputes the functions of + * temperature needed for each species. What it does is to create + * a vector of SpeciesThermoInterpType objects. + * + * @ingroup mgrsrefcalc + */ +class GeneralSpeciesThermo : public SpeciesThermo +{ - public: +public: //! Constructor GeneralSpeciesThermo(); @@ -214,7 +214,7 @@ namespace Cantera #endif - private: +private: //! Provide the SpeciesthermoInterpType object /*! * provide access to the SpeciesThermoInterpType object. @@ -226,7 +226,7 @@ namespace Cantera */ SpeciesThermoInterpType* provideSTIT(size_t k); - protected: +protected: /** * This is the main unknown in the object. It is @@ -261,7 +261,7 @@ namespace Cantera friend class VPSSMgr; - }; +}; } diff --git a/include/cantera/thermo/IdealGasPhase.h b/include/cantera/thermo/IdealGasPhase.h index 62c5a5862..00af64dc2 100644 --- a/include/cantera/thermo/IdealGasPhase.h +++ b/include/cantera/thermo/IdealGasPhase.h @@ -424,64 +424,64 @@ public: * property manager. * @see SpeciesThermo */ - virtual doublereal cp_mole() const; + virtual doublereal cp_mole() const; - /** - * Molar heat capacity at constant volume. Units: J/kmol/K. - * For an ideal gas mixture, - * \f[ \hat c_v = \hat c_p - \hat R. \f] - */ - virtual doublereal cv_mole() const; + /** + * Molar heat capacity at constant volume. Units: J/kmol/K. + * For an ideal gas mixture, + * \f[ \hat c_v = \hat c_p - \hat R. \f] + */ + virtual doublereal cv_mole() const; - /** - * @returns species translational/rotational specific heat at - * constant volume. Inferred from the species gas - * constant and number of translational/rotational - * degrees of freedom. The translational/rotational - * modes are assumed to be fully populated, and are - * given by - * \f[ - * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{5}{2} R_s - * \f] - * for diatomic molecules and - * \f[ - * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{3}{2} R_s - * \f] - * for atoms. - */ - 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 translational/rotational specific heat at + * constant volume. Inferred from the species gas + * constant and number of translational/rotational + * degrees of freedom. The translational/rotational + * modes are assumed to be fully populated, and are + * given by + * \f[ + * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{5}{2} R_s + * \f] + * for diatomic molecules and + * \f[ + * C^{tr}_{v,s} \equiv \frac{\partial e^{tr}_s}{\partial T} = \frac{3}{2} R_s + * \f] + * for atoms. + */ + virtual doublereal cv_tr(doublereal) const; - /** - * @returns species rotational specific heat at constant volume. - * By convention, we lump the translational/rotational components - * \f[ - * C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s} - * \f] - * so then - * \f[ - * C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s} - * \f] - */ - virtual doublereal cv_rot(double atomicity) 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 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; + /** + * @returns species rotational specific heat at constant volume. + * By convention, we lump the translational/rotational components + * \f[ + * C^{tr}_{v,s} \equiv C^{trans}_{v,s} + C^{rot}_{v,s} + * \f] + * so then + * \f[ + * C^{rot}_{v,s} \equiv C^{tr}_{v,s} - C^{trans}_{v,s} + * \f] + */ + 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; //@} diff --git a/include/cantera/thermo/NasaPoly1.h b/include/cantera/thermo/NasaPoly1.h index 09c28643c..0e3a02ce1 100644 --- a/include/cantera/thermo/NasaPoly1.h +++ b/include/cantera/thermo/NasaPoly1.h @@ -254,11 +254,11 @@ public: } } - //! Modify parameters for the standard state - /*! - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state. - */ + //! Modify parameters for the standard state + /*! + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. + */ virtual void modifyParameters(doublereal* coeffs) { m_coeff[0] = coeffs[5]; m_coeff[1] = coeffs[6]; diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index fc2cbb15c..8f70912f2 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -106,8 +106,8 @@ public: //! @param right Reference to the class to be used in the copy Phase(const Phase& right); - //! Assignment operator - //! @param right Reference to the class to be used in the copy + //! Assignment operator + //! @param right Reference to the class to be used in the copy Phase& operator=(const Phase& right); //! Returns a reference to the XML_Node stored for the phase. diff --git a/include/cantera/thermo/SpeciesThermoMgr.h b/include/cantera/thermo/SpeciesThermoMgr.h index 1fee5c6ea..1a4eef52d 100644 --- a/include/cantera/thermo/SpeciesThermoMgr.h +++ b/include/cantera/thermo/SpeciesThermoMgr.h @@ -74,8 +74,7 @@ public: /*! * @param right Object to be copied */ - SpeciesThermoDuo(const SpeciesThermoDuo& right) - { + SpeciesThermoDuo(const SpeciesThermoDuo& right) { *this = operator=(right); } @@ -128,8 +127,7 @@ public: * @param stit_ptr Pointer to the SpeciesThermoInterpType object * 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"); } @@ -161,8 +159,7 @@ public: * * @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()); } @@ -176,8 +173,7 @@ public: * * @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()); } @@ -194,8 +190,7 @@ public: * * @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; } diff --git a/include/cantera/thermo/StatMech.h b/include/cantera/thermo/StatMech.h index 943a9a9b1..26df38b32 100644 --- a/include/cantera/thermo/StatMech.h +++ b/include/cantera/thermo/StatMech.h @@ -1,10 +1,10 @@ /** * @file StatMech.h * 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 * U.S. Government retains certain rights in this software. */ @@ -12,28 +12,23 @@ #ifndef 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 "SpeciesThermoInterpType.h" #include "SpeciesThermoMgr.h" #include #include -namespace Cantera { - - //! - /*! - * @ingroup spthermo - */ - class StatMech : public SpeciesThermoInterpType { +namespace Cantera +{ - public: +//! +/*! + * @ingroup spthermo + */ +class StatMech : public SpeciesThermoInterpType +{ + +public: //! Empty constructor StatMech(); @@ -49,7 +44,7 @@ namespace Cantera { * parameters for the standard state. */ 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 /*! @@ -67,7 +62,7 @@ namespace Cantera { virtual ~StatMech(); //! duplicator - virtual SpeciesThermoInterpType * + virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; //! Returns the minimum temperature that the thermo @@ -89,7 +84,7 @@ namespace Cantera { //! Build a series of maps for the properties needed for species int buildmap(); - + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the functions of @@ -114,10 +109,10 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void updateProperties(const doublereal* tt, - doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; + virtual void updateProperties(const doublereal* tt, + doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; + - //! Compute the reference-state property of one species /*! * Given temperature T in K, this method updates the values of @@ -143,12 +138,12 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void updatePropertiesTemp(const doublereal temp, - doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const; + virtual void updatePropertiesTemp(const doublereal temp, + doublereal* cp_R, doublereal* h_RT, + doublereal* s_R) const; - //!This utility function reports back the type of - //! parameterization and all of the parameters for the + //!This utility function reports back the type of + //! parameterization and all of the parameters for the //! species, index. /*! * All parameters are output variables @@ -167,10 +162,10 @@ namespace Cantera { * coeffs[2] is max temperature * coeffs[3+i] from i =0,9 are the coefficients themselves */ - virtual void reportParameters(size_t& n, int &type, - doublereal &tlow, doublereal &thigh, - doublereal &pref, - doublereal* const coeffs) const; + virtual void reportParameters(size_t& n, int& type, + doublereal& tlow, doublereal& thigh, + doublereal& pref, + doublereal* const coeffs) const; //! Modify parameters for the standard state /*! @@ -179,16 +174,16 @@ namespace Cantera { */ virtual void modifyParameters(doublereal* coeffs); - protected: +protected: //! lowest valid temperature - doublereal m_lowT; + doublereal m_lowT; //! highest valid temperature - doublereal m_highT; + doublereal m_highT; //! standard-state pressure - doublereal m_Pref; + doublereal m_Pref; //! species index - int m_index; - //! array of polynomial coefficients + int m_index; + //! array of polynomial coefficients vector_fp m_coeff; std::string sp_name; @@ -196,24 +191,23 @@ namespace Cantera { //*generic species struct that contains everything we need here // achtung: add doxygen markup here // achtung: convert doubles to realdoubles - struct species - { - //Nominal T-R Degrees of freedom (cv = cfs*k*T) - doublereal cfs; - - // Mol. Wt. Molecular weight (kg/kmol) - doublereal mol_weight; - - // number of vibrational temperatures necessary - int nvib; - - // Theta_v Characteristic vibrational temperature(s) (K) - doublereal theta[5]; + struct species { + //Nominal T-R Degrees of freedom (cv = cfs*k*T) + doublereal cfs; + + // Mol. Wt. Molecular weight (kg/kmol) + doublereal mol_weight; + + // number of vibrational temperatures necessary + int nvib; + + // Theta_v Characteristic vibrational temperature(s) (K) + doublereal theta[5]; }; std::map name_map; - }; +}; } #endif diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index 9335cc46d..b2f26bc1c 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -298,16 +298,16 @@ public: return err("cv_mole"); } - /** - * @returns species vibrational specific heat at - * constant volume. - * - */ - /// Molar heat capacity at constant volume. Units: J/kmol/K. - virtual doublereal cv_vib(int, double) const { - return err("cv_vib"); - } - + /** + * @returns species vibrational specific heat at + * constant volume. + * + */ + /// Molar heat capacity at constant volume. Units: J/kmol/K. + virtual doublereal cv_vib(int, double) const { + return err("cv_vib"); + } + /** * @} * @name Mechanical Properties diff --git a/include/cantera/transport/GasTransport.h b/include/cantera/transport/GasTransport.h index ceb92baad..4def843c5 100644 --- a/include/cantera/transport/GasTransport.h +++ b/include/cantera/transport/GasTransport.h @@ -7,7 +7,8 @@ #include "TransportBase.h" -namespace Cantera { +namespace Cantera +{ //! Class GasTransport implements some functions and properties that are //! shared by the MixTransport and MultiTransport classes. diff --git a/include/cantera/transport/PecosTransport.h b/include/cantera/transport/PecosTransport.h index c5f107cfa..f3a719778 100644 --- a/include/cantera/transport/PecosTransport.h +++ b/include/cantera/transport/PecosTransport.h @@ -3,24 +3,12 @@ * Header file defining class PecosTransport */ -/* $Author$ - * $Revision$ - * $Date$ - */ - // Copyright 2001 California Institute of Technology #ifndef 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 #include #include @@ -42,24 +30,28 @@ using namespace std; #include "TransportBase.h" #include "cantera/numerics/DenseMatrix.h" -namespace Cantera { +namespace Cantera +{ - class GasTransportParams; +class GasTransportParams; - /** - * - * Class PecosTransport implements mixture-averaged transport - * properties for ideal gas mixtures. - * - */ - class PecosTransport : public Transport { +/** + * + * Class PecosTransport implements mixture-averaged transport + * properties for ideal gas mixtures. + * + */ +class PecosTransport : public Transport +{ - public: +public: virtual ~PecosTransport() {} - virtual int model() const { return cPecosTransport; } + virtual int model() const { + return cPecosTransport; + } //! Viscosity of the mixture /*! @@ -67,8 +59,11 @@ namespace Cantera { */ virtual doublereal viscosity(); - virtual void getSpeciesViscosities(doublereal* visc) - { update_T(); updateViscosity_T(); copy(m_visc.begin(), m_visc.end(), visc); } + virtual void getSpeciesViscosities(doublereal* visc) { + update_T(); + updateViscosity_T(); + copy(m_visc.begin(), m_visc.end(), visc); + } //! Return the thermal diffusion coefficients /*! @@ -80,9 +75,9 @@ namespace Cantera { * * This is computed using the lumped model, * \f[ - * k = k^{tr} + k^{ve} + * k = k^{tr} + k^{ve} * \f] - * where, + * where, * \f[ * k^{tr}= 5/2 \mu_s C_{v,s}^{trans} + \mu_s C_{v,s}^{rot} * \f] @@ -90,14 +85,14 @@ namespace Cantera { * \f[ * k^{ve}= \mu_s C_{v,s}^{vib} + \mu_s C_{v,s}^{elec} * \f] - * + * */ virtual doublereal thermalConductivity(); 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 * the routine returns the self-diffusion coefficient. @@ -133,31 +128,31 @@ namespace Cantera { virtual void update_T(); virtual void update_C(); - //! Get the species diffusive mass fluxes wrt to - //! the mass averaged velocity, + //! Get the species diffusive mass fluxes wrt to + //! the mass averaged velocity, //! given the gradients in mole fraction and temperature /*! * Units for the returned fluxes are kg m-2 s-1. - * + * * @param ndim Number of dimensions in the flux expressions * @param grad_T Gradient of the temperature * (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) * @param grad_X Gradients of the mole fraction * Flat vector with the m_nsp in the inner loop. * 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) * @param fluxes Output of the diffusive mass fluxes * Flat vector with the m_nsp in the inner loop. * length = ldx * ndim */ - virtual void getSpeciesFluxes(int ndim, - const doublereal* grad_T, - int ldx, - const doublereal* grad_X, - int ldf, doublereal* fluxes); + virtual void getSpeciesFluxes(int ndim, + const doublereal* grad_T, + int ldx, + const doublereal* grad_X, + int ldf, doublereal* fluxes); //! Initialize the transport object /*! @@ -167,20 +162,20 @@ namespace Cantera { * * @param tr Transport parameters for all of the species * 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 user-specified transport table, appending new species - * data and/or replacing default species data. + * + * Reads the user-specified transport table, appending new species + * data and/or replacing default species data. * */ - void read_blottner_transport_table (); + void read_blottner_transport_table(); friend class TransportFactory; @@ -193,17 +188,17 @@ namespace Cantera { */ struct GasTransportData getGasTransportData(int); - protected: +protected: /// default constructor PecosTransport(); - private: +private: //! Calculate the pressure from the ideal gas law doublereal pressure_ig() const { - return (m_thermo->molarDensity() * GasConstant * - m_thermo->temperature()); + return (m_thermo->molarDensity() * GasConstant * + m_thermo->temperature()); } // mixture attributes @@ -290,6 +285,6 @@ namespace Cantera { vector_fp cp_R; vector_fp cv_int; - }; +}; } #endif diff --git a/src/base/application.cpp b/src/base/application.cpp index 57c5c5bd9..3b5688f09 100644 --- a/src/base/application.cpp +++ b/src/base/application.cpp @@ -21,7 +21,8 @@ using std::endl; #pragma comment(lib, "advapi32") #endif -namespace Cantera { +namespace Cantera +{ // If running multiple threads in a cpp application, the Application class // 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)); } -Application::Messages& Application::Messages::operator=(const Messages& r) { +Application::Messages& Application::Messages::operator=(const Messages& r) +{ if (this == &r) { return *this; } @@ -99,7 +101,8 @@ Application::Messages& Application::Messages::operator=(const Messages& r) { return *this; } -Application::Messages::~Messages() { +Application::Messages::~Messages() +{ delete logwriter; #ifdef WITH_HTML_LOGS if (xmllog) { @@ -329,7 +332,8 @@ Application::Application() : stop_on_error(false), options(), xmlfiles(), - pMessenger() { + pMessenger() +{ #if !defined( THREAD_SAFE_CANTERA ) pMessenger = std::auto_ptr(new Messages()); #endif @@ -349,7 +353,8 @@ Application::Application() : #endif } -Application* Application::Instance() { +Application* Application::Instance() +{ ScopedLock appLock(app_mutex); if (Application::s_app == 0) { Application::s_app = new Application(); @@ -367,7 +372,8 @@ Application::~Application() } } -void Application::ApplicationDestroy() { +void Application::ApplicationDestroy() +{ ScopedLock appLock(app_mutex); if (Application::s_app != 0) { delete Application::s_app; @@ -435,11 +441,11 @@ XML_Node* Application::get_XML_File(std::string file, int debug) * the processed xml tree. */ if (xmlfiles.find(ff) != xmlfiles.end()) { - if (debug > 0) { - writelog("get_XML_File(): File, " + ff + - ", was previously read." + - " Retrieving the stored xml tree.\n"); - } + if (debug > 0) { + writelog("get_XML_File(): File, " + ff + + ", was previously read." + + " Retrieving the stored xml tree.\n"); + } return xmlfiles[ff]; } /* diff --git a/src/base/application.h b/src/base/application.h index 98011b740..6bb3a5fb1 100644 --- a/src/base/application.h +++ b/src/base/application.h @@ -10,7 +10,8 @@ #include #include -namespace Cantera { +namespace Cantera +{ class XML_Node; diff --git a/src/base/ct2ctml.cpp b/src/base/ct2ctml.cpp index d7dd83c8f..0a9a1280c 100644 --- a/src/base/ct2ctml.cpp +++ b/src/base/ct2ctml.cpp @@ -83,13 +83,13 @@ void ct2ctml(const char* file, const int debug) python.start(pypath(), "-i"); stringstream output_stream; python.in() << - "if True:\n" << // Use this so that the rest is a single block - " import sys\n" << - " sys.stderr = sys.stdout\n" << - " import ctml_writer\n" << - " ctml_writer.convert(r'" << file << "')\n" << - " sys.exit(0)\n\n" - "sys.exit(7)\n"; + "if True:\n" << // Use this so that the rest is a single block + " import sys\n" << + " sys.stderr = sys.stdout\n" << + " import ctml_writer\n" << + " ctml_writer.convert(r'" << file << "')\n" << + " sys.exit(0)\n\n" + "sys.exit(7)\n"; python.close_in(); std::string line; while (python.out().good()) { diff --git a/src/base/ctexceptions.cpp b/src/base/ctexceptions.cpp index 116025385..c84d3beab 100644 --- a/src/base/ctexceptions.cpp +++ b/src/base/ctexceptions.cpp @@ -7,7 +7,8 @@ #include #include -namespace Cantera { +namespace Cantera +{ // *** Exceptions *** @@ -38,7 +39,8 @@ void CanteraError::save() } } -const char* CanteraError::what() const throw() { +const char* CanteraError::what() const throw() +{ try { formattedMessage_ = "\n"; formattedMessage_ += stars; @@ -51,22 +53,25 @@ const char* CanteraError::what() const throw() { // Something went terribly wrong and we couldn't even format the message. } return formattedMessage_.c_str(); - } +} -std::string CanteraError::getMessage() const { +std::string CanteraError::getMessage() const +{ return msg_; } -std::string ArraySizeError::getMessage() const { +std::string ArraySizeError::getMessage() const +{ std::stringstream ss; ss << "Array size (" << sz_ << ") too small. Must be at least " << reqd_ << "."; return ss.str(); } -std::string IndexError::getMessage() const { +std::string IndexError::getMessage() const +{ std::stringstream ss; ss << "IndexError: " << arrayName_ << "[" << m_ << "]" << - " outside valid range of 0 to " << (mmax_) << "."; + " outside valid range of 0 to " << (mmax_) << "."; return ss.str(); } diff --git a/src/base/ctml.cpp b/src/base/ctml.cpp index cae94d1cb..1877dfbe3 100644 --- a/src/base/ctml.cpp +++ b/src/base/ctml.cpp @@ -1132,7 +1132,7 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector & v, } //==================================================================================================================== size_t getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector & v, - const bool convert, const std::string unitsString) + const bool convert, const std::string unitsString) { std::string::size_type icom; std::string numstr; diff --git a/src/base/global.cpp b/src/base/global.cpp index 829c50fe4..cb4aff2a4 100644 --- a/src/base/global.cpp +++ b/src/base/global.cpp @@ -11,7 +11,8 @@ using namespace std; -namespace Cantera { +namespace Cantera +{ //! Return a pointer to the application object static Application* app() diff --git a/src/base/plots.cpp b/src/base/plots.cpp index 7cc394fb0..dd703c699 100644 --- a/src/base/plots.cpp +++ b/src/base/plots.cpp @@ -102,7 +102,7 @@ void outputExcel(std::ostream& s, const std::string& title, s << ","; } } - s << endl; + s << endl; for (i = 0; i < npts; i++) { for (j = 0; j < nv; j++) { s << data(j,i); diff --git a/src/base/xml.cpp b/src/base/xml.cpp index 7cb00d89e..ca70aac3d 100644 --- a/src/base/xml.cpp +++ b/src/base/xml.cpp @@ -899,7 +899,7 @@ const std::vector& XML_Node::children() const size_t XML_Node::nChildren(const bool discardComments) const { if (discardComments) { - size_t count = 0; + size_t count = 0; for (size_t i = 0; i < m_nchildren; i++) { XML_Node* xc = m_children[i]; if (!(xc->isComment())) { diff --git a/src/clib/clib_defs.h b/src/clib/clib_defs.h index 606e8beb5..0c76f5c86 100644 --- a/src/clib/clib_defs.h +++ b/src/clib/clib_defs.h @@ -33,7 +33,8 @@ # define DERR -999.999 #endif -namespace Cantera { +namespace Cantera +{ //! Exception handler used at language interface boundaries. /*! @@ -56,12 +57,12 @@ T handleAllExceptions(T ctErrorCode, T otherErrorCode) return ctErrorCode; } catch (std::exception& err) { std::cerr << "Cantera: caught an instance of " - << err.what() << std::endl; + << err.what() << std::endl; setError("handleAllExceptions", err.what()); return otherErrorCode; } catch (...) { std::cerr << "Cantera: caught an instance of " - "an unknown exception type" << std::endl; + "an unknown exception type" << std::endl; setError("handleAllExceptions", "unknown exception"); return otherErrorCode; } diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 869d5bc3d..3894332c7 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -252,7 +252,7 @@ extern "C" { } int phase_setMassFractions(int n, size_t leny, - double* y, int norm) + double* y, int norm) { try { ThermoPhase& p = ThermoCabinet::item(n); @@ -628,7 +628,7 @@ extern "C" { } 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 { equilibrate(ThermoCabinet::item(n), XY, solver, rtol, maxsteps, @@ -804,8 +804,8 @@ extern "C" { //-------------- Kinetics ------------------// size_t newKineticsFromXML(int mxml, int iphase, - int neighbor1, int neighbor2, int neighbor3, - int neighbor4) + int neighbor1, int neighbor2, int neighbor3, + int neighbor4) { try { XML_Node& x = XmlCabinet::item(mxml); @@ -835,7 +835,7 @@ extern "C" { } int installRxnArrays(int pxml, int ikin, - char* default_phase) + char* default_phase) { try { XML_Node& p = XmlCabinet::item(pxml); @@ -871,7 +871,7 @@ extern "C" { { try { return KineticsCabinet::item(n).kineticsSpeciesIndex(string(nm), - string(ph)); + string(ph)); } catch (...) { return handleAllExceptions(npos, npos); } @@ -1309,7 +1309,7 @@ extern "C" { } int trans_getMolarFluxes(int n, const double* state1, - const double* state2, double delta, double* fluxes) + const double* state2, double delta, double* fluxes) { try { TransportCabinet::item(n).getMolarFluxes(state1, state2, delta, fluxes); @@ -1320,7 +1320,7 @@ extern "C" { } int trans_getMassFluxes(int n, const double* state1, - const double* state2, double delta, double* fluxes) + const double* state2, double delta, double* fluxes) { try { TransportCabinet::item(n).getMassFluxes(state1, state2, delta, fluxes); @@ -1511,7 +1511,7 @@ extern "C" { } int buildSolutionFromXML(char* src, int ixml, char* id, - int ith, int ikin) + int ith, int ikin) { try { XML_Node* root = 0; diff --git a/src/clib/ct.h b/src/clib/ct.h index 966089fa2..324ff21fd 100644 --- a/src/clib/ct.h +++ b/src/clib/ct.h @@ -76,7 +76,7 @@ extern "C" { CANTERA_CAPI int th_set_SV(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, - 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_critPressure(int n); @@ -88,10 +88,10 @@ extern "C" { CANTERA_CAPI int th_setState_Tsat(int n, double t, double x); CANTERA_CAPI size_t newKineticsFromXML(int mxml, int iphase, - int neighbor1=-1, int neighbor2=-1, int neighbor3=-1, - int neighbor4=-1); + int neighbor1=-1, int neighbor2=-1, int neighbor3=-1, + int neighbor4=-1); 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_nReactions(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 newTransport(char* model, - int th, int loglevel); + int th, int loglevel); CANTERA_CAPI double trans_viscosity(int n); CANTERA_CAPI double trans_thermalConductivity(int n); 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_setParameters(int n, int type, int k, double* d); 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, - 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_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 showCanteraErrors(); CANTERA_CAPI int write_HTML_log(const char* file); @@ -152,10 +152,10 @@ extern "C" { CANTERA_CAPI int delTransport(int n); CANTERA_CAPI int readlog(int n, char* buf); 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, - 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); } diff --git a/src/clib/ctmultiphase.h b/src/clib/ctmultiphase.h index 608da3c5d..984787795 100644 --- a/src/clib/ctmultiphase.h +++ b/src/clib/ctmultiphase.h @@ -41,8 +41,8 @@ extern "C" { int maxiter, int loglevel); CANTERA_CAPI int mix_getChemPotentials(int i, size_t lenmu, double* mu); CANTERA_CAPI int mix_getValidChemPotentials(int i, double bad_mu, - int standard, size_t lenmu, - double* mu); + int standard, size_t lenmu, + double* mu); CANTERA_CAPI double mix_enthalpy(int i); CANTERA_CAPI double mix_entropy(int i); CANTERA_CAPI double mix_gibbs(int i); diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index fc6367c76..65420d869 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -173,7 +173,7 @@ extern "C" { } int domain_setTolerances(int i, int n, double rtol, - double atol, int itime) + double atol, int itime) { try { Domain1D& dom = DomainCabinet::item(i); @@ -457,7 +457,7 @@ extern "C" { } int stflow_setFixedTempProfile(int i, size_t n, double* pos, - size_t m, double* temp) + size_t m, double* temp) { try { vector_fp vpos(n), vtemp(n); diff --git a/src/clib/ctonedim.h b/src/clib/ctonedim.h index e82ff26fb..7a88ea224 100644 --- a/src/clib/ctonedim.h +++ b/src/clib/ctonedim.h @@ -17,11 +17,11 @@ extern "C" { 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 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_upperBound(int i, int n); 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_atol(int i, int n); 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_setValue(int i, int dom, int comp, int localPoint, double value); 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_showSolution(int i, char* fname); 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, double slope, double curve, double prune); 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_writeStats(int i, int printTime = 1); 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_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_setMaxJacAge(int i, int ss_age, int ts_age); CANTERA_CAPI int sim1D_timeStepFactor(int i, double tfactor); diff --git a/src/clib/ctreactor.cpp b/src/clib/ctreactor.cpp index feb10187a..87b8f0812 100644 --- a/src/clib/ctreactor.cpp +++ b/src/clib/ctreactor.cpp @@ -467,7 +467,7 @@ extern "C" { { try { bool ok = FlowDeviceCabinet::item(i).install(ReactorCabinet::item(n), - ReactorCabinet::item(m)); + ReactorCabinet::item(m)); if (!ok) { throw CanteraError("install","Could not install flow device."); } diff --git a/src/clib/ctrpath.cpp b/src/clib/ctrpath.cpp index 3e0bb7522..14745118f 100644 --- a/src/clib/ctrpath.cpp +++ b/src/clib/ctrpath.cpp @@ -225,7 +225,7 @@ extern "C" { } int rdiag_findMajor(int i, double threshold, - size_t lda, double* a) + size_t lda, double* a) { try { 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 idiag, int iquiet) + int idiag, int iquiet) { try { ofstream fdot(dotfile); diff --git a/src/clib/ctrpath.h b/src/clib/ctrpath.h index 901b865c8..eca30db14 100644 --- a/src/clib/ctrpath.h +++ b/src/clib/ctrpath.h @@ -33,7 +33,7 @@ extern "C" { CANTERA_CAPI int rbuild_del(int i); CANTERA_CAPI int rbuild_init(int i, char* logfile, int k); CANTERA_CAPI int rbuild_build(int i, int k, char* el, char* dotfile, - int idiag, int iquiet); + int idiag, int iquiet); } #endif diff --git a/src/clib/ctsurf.cpp b/src/clib/ctsurf.cpp index 8e064d290..a1b00e83a 100644 --- a/src/clib/ctsurf.cpp +++ b/src/clib/ctsurf.cpp @@ -61,17 +61,17 @@ extern "C" { _surfphase(i).setCoveragesByName(string(c)); return 0; } catch (...) { - return handleAllExceptions(-1, ERR); + return handleAllExceptions(-1, ERR); } } int surf_getcoverages(int i, double* c) { try { - _surfphase(i).getCoverages(c); - return 0; + _surfphase(i).getCoverages(c); + return 0; } catch (...) { - return handleAllExceptions(-1, ERR); + return handleAllExceptions(-1, ERR); } } @@ -81,7 +81,7 @@ extern "C" { _surfphase(i).setConcentrations(c); return 0; } catch (...) { - return handleAllExceptions(-1, ERR); + return handleAllExceptions(-1, ERR); } } @@ -91,7 +91,7 @@ extern "C" { _surfphase(i).getConcentrations(c); return 0; } catch (...) { - return handleAllExceptions(-1, ERR); + return handleAllExceptions(-1, ERR); } } } diff --git a/src/clib/ctxml.cpp b/src/clib/ctxml.cpp index 6b24d0547..393a75041 100644 --- a/src/clib/ctxml.cpp +++ b/src/clib/ctxml.cpp @@ -31,8 +31,8 @@ extern "C" { } return XmlCabinet::add(x); } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_get_XML_File(const char* file, int debug) @@ -62,8 +62,8 @@ extern "C" { XmlCabinet::del(i); return 0; } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_removeChild(int i, int j) @@ -72,8 +72,8 @@ extern "C" { XmlCabinet::item(i).removeChild(&XmlCabinet::item(j)); return 0; } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_copy(int i) @@ -81,8 +81,8 @@ extern "C" { try { return XmlCabinet::newCopy(i); } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_assign(int i, int j) @@ -90,8 +90,8 @@ extern "C" { try { return XmlCabinet::assign(i,j); } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_build(int i, const char* file) @@ -250,8 +250,8 @@ extern "C" { XML_Node& node = XmlCabinet::item(i); return (int) node.nChildren(); } catch (...) { - return handleAllExceptions(-1, ERR); - } + return handleAllExceptions(-1, ERR); + } } int xml_addChild(int i, const char* name, const char* value) diff --git a/src/equil/vcs_phaseStability.cpp b/src/equil/vcs_phaseStability.cpp index 682aee9af..f9a476feb 100644 --- a/src/equil/vcs_phaseStability.cpp +++ b/src/equil/vcs_phaseStability.cpp @@ -887,7 +887,7 @@ double VCS_SOLVE::vcs_phaseStabilityTest(const size_t iph) for (k = 0; k < Vphase->nSpecies(); k++) { if (fabs(damp * delFrac[k]) > 0.3*fabs(fracDelta_old[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 (2.0 * damp * (-delFrac[k]) > fracDelta_old[k]) { diff --git a/src/equil/vcs_prep.cpp b/src/equil/vcs_prep.cpp index 770a1da2f..c1f4f69c4 100644 --- a/src/equil/vcs_prep.cpp +++ b/src/equil/vcs_prep.cpp @@ -126,9 +126,9 @@ int VCS_SOLVE::vcs_prep_oneTime(int printLvl) * equal to nspecies - nelements. This may be changed below */ if (m_numElemConstraints > m_numSpeciesTot) { - m_numRxnTot = 0; + m_numRxnTot = 0; } else { - m_numRxnTot = m_numSpeciesTot - m_numElemConstraints; + m_numRxnTot = m_numSpeciesTot - m_numElemConstraints; } m_numRxnRdc = m_numRxnTot; m_numSpeciesRdc = m_numSpeciesTot; diff --git a/src/fortran/fct.cpp b/src/fortran/fct.cpp index 61dc2b22a..341d0f7b6 100644 --- a/src/fortran/fct.cpp +++ b/src/fortran/fct.cpp @@ -88,7 +88,7 @@ extern "C" { //--------------- Phase ---------------------// status_t phase_getname_(const integer* n, char* nm, - ftnlen lennm) + ftnlen lennm) { try { std::string pnm = _fph(n)->name(); @@ -108,7 +108,7 @@ extern "C" { try { return _fph(n)->nElements(); } catch (...) { - return handleAllExceptions(-1, ERR); + return handleAllExceptions(-1, ERR); } } @@ -225,7 +225,7 @@ extern "C" { } catch (...) { return handleAllExceptions(-1, ERR); } - return 0; + return 0; } doublereal phase_massfraction_(const integer* n, integer* k) @@ -649,8 +649,8 @@ extern "C" { //-------------- Kinetics ------------------// integer newkineticsfromxml_(integer* mxml, integer* iphase, - const integer* neighbor1, const integer* neighbor2, const integer* neighbor3, - const integer* neighbor4) + const integer* neighbor1, const integer* neighbor2, const integer* neighbor3, + const integer* neighbor4) { try { XML_Node* x = _xml(mxml); @@ -700,7 +700,7 @@ extern "C" { } integer kin_speciesindex_(const integer* n, const char* nm, const char* ph, - ftnlen lennm, ftnlen lenph) + ftnlen lennm, ftnlen lenph) { try { return _fkin(n)->kineticsSpeciesIndex(f2string(nm, lennm), @@ -1018,7 +1018,7 @@ extern "C" { //-------------------- Functions --------------------------- status_t ctphase_report_(const integer* nth, - char* buf, integer* show_thermo, ftnlen buflen) + char* buf, integer* show_thermo, ftnlen buflen) { try { bool stherm = (*show_thermo != 0); @@ -1065,7 +1065,7 @@ extern "C" { 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 { XML_Node* root = 0; diff --git a/src/kinetics/InterfaceKinetics.cpp b/src/kinetics/InterfaceKinetics.cpp index d1e737a44..1cb318b8e 100644 --- a/src/kinetics/InterfaceKinetics.cpp +++ b/src/kinetics/InterfaceKinetics.cpp @@ -1115,10 +1115,10 @@ void InterfaceKinetics::addElementaryReaction(ReactionData& r) */ int reactionRateCoeffType_orig = r.rateCoeffType; 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) { - 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 diff --git a/src/kinetics/importKinetics.cpp b/src/kinetics/importKinetics.cpp index ed877ab3d..e759ea434 100644 --- a/src/kinetics/importKinetics.cpp +++ b/src/kinetics/importKinetics.cpp @@ -489,8 +489,8 @@ static void getEfficiencies(const XML_Node& eff, Kinetics& kin, rdata.thirdBodyEfficiencies[k] = fpValue(val[n]); // bb->second; } else if (!rules.skipUndeclaredThirdBodies) { throw CanteraError("getEfficiencies", "Encountered third-body " - "efficiency for undefined species \"" + nm + "\"\n" - "while adding reaction " + int2str(rdata.number+1) + "."); + "efficiency for undefined species \"" + nm + "\"\n" + "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); double p = getFloat(node, "P", "toSI"); vector_fp& rate = rdata.plogParameters.insert( - std::make_pair(p, vector_fp()))->second; + std::make_pair(p, vector_fp()))->second; rate.resize(3); rate[0] = getFloat(node, "A", "toSI"); rate[1] = getFloat(node, "b"); @@ -853,8 +853,8 @@ bool rxninfo::installReaction(int iRxn, const XML_Node& r, Kinetics& kin, rdata.number = iRxn; rdata.rxn_number = iRxn; - // Read the rate coefficient data from the XML file. Trigger an - // exception for negative A unless specifically authorized. + // Read the rate coefficient data from the XML file. Trigger an + // exception for negative A unless specifically authorized. getRateCoefficient(r.child("rateCoeff"), kin, rdata, rules); // Check to see that the elements balance in the reaction. diff --git a/src/matlab/phasemethods.cpp b/src/matlab/phasemethods.cpp index e88891c55..2a369eff1 100644 --- a/src/matlab/phasemethods.cpp +++ b/src/matlab/phasemethods.cpp @@ -86,8 +86,9 @@ void phasemethods(int nlhs, mxArray* plhs[], buflen = (mwSize)(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; input_buf = (char*)mxCalloc(buflen, sizeof(char)); status = mxGetString(prhs[3], input_buf, buflen); - if (status != 0) + if (status != 0) { mexWarnMsgTxt("Not enough space. " "String is truncated."); + } switch (mjob) { case 30: diff --git a/src/numerics/DAE_solvers.cpp b/src/numerics/DAE_solvers.cpp index a027dfc9e..9432d87d7 100644 --- a/src/numerics/DAE_solvers.cpp +++ b/src/numerics/DAE_solvers.cpp @@ -18,22 +18,23 @@ #define DAE_DEVEL #ifdef DAE_DEVEL -namespace Cantera { - DAE_Solver* newDAE_Solver(std::string itype, ResidJacEval& f) { - if (itype == "IDA") { +namespace Cantera +{ +DAE_Solver* newDAE_Solver(std::string itype, ResidJacEval& f) +{ + if (itype == "IDA") { #ifdef HAS_SUNDIALS - return new IDA_Solver(f); + return new IDA_Solver(f); #else - throw CanteraError("newDAE_Solver","IDA solver requires sundials" - " package, but Cantera was not built with sundials."); + throw CanteraError("newDAE_Solver","IDA solver requires sundials" + " package, but Cantera was not built with sundials."); #endif - } - else { - throw CanteraError("newDAE_Solver", - "unknown DAE solver: "+itype); - } + } else { + throw CanteraError("newDAE_Solver", + "unknown DAE solver: "+itype); } } +} # #endif diff --git a/src/numerics/NonlinearSolver.cpp b/src/numerics/NonlinearSolver.cpp index e858f226a..6060cac98 100644 --- a/src/numerics/NonlinearSolver.cpp +++ b/src/numerics/NonlinearSolver.cpp @@ -3738,8 +3738,8 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, if (s_print_NumJac) { if (m_print_flag >= 7) { if (retn != 1) { - printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); - printf("\t\t We will bail after calculating the Jacobian\n"); + printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); + printf("\t\t We will bail after calculating the Jacobian\n"); } if (neq_ < 20) { 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 (m_print_flag >= 7) { if (retn != 1) { - printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); - printf("\t\t We will bail after calculating the Jacobian\n"); + printf("\t\tbeuler_jac ERROR: calcDeltaSolnVariables() returned an error condition.\n"); + printf("\t\t We will bail after calculating the Jacobian\n"); } if (neq_ < 20) { 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, - DATA_PTR(m_wksp), JacDelta_ResidEval, - static_cast(j), dy); + DATA_PTR(m_wksp), JacDelta_ResidEval, + static_cast(j), dy); m_nfe++; if (info != 1) { mdp::mdp_safe_free((void**) &dyVector); @@ -3875,7 +3875,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, doublereal diff; - int ileft = (int) j - (int) ku; + int ileft = (int) j - (int) ku; int iright = static_cast(j + kl); for (int i = ileft; i <= iright; i++) { if (i >= 0 && i < (int) neq_) { @@ -3885,14 +3885,14 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, col_j[index] = diff / dy; } } -/* - for (size_t i = j - ku; i <= j + kl; i++) { - if (i < neq_) { - diff = subtractRD(m_wksp[i], f[i]); - col_j[kl + ku + i - j] = diff / dy; - } - } -*/ + /* + for (size_t i = j - ku; i <= j + kl; i++) { + if (i < neq_) { + diff = subtractRD(m_wksp[i], f[i]); + col_j[kl + ku + i - j] = diff / dy; + } + } + */ y[j] = ysave; if (solnType_ != NSOLN_TYPE_STEADY_STATE) { ydot[j] = ydotsave; diff --git a/src/oneD/MultiNewton.cpp b/src/oneD/MultiNewton.cpp index b40ce8185..73cabb8e9 100644 --- a/src/oneD/MultiNewton.cpp +++ b/src/oneD/MultiNewton.cpp @@ -176,8 +176,8 @@ doublereal MultiNewton::boundStep(const doublereal* x0, doublereal fbound = 1.0; for (size_t i = 0; i < r.nDomains(); i++) { fbound = std::min(fbound, - bound_step(x0 + r.start(i), step0 + r.start(i), - r.domain(i), loglevel)); + bound_step(x0 + r.start(i), step0 + r.start(i), + r.domain(i), loglevel)); } return fbound; } diff --git a/src/oneD/Sim1D.cpp b/src/oneD/Sim1D.cpp index 61904f31d..34a0b3f44 100644 --- a/src/oneD/Sim1D.cpp +++ b/src/oneD/Sim1D.cpp @@ -260,7 +260,7 @@ int Sim1D::newtonSolve(int loglevel) return -1; } else { throw CanteraError("Sim1D::newtonSolve", - "ERROR: OneDim::solve returned m = " + int2str(m) + "\n"); + "ERROR: OneDim::solve returned m = " + int2str(m) + "\n"); } } diff --git a/src/thermo/GeneralSpeciesThermo.cpp b/src/thermo/GeneralSpeciesThermo.cpp index 4895dcd5c..7757acfdf 100644 --- a/src/thermo/GeneralSpeciesThermo.cpp +++ b/src/thermo/GeneralSpeciesThermo.cpp @@ -22,110 +22,109 @@ namespace Cantera { - /* - * Constructors - */ - GeneralSpeciesThermo::GeneralSpeciesThermo() : +/* + * Constructors + */ +GeneralSpeciesThermo::GeneralSpeciesThermo() : SpeciesThermo(), m_tlow_max(0.0), m_thigh_min(1.0E30), m_p0(OneAtm), m_kk(0) - { +{ m_tlow_max = 0.0; m_thigh_min = 1.0E30; - } +} - GeneralSpeciesThermo:: - GeneralSpeciesThermo(const GeneralSpeciesThermo& b) : +GeneralSpeciesThermo:: +GeneralSpeciesThermo(const GeneralSpeciesThermo& b) : m_tlow_max(b.m_tlow_max), m_thigh_min(b.m_thigh_min), m_kk(b.m_kk) - { +{ m_sp.resize(m_kk, 0); for (size_t k = 0; k < m_kk; k++) { - SpeciesThermoInterpType* bk = b.m_sp[k]; - if (bk) { - m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); - } + SpeciesThermoInterpType* bk = b.m_sp[k]; + if (bk) { + m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); + } } - } +} - GeneralSpeciesThermo& - GeneralSpeciesThermo::operator=(const GeneralSpeciesThermo& b) - { +GeneralSpeciesThermo& +GeneralSpeciesThermo::operator=(const GeneralSpeciesThermo& b) +{ if (&b != this) { - m_tlow_max = b.m_tlow_max; - m_thigh_min = b.m_thigh_min; + m_tlow_max = b.m_tlow_max; + m_thigh_min = b.m_thigh_min; - for (size_t k = 0; k < m_kk; k++) { - SpeciesThermoInterpType* sp = m_sp[k]; - if (sp) { - delete sp; - m_sp[k] = 0; - } - } - m_kk = b.m_kk; - m_sp.resize(m_kk, 0); - for (size_t k = 0; k < m_kk; k++) { - SpeciesThermoInterpType* bk = b.m_sp[k]; - if (bk) { - m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); - } - } + for (size_t k = 0; k < m_kk; k++) { + SpeciesThermoInterpType* sp = m_sp[k]; + if (sp) { + delete sp; + m_sp[k] = 0; + } + } + m_kk = b.m_kk; + m_sp.resize(m_kk, 0); + for (size_t k = 0; k < m_kk; k++) { + SpeciesThermoInterpType* bk = b.m_sp[k]; + if (bk) { + m_sp[k] = bk->duplMyselfAsSpeciesThermoInterpType(); + } + } } return *this; - } +} - GeneralSpeciesThermo::~GeneralSpeciesThermo() - { +GeneralSpeciesThermo::~GeneralSpeciesThermo() +{ for (size_t k = 0; k < m_kk; k++) { - SpeciesThermoInterpType* sp = m_sp[k]; - if (sp) { - delete sp; - m_sp[k] = 0; - } + SpeciesThermoInterpType* sp = m_sp[k]; + if (sp) { + delete sp; + m_sp[k] = 0; + } } - } +} - SpeciesThermo* - GeneralSpeciesThermo::duplMyselfAsSpeciesThermo() const - { +SpeciesThermo* +GeneralSpeciesThermo::duplMyselfAsSpeciesThermo() const +{ GeneralSpeciesThermo* gsth = new GeneralSpeciesThermo(*this); return (SpeciesThermo*) gsth; - } +} - /* - * Install parameterization for a species. - * @param index Species index - * @param type parameterization type - * @param c coefficients. The meaning of these depends on - * the parameterization. - */ - void GeneralSpeciesThermo::install(std::string name, - size_t index, - int type, - const doublereal* c, - doublereal minTemp, - doublereal maxTemp, - doublereal refPressure) - { +/* + * Install parameterization for a species. + * @param index Species index + * @param type parameterization type + * @param c coefficients. The meaning of these depends on + * the parameterization. + */ +void GeneralSpeciesThermo::install(std::string name, + size_t index, + int type, + const doublereal* c, + doublereal minTemp, + doublereal maxTemp, + doublereal refPressure) +{ /* * Resize the arrays if necessary, filling the empty * slots with the zero pointer. */ - - if(minTemp <= 0.0) - { - throw CanteraError("Error in GeneralSpeciesThermo.cpp", - " Cannot take 0 tmin as input. \n\n"); - } - + + if (minTemp <= 0.0) { + throw CanteraError("Error in GeneralSpeciesThermo.cpp", + " Cannot take 0 tmin as input. \n\n"); + } + if (index >= m_kk) { - m_sp.resize(index+1, 0); - m_kk = index+1; + m_sp.resize(index+1, 0); + m_kk = index+1; } //int nfreq = 3; @@ -135,74 +134,74 @@ namespace Cantera switch (type) { case NASA1: - m_sp[index] = new NasaPoly1(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new NasaPoly1(index, minTemp, maxTemp, + refPressure, c); + break; case SHOMATE1: - m_sp[index] = new ShomatePoly(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new ShomatePoly(index, minTemp, maxTemp, + refPressure, c); + break; case CONSTANT_CP: case SIMPLE: - m_sp[index] = new ConstCpPoly(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new ConstCpPoly(index, minTemp, maxTemp, + refPressure, c); + break; case MU0_INTERP: - m_sp[index] = new Mu0Poly(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new Mu0Poly(index, minTemp, maxTemp, + refPressure, c); + break; case SHOMATE2: - m_sp[index] = new ShomatePoly2(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new ShomatePoly2(index, minTemp, maxTemp, + refPressure, c); + break; case NASA2: - m_sp[index] = new NasaPoly2(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new NasaPoly2(index, minTemp, maxTemp, + refPressure, c); + break; case STAT: - m_sp[index] = new StatMech(index, minTemp, maxTemp, - refPressure, c, name); - break; + m_sp[index] = new StatMech(index, minTemp, maxTemp, + refPressure, c, name); + break; case ADSORBATE: - m_sp[index] = new Adsorbate(index, minTemp, maxTemp, - refPressure, c); - break; + m_sp[index] = new Adsorbate(index, minTemp, maxTemp, + refPressure, c); + break; default: - throw UnknownSpeciesThermoModel( - "GeneralSpeciesThermo::install", - "unknown species type", int2str(type)); - break; + throw UnknownSpeciesThermoModel( + "GeneralSpeciesThermo::install", + "unknown species type", int2str(type)); + break; } if (!m_sp[index]) { - cout << "Null m_sp... index = " << index << endl; - cout << "type = " << type << endl; + cout << "Null m_sp... index = " << index << endl; + cout << "type = " << type << endl; } m_tlow_max = max(minTemp, m_tlow_max); m_thigh_min = min(maxTemp, m_thigh_min); - } +} - // Install a new species thermodynamic property - // parameterization for one species. - /* - * @param stit_ptr Pointer to the SpeciesThermoInterpType object - * This will set up the thermo for one species - */ - void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr) - { +// Install a new species thermodynamic property +// parameterization for one species. +/* + * @param stit_ptr Pointer to the SpeciesThermoInterpType object + * This will set up the thermo for one species + */ +void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr) +{ /* * Resize the arrays if necessary, filling the empty * slots with the zero pointer. */ if (!stit_ptr) { - throw CanteraError("GeneralSpeciesThermo::install_STIT", - "zero pointer"); + throw CanteraError("GeneralSpeciesThermo::install_STIT", + "zero pointer"); } size_t index = stit_ptr->speciesIndex(); if (index >= m_kk) { - m_sp.resize(index+1, 0); - m_kk = index+1; + m_sp.resize(index+1, 0); + m_kk = index+1; } AssertThrow(m_sp[index] == 0, "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_thigh_min = min(maxTemp, m_thigh_min); - } +} - void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, - VPSSMgr* vpssmgr_ptr) - { +void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, + VPSSMgr* vpssmgr_ptr) +{ STITbyPDSS* stit_ptr = new STITbyPDSS(k, vpssmgr_ptr, PDSS_ptr); install_STIT(stit_ptr); - } +} - /** - * Update the properties for one species. - */ - void GeneralSpeciesThermo:: - update_one(size_t k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const - { +/** + * Update the properties for one species. + */ +void GeneralSpeciesThermo:: +update_one(size_t k, doublereal t, doublereal* cp_R, + doublereal* h_RT, doublereal* s_R) const +{ SpeciesThermoInterpType* sp_ptr = m_sp[k]; 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. - */ - void GeneralSpeciesThermo:: - update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const - { +/** + * Update the properties for all species. + */ +void GeneralSpeciesThermo:: +update(doublereal t, doublereal* cp_R, + doublereal* h_RT, doublereal* s_R) const +{ vector::const_iterator _begin, _end; _begin = m_sp.begin(); _end = m_sp.end(); SpeciesThermoInterpType* sp_ptr = 0; for (; _begin != _end; ++_begin) { - sp_ptr = *(_begin); - if (sp_ptr) { - sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R); - } - // else { - // writelog("General::update: sp_ptr is NULL!\n"); - //} + sp_ptr = *(_begin); + if (sp_ptr) { + sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R); + } + // else { + // writelog("General::update: sp_ptr is NULL!\n"); + //} } - } +} - /** - * This utility function reports the type of parameterization - * used for the species, index. - */ - int GeneralSpeciesThermo::reportType(size_t index) const - { +/** + * This utility function reports the type of parameterization + * used for the species, index. + */ +int GeneralSpeciesThermo::reportType(size_t index) const +{ SpeciesThermoInterpType* sp = m_sp[index]; if (sp) { - return sp->reportType(); + return sp->reportType(); } return -1; - } +} - /** - * This utility function reports back the type of - * parameterization and all of the parameters for the - * species, index. - * For the NASA object, there are 15 coefficients. - */ - void GeneralSpeciesThermo:: - reportParams(size_t index, int& type, doublereal* const c, - doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure) const - { +/** + * This utility function reports back the type of + * parameterization and all of the parameters for the + * species, index. + * For the NASA object, there are 15 coefficients. + */ +void GeneralSpeciesThermo:: +reportParams(size_t index, int& type, doublereal* const c, + doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure) const +{ SpeciesThermoInterpType* sp = m_sp[index]; size_t n; if (sp) { - sp->reportParameters(n, type, minTemp, maxTemp, - refPressure, c); - if (n != index) { - throw CanteraError("GeneralSpeciesThermo::reportParams", - "Internal error encountered"); - } + sp->reportParameters(n, type, minTemp, maxTemp, + refPressure, c); + if (n != index) { + throw CanteraError("GeneralSpeciesThermo::reportParams", + "Internal error encountered"); + } } else { - type = -1; + type = -1; } - } +} - // //! Modify parameters for the standard state - // /*! - // * @param index Species index - // * @param c Vector of coefficients used to set the - // * parameters for the standard state. - // */ - // void GeneralSpeciesThermo:: - // modifyParams(size_t index, doublereal* c) - // { - // SpeciesThermoInterpType* sp = m_sp[index]; - // if (sp) { - // sp->modifyParameters(c); - // } - // } +// //! Modify parameters for the standard state +// /*! +// * @param index Species index +// * @param c Vector of coefficients used to set the +// * parameters for the standard state. +// */ +// void GeneralSpeciesThermo:: +// modifyParams(size_t index, doublereal* c) +// { +// SpeciesThermoInterpType* sp = m_sp[index]; +// if (sp) { +// sp->modifyParameters(c); +// } +// } - /** - * Return the lowest temperature at which the thermodynamic - * parameterization is valid. If no argument is supplied, the - * value is the one for which all species parameterizations - * are valid. Otherwise, if an integer argument is given, the - * value applies only to the species with that index. - */ - doublereal GeneralSpeciesThermo::minTemp(size_t k) const - { +/** + * Return the lowest temperature at which the thermodynamic + * parameterization is valid. If no argument is supplied, the + * value is the one for which all species parameterizations + * are valid. Otherwise, if an integer argument is given, the + * value applies only to the species with that index. + */ +doublereal GeneralSpeciesThermo::minTemp(size_t k) const +{ if (k == npos) { - return m_tlow_max; + return m_tlow_max; } else { - SpeciesThermoInterpType* sp = m_sp[k]; - if (sp) { - return sp->minTemp(); - } + SpeciesThermoInterpType* sp = m_sp[k]; + if (sp) { + return sp->minTemp(); + } } return m_tlow_max; - } +} - doublereal GeneralSpeciesThermo::maxTemp(size_t k) const - { +doublereal GeneralSpeciesThermo::maxTemp(size_t k) const +{ if (k == npos) { - return m_thigh_min; + return m_thigh_min; } else { - SpeciesThermoInterpType* sp = m_sp[k]; - if (sp) { - return sp->maxTemp(); - } + SpeciesThermoInterpType* sp = m_sp[k]; + if (sp) { + return sp->maxTemp(); + } } return m_thigh_min; - } +} - doublereal GeneralSpeciesThermo::refPressure(size_t k) const - { +doublereal GeneralSpeciesThermo::refPressure(size_t k) const +{ if (k == npos) { - return m_p0; + return m_p0; } else { - SpeciesThermoInterpType* sp = m_sp[k]; - if (sp) { - return sp->refPressure(); - } + SpeciesThermoInterpType* sp = m_sp[k]; + if (sp) { + return sp->refPressure(); + } } return m_p0; - } +} - SpeciesThermoInterpType* GeneralSpeciesThermo::provideSTIT(size_t k) - { +SpeciesThermoInterpType* GeneralSpeciesThermo::provideSTIT(size_t k) +{ return (m_sp[k]); - } +} #ifdef H298MODIFY_CAPABILITY - doublereal GeneralSpeciesThermo::reportOneHf298(int k) const - { +doublereal GeneralSpeciesThermo::reportOneHf298(int k) const +{ SpeciesThermoInterpType* sp_ptr = m_sp[k]; doublereal h = -1.0; if (sp_ptr) { - h = sp_ptr->reportHf298(0); + h = sp_ptr->reportHf298(0); } 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]; if (sp_ptr) { - sp_ptr->modifyOneHf298(k, Hf298New); + sp_ptr->modifyOneHf298(k, Hf298New); } - } +} #endif diff --git a/src/thermo/IdealGasPhase.cpp b/src/thermo/IdealGasPhase.cpp index 5a8a7fba3..59eaf42fd 100644 --- a/src/thermo/IdealGasPhase.cpp +++ b/src/thermo/IdealGasPhase.cpp @@ -155,15 +155,15 @@ doublereal IdealGasPhase::cv_mole() const return cp_mole() - GasConstant; } - /** - * @returns species translational/rotational specific heat at - * constant volume. - * - * Either: $5/2 R_s$ or $3/2 R_s$ for molecules/atoms. - * - */ - doublereal IdealGasPhase::cv_tr (doublereal atomicity) const - { +/** + * @returns species translational/rotational specific heat at + * constant volume. + * + * Either: $5/2 R_s$ or $3/2 R_s$ for molecules/atoms. + * + */ +doublereal IdealGasPhase::cv_tr(doublereal atomicity) const +{ // k is the species number int dum = 0; int type = 0; @@ -173,54 +173,57 @@ doublereal IdealGasPhase::cv_mole() const doublereal refPressure; m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure); - - if(type != 111) - { - throw CanteraError("Error in IdealGasPhase.cpp", - "cv_tr only supported for StatMech!. \n\n"); - - } - + + if (type != 111) { + throw CanteraError("Error in IdealGasPhase.cpp", + "cv_tr only supported for StatMech!. \n\n"); + + } + // see reportParameters for specific details 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. - * - */ - doublereal IdealGasPhase::cv_rot (double atom) const - { return std::max(cv_tr(atom) - cv_trans(), 0.); } - - /** - * @returns species vibrational specific heat at - * constant volume. - * - * C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T} - * - * The species vibration energy ($e^{vib}_{v,s}$) is: - * - * 0: atom - * - * Diatomic: - * \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 - { +/** + * @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. + * + */ +doublereal IdealGasPhase::cv_rot(double atom) const +{ + return std::max(cv_tr(atom) - cv_trans(), 0.); +} + +/** + * @returns species vibrational specific heat at + * constant volume. + * + * C^{vib}_{v,s} = \frac{\partial e^{vib}_{v,s} }{\partial T} + * + * The species vibration energy ($e^{vib}_{v,s}$) is: + * + * 0: atom + * + * Diatomic: + * \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 int dum = 0; @@ -234,18 +237,17 @@ doublereal IdealGasPhase::cv_mole() const m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure); - // basic sanity check - if(type != 111) - { - throw CanteraError("Error in IdealGasPhase.cpp", - "cv_vib only supported for StatMech!. \n\n"); + // basic sanity check + if (type != 111) { + throw CanteraError("Error in IdealGasPhase.cpp", + "cv_vib only supported for StatMech!. \n\n"); - } + } // see reportParameters for specific details return c[4]; - } +} // Mechanical Equation of State ---------------------------- // Chemical Potentials and Activities ---------------------- diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 62afddad0..484bbdc15 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -721,7 +721,7 @@ void Phase::addUniqueElement(const std::string& symbol, doublereal weight, } else { if (m_atomicWeights[i] != weight) { 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 if (! phase.hasChild("elementArray")) { 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"); vector enames; @@ -865,8 +865,8 @@ void Phase::addSpecies(const std::string& name, const doublereal* comp, if (fabs(charge + ecomp) > 0.001) { if (ecomp != 0.0) { throw CanteraError("Phase::addSpecies", - "Input charge and element E compositions differ " - "for species " + name); + "Input charge and element E compositions differ " + "for species " + name); } else { // Just fix up the element E composition based on the input // species charge diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 40abbd7cb..12ddececa 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -645,52 +645,52 @@ static void installNasa9ThermoFromXML(std::string speciesName, } } -/** +/** * Install a stat mech based property solver * for species k into a SpeciesThermo instance. */ static void installStatMechThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, - const std::vector& tp) -{ - const XML_Node * fptr = tp[0]; - int nRegTmp = tp.size(); - int nRegions = 0; - vector_fp cPoly; - StatMech *np_ptr = 0; - std::vector regionPtrs; - doublereal tmin, tmax, pref = OneAtm; + SpeciesThermo& sp, int k, + const std::vector& tp) +{ + const XML_Node* fptr = tp[0]; + int nRegTmp = tp.size(); + int nRegions = 0; + vector_fp cPoly; + StatMech* np_ptr = 0; + std::vector regionPtrs; + doublereal tmin, tmax, pref = OneAtm; - // Loop over all of the possible temperature regions - for (int i = 0; i < nRegTmp; i++) { - fptr = tp[i]; - if (fptr) { - if (fptr->name() == "StatMech") { - if (fptr->hasChild("floatArray")) { + // Loop over all of the possible temperature regions + for (int i = 0; i < nRegTmp; i++) { + fptr = tp[i]; + if (fptr) { + if (fptr->name() == "StatMech") { + if (fptr->hasChild("floatArray")) { - tmin = fpValue((*fptr)["Tmin"]); - tmax = fpValue((*fptr)["Tmax"]); - if ((*fptr).hasAttrib("P0")) { - pref = fpValue((*fptr)["P0"]); - } - if ((*fptr).hasAttrib("Pref")) { - pref = fpValue((*fptr)["Pref"]); - } + tmin = fpValue((*fptr)["Tmin"]); + tmax = fpValue((*fptr)["Tmax"]); + if ((*fptr).hasAttrib("P0")) { + pref = fpValue((*fptr)["P0"]); + } + if ((*fptr).hasAttrib("Pref")) { + pref = fpValue((*fptr)["Pref"]); + } - getFloatArray(fptr->child("floatArray"), cPoly, false); - if (cPoly.size() != 0) { - throw CanteraError("installStatMechThermoFromXML", - "Expected no coeff: this is not a polynomial representation"); - } - } - } + getFloatArray(fptr->child("floatArray"), cPoly, false); + if (cPoly.size() != 0) { + throw CanteraError("installStatMechThermoFromXML", + "Expected no coeff: this is not a polynomial representation"); + } + } + } + } } - } - // set properties - tmin = 0.1; - vector_fp coeffs(1); - coeffs[0] = 0.0; - (&sp)->install(speciesName, k, STAT, &coeffs[0], tmin, tmax, pref); + // set properties + tmin = 0.1; + vector_fp coeffs(1); + coeffs[0] = 0.0; + (&sp)->install(speciesName, k, STAT, &coeffs[0], tmin, tmax, pref); } //! 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") { installMu0ThermoFromXML(speciesNode["name"], spthermo, k, f); } else if (f->name() == "NASA9") { - installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); - } - else if (f->name() == "StatMech") { - installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); - } - else if (f->name() == "adsorbate") { + installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); + } else if (f->name() == "StatMech") { + installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); + } else if (f->name() == "adsorbate") { installAdsorbateThermoFromXML(speciesNode["name"], spthermo, k, *f); - } - else { + } else { throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], f->name()); } @@ -813,11 +810,9 @@ void SpeciesThermoFactory::installThermoForSpecies installNasaThermoFromXML(speciesNode["name"], spthermo, k, f0, f1); } else if (f0->name() == "Shomate" && f1->name() == "Shomate") { installShomateThermoFromXML(speciesNode["name"], spthermo, k, f0, f1); - } - else if (f0->name() == "StatMech") { - installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); - } - else if (f0->name() == "NASA9" && f1->name() == "NASA9") { + } else if (f0->name() == "StatMech") { + installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); + } else if (f0->name() == "NASA9" && f1->name() == "NASA9") { installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); } else { throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], @@ -827,17 +822,15 @@ void SpeciesThermoFactory::installThermoForSpecies const XML_Node* f0 = tp[0]; if (f0->name() == "NASA9") { installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp); - } - else if (f0->name() == "StatMech") { - installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); - } - else { - throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], - "multiple"); + } else if (f0->name() == "StatMech") { + installStatMechThermoFromXML(speciesNode["name"], spthermo, k, tp); + } else { + throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], + "multiple"); } } else { - throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], - "multiple"); + throw UnknownSpeciesThermoModel("installThermoForSpecies", speciesNode["name"], + "multiple"); } } } diff --git a/src/thermo/StatMech.cpp b/src/thermo/StatMech.cpp index f680df1ce..d990bee14 100644 --- a/src/thermo/StatMech.cpp +++ b/src/thermo/StatMech.cpp @@ -1,208 +1,212 @@ /** * @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 #include "cantera/thermo/StatMech.h" #include #include -namespace Cantera +namespace Cantera { - // Statistical mechanics - /* - * @ingroup spthermo - */ - - //! Empty constructor - StatMech::StatMech() - : m_lowT(0.1), m_highT (1.0), - m_Pref(1.0E5), m_index (0) {} +// Statistical mechanics +/* + * @ingroup spthermo + */ + +//! Empty constructor +StatMech::StatMech() + : m_lowT(0.1), m_highT(1.0), + m_Pref(1.0E5), m_index(0) {} - // constructor used in templated instantiations - /* - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state. - */ - StatMech::StatMech(int n, doublereal tlow, doublereal thigh, - doublereal pref, - const doublereal* coeffs, - std::string my_name) : - m_lowT (tlow), - m_highT (thigh), - m_Pref (pref), - m_index (n), - sp_name (my_name) - { +// constructor used in templated instantiations +/* + * @param n Species index + * @param tlow Minimum temperature + * @param thigh Maximum temperature + * @param pref reference pressure (Pa). + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. + */ +StatMech::StatMech(int n, doublereal tlow, doublereal thigh, + doublereal pref, + const doublereal* coeffs, + std::string my_name) : + m_lowT(tlow), + m_highT(thigh), + m_Pref(pref), + m_index(n), + sp_name(my_name) +{ // should error on zero -- cannot take ln(0) - if(m_lowT <= 0.0){ - throw CanteraError("Error in StatMech.cpp", - " Cannot take 0 tmin as input. \n\n"); - } + if (m_lowT <= 0.0) { + throw CanteraError("Error in StatMech.cpp", + " Cannot take 0 tmin as input. \n\n"); + } buildmap(); - } +} - // copy constructor - /* - * @param b object to be copied - */ - StatMech::StatMech(const StatMech& b) : - m_lowT (b.m_lowT), - m_highT (b.m_highT), - m_Pref (b.m_Pref), - m_index (b.m_index) - { +// copy constructor +/* + * @param b object to be copied + */ +StatMech::StatMech(const StatMech& b) : + m_lowT(b.m_lowT), + m_highT(b.m_highT), + m_Pref(b.m_Pref), + m_index(b.m_index) +{ - } +} - // assignment operator - /* - * @param b object to be copied - */ - StatMech& StatMech::operator=(const StatMech& b) { +// assignment operator +/* + * @param b object to be copied + */ +StatMech& StatMech::operator=(const StatMech& b) +{ if (&b != this) { - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + m_lowT = b.m_lowT; + m_highT = b.m_highT; + m_Pref = b.m_Pref; + m_index = b.m_index; } return *this; - } +} - // Destructor - StatMech::~StatMech() { - } +// Destructor +StatMech::~StatMech() +{ +} - // duplicator - SpeciesThermoInterpType * - StatMech::duplMyselfAsSpeciesThermoInterpType() const { +// duplicator +SpeciesThermoInterpType* +StatMech::duplMyselfAsSpeciesThermoInterpType() const +{ StatMech* np = new StatMech(*this); - return (SpeciesThermoInterpType *) np; - } + return (SpeciesThermoInterpType*) np; +} - // Returns the minimum temperature that the thermo - // parameterization is valid - doublereal StatMech::minTemp() const - { - return m_lowT; - } +// Returns the minimum temperature that the thermo +// parameterization is valid +doublereal StatMech::minTemp() const +{ + return m_lowT; +} - // Returns the maximum temperature that the thermo - // parameterization is valid - doublereal StatMech::maxTemp() const { +// Returns the maximum temperature that the thermo +// parameterization is valid +doublereal StatMech::maxTemp() const +{ return m_highT; - } +} - // Returns the reference pressure (Pa) - doublereal StatMech::refPressure() const { return m_Pref; } +// Returns the reference pressure (Pa) +doublereal StatMech::refPressure() const +{ + return m_Pref; +} - // Returns an integer representing the type of parameterization - int StatMech::reportType() const { +// Returns an integer representing the type of parameterization +int StatMech::reportType() const +{ 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 std::vector SS; - + // now just iterate over name map to place each // string in a key SS.push_back("Air"); SS.push_back("CPAir"); - SS.push_back("Ar" ); - SS.push_back("Ar+" ); - SS.push_back("C" ); - SS.push_back("C+" ); - SS.push_back("C2" ); - SS.push_back("C2H" ); - SS.push_back("C2H2" ); - SS.push_back("C3" ); - SS.push_back("CF" ); - SS.push_back("CF2" ); - SS.push_back("CF3" ); - SS.push_back("CF4" ); - SS.push_back("CH" ); - SS.push_back("CH2" ); - SS.push_back("CH3" ); - SS.push_back("CH4" ); - SS.push_back("Cl" ); - SS.push_back("Cl2" ); - SS.push_back("CN" ); - SS.push_back("CN+" ); - SS.push_back("CO" ); - SS.push_back("CO+" ); - SS.push_back("CO2" ); - SS.push_back("F" ); - SS.push_back("F2" ); - SS.push_back("H" ); - SS.push_back("H+" ); - SS.push_back("H2" ); - SS.push_back("H2+" ); - SS.push_back("H2O" ); - SS.push_back("HCl" ); - SS.push_back("HCN" ); - SS.push_back("He" ); - SS.push_back("He+" ); - SS.push_back("N" ); - SS.push_back("N+" ); - SS.push_back("N2" ); - SS.push_back("CPN2" ); - SS.push_back("N2+" ); - SS.push_back("Ne" ); - SS.push_back("NCO" ); - SS.push_back("NH" ); - SS.push_back("NH+" ); - SS.push_back("NH2" ); - SS.push_back("NH3" ); - SS.push_back("NO" ); - SS.push_back("NO+" ); - SS.push_back("NO2" ); - SS.push_back("O" ); - SS.push_back("O+" ); - SS.push_back("O2" ); - SS.push_back("O2+" ); - SS.push_back("OH" ); - SS.push_back("Si" ); - SS.push_back("SiO" ); - SS.push_back("e"); + SS.push_back("Ar"); + SS.push_back("Ar+"); + SS.push_back("C"); + SS.push_back("C+"); + SS.push_back("C2"); + SS.push_back("C2H"); + SS.push_back("C2H2"); + SS.push_back("C3"); + SS.push_back("CF"); + SS.push_back("CF2"); + SS.push_back("CF3"); + SS.push_back("CF4"); + SS.push_back("CH"); + SS.push_back("CH2"); + SS.push_back("CH3"); + SS.push_back("CH4"); + SS.push_back("Cl"); + SS.push_back("Cl2"); + SS.push_back("CN"); + SS.push_back("CN+"); + SS.push_back("CO"); + SS.push_back("CO+"); + SS.push_back("CO2"); + SS.push_back("F"); + SS.push_back("F2"); + SS.push_back("H"); + SS.push_back("H+"); + SS.push_back("H2"); + SS.push_back("H2+"); + SS.push_back("H2O"); + SS.push_back("HCl"); + SS.push_back("HCN"); + SS.push_back("He"); + SS.push_back("He+"); + SS.push_back("N"); + SS.push_back("N+"); + SS.push_back("N2"); + SS.push_back("CPN2"); + SS.push_back("N2+"); + SS.push_back("Ne"); + SS.push_back("NCO"); + SS.push_back("NH"); + SS.push_back("NH+"); + SS.push_back("NH2"); + SS.push_back("NH3"); + SS.push_back("NO"); + SS.push_back("NO+"); + SS.push_back("NO2"); + SS.push_back("O"); + SS.push_back("O+"); + SS.push_back("O2"); + SS.push_back("O2+"); + SS.push_back("OH"); + SS.push_back("Si"); + SS.push_back("SiO"); + SS.push_back("e"); // now place each species in a map int ii; - for(ii=0; ii < SS.size(); ii++) - { - name_map[SS[ii]]=(new species); + for (ii=0; ii < SS.size(); ii++) { + name_map[SS[ii]]=(new species); - // init to crazy defaults - name_map[SS[ii]]->nvib = -1; - name_map[SS[ii]]->cfs = -1; - name_map[SS[ii]]->mol_weight = -1; + // init to crazy defaults + name_map[SS[ii]]->nvib = -1; + name_map[SS[ii]]->cfs = -1; + name_map[SS[ii]]->mol_weight = -1; - name_map[SS[ii]]->theta[0] =0.0; - name_map[SS[ii]]->theta[1] =0.0; - name_map[SS[ii]]->theta[2] =0.0; - name_map[SS[ii]]->theta[3] =0.0; - name_map[SS[ii]]->theta[4] =0.0; - } + name_map[SS[ii]]->theta[0] =0.0; + name_map[SS[ii]]->theta[1] =0.0; + name_map[SS[ii]]->theta[2] =0.0; + name_map[SS[ii]]->theta[3] =0.0; + name_map[SS[ii]]->theta[4] =0.0; + } // now set all species information @@ -220,12 +224,12 @@ namespace Cantera name_map["Ar"]->cfs = 1.5; name_map["Ar"]->mol_weight=39.944; name_map["Ar"]->nvib=0; - + // build Ar+ name_map["Ar+"]->cfs = 1.5; name_map["Ar+"]->mol_weight=39.94345; name_map["Ar+"]->nvib=0; - + // build C name_map["C"]->cfs = 1.5; name_map["C"]->mol_weight=12.011; @@ -235,7 +239,7 @@ namespace Cantera name_map["C+"]->cfs = 1.5; name_map["C+"]->mol_weight=12.01045; name_map["C+"]->nvib=0; - + // C2 name_map["C2"]->cfs=2.5; 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[2]=4.54960e+03; name_map["CH3"]->theta[3]=2.01150e+03; - + // CH4 name_map["CH4"]->cfs=3; name_map["CH4"]->mol_weight=16.04300; @@ -570,88 +574,79 @@ namespace Cantera name_map["e"]->nvib=0; int dum = 0; - for(ii=0; ii < SS.size(); ii++) - { - // check nvib was initalized for all species - if(name_map[SS[ii]]->nvib == -1) - { - std::cout << name_map[SS[ii]]->nvib << std::endl; - throw CanteraError("Error in StatMech.cpp", - "nvib not initialized!. \n\n"); + for (ii=0; ii < SS.size(); ii++) { + // check nvib was initalized for all species + if (name_map[SS[ii]]->nvib == -1) { + std::cout << name_map[SS[ii]]->nvib << std::endl; + throw CanteraError("Error in StatMech.cpp", + "nvib not initialized!. \n\n"); - } - else - { - // check that theta is initalized - for(int i=0;invib;i++) - { - if(name_map[SS[ii]]->theta[i] <= 0.0) - { - throw CanteraError("Error in StatMech.cpp", - "theta not initalized!. \n\n"); - } - } + } else { + // check that theta is initalized + for (int i=0; invib; i++) { + 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 - // for any theta larger than nvib! - for(int i=name_map[SS[ii]]->nvib;i<5;i++) - { - if(name_map[SS[ii]]->theta[i] != 0.0) - { - std::string err = "bad theta value for "+SS[ii]+"\n"; - throw CanteraError("StatMech.cpp",err); - } - } // done with for loop - } + // check that no non-zero theta exist + // for any theta larger than nvib! + for (int i=name_map[SS[ii]]->nvib; i<5; i++) { + if (name_map[SS[ii]]->theta[i] != 0.0) { + std::string err = "bad theta value for "+SS[ii]+"\n"; + throw CanteraError("StatMech.cpp",err); + } + } // done with for loop + } - // check mol weight was initialized for all species - if(name_map[SS[ii]]->mol_weight == -1) - { - std::cout << name_map[SS[ii]]->mol_weight << std::endl; - throw CanteraError("Error in StatMech.cpp", - "mol_weight not initialized!. \n\n"); + // check mol weight was initialized for all species + if (name_map[SS[ii]]->mol_weight == -1) { + std::cout << name_map[SS[ii]]->mol_weight << std::endl; + throw CanteraError("Error in StatMech.cpp", + "mol_weight not initialized!. \n\n"); - } + } - // cfs was initialized for all species - if(name_map[SS[ii]]->cfs == -1) - { - std::cout << name_map[SS[ii]]->cfs << std::endl; - throw CanteraError("Error in StatMech.cpp", - "cfs not initialized!. \n\n"); + // cfs was initialized for all species + if (name_map[SS[ii]]->cfs == -1) { + std::cout << name_map[SS[ii]]->cfs << std::endl; + throw CanteraError("Error in StatMech.cpp", + "cfs not initialized!. \n\n"); + + } + + } // done with sanity checks - } - - } // done with sanity checks - // mark it zero, dude return 0; - } +} - // Update the properties for this species - /** - * - * \f[ - * \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1 - * \f] - * - * Where, - * \f[ - * \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R} - * \f] - * - * - * @param tt vector of temperature polynomials - * @param cp_R Vector of Dimensionless heat capacities. - * (length m_kk). - * @param h_RT Vector of Dimensionless enthalpies. - * (length m_kk). - * @param s_R Vector of Dimensionless entropies. - * (length m_kk). - */ - void StatMech::updateProperties(const doublereal* tt, - doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const { +// Update the properties for this species +/** + * + * \f[ + * \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1 + * \f] + * + * Where, + * \f[ + * \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R} + * \f] + * + * + * @param tt vector of temperature polynomials + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ +void StatMech::updateProperties(const doublereal* tt, + doublereal* cp_R, doublereal* h_RT, + doublereal* s_R) const +{ std::map::iterator it; @@ -659,97 +654,94 @@ namespace Cantera species* s; // pointer to map location of particular species - if(name_map.find(sp_name) != name_map.end()) - { - s = name_map.find(sp_name)->second; - } - else - { - //std::cout << sp_name << std::endl; - throw CanteraError("StatMech.cpp", - "species properties not found!. \n\n"); - } + if (name_map.find(sp_name) != name_map.end()) { + s = name_map.find(sp_name)->second; + } else { + //std::cout << sp_name << std::endl; + throw CanteraError("StatMech.cpp", + "species properties not found!. \n\n"); + } // translational + rotational specific heat doublereal ctr = 0.0; double theta = 0.0; - + // 5/2 * R for molecules, 3/2 * R for atoms ctr += GasConstant * s->cfs; // vibrational energy - for(int i=0; i< s->nvib; 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)); - } + for (int i=0; i< s->nvib; 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)); + } // Cp = Cv + R doublereal cpdivR = ctr/GasConstant + 1; - // ACTUNG: fix enthalpy and entropy + // ACTUNG: fix enthalpy and entropy doublereal hdivRT = 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 cp_R[m_index] = cpdivR; h_RT[m_index] = hdivRT; s_R [m_index] = sdivR; - } +} - - // Compute the reference-state property of one species - /* - * Given temperature T in K, this method updates the values of - * the non-dimensional heat capacity at constant pressure, - * enthalpy, and entropy, at the reference pressure, Pref - * of one of the species. The species index is used - * to reference into the cp_R, h_RT, and s_R arrays. - * - * Temperature Polynomial: - * tt[0] = t; - * tt[1] = t*t; - * tt[2] = t*t*t; - * tt[3] = t*t*t*t; - * tt[4] = 1.0/t; - * tt[5] = 1.0/(t*t); - * tt[6] = std::log(t); - * - * @param temp Temperature (Kelvin) - * @param cp_R Vector of Dimensionless heat capacities. - * (length m_kk). - * @param h_RT Vector of Dimensionless enthalpies. - * (length m_kk). - * @param s_R Vector of Dimensionless entropies. - * (length m_kk). - */ - void StatMech::updatePropertiesTemp(const doublereal temp, - doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const { + +// Compute the reference-state property of one species +/* + * Given temperature T in K, this method updates the values of + * the non-dimensional heat capacity at constant pressure, + * enthalpy, and entropy, at the reference pressure, Pref + * of one of the species. The species index is used + * to reference into the cp_R, h_RT, and s_R arrays. + * + * Temperature Polynomial: + * tt[0] = t; + * tt[1] = t*t; + * tt[2] = t*t*t; + * tt[3] = t*t*t*t; + * tt[4] = 1.0/t; + * tt[5] = 1.0/(t*t); + * tt[6] = std::log(t); + * + * @param temp Temperature (Kelvin) + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ +void StatMech::updatePropertiesTemp(const doublereal temp, + doublereal* cp_R, doublereal* h_RT, + doublereal* s_R) const +{ double tPoly[1]; tPoly[0] = temp; updateProperties(tPoly, cp_R, h_RT, s_R); - } +} - //This utility function reports back the type of - // parameterization and all of the parameters for the - // species, index. - /* - * All parameters are output variables - * - * @param n Species index - * @param type Integer type of the standard type - * @param tlow output - Minimum temperature - * @param thigh output - Maximum temperature - * @param pref output - reference pressure (Pa). - * @param coeffs Vector of species state data - */ - void StatMech::reportParameters(size_t &n, int &type, - doublereal &tlow, doublereal &thigh, - doublereal &pref, - doublereal* const coeffs) const - { +//This utility function reports back the type of +// parameterization and all of the parameters for the +// species, index. +/* + * All parameters are output variables + * + * @param n Species index + * @param type Integer type of the standard type + * @param tlow output - Minimum temperature + * @param thigh output - Maximum temperature + * @param pref output - reference pressure (Pa). + * @param coeffs Vector of species state data + */ +void StatMech::reportParameters(size_t& n, int& type, + doublereal& tlow, doublereal& thigh, + doublereal& pref, + doublereal* const coeffs) const +{ species* s; n = m_index; @@ -757,55 +749,50 @@ namespace Cantera tlow = m_lowT; thigh = m_highT; pref = m_Pref; - for (int i = 0; i < 9; i++) - { - coeffs[i] = 0.0; - } + for (int i = 0; i < 9; i++) { + coeffs[i] = 0.0; + } doublereal temp = coeffs[0]; coeffs[1] = m_lowT; coeffs[2] = m_highT; // get species name, to gather species properties // pointer to map location of particular species - if(name_map.find(sp_name) != name_map.end()) - { - s = name_map.find(sp_name)->second; - } - else - { - //std::cout << sp_name << std::endl; - throw CanteraError("StatMech.cpp", - "species properties not found!. \n\n"); - } + if (name_map.find(sp_name) != name_map.end()) { + s = name_map.find(sp_name)->second; + } else { + //std::cout << sp_name << std::endl; + throw CanteraError("StatMech.cpp", + "species properties not found!. \n\n"); + } double theta = 0.0; doublereal cvib = 0; - + // vibrational energy - for(int i=0; i< s->nvib; i++) - { - theta = s->theta[i]; - cvib += GasConstant * theta * (theta* exp(theta/temp)/(temp*temp))/((exp(theta/temp)-1) * (exp(theta/temp)-1)); - } + for (int i=0; i< s->nvib; i++) { + theta = s->theta[i]; + cvib += GasConstant * theta * (theta* exp(theta/temp)/(temp*temp))/((exp(theta/temp)-1) * (exp(theta/temp)-1)); + } // load vibrational energy coeffs[3] = GasConstant * s->cfs; coeffs[4] = cvib; - } +} - // Modify parameters for the standard state - /* - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state. - */ - void StatMech::modifyParameters(doublereal* coeffs) - { +// Modify parameters for the standard state +/* + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. + */ +void StatMech::modifyParameters(doublereal* coeffs) +{ - - - } } - + + +} + diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 8c20d470a..f5bea5aca 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -249,16 +249,13 @@ ThermoPhase* newPhase(XML_Node& xmlphase) ThermoPhase* t = newThermoPhase(model); if (model == "singing cows") { throw CanteraError(" newPhase", "Cows don't sing"); - } - else if (model == "HMW") { + } else if (model == "HMW") { HMWSoln* p = dynamic_cast(t); p->constructPhaseXML(xmlphase,""); - } - else if (model == "IonsFromNeutralMolecule") { + } else if (model == "IonsFromNeutralMolecule") { IonsFromNeutralVPSSTP* p = dynamic_cast(t); p->constructPhaseXML(xmlphase,""); - } - else { + } else { importPhase(xmlphase, t); } return t; diff --git a/src/thermo/WaterProps.cpp b/src/thermo/WaterProps.cpp index b1e5f39db..207147b2c 100644 --- a/src/thermo/WaterProps.cpp +++ b/src/thermo/WaterProps.cpp @@ -294,7 +294,7 @@ doublereal WaterProps::ADebye(doublereal T, doublereal P_input, int ifunc) doublereal dw = density_IAPWS(T, P); doublereal tmp = sqrt(2.0 * Avogadro * dw / 1000.); doublereal tmp2 = ElectronCharge * ElectronCharge * Avogadro / - (epsilon * GasConstant * T); + (epsilon * GasConstant * T); doublereal tmp3 = tmp2 * sqrt(tmp2); doublereal A_Debye = tmp * tmp3 / (8.0 * Pi); diff --git a/src/tpx/Sub.cpp b/src/tpx/Sub.cpp index 8efca3288..4772d7625 100644 --- a/src/tpx/Sub.cpp +++ b/src/tpx/Sub.cpp @@ -687,7 +687,7 @@ void Substance::set_TPp(double Temp, double Pressure) // loop 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) { BracketSlope(Pressure); } else { diff --git a/src/transport/GasTransport.cpp b/src/transport/GasTransport.cpp index 213abf900..cf556486a 100644 --- a/src/transport/GasTransport.cpp +++ b/src/transport/GasTransport.cpp @@ -1,7 +1,8 @@ #include "cantera/transport/GasTransport.h" #include "cantera/transport/TransportParams.h" -namespace Cantera { +namespace Cantera +{ GasTransport::GasTransport(ThermoPhase* thermo) : Transport(thermo), @@ -135,7 +136,8 @@ bool GasTransport::initGas(GasTransportParams& tr) return true; } -void GasTransport::update_T(void) { +void GasTransport::update_T(void) +{ double T = m_thermo->temperature(); if (T == m_temp) { return; diff --git a/src/transport/PecosTransport.cpp b/src/transport/PecosTransport.cpp index cb844e393..73e397d8b 100755 --- a/src/transport/PecosTransport.cpp +++ b/src/transport/PecosTransport.cpp @@ -1,12 +1,7 @@ /** * @file PecosTransport.cpp * Mixture-averaged transport properties. - * - */ - -/* $Author$ - * $Revision$ - * $Date$ + * */ #include "cantera/thermo/ThermoPhase.h" @@ -22,28 +17,30 @@ #include using namespace std; -/** +/** * Mole fractions below MIN_X will be set to MIN_X when computing * transport properties. */ #define MIN_X 1.e-20 -namespace Cantera { +namespace Cantera +{ - //////////////////// class PecosTransport methods ////////////// +//////////////////// class PecosTransport methods ////////////// - PecosTransport::PecosTransport() : +PecosTransport::PecosTransport() : m_nsp(0), m_tmin(-1.0), m_tmax(100000.), m_temp(-1.0), m_logt(0.0) - { +{ - } +} - bool PecosTransport::initGas( GasTransportParams& tr ) { +bool PecosTransport::initGas(GasTransportParams& tr) +{ // constant substance attributes m_thermo = tr.thermo; @@ -53,8 +50,8 @@ namespace Cantera { // make a local copy of the molecular weights m_mw.resize(m_nsp); - copy(m_thermo->molecularWeights().begin(), - m_thermo->molecularWeights().end(), m_mw.begin()); + copy(m_thermo->molecularWeights().begin(), + m_thermo->molecularWeights().end(), m_mw.begin()); // copy polynomials and parameters into local storage m_poly = tr.poly; @@ -71,20 +68,20 @@ namespace Cantera { m_alpha = tr.alpha; m_dipoleDiag.resize(m_nsp); for (int i = 0; i < m_nsp; i++) { - m_dipoleDiag[i] = tr.dipole(i,i); + m_dipoleDiag[i] = tr.dipole(i,i); } m_phi.resize(m_nsp, m_nsp, 0.0); m_wratjk.resize(m_nsp, m_nsp, 0.0); m_wratkj1.resize(m_nsp, m_nsp, 0.0); int j, k; - for (j = 0; j < m_nsp; j++) - for (k = j; k < m_nsp; k++) { - m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]); - m_wratjk(k,j) = sqrt(m_wratjk(j,k)); - m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]); - } - + for (j = 0; j < m_nsp; j++) + for (k = j; k < m_nsp; k++) { + m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]); + m_wratjk(k,j) = sqrt(m_wratjk(j,k)); + m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]); + } + m_polytempvec.resize(5); m_visc.resize(m_nsp); m_sqvisc.resize(m_nsp); @@ -106,116 +103,126 @@ namespace Cantera { // read blottner fit parameters (A,B,C) read_blottner_transport_table(); - + // set specific heats cv_rot.resize(m_nsp); - cp_R.resize(m_nsp); + cp_R.resize(m_nsp); cv_int.resize(m_nsp); for (k = 0; k < m_nsp; k++) { - cv_rot[k] = tr.crot[k]; - cp_R[k] = ((IdealGasPhase*)tr.thermo)->cp_R_ref()[k]; - cv_int[k] = cp_R[k] - 2.5 - cv_rot[k]; + cv_rot[k] = tr.crot[k]; + cp_R[k] = ((IdealGasPhase*)tr.thermo)->cp_R_ref()[k]; + cv_int[k] = cp_R[k] - 2.5 - cv_rot[k]; } return true; - } +} - /********************************************************* - * - * Public methods - * - *********************************************************/ +/********************************************************* + * + * Public methods + * + *********************************************************/ - /****************** viscosity ******************************/ +/****************** viscosity ******************************/ + +/** + * The viscosity is computed using the Wilke mixture rule. + * \f[ + * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}. + * \f] + * Here \f$ \mu_k \f$ is the viscosity of pure species \e k, + * and + * \f[ + * \Phi_{k,j} = \frac{\left[1 + * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2} + * {\sqrt{8}\sqrt{1 + M_k/M_j}} + * \f] + * @see updateViscosity_T(); + */ +doublereal PecosTransport::viscosity() +{ - /** - * The viscosity is computed using the Wilke mixture rule. - * \f[ - * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}. - * \f] - * Here \f$ \mu_k \f$ is the viscosity of pure species \e k, - * and - * \f[ - * \Phi_{k,j} = \frac{\left[1 - * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2} - * {\sqrt{8}\sqrt{1 + M_k/M_j}} - * \f] - * @see updateViscosity_T(); - */ - doublereal PecosTransport::viscosity() { - update_T(); update_C(); - if (m_viscmix_ok) return m_viscmix; + if (m_viscmix_ok) { + return m_viscmix; + } doublereal vismix = 0.0; int k; // update m_visc and m_phi if necessary - if (!m_viscwt_ok) updateViscosity_T(); + if (!m_viscwt_ok) { + updateViscosity_T(); + } multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); for (k = 0; k < m_nsp; k++) { - vismix += m_molefracs[k] * m_visc[k]/m_spwork[k]; //denom; + vismix += m_molefracs[k] * m_visc[k]/m_spwork[k]; //denom; } m_viscmix = vismix; return vismix; - } +} - /******************* binary diffusion coefficients **************/ - /* - * - * Using Ramshaw's self-consistent Effective Binary Diffusion - * (1990, J. Non-Equilib. Thermo) - * Adding more doxygen would be good here - */ +/******************* binary diffusion coefficients **************/ +/* + * + * Using Ramshaw's self-consistent Effective Binary Diffusion + * (1990, J. Non-Equilib. Thermo) + * Adding more doxygen would be good here + */ - void PecosTransport::getBinaryDiffCoeffs(const int ld, doublereal* const d) { +void PecosTransport::getBinaryDiffCoeffs(const int ld, doublereal* const d) +{ int i,j; update_T(); // if necessary, evaluate the binary diffusion coefficents - if (!m_bindiff_ok) updateDiff_T(); + if (!m_bindiff_ok) { + updateDiff_T(); + } doublereal rp = 1.0/pressure_ig(); - for (i = 0; i < m_nsp; i++) - for (j = 0; j < m_nsp; j++) { - d[ld*j + i] = rp * m_bdiff(i,j); - } - } + for (i = 0; i < m_nsp; i++) + for (j = 0; j < m_nsp; j++) { + d[ld*j + i] = rp * m_bdiff(i,j); + } +} - void PecosTransport::getMobilities(doublereal* const mobil) { +void PecosTransport::getMobilities(doublereal* const mobil) +{ int k; getMixDiffCoeffs(DATA_PTR(m_spwork)); doublereal c1 = ElectronCharge / (Boltzmann * m_temp); for (k = 0; k < m_nsp; k++) { - mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k); + mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k); } - } - +} - /****************** thermal conductivity **********************/ - /** - * The thermal conductivity is computed using the Wilke mixture rule. - * \f[ - * \k = \sum_s \frac{k_s X_s}{\sum_j \Phi_{s,j} X_j}. - * \f] - * Here \f$ \k_s \f$ is the conductivity of pure species \e s, - * and - * \f[ - * \Phi_{s,j} = \frac{\left[1 - * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_s}}\right)}\right]^2} - * {\sqrt{8}\sqrt{1 + M_s/M_j}} - * \f] - * @see updateCond_T(); - */ - doublereal PecosTransport::thermalConductivity() { +/****************** thermal conductivity **********************/ + +/** + * The thermal conductivity is computed using the Wilke mixture rule. + * \f[ + * \k = \sum_s \frac{k_s X_s}{\sum_j \Phi_{s,j} X_j}. + * \f] + * Here \f$ \k_s \f$ is the conductivity of pure species \e s, + * and + * \f[ + * \Phi_{s,j} = \frac{\left[1 + * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_s}}\right)}\right]^2} + * {\sqrt{8}\sqrt{1 + M_s/M_j}} + * \f] + * @see updateCond_T(); + */ +doublereal PecosTransport::thermalConductivity() +{ int k; doublereal lambda = 0.0; @@ -223,52 +230,56 @@ namespace Cantera { update_C(); // update m_cond and m_phi if necessary - if (!m_spcond_ok) updateCond_T(); + if (!m_spcond_ok) { + updateCond_T(); + } if (!m_condmix_ok) { - multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); - - for (k = 0; k < m_nsp; k++) { - lambda += m_molefracs[k] * m_cond[k]/m_spwork[k]; //denom; - } + multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); + + for (k = 0; k < m_nsp; k++) { + lambda += m_molefracs[k] * m_cond[k]/m_spwork[k]; //denom; + } } m_lambda = lambda; return m_lambda; - } +} - /****************** thermal diffusion coefficients ************/ +/****************** thermal diffusion coefficients ************/ - /** - * Thermal diffusion is not considered in this pecos - * model. To include thermal diffusion, use transport manager - * MultiTransport instead. This methods fills out array dt with - * zeros. - */ - void PecosTransport::getThermalDiffCoeffs(doublereal* const dt) { +/** + * Thermal diffusion is not considered in this pecos + * model. To include thermal diffusion, use transport manager + * MultiTransport instead. This methods fills out array dt with + * zeros. + */ +void PecosTransport::getThermalDiffCoeffs(doublereal* const dt) +{ int k; for (k = 0; k < m_nsp; k++) { - dt[k] = 0.0; + dt[k] = 0.0; } - } +} - /** - * @param ndim The number of spatial dimensions (1, 2, or 3). - * @param grad_T The temperature gradient (ignored in this model). - * @param ldx Leading dimension of the grad_X array. - * The diffusive mass flux of species \e k is computed from - * \f[ - * \vec{j}_k = -n M_k D_k \nabla X_k + \frac{\rho_k}{\rho} \sum_r n M_r D_r \nabla X_r - * \f] - * - * This is neglective pressure, forced and thermal diffusion. - * - */ - void PecosTransport::getSpeciesFluxes(int ndim, - const doublereal* grad_T, int ldx, const doublereal* grad_X, - int ldf, doublereal* fluxes) { +/** + * @param ndim The number of spatial dimensions (1, 2, or 3). + * @param grad_T The temperature gradient (ignored in this model). + * @param ldx Leading dimension of the grad_X array. + * The diffusive mass flux of species \e k is computed from + * \f[ + * \vec{j}_k = -n M_k D_k \nabla X_k + \frac{\rho_k}{\rho} \sum_r n M_r D_r \nabla X_r + * \f] + * + * This is neglective pressure, forced and thermal diffusion. + * + */ +void PecosTransport::getSpeciesFluxes(int ndim, + const doublereal* grad_T, int ldx, const doublereal* grad_X, + int ldf, doublereal* fluxes) +{ int n, k; update_T(); @@ -284,140 +295,146 @@ namespace Cantera { doublereal correction=0.0; // grab 2nd (summation) term -- still need to multiply by mass fraction (\rho_s / \rho) - for (k = 0; k < m_nsp; k++) - { - correction += rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k]; - } + for (k = 0; k < m_nsp; k++) { + correction += rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k]; + } for (n = 0; n < ndim; n++) { - for (k = 0; k < m_nsp; k++) { - fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k] + y[k]*correction; - sum[n] += fluxes[n*ldf + k]; - } + for (k = 0; k < m_nsp; k++) { + fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k] + y[k]*correction; + sum[n] += fluxes[n*ldf + k]; + } } // add correction flux to enforce sum to zero for (n = 0; n < ndim; n++) { - for (k = 0; k < m_nsp; k++) { - fluxes[n*ldf + k] -= y[k]*sum[n]; - } + for (k = 0; k < m_nsp; k++) { + fluxes[n*ldf + k] -= y[k]*sum[n]; + } } - } +} - /** - * Mixture-averaged diffusion coefficients [m^2/s]. - * - * For the single species case or the pure fluid case - * the routine returns the self-diffusion coefficient. - * This is need to avoid a Nan result in the formula - * below. - */ - void PecosTransport::getMixDiffCoeffs(doublereal* const d) { +/** + * Mixture-averaged diffusion coefficients [m^2/s]. + * + * For the single species case or the pure fluid case + * the routine returns the self-diffusion coefficient. + * This is need to avoid a Nan result in the formula + * below. + */ +void PecosTransport::getMixDiffCoeffs(doublereal* const d) +{ update_T(); update_C(); // update the binary diffusion coefficients if necessary - if (!m_bindiff_ok) updateDiff_T(); + if (!m_bindiff_ok) { + updateDiff_T(); + } int k, j; doublereal mmw = m_thermo->meanMolecularWeight(); doublereal sumxw = 0.0, sum2; doublereal p = pressure_ig(); if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; + d[0] = m_bdiff(0,0) / p; } else { - for (k = 0; k < m_nsp; k++) sumxw += m_molefracs[k] * m_mw[k]; - for (k = 0; k < m_nsp; k++) { - sum2 = 0.0; - for (j = 0; j < m_nsp; j++) { - if (j != k) { - sum2 += m_molefracs[j] / m_bdiff(j,k); - } - } - if (sum2 <= 0.0) { - d[k] = m_bdiff(k,k) / p; - } else { - d[k] = (sumxw - m_molefracs[k] * m_mw[k])/(p * mmw * sum2); - } - } + for (k = 0; k < m_nsp; k++) { + sumxw += m_molefracs[k] * m_mw[k]; + } + for (k = 0; k < m_nsp; k++) { + sum2 = 0.0; + for (j = 0; j < m_nsp; j++) { + if (j != k) { + sum2 += m_molefracs[j] / m_bdiff(j,k); + } + } + if (sum2 <= 0.0) { + d[k] = m_bdiff(k,k) / p; + } else { + d[k] = (sumxw - m_molefracs[k] * m_mw[k])/(p * mmw * sum2); + } + } } - } +} - void PecosTransport::getMixDiffCoeffsMole(doublereal* const d) - { +void PecosTransport::getMixDiffCoeffsMole(doublereal* const d) +{ update_T(); update_C(); // update the binary diffusion coefficients if necessary if (!m_bindiff_ok) { - updateDiff_T(); + updateDiff_T(); } doublereal p = m_thermo->pressure(); if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; + d[0] = m_bdiff(0,0) / p; } else { - for (size_t k = 0; k < m_nsp; k++) { - double sum2 = 0.0; - for (size_t j = 0; j < m_nsp; j++) { - if (j != k) { - sum2 += m_molefracs[j] / m_bdiff(j,k); - } - } - if (sum2 <= 0.0) { - d[k] = m_bdiff(k,k) / p; - } else { - d[k] = (1 - m_molefracs[k]) / (p * sum2); - } - } + for (size_t k = 0; k < m_nsp; k++) { + double sum2 = 0.0; + for (size_t j = 0; j < m_nsp; j++) { + if (j != k) { + sum2 += m_molefracs[j] / m_bdiff(j,k); + } + } + if (sum2 <= 0.0) { + d[k] = m_bdiff(k,k) / p; + } else { + d[k] = (1 - m_molefracs[k]) / (p * sum2); + } + } } - } +} - void PecosTransport::getMixDiffCoeffsMass(doublereal* const d) - { +void PecosTransport::getMixDiffCoeffsMass(doublereal* const d) +{ update_T(); update_C(); // update the binary diffusion coefficients if necessary if (!m_bindiff_ok) { - updateDiff_T(); + updateDiff_T(); } doublereal mmw = m_thermo->meanMolecularWeight(); doublereal p = m_thermo->pressure(); if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; + d[0] = m_bdiff(0,0) / p; } else { - for (size_t k=0; ktemperature(); - if (t == m_temp) return; + if (t == m_temp) { + return; + } if (t <= 0.0) { - throw CanteraError("PecosTransport::update_T", - "negative temperature "+fp2str(t)); + throw CanteraError("PecosTransport::update_T", + "negative temperature "+fp2str(t)); } m_temp = t; m_logt = log(m_temp); @@ -443,16 +460,16 @@ namespace Cantera { m_diffmix_ok = false; m_bindiff_ok = false; m_abc_ok = false; - m_condmix_ok = false; - } + m_condmix_ok = false; +} - /** - * @internal This is called the first time any transport property - * is requested from Mixture after the concentrations - * have changed. - */ - void PecosTransport::update_C() - { +/** + * @internal This is called the first time any transport property + * is requested from Mixture after the concentrations + * have changed. + */ +void PecosTransport::update_C() +{ // signal that concentration-dependent quantities will need to // be recomputed before use, and update the local mole // fractions. @@ -466,88 +483,90 @@ namespace Cantera { // add an offset to avoid a pure species condition int k; for (k = 0; k < m_nsp; k++) { - m_molefracs[k] = std::max(MIN_X, m_molefracs[k]); + m_molefracs[k] = std::max(MIN_X, m_molefracs[k]); } - } +} - /************************************************************************* - * - * methods to update temperature-dependent properties - * - *************************************************************************/ +/************************************************************************* + * + * methods to update temperature-dependent properties + * + *************************************************************************/ - /** - * - * Update the temperature-dependent parts of the mixture-averaged - * thermal conductivity. - * - * Calculated as, - * \f[ - * k= \mu_s (5/2 * C_{v,s}^{trans} + C_{v,s}^{rot} + C_{v,s}^{vib} - * \f] - * - * - */ - void PecosTransport::updateCond_T() { +/** + * + * Update the temperature-dependent parts of the mixture-averaged + * thermal conductivity. + * + * Calculated as, + * \f[ + * k= \mu_s (5/2 * C_{v,s}^{trans} + C_{v,s}^{rot} + C_{v,s}^{vib} + * \f] + * + * + */ +void PecosTransport::updateCond_T() +{ int k; doublereal fivehalves = 5/2; for (k = 0; k < m_nsp; k++) { - // need to add cv_elec in the future - m_cond[k] = m_visc[k] * ( fivehalves * cv_int[k] + cv_rot[k] + m_thermo->cv_vib(k,m_temp) ); + // need to add cv_elec in the future + m_cond[k] = m_visc[k] * (fivehalves * cv_int[k] + cv_rot[k] + m_thermo->cv_vib(k,m_temp)); } m_spcond_ok = true; m_condmix_ok = false; - } +} - /** - * Update the binary diffusion coefficients. These are evaluated - * from the polynomial fits at unit pressure (1 Pa). - */ - void PecosTransport::updateDiff_T() { +/** + * Update the binary diffusion coefficients. These are evaluated + * from the polynomial fits at unit pressure (1 Pa). + */ +void PecosTransport::updateDiff_T() +{ // evaluate binary diffusion coefficients at unit pressure int i,j; int ic = 0; if (m_mode == CK_Mode) { - for (i = 0; i < m_nsp; i++) { - for (j = i; j < m_nsp; j++) { - m_bdiff(i,j) = exp(dot4(m_polytempvec, m_diffcoeffs[ic])); - m_bdiff(j,i) = m_bdiff(i,j); - ic++; - } - } - } - else { - for (i = 0; i < m_nsp; i++) { - for (j = i; j < m_nsp; j++) { - m_bdiff(i,j) = m_temp * m_sqrt_t*dot5(m_polytempvec, - m_diffcoeffs[ic]); - m_bdiff(j,i) = m_bdiff(i,j); - ic++; - } - } + for (i = 0; i < m_nsp; i++) { + for (j = i; j < m_nsp; j++) { + m_bdiff(i,j) = exp(dot4(m_polytempvec, m_diffcoeffs[ic])); + m_bdiff(j,i) = m_bdiff(i,j); + ic++; + } + } + } else { + for (i = 0; i < m_nsp; i++) { + for (j = i; j < m_nsp; j++) { + m_bdiff(i,j) = m_temp * m_sqrt_t*dot5(m_polytempvec, + m_diffcoeffs[ic]); + m_bdiff(j,i) = m_bdiff(i,j); + ic++; + } + } } m_bindiff_ok = true; m_diffmix_ok = false; - } +} - /** - * - * Update the pure-species viscosities. (Pa-s) = (kg/m/sec) - * - * Using Blottner fit for viscosity. Defines kinematic viscosity - * of the form - * \f[ - * \mu_s\left(T\right) = 0.10 \exp\left(A_s\left(\log T\right)^2 + B_s\log T + C_s\right) - * \f] - * where \f$ A_s \f$, \f$ B_s \f$, and \f$ C_s \f$ are constants. - * - */ - void PecosTransport::updateSpeciesViscosities() { +/** + * + * Update the pure-species viscosities. (Pa-s) = (kg/m/sec) + * + * Using Blottner fit for viscosity. Defines kinematic viscosity + * of the form + * \f[ + * \mu_s\left(T\right) = 0.10 \exp\left(A_s\left(\log T\right)^2 + B_s\log T + C_s\right) + * \f] + * where \f$ A_s \f$, \f$ B_s \f$, and \f$ C_s \f$ are constants. + * + */ +void PecosTransport::updateSpeciesViscosities() +{ // blottner // return 0.10*std::exp(_a*(logT*logT) + _b*logT + _c); @@ -555,22 +574,22 @@ namespace Cantera { int k; // iterate over species, update pure-species viscosity for (k = 0; k < m_nsp; k++) { - m_visc[k] = 0.10*std::exp(a[k]*(m_logt*m_logt) + b[k]*m_logt + c[k]); - m_sqvisc[k] = sqrt(m_visc[k]); + m_visc[k] = 0.10*std::exp(a[k]*(m_logt*m_logt) + b[k]*m_logt + c[k]); + m_sqvisc[k] = sqrt(m_visc[k]); } // time to update mixing m_spvisc_ok = true; - } +} - /* - * read_blottner_transport_table() - * loads up A B and C for blottner fits - * hardcoded for air, will need to generalize later - */ +/* + * read_blottner_transport_table() + * loads up A B and C for blottner fits + * hardcoded for air, will need to generalize later + */ - void PecosTransport::read_blottner_transport_table() - { +void PecosTransport::read_blottner_transport_table() +{ // istringstream blot // ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" // "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" @@ -591,14 +610,14 @@ namespace Cantera { // "H -8.3912e-3 0.7743270 -13.6653000\n" // "H2 -8.3346e-3 0.7815380 -13.5351000\n" // "e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n"); - + // // from: AIAA-1997-2474 and Sandia Report SC-RR-70-754 - // + // // # Air -- Identical to N2 fit // # N -- Sandia Report SC-RR-70-754 // # N2 -- Sandia Report SC-RR-70-754 - // # CPN2 -- Identical to N2 fit + // # CPN2 -- Identical to N2 fit // # NO -- Sandia Report SC-RR-70-754 // # O -- Sandia Report SC-RR-70-754 // # O2 -- Sandia Report SC-RR-70-754 @@ -615,77 +634,72 @@ namespace Cantera { // # e -- Sandia Report SC-RR-70-754 istringstream blot - ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "N 1.15572000000e-02 6.03167900000e-01 -1.24327495000e+01\n" - "N2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "CPN2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "NO 4.36378000000e-02 -3.35511000000e-02 -9.57674300000e+00\n" - "O 2.03144000000e-02 4.29440400000e-01 -1.16031403000e+01\n" - "O2 4.49290000000e-02 -8.26158000000e-02 -9.20194750000e+00\n" - "C -8.3285e-3 0.7703240 -12.7378000\n" - "C2 -8.4311e-3 0.7876060 -13.0268000\n" - "C3 -8.4312e-3 0.7876090 -12.8240000\n" - "C2H -2.4241e-2 1.0946550 -14.5835500\n" - "CN -8.3811e-3 0.7860330 -12.9406000\n" - "CO -0.019527394 1.013295 -13.97873\n" - "CO2 -0.019527387 1.047818 -14.32212\n" - "HCN -2.4241e-2 1.0946550 -14.5835500\n" - "H -8.3912e-3 0.7743270 -13.6653000\n" - "H2 -8.3346e-3 0.7815380 -13.5351000\n" - "e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n"); + ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" + "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" + "N 1.15572000000e-02 6.03167900000e-01 -1.24327495000e+01\n" + "N2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" + "CPN2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" + "NO 4.36378000000e-02 -3.35511000000e-02 -9.57674300000e+00\n" + "O 2.03144000000e-02 4.29440400000e-01 -1.16031403000e+01\n" + "O2 4.49290000000e-02 -8.26158000000e-02 -9.20194750000e+00\n" + "C -8.3285e-3 0.7703240 -12.7378000\n" + "C2 -8.4311e-3 0.7876060 -13.0268000\n" + "C3 -8.4312e-3 0.7876090 -12.8240000\n" + "C2H -2.4241e-2 1.0946550 -14.5835500\n" + "CN -8.3811e-3 0.7860330 -12.9406000\n" + "CO -0.019527394 1.013295 -13.97873\n" + "CO2 -0.019527387 1.047818 -14.32212\n" + "HCN -2.4241e-2 1.0946550 -14.5835500\n" + "H -8.3912e-3 0.7743270 -13.6653000\n" + "H2 -8.3346e-3 0.7815380 -13.5351000\n" + "e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n"); string line; string name; - string ss1,ss2,ss3,ss4,sss; + string ss1,ss2,ss3,ss4,sss; int k; int i = 0; - while (std::getline(blot, line)) - { + while (std::getline(blot, line)) { - istringstream ss(line); - std::getline(ss, ss1, ' '); - std::getline(ss, ss2, ' '); - std::getline(ss, ss3, ' '); - std::getline(ss, ss4, ' '); - name = ss1; + istringstream ss(line); + std::getline(ss, ss1, ' '); + std::getline(ss, ss2, ' '); + std::getline(ss, ss3, ' '); + std::getline(ss, ss4, ' '); + name = ss1; - // now put coefficients in correct species - for (k = 0; k < m_nsp; k++) - { - string sss = m_thermo->speciesName(k); + // now put coefficients in correct species + for (k = 0; k < m_nsp; k++) { + string sss = m_thermo->speciesName(k); - // this is the right species index - if(sss.compare(ss1) == 0) - { - a[k] = atof(ss2.c_str()); - b[k] = atof(ss3.c_str()); - c[k] = atof(ss4.c_str()); - - // index - i++; - } - else // default to air - { - - a[k] = 0.026; - b[k] = 0.3; - c[k] = -11.3; - } - - } // done with for loop - } + // this is the right species index + if (sss.compare(ss1) == 0) { + a[k] = atof(ss2.c_str()); + b[k] = atof(ss3.c_str()); + c[k] = atof(ss4.c_str()); + + // index + i++; + } else { // default to air + + a[k] = 0.026; + b[k] = 0.3; + c[k] = -11.3; + } + + } // done with for loop + } - // for (k = 0; k < m_nsp; k++) - // { - // string sss = m_thermo->speciesName(k); - // cout << sss << endl; - // cout << a[k] << endl; - // cout << b[k] << endl; - // cout << c[k] << endl; - // } + // for (k = 0; k < m_nsp; k++) + // { + // string sss = m_thermo->speciesName(k); + // cout << sss << endl; + // cout << a[k] << endl; + // cout << b[k] << endl; + // cout << c[k] << endl; + // } // simple sanity check // if(i != m_nsp-1) @@ -693,38 +707,41 @@ namespace Cantera { // std::cout << "error\n" << i << std::endl; // } - } +} - /** - * - * Update the temperature-dependent viscosity terms. - * Updates the array of pure species viscosities, and the - * weighting functions in the viscosity mixture rule. - * The flag m_visc_ok is set to true. - * - */ - void PecosTransport::updateViscosity_T() { +/** + * + * Update the temperature-dependent viscosity terms. + * Updates the array of pure species viscosities, and the + * weighting functions in the viscosity mixture rule. + * The flag m_visc_ok is set to true. + * + */ +void PecosTransport::updateViscosity_T() +{ doublereal vratiokj, wratiojk, factor1; - if (!m_spvisc_ok) updateSpeciesViscosities(); + if (!m_spvisc_ok) { + updateSpeciesViscosities(); + } // see Eq. (9-5.15) of Reid, Prausnitz, and Poling int j, k; for (j = 0; j < m_nsp; j++) { - for (k = j; k < m_nsp; k++) { - vratiokj = m_visc[k]/m_visc[j]; - wratiojk = m_mw[j]/m_mw[k]; + for (k = j; k < m_nsp; k++) { + vratiokj = m_visc[k]/m_visc[j]; + wratiojk = m_mw[j]/m_mw[k]; - // Note that m_wratjk(k,j) holds the square root of - // m_wratjk(j,k)! - factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j); - m_phi(k,j) = factor1*factor1 / - (SqrtEight * m_wratkj1(j,k)); - m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk); - } + // Note that m_wratjk(k,j) holds the square root of + // m_wratjk(j,k)! + factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j); + m_phi(k,j) = factor1*factor1 / + (SqrtEight * m_wratkj1(j,k)); + m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk); + } } m_viscwt_ok = true; - } +} } diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index c1d01cd29..1e3002d59 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -373,7 +373,7 @@ Transport* TransportFactory::newTransport(std::string transportModel, tr = new MixTransport; initTransport(tr, phase, CK_Mode, log_level); break; - // adding pecos transport model 2/13/12 + // adding pecos transport model 2/13/12 case cPecosTransport: tr = new PecosTransport; initTransport(tr, phase, 0, log_level); @@ -712,8 +712,8 @@ void TransportFactory::initLiquidTransport(Transport* tran, } void TransportFactory::fitCollisionIntegrals(ostream& logfile, - GasTransportParams& tr, - MMCollisionInt& integrals) + GasTransportParams& tr, + MMCollisionInt& integrals) { vector_fp::iterator dptr; doublereal dstar; @@ -1145,7 +1145,7 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp *********************************************************/ void TransportFactory::fitProperties(GasTransportParams& tr, - MMCollisionInt& integrals, std::ostream& logfile) + MMCollisionInt& integrals, std::ostream& logfile) { doublereal tstar; int ndeg = 0; diff --git a/test_problems/cxx_ex/runtest b/test_problems/cxx_ex/runtest index 086cc6c17..6ca577dd0 100755 --- a/test_problems/cxx_ex/runtest +++ b/test_problems/cxx_ex/runtest @@ -1,7 +1,5 @@ #!/bin/sh # -# $Id: runtest,v 1.8 2006/08/14 19:32:55 hkmoffa Exp $ -# temp_success="1" /bin/rm -f eq1.csv tr1.csv tr2.csv kin1.csv kin2.csv \ kin1_blessed_tmp.csv kin2_blessed_tmp.csv @@ -115,7 +113,7 @@ fi # cp kin1_blessed.csv kin1_blessed_tmp.csv 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 $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 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 $CANTERA_BIN/csvdiff kin2.csv kin2_blessed_tmp.csv > kin2_test.out