From 13db7c6dc605d941b830e4fe88d0ee6f27813adf Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Tue, 3 Aug 2004 09:09:19 +0000 Subject: [PATCH] removed unused files --- Cantera/src/Constituents.cpp | 12 +- Cantera/src/DenseMatrix.h | 6 +- Cantera/src/EOS_TPX.h | 209 -------------------------- Cantera/src/EdgePhase.h | 1 + Cantera/src/GRI30.h | 89 ----------- Cantera/src/IdealGasThermo.h | 212 --------------------------- Cantera/src/InterfaceKinetics.cpp | 4 +- Cantera/src/Makefile.in | 24 +-- Cantera/src/NasaThermo.h | 7 +- Cantera/src/ReactionData.h | 8 +- Cantera/src/Resid.h | 141 ------------------ Cantera/src/RxnRates.h | 1 + Cantera/src/ShomateThermo.h | 2 +- Cantera/src/SimpleThermo.h | 2 +- Cantera/src/SolidCompound.h | 187 ----------------------- Cantera/src/SpeciesThermo.h | 2 +- Cantera/src/SpeciesThermoFactory.cpp | 36 +++-- Cantera/src/SpeciesThermoMgr.h | 13 +- Cantera/src/StoichManager.h | 6 +- Cantera/src/exceptions.h | 80 ---------- Cantera/src/fitPoly.h | 117 --------------- Cantera/src/pureSubstances.h | 138 ----------------- Cantera/src/surfKinetics.h | 190 ------------------------ Cantera/src/transportModels.h | 16 -- Cantera/src/xml.cpp | 89 ++--------- 25 files changed, 76 insertions(+), 1516 deletions(-) delete mode 100755 Cantera/src/EOS_TPX.h delete mode 100755 Cantera/src/GRI30.h delete mode 100755 Cantera/src/IdealGasThermo.h delete mode 100755 Cantera/src/Resid.h delete mode 100644 Cantera/src/SolidCompound.h delete mode 100755 Cantera/src/exceptions.h delete mode 100755 Cantera/src/fitPoly.h delete mode 100755 Cantera/src/pureSubstances.h delete mode 100755 Cantera/src/surfKinetics.h delete mode 100755 Cantera/src/transportModels.h diff --git a/Cantera/src/Constituents.cpp b/Cantera/src/Constituents.cpp index 27b9dd178..150858cee 100755 --- a/Cantera/src/Constituents.cpp +++ b/Cantera/src/Constituents.cpp @@ -23,12 +23,12 @@ using namespace std; namespace Cantera { - class ElementsFrozen : public CanteraError { - public: - ElementsFrozen(string func) - : CanteraError(func, - "elements cannot be added after species.") {} - }; + //class ElementsFrozen : public CanteraError { + //public: + // ElementsFrozen(string func) + // : CanteraError(func, + // "elements cannot be added after species.") {} + //}; /******************************************************************** * diff --git a/Cantera/src/DenseMatrix.h b/Cantera/src/DenseMatrix.h index 73e2ad13c..0d8adfbe7 100755 --- a/Cantera/src/DenseMatrix.h +++ b/Cantera/src/DenseMatrix.h @@ -17,9 +17,9 @@ #ifndef CT_DENSEMATRIX_H #define CT_DENSEMATRIX_H -#include -#include -using namespace std; +//#include +//#include +//using namespace std; #include "ct_defs.h" #include "Array.h" diff --git a/Cantera/src/EOS_TPX.h b/Cantera/src/EOS_TPX.h deleted file mode 100755 index 3f63b0a27..000000000 --- a/Cantera/src/EOS_TPX.h +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @file EOS.h - * - * Declares virtual base class EOS - */ - -// Copyright 2001 California Institute of Technology - -#ifndef CT_EOS_TPX_H -#define CT_EOS_TPX_H - -#include "EOS.h" -#include "../ext/tpx/Sub.h" -#include "../ext/tpx/utils.h" - -namespace Cantera { - - class TPX_Error { - public: - TPX_Error(string proc, int err, int fatal = 1) { - cerr << "Error in EOS_TPX::" << proc << ": " - << tpx::errorMsg(err) << endl; - if (fatal) exit(-1); - } - }; - - - class EOS_TPX : public EOS { - - public: - - EOS_TPX(int subflag, double h0 = 0.0, double s0 = 0.0) { - m_sub = tpx::GetSub(subflag); - m_mw = m_sub->MolWt(); - m_sub->setStdState(h0/m_mw, s0/m_mw); - } - - virtual ~EOS_TPX() { delete m_sub; } - - - /** - * Mixture molar enthalpy. Units: J/mol. - */ - virtual doublereal enthalpy_mole(const State& s, - const vector_fp& h0_RT) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->h() * m_mw; - } - /** - * Mixture molar internal energy. Units: J/mol. - */ - virtual doublereal intEnergy_mole(const State& s, - const vector_fp& h0_RT) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->u() * m_mw; - } - - /** - * Mixture molar entropy. Units: J/mol/K. - */ - virtual doublereal entropy_mole(const State& s, - const vector_fp& s0_RT, - doublereal log_Pp_bar = -999.0 ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->s() * m_mw; - } - - /** - * Mixture molar Gibbs function. Units: J/mol. - */ - virtual doublereal gibbs_mole(const State& s, - const vector_fp& g0_RT, - doublereal log_Pp_bar = -999.0 ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->g() * m_mw; - } - - /** - * Mixture molar heat capacity at constant pressure. - * Units: J/mol/K. - */ - virtual doublereal cp_mole(const State& s, - const vector_fp& cp0_R ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->cp() * m_mw; - } - - /** - * Mixture molar heat capacity at constant volume. - * Units: J/mol/K. - */ - virtual doublereal cv_mole(const State& s, - const vector_fp& cp0_R ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return m_sub->cv() * m_mw; - } - - /** - * Mixture molar isothermal compressibility - * \f$ -(1/V)(\partial V/\partial P)_T\f$. Units: 1/Pa. - */ - virtual doublereal compressibility_T(const State& s, - const vector_fp& cp0_R ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - return -999.0; - } - - /** - * Mixture molar volumetric thermal expansion coefficient - * \f$ (1/V)(\partial V/\partial T)_P\f$. Units: 1/K. - */ - virtual doublereal thermalExpansionCoeff(const State& s, - const vector_fp& cp0_R ) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - doublereal beta = m_sub->thermExpCoeff(); - if (m_sub->Error()) - throw TPX_Error("thermalExpansionCoeff", m_sub->Error()); - return beta; - } - - - /** - * Pressure. Units: Pa - */ - virtual doublereal pressure(const State& s) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - doublereal pp = m_sub->P(); - if (m_sub->Error()) - throw TPX_Error("pressure", m_sub->Error()); - return pp; - } - - - /** - * Set the pressure, holding temperature and composition - * fixed. - * - * @param s State instance defining the thermodynamic state. - * The density attribute of s will be set to a value such that - * the value of pressure() equals p. - * - * @param p Pressure in Pa. - */ - virtual void setPressure(State& s, doublereal p) const { - m_sub->Set(tpx::TP, s.temperature(), p); - s.setDensity(1.0/m_sub->v()); - if (m_sub->Error()) - throw TPX_Error("setPressure", m_sub->Error()); - } - - virtual void getChemPotentials_RT(const State& s, - const vector_fp& g0_RT, const vector_fp& x, - doublereal* mu) const { - m_sub->Set(tpx::TV, s.temperature(), 1.0/s.density()); - mu[0] = gibbs_mole(s, g0_RT); - if (m_sub->Error()) - throw TPX_Error("getChemPotentials_RT", m_sub->Error()); - } - - tpx::Substance& TPX_Substance() { return *m_sub; } - doublereal Tmin() { return m_sub->Tmin(); } - doublereal Tmax() { return m_sub->Tmax(); } - - /// critical state properties - virtual doublereal critTemperature() { return m_sub->Tcrit(); } - virtual doublereal critPressure() { return m_sub->Pcrit(); } - virtual doublereal critDensity() { return 1.0/m_sub->Vcrit(); } - - /// saturation properties - virtual doublereal satTemperature(doublereal p) { - doublereal ts = m_sub->Tsat(p); - if (ts == tpx::Undef) throw TPX_Error("satTemperature",m_sub->Error()); - return ts; - } - virtual doublereal satPressure(doublereal t) { - doublereal tsv = m_sub->Temp(); - doublereal vsv = m_sub->v(); - m_sub->Set(tpx::TP, t, 0.5*m_sub->Pcrit()); - doublereal ps = m_sub->Ps(); - if (ps == tpx::Undef) throw TPX_Error("satPressure",m_sub->Error()); - m_sub->Set(tpx::TV,tsv,vsv); - return ps; - } - - virtual int phase() { - doublereal xx = m_sub->x(); - if (xx > 0.99999) - return Vapor_Phase; - else if (xx < 1.e-5) - return Liquid_Phase; - else - return Liquid_Phase + Vapor_Phase; - } - - - protected: - - tpx::Substance* m_sub; - doublereal m_mw; - }; - -} - -#endif - - - - - diff --git a/Cantera/src/EdgePhase.h b/Cantera/src/EdgePhase.h index 13ddd2eda..4aab9310e 100644 --- a/Cantera/src/EdgePhase.h +++ b/Cantera/src/EdgePhase.h @@ -18,6 +18,7 @@ #include "mix_defs.h" #include "ThermoPhase.h" +#include "SurfPhase.h" namespace Cantera { diff --git a/Cantera/src/GRI30.h b/Cantera/src/GRI30.h deleted file mode 100755 index 14b7edfbd..000000000 --- a/Cantera/src/GRI30.h +++ /dev/null @@ -1,89 +0,0 @@ - -DEPRECATED - -/** - * @file GRI30.h - * - * GRI-Mech 3.0 - * - */ - -// Copyright 2001 California Institute of Technology - -#ifndef CT_GRI30_H -#define CT_GRI30_H - -#include - -#include "Phase.h" -#include "IdealGasThermo.h" -#include "GRI_30_Kinetics.h" - -#include "global.h" -#include "import.h" -#include "SpeciesThermoFactory.h" - -#include "speciesThermoTypes.h" - - -namespace Cantera { - - /** - * Implements reaction mechanism GRI-Mech 3.0 - */ - class GRI30 : - public Phase, public IdealGasThermo, public GRI_30_Kinetics - { - public: - -// GRI30(map& params) { -// setSpThermo(NASA); -// initThermo(*this); -// GRI_30_Kinetics::setThermo(*this); -// m_ok = importFromFile(this, this, params); -// } - - GRI30() { - setSpThermo(NASA); - initThermo(*this); - GRI_30_Kinetics::setThermo(*this); - map params; - params["input"] = "gri30.xml"; - params["ID"] = "gri30"; - //if (validate) params["validate"] = "yes"; - m_ok = importFromFile(this, this, params); - //m_ok = import("gri30.xml", "", false); - } - - /** - * Destructor. Does nothing. - */ - virtual ~GRI30() {} - - bool valid() const { return m_ok; } - - bool operator!() const {return !m_ok;} - - protected: - -// bool import(string infile, string dbfile="", bool validate=false) { -// map params; -// params["input"] = infile; -// params["database"] = dbfile; -// if (validate) params["validate"] = "yes"; -// m_ok = importFromFile(this, this, params); -// return m_ok; -// } - - void setSpThermo(int paramType, SpeciesThermoFactory* fsp = 0) { - if (fsp == 0) fsp = SpeciesThermoFactory::factory(); - setSpeciesThermo(fsp->newSpeciesThermo(paramType)); - } - - bool m_ok; - - private: - }; -} - -#endif diff --git a/Cantera/src/IdealGasThermo.h b/Cantera/src/IdealGasThermo.h deleted file mode 100755 index e59728e84..000000000 --- a/Cantera/src/IdealGasThermo.h +++ /dev/null @@ -1,212 +0,0 @@ -/** - * - * @file IdealGasThermo.h - * - * Template for an equation of state class that implements the ideal - * gas equation. - */ - -/* $Author$ - * $Date$ - * $Revision$ - * - * Copyright 2001 California Institute of Technology - * - */ - - -#ifndef CT_IDEALGASTHERMO_H -#define CT_IDEALGASTHERMO_H - -#include "ct_defs.h" -#include "mix_defs.h" -#include "Thermo.h" -#include "SpeciesThermo.h" - -namespace Cantera { - - /** - * Overloads the virtual methods of class Thermo to implement the - * ideal gas equation of state. - */ - class IdealGasThermo : public Thermo { - - public: - - IdealGasThermo(phase_t* phase=0, SpeciesThermo* sptherm = 0) - : Thermo(phase, sptherm), m_tlast(0.0) {} - - virtual ~IdealGasThermo() {} - - virtual int eosType() const { return cIdealGas; } - - virtual doublereal enthalpy_mole() const { - return GasConstant * m_s->temperature() * - m_s->mean_X(enthalpy_RT().begin()); - } - - virtual doublereal intEnergy_mole() const { - return GasConstant * m_s->temperature() - * ( m_s->mean_X(enthalpy_RT().begin()) - 1.0); - } - - virtual doublereal entropy_mole() const { - return GasConstant * (m_s->mean_X(entropy_R().begin()) - - m_s->sum_xlogx() - log(pressure()/m_spthermo->refPressure())); - } - - virtual doublereal gibbs_mole() const { - return enthalpy_mole() - m_s->temperature() * entropy_mole(); - } - - virtual doublereal cp_mole() const { - return GasConstant * m_s->mean_X(cp_R().begin()); - } - - virtual doublereal cv_mole() const { - return cp_mole() - GasConstant; - } - - virtual doublereal pressure() const { - return GasConstant * m_s->molarDensity() * m_s->temperature(); - } - - virtual void setPressure(doublereal p) { - m_s->setDensity(p * m_s->meanMolecularWeight() - /(GasConstant * m_s->temperature())); - } - - virtual void getChemPotentials(doublereal* mu) const; - - virtual void getPartialMolarEnthalpies(doublereal* hbar) const { - const array_fp& _h = enthalpy_RT(); - doublereal rt = GasConstant * _temp(); - scale(_h.begin(), _h.end(), hbar, rt); - } - - //virtual void getPartialMolarEntropies(doublereal* sbar) const { - // err("getPartialMolarEntropies"); - //} - - //virtual void getPartialMolarVolumes(doublereal* vbar) const { - // err("getPartialMolarVolumes"); - //} - - virtual void getPureGibbs(doublereal* gpure) const { - const array_fp& gibbsrt = gibbs_RT(); - scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT()); - } - - void getEnthalpy_RT(doublereal* hrt) const { - const array_fp& _h = enthalpy_RT(); - copy(_h.begin(), _h.end(), hrt); - } - - void getEntropy_R(doublereal* sr) const { - const array_fp& _s = entropy_R(); - copy(_s.begin(), _s.end(), sr); - } - - virtual void getGibbs_RT(doublereal* grt) const { - const array_fp& gibbsrt = gibbs_RT(); - copy(gibbsrt.begin(), gibbsrt.end(), grt); - } - - void getCp_R(doublereal* cpr) const { - const array_fp& _cpr = cp_R(); - copy(_cpr.begin(), _cpr.end(), cpr); - } - - virtual doublereal minTemp(int k = -1) { - return m_spthermo->minTemp(k); - } - - virtual doublereal maxTemp(int k = -1) { - return m_spthermo->maxTemp(k); - } - - // new methods defined here - - const array_fp& enthalpy_RT() const { - _updateThermo(); - return m_h0_RT; - } - - const array_fp& gibbs_RT() const { - _updateThermo(); - return m_g0_RT; - } - - const array_fp& expGibbs_RT() const { - _updateThermo(); - int k; - for (k = 0; k != m_kk; k++) m_expg0_RT[k] = exp(m_g0_RT[k]); - return m_expg0_RT; - } - - const array_fp& entropy_R() const { - _updateThermo(); - return m_s0_R; - } - - const array_fp& cp_R() const { - _updateThermo(); - return m_cp0_R; - } - - void setPotentialEnergy(int k, doublereal pe) { - m_pe[k] = pe; - } - - doublereal potentialEnergy(int k) { - return m_pe[k]; - } - - virtual doublereal refPressure() const { - return m_spthermo->refPressure(); - } - - void initThermo(Phase& s); - - - /** - * Set mixture to an equilibrium state consistent with specified - * element potentials and temperature. - * - * @param lambda_RT vector of non-dimensional element potentials - * \f[ \lambda_m/RT \f]. - * @param t temperature in K. - * @param work. Temporary work space. Must be dimensioned at least - * as large as the number of species. - * - */ - virtual void setToEquilState(const doublereal* lambda_RT); - - - - protected: - - int m_kk, m_mm; - doublereal m_tmin, m_tmax, m_p0; - - mutable doublereal m_tlast; - mutable array_fp m_h0_RT; - mutable array_fp m_cp0_R; - mutable array_fp m_g0_RT; - mutable array_fp m_s0_R; - mutable array_fp m_expg0_RT; - mutable array_fp m_pe; - mutable array_fp m_pp; - - private: - - void _updateThermo() const; - }; -} - -#endif - - - - - diff --git a/Cantera/src/InterfaceKinetics.cpp b/Cantera/src/InterfaceKinetics.cpp index 11eeea884..05c04c195 100644 --- a/Cantera/src/InterfaceKinetics.cpp +++ b/Cantera/src/InterfaceKinetics.cpp @@ -21,8 +21,8 @@ #include "ImplicitSurfChem.h" -#include -using namespace std; +//#include +//using namespace std; namespace Cantera { diff --git a/Cantera/src/Makefile.in b/Cantera/src/Makefile.in index 147305148..7d26212a1 100755 --- a/Cantera/src/Makefile.in +++ b/Cantera/src/Makefile.in @@ -9,7 +9,7 @@ ############################################################### SUFFIXES= -SUFFIXES= .cpp .d .o .dh +SUFFIXES= .cpp .d .o .dh .h .h.gch OBJDIR = . @@ -54,28 +54,23 @@ FLOW1D = $(KINETICS) $(SOLVERS) EVERYTHING = $(KINETICS) $(HETEROKIN) $(ELECTROCHEM) $(EQUIL) $(CK) \ $(TRANSPORT) $(REACTOR) $(RPATH) $(SOLVERS) $(FLOW1D) +PCH = all.h +#config.h ct_defs.h utilities.h ThermoPhase.h Kinetics.h ReactionData.h RateCoeffMgr.h ReactionStoichMgr.h -PCH = ct_defs.h.gch utilities.h.gch ThermoPhase.h.gch Kinetics.h.gch -PCHSRC = ($PCH:.h.gch=.h) +PCHGCH = $(PCH:.h=.h.gch) -all: config.h $(PCH) @KERNEL@ lib +all: config.h $(PCHGCH) @KERNEL@ lib config.h: ../../config.h cp -f ../../config.h ./config.h -# @(if test "x`diff -bB --brief config.h ../../config.h`" != "x"; then (cp -f ../../config.h ./config.h; echo 'copied ../../config.h'); fi) - -%.h.gch: +%.h.gch : %.h ifeq (@precompile_headers@,yes) @CXX@ $*.h $(CXX_FLAGS) else @echo 'skipping precompiling header file $*.h' endif -ct_defs.h.gch: ct_defs.h -utilities.h.gch: utilities.h -ThermoPhase.h.gch: ThermoPhase.h -Kinetics.h.gch: Kinetics.h base: $(BASE) @@ -110,15 +105,12 @@ CXX_LIBS = @LIBS@ CXX_INCLUDES = -I. CANTERA_LIB = @buildlib@/libcantera.a -DEPENDS = $(EVERYTHING:.o=.d) $(PCH:.h.gch=.dh) -SRCS = $(EVERYTHING:.o=.cpp) $(PCH:.gch=) +DEPENDS = $(EVERYTHING:.o=.d) +SRCS = $(EVERYTHING:.o=.cpp) .cpp.d: g++ -MM $(CXX_INCLUDES) $*.cpp > $*.d -.h.dh: - g++ -MM $(CXX_INCLUDES) $*.h > $*.dh - .cpp.o: @CXX@ -c $< $(CXX_FLAGS) #$(CXX_INCLUDES) diff --git a/Cantera/src/NasaThermo.h b/Cantera/src/NasaThermo.h index b81c14afa..8416eb1c6 100755 --- a/Cantera/src/NasaThermo.h +++ b/Cantera/src/NasaThermo.h @@ -11,6 +11,7 @@ #ifndef CT_NASATHERMO_H #define CT_NASATHERMO_H +#include #include "SpeciesThermoMgr.h" #include "NasaPoly1.h" @@ -64,7 +65,7 @@ namespace Cantera { * - c[1] - c[7] coefficients for low T range * - c[8] - c[14] coefficients for high T range */ - virtual void install(int index, int type, const doublereal* c, + virtual void install(string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { @@ -91,7 +92,7 @@ namespace Cantera { vector_fp chigh(7); copy(c + 8, c + 15, chigh.begin()); - checkContinuity(tmid, clow, chigh.begin()); + checkContinuity(name, tmid, clow, chigh.begin()); m_high[igrp-1].push_back(NasaPoly1(index, tmid, thigh, pref, chigh.begin())); @@ -263,7 +264,7 @@ namespace Cantera { private: // see SpeciesThermoFactory.cpp for the definition - void checkContinuity(double tmid, const doublereal* clow, + void checkContinuity(string name, double tmid, const doublereal* clow, doublereal* chigh); /// for internal use by checkContinuity diff --git a/Cantera/src/ReactionData.h b/Cantera/src/ReactionData.h index 457c1f9c9..909832e5e 100755 --- a/Cantera/src/ReactionData.h +++ b/Cantera/src/ReactionData.h @@ -12,10 +12,10 @@ #ifndef CT_REACTION_DATA_H #define CT_REACTION_DATA_H -#include -#include -#include -using namespace std; +//#include +//#include +//#include +//using namespace std; #include "reaction_defs.h" diff --git a/Cantera/src/Resid.h b/Cantera/src/Resid.h deleted file mode 100755 index ff8492ed9..000000000 --- a/Cantera/src/Resid.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * - * @file Resid.h - * - * >>>>> Under construction! <<<<< - * - * $Author$ - * $Date$ - * $Revision$ - * - * Copyright 2002 California Institute of Technology - * - */ - -#ifndef CT_RESID_H -#define CT_RESID_H - -#include -#include "ctexceptions.h" -#include "stringUtils.h" - -namespace Cantera { - - - /** - * Residual function evaluator for a zero-dimensional problem. - */ - class Resid { - public: - - /** - * Constructor. - * @param nv Number of variables at each grid point. - * @param points Number of grid points. - */ - Resid(int nv=1, doublereal time = 0.0) { - m_nv = nv; - m_max.resize(m_nv, 0.0); - m_min.resize(m_nv, 0.0); - m_rtol.resize(m_nv, 0.0); - m_atol.resize(m_nv, 0.0); - m_time = time; - m_slast.resize(m_nv); - setSteadyMode(); - } - - void resize(int nv) { - m_nv = nv; - m_max.resize(m_nv, 0.0); - m_min.resize(m_nv, 0.0); - m_rtol.resize(m_nv, 0.0); - m_atol.resize(m_nv, 0.0); - m_slast.resize(m_nv); - setSteadyMode(); - } - - /// Destructor. - virtual ~Resid(){} - - /// Number of components - int nComponents() const { return m_nv; } - - /// Name of the nth component. - virtual string componentName(int n) const { - return "component " + int2str(n); } - - void setBounds(int nl, const doublereal* lower, - int nu, const doublereal* upper) { - if (nl != m_nv || nu != m_nv) - throw CanteraError("Resid::setBounds", - "wrong array size for solution bounds"); - copy(upper, upper + m_nv, m_max.begin()); - copy(lower, lower + m_nv, m_min.begin()); - } - - void setTolerances(int nr, const doublereal* rtol, - int na, const doublereal* atol) { - if (nr != m_nv || na != m_nv) - throw CanteraError("Resid::setTolerances", - "wrong array size for solution error tolerances"); - copy(rtol, rtol + m_nv, m_rtol.begin()); - copy(atol, atol + m_nv, m_atol.begin()); - } - - doublereal rtol(int n) { return m_rtol[n]; } - doublereal atol(int n) { return m_atol[n]; } - - doublereal upperBound(int n) const { return m_max[n]; } - doublereal lowerBound(int n) const { return m_min[n]; } - - void initTimeInteg(doublereal dt, const doublereal* x0) { - copy(x0, x0 + m_nv, m_slast.begin()); - m_rdt = 1.0/dt; - } - - void setSteadyMode() { m_rdt = 0.0; } - - bool steady() { return (m_rdt == 0.0); } - bool transient() { return (m_rdt != 0.0); } - - - /** - * Evaluate the residual function. - */ - virtual void eval(doublereal* x, doublereal* r) { - throw CanteraError("Resid::eval", - "residual function not defined."); - } - - virtual void update(doublereal* x) {} - - void evalss(doublereal* x, doublereal* r) { - doublereal rdt_save = m_rdt; - m_rdt = 0.0; - eval(x, r); - m_rdt = rdt_save; - } - - doublereal time() { return m_time;} - doublereal rdt() { return m_rdt; } - void incrementTime(doublereal dt) { m_time += dt; } - - protected: - int m_nv; - int m_points; - vector_fp m_slast; - doublereal m_rdt; - doublereal m_time; - vector_fp m_max; - vector_fp m_min; - vector_fp m_rtol; - vector_fp m_atol; - - private: - - }; -} - -#endif - - diff --git a/Cantera/src/RxnRates.h b/Cantera/src/RxnRates.h index 62eea65a8..3d43b7a79 100755 --- a/Cantera/src/RxnRates.h +++ b/Cantera/src/RxnRates.h @@ -15,6 +15,7 @@ #define CT_RXNRATES_H #include "reaction_defs.h" +#include "ctexceptions.h" namespace Cantera { diff --git a/Cantera/src/ShomateThermo.h b/Cantera/src/ShomateThermo.h index 17199e510..716428937 100755 --- a/Cantera/src/ShomateThermo.h +++ b/Cantera/src/ShomateThermo.h @@ -54,7 +54,7 @@ namespace Cantera { * in the same units as used in the NIST Chemistry WebBook. * */ - virtual void install(int index, int type, const doublereal* c, + virtual void install(string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { int imid = int(c[0]); // midpoint temp converted to integer int igrp = m_index[imid]; // has this value been seen before? diff --git a/Cantera/src/SimpleThermo.h b/Cantera/src/SimpleThermo.h index 547503f86..b9d2cba6b 100644 --- a/Cantera/src/SimpleThermo.h +++ b/Cantera/src/SimpleThermo.h @@ -27,7 +27,7 @@ namespace Cantera { virtual ~SimpleThermo() {} - virtual void install(int index, int type, const doublereal* c, + virtual void install(string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { m_logt0.push_back(log(c[0])); m_t0.push_back(c[0]); diff --git a/Cantera/src/SolidCompound.h b/Cantera/src/SolidCompound.h deleted file mode 100644 index 9354d22b8..000000000 --- a/Cantera/src/SolidCompound.h +++ /dev/null @@ -1,187 +0,0 @@ -/** - * - * @file SolidPhase.h - * - */ - -/* $Author$ - * $Date$ - * $Revision$ - * - * Copyright 2001 California Institute of Technology - * - */ - - -#ifndef CT_SOLIDPHASE_H -#define CT_SOLIDPHASE_H - -//#include "ct_defs.h" -#include "mix_defs.h" -#include "ThermoPhase.h" -#include "SpeciesThermo.h" - -namespace Cantera { - - /** - * @ingroup thermoprops - * - * Class SolidCompound represents solid compounds. - * It derives from class ThermoPhase, - * and overloads the virtual methods defined there with ones that - * use expressions appropriate for solid compounds - * - */ - class SolidCompound : public ThermoPhase { - - public: - - SolidCompound(): - m_kk(0), - m_tmin(0.0), - m_tmax(0.0), - m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) {} - - virtual ~SolidCompound() {} - - /** - * Equation of state flag. Returns the value cSolidCompound, defined - * in mix_defs.h. - */ - virtual int eosType() const { return cSolidCompound; } - - - /** - * @name Molar Thermodynamic Properties - * @{ - */ - - /** - * Molar enthalpy. Units: J/kmol. - */ - virtual doublereal enthalpy_mole() const { - double hh = intEnergy_mole() + m_press / molarDensity(); - return hh; - } - - /** - * Molar internal energy. J/kmol. - */ - virtual doublereal intEnergy_mole() const { - _updateThermo(); - return GasConstant * temperature() * m_h0_RT[0] - - m_p0 / molarDensity(); - } - - /** - * Molar entropy. Units: J/kmol/K. - */ - virtual doublereal entropy_mole() const { - _updateThermo(); - return GasConstant * m_s0_R[0]; - } - - - virtual doublereal gibbs_mole() const { - return enthalpy_mole() - temperature() * entropy_mole(); - } - - - /** - * Molar heat capacity at constant pressure. Units: J/kmol/K. - */ - virtual doublereal cp_mole() const { - _updateThermo(); - return GasConstant * m_cp0_R[0]; - } - - /** - * Molar heat capacity at constant volume. Units: J/kmol/K. - */ - virtual doublereal cv_mole() const { - return cp_mole(); - } - - //@} - - - /** - * @name Mechanical Equation of State - * @{ - */ - - /** - * Pressure. Units: Pa. - */ - virtual doublereal pressure() const { - return m_press; - } - - /** - * Set the pressure at constant temperature. Units: Pa. - */ - virtual void setPressure(doublereal p) { - m_press = p; - } - - //@} - - - virtual void getChemPotentials(doublereal* mu) const { - mu[0] = gibbs_mole(); - } - - virtual void getStandardChemPotentials(doublereal* mu0) const { - mu0[0] = gibbs_mole(); - } - - /** - * This method returns the array of generalized - * concentrations. For a solid compound, there is only one - * species, and the generalized concentration is 1.0. - */ - virtual void getActivityConcentrations(doublereal* c) const { - c[0] = 1.0; - } - - /** - * The standard concentration. This is defined as the concentration - * by which the generalized concentration is normalized to produce - * the activity. - */ - virtual doublereal standardConcentration(int k=0) const { - return 1.0; - } - - virtual doublereal logStandardConc(int k=0) const { - return 0.0; - } - - virtual void initThermo(); - - - protected: - - int m_kk; - doublereal m_tmin, m_tmax, m_press, m_p0; - - mutable doublereal m_tlast; - mutable array_fp m_h0_RT; - mutable array_fp m_cp0_R; - mutable array_fp m_s0_R; - - private: - - void _updateThermo() const; - }; - -} - -#endif - - - - - diff --git a/Cantera/src/SpeciesThermo.h b/Cantera/src/SpeciesThermo.h index 6ab58bf00..a93d5bf7a 100755 --- a/Cantera/src/SpeciesThermo.h +++ b/Cantera/src/SpeciesThermo.h @@ -64,7 +64,7 @@ namespace Cantera { * parameterization. * @see speciesThermoTypes.h */ - virtual void install(int index, int type, const doublereal* c, + virtual void install(string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure)=0; /** diff --git a/Cantera/src/SpeciesThermoFactory.cpp b/Cantera/src/SpeciesThermoFactory.cpp index 42537d41e..b1bdb485e 100755 --- a/Cantera/src/SpeciesThermoFactory.cpp +++ b/Cantera/src/SpeciesThermoFactory.cpp @@ -28,6 +28,7 @@ #include "xml.h" #include "ctml.h" + using namespace ctml; namespace Cantera { @@ -126,7 +127,7 @@ namespace Cantera { /// Check the continuity of properties at the midpoint /// temperature. - void NasaThermo::checkContinuity(double tmid, const doublereal* clow, + void NasaThermo::checkContinuity(string name, double tmid, const doublereal* clow, doublereal* chigh) { // heat capacity @@ -134,7 +135,8 @@ namespace Cantera { doublereal cphigh = poly4(tmid, chigh+2); doublereal delta = cplow - cphigh; if (fabs(delta/cplow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in cp/R detected at Tmid = " + writelog("\n**** WARNING ****\nFor species "+name+ + ", discontinuity in cp/R detected at Tmid = " +fp2str(tmid)+"\n"); writelog("\tValue computed using low-temperature polynomial: "+fp2str(cplow)+".\n"); writelog("\tValue computed using high-temperature polynomial: "+fp2str(cphigh)+".\n"); @@ -145,7 +147,7 @@ namespace Cantera { doublereal hrthigh = enthalpy_RT(tmid, chigh); delta = hrtlow - hrthigh; if (fabs(delta/hrtlow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in h/RT detected at Tmid = " + writelog("\n**** WARNING ****\nFor species "+name+", discontinuity in h/RT detected at Tmid = " +fp2str(tmid)+"\n"); writelog("\tValue computed using low-temperature polynomial: "+fp2str(hrtlow)+".\n"); writelog("\tValue computed using high-temperature polynomial: "+fp2str(hrthigh)+".\n"); @@ -156,7 +158,7 @@ namespace Cantera { doublereal srhigh = entropy_R(tmid, chigh); delta = srlow - srhigh; if (fabs(delta/srlow) > 0.001) { - writelog("\n**** WARNING ****\nDiscontinuity in s/R detected at Tmid = " + writelog("\n**** WARNING ****\nFor species "+name+", discontinuity in s/R detected at Tmid = " +fp2str(tmid)+"\n"); writelog("\tValue computed using low-temperature polynomial: "+fp2str(srlow)+".\n"); writelog("\tValue computed using high-temperature polynomial: "+fp2str(srhigh)+".\n"); @@ -168,7 +170,8 @@ namespace Cantera { * Install a NASA polynomial thermodynamic property * parameterization for species k into a SpeciesThermo instance. */ - static void installNasaThermoFromXML(SpeciesThermo& sp, int k, + static void installNasaThermoFromXML(string speciesName, + SpeciesThermo& sp, int k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -215,7 +218,7 @@ namespace Cantera { c[8] = c1[5]; c[9] = c1[6]; copy(c1.begin(), c1.begin()+5, c.begin() + 10); - sp.install(k, NASA, c.begin(), tmin, tmax, p0); + sp.install(speciesName, k, NASA, c.begin(), tmin, tmax, p0); } @@ -223,7 +226,8 @@ namespace Cantera { * Install a NASA polynomial thermodynamic property * parameterization for species k. */ - static void installShomateThermoFromXML(SpeciesThermo& sp, int k, + static void installShomateThermoFromXML(string speciesName, + SpeciesThermo& sp, int k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -266,7 +270,7 @@ namespace Cantera { doublereal p0 = OneAtm; copy(c0.begin(), c0.begin()+7, c.begin() + 1); copy(c1.begin(), c1.begin()+7, c.begin() + 8); - sp.install(k, SHOMATE, c.begin(), tmin, tmax, p0); + sp.install(speciesName, k, SHOMATE, c.begin(), tmin, tmax, p0); } @@ -275,7 +279,8 @@ namespace Cantera { * Install a constant-cp thermodynamic property * parameterization for species k. */ - static void installSimpleThermoFromXML(SpeciesThermo& sp, int k, + static void installSimpleThermoFromXML(string speciesName, + SpeciesThermo& sp, int k, const XML_Node& f) { doublereal tmin, tmax; tmin = fpValue(f["Tmin"]); @@ -288,10 +293,9 @@ namespace Cantera { c[2] = getFloat(f, "s0", "-"); c[3] = getFloat(f, "cp0", "-"); doublereal p0 = OneAtm; - sp.install(k, SIMPLE, c.begin(), tmin, tmax, p0); + sp.install(speciesName, k, SIMPLE, c.begin(), tmin, tmax, p0); } - /** * Install a species thermodynamic property parameterization * for one species into a species thermo manager. @@ -316,13 +320,13 @@ namespace Cantera { if (nc == 1) { const XML_Node* f = tp[0]; if (f->name() == "Shomate") { - installShomateThermoFromXML(spthermo, k, f, 0); + installShomateThermoFromXML(s["name"], spthermo, k, f, 0); } else if (f->name() == "const_cp") { - installSimpleThermoFromXML(spthermo, k, *f); + installSimpleThermoFromXML(s["name"], spthermo, k, *f); } else if (f->name() == "NASA") { - installNasaThermoFromXML(spthermo, k, f, 0); + installNasaThermoFromXML(s["name"], spthermo, k, f, 0); } else { throw UnknownSpeciesThermoModel("installSpecies", @@ -333,10 +337,10 @@ namespace Cantera { const XML_Node* f0 = tp[0]; const XML_Node* f1 = tp[1]; if (f0->name() == "NASA" && f1->name() == "NASA") { - installNasaThermoFromXML(spthermo, k, f0, f1); + installNasaThermoFromXML(s["name"], spthermo, k, f0, f1); } else if (f0->name() == "Shomate" && f1->name() == "Shomate") { - installShomateThermoFromXML(spthermo, k, f0, f1); + installShomateThermoFromXML(s["name"], spthermo, k, f0, f1); } else { throw UnknownSpeciesThermoModel("installSpecies", s["name"], diff --git a/Cantera/src/SpeciesThermoMgr.h b/Cantera/src/SpeciesThermoMgr.h index c55eb6cd5..9b446c84e 100755 --- a/Cantera/src/SpeciesThermoMgr.h +++ b/Cantera/src/SpeciesThermoMgr.h @@ -8,7 +8,6 @@ // Copyright 2001 California Institute of Technology - #ifndef CT_SPECIESTHERMO_MGR_H #define CT_SPECIESTHERMO_MGR_H @@ -111,14 +110,14 @@ namespace Cantera { SpeciesThermoDuo() {} virtual ~SpeciesThermoDuo(){} - virtual void install(int sp, int type, const doublereal* c, + virtual void install(string name, int sp, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { m_p0 = refPressure; if (type == m_thermo1.ID) { - m_thermo1.install(sp, 0, c, minTemp, maxTemp, refPressure); + m_thermo1.install(name, sp, 0, c, minTemp, maxTemp, refPressure); speciesToType[sp] = m_thermo1.ID; } else if (type == m_thermo2.ID) { - m_thermo2.install(sp, 0, c, minTemp, maxTemp, refPressure); + m_thermo2.install(name, sp, 0, c, minTemp, maxTemp, refPressure); speciesToType[sp] = m_thermo2.ID; } else { throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type); @@ -181,6 +180,8 @@ namespace Cantera { map speciesToType; }; +#define REMOVE_FOR_V155 +#ifndef REMOVE_FOR_V155 /** * This species thermo manager requires that all species have the @@ -194,7 +195,7 @@ namespace Cantera { SpeciesThermo1() : m_pref(0.0) {} virtual ~SpeciesThermo1(){} - virtual void install(int sp, int type, const vector_fp& c) { + virtual void install(string name, int sp, int type, const vector_fp& c) { m_thermo.push_back(T(sp, c)); if (m_pref) { if (m_thermo.begin()->refPressure() != m_pref) { @@ -245,6 +246,8 @@ namespace Cantera { vector m_thermo; doublereal m_pref; }; +#endif + } #endif diff --git a/Cantera/src/StoichManager.h b/Cantera/src/StoichManager.h index 932d180f8..8a35c0c08 100755 --- a/Cantera/src/StoichManager.h +++ b/Cantera/src/StoichManager.h @@ -12,9 +12,9 @@ #ifndef CT_STOICH_MGR_H #define CT_STOICH_MGR_H -#include -#include -using namespace std; +//#include +//#include +//using namespace std; #include "stringUtils.h" diff --git a/Cantera/src/exceptions.h b/Cantera/src/exceptions.h deleted file mode 100755 index 3e7fa7f43..000000000 --- a/Cantera/src/exceptions.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file exceptions.h - * - * @deprecated - * $Author$ - * $Revision$ - * $Date$ - */ - -// Copyright 2001 California Institute of Technology - - -#ifndef CT_DEBUG_EXC_H -#define CT_DEBUG_EXC_H - -#include - -#ifdef WIN32 -#define _TYPENAME_ -#else -#define _TYPENAME_ typename -#endif - -__BEGIN_DEBUG_NAMESPACE - -template -void show_values(const T& x, size_t max_show = 20) { - - cerr << "values: <"; - if (x.size() < max_show) { - copy(x.begin(), x.begin() + x.size(), - ostream_iterator<_TYPENAME_ T::value_type>(cerr, " ")); - } - else { - size_t m2 = max_show/2; - copy(x.begin(), x.begin() + m2, - ostream_iterator<_TYPENAME_ T::value_type>(cerr, " ")); - cerr << "...(skipping " << x.size() - max_show << ")... "; - copy(x.end() - max_show + m2, x.end(), - ostream_iterator<_TYPENAME_ T::value_type>(cerr, " ")); - } - cerr << ">" << endl << endl; -} - - -template -class RangeError { - -public: - - RangeError(const T& vec, typename T::size_type n) { - - cerr << "\n###RANGE ERROR###\n" - << "attempt to access element " - << n << " outside valid range [0," - << vec.size()-1 << "]" << endl; - cerr << "object at " << &vec << endl; - show_values(vec); - } -}; - - -template -class SizeError { - -public: - - SizeError(const T& vec, typename T::size_type n) { - - cerr << "\n###SIZE ERROR###\n" - << "size = " << vec.size() << ", but should be " << n < - void fitPolynomial(int n, M& mix, int fittype, vector& coeffs, - doublereal tmin = -1.0, doublereal tmax = -1.0) { - int i, k; - doublereal temp; - if (tmin < 0.0) tmin = mix.minTemp(); - if (tmax < 0.0) tmax = mix.maxTemp(); - - // generate data - int np = int((tmax - tmin)/20.0 + 1); - if (np < 2*n+2) np = 2*n+2; - doublereal dt = (tmax - tmin)/(np - 1); - - int nsp = mix.nSpecies(); - - coeffs.resize(nsp); - - vector cp(nsp); - vector_fp x(np), w(np); - for (k = 0; k < nsp; k++) { - cp[k].resize(np); - } - - mix.setTemperature(298.15); - vector_fp h0 = mix.enthalpy_RT(); - vector_fp s0 = mix.entropy_R(); - - for (i = 0; i < np; i++) { - temp = tmin + i*dt; - mix.setTemperature(temp); - const vector_fp& cpr = mix.cp_R(); - switch (fittype) { - case 0: x[i] = temp; break; - case 1: x[i] = 1.0/temp; break; - case 2: x[i] = log(temp); break; - default: - cout << " unknown fit type (" << fittype << ")" << endl; - return; - } - w[i] = -1.0; - for (k = 0; k < nsp; k++) { - cp[k][i] = cpr[k]; - } - } - doublereal err; - for (k = 0; k < nsp; k++) { - coeffs[k].resize(n + 3); - err = polyfit(np, x.begin(), cp[k].begin(), w.begin(), - n, n, 0.0, coeffs[k].begin()+2); - coeffs[k][0] = 298.15 * (h0[k] - - poly_enthalpy_RT(298.15, n, coeffs[k].begin()+2, 0.0)); - coeffs[k][1] = (s0[k] - - poly_entropy_R(298.15, n, coeffs[k].begin()+2, 0.0)); - } - } -} - -#undef TESTIT -#ifdef TESTIT - -#include "Cantera.h" -#include "../Cantera/src/IdealGasMix.h" - -main() { - IdealGasMix mix("gri30.inp"); - int fittype = 0; - int n; - cout << " enter n: "; - cin >> n; - fitPolynomial(n, mix, fittype); -} - -#endif - -#endif diff --git a/Cantera/src/pureSubstances.h b/Cantera/src/pureSubstances.h deleted file mode 100755 index 509bed469..000000000 --- a/Cantera/src/pureSubstances.h +++ /dev/null @@ -1,138 +0,0 @@ - -#ifndef CT_PURESUBS_H -#define CT_PURESUBS_H - -#include "ct_defs.h" -#include "Phase.h" -#include "EOS_TPX.h" -#include "SpeciesThermoMgr.h" - -namespace Cantera { - - static double h0[5] = { - -2.8583e8, - 0.0, - -7.4850e7, - 0.0, - 0.0 - }; - - static double s0[5] = { - 6.995e4, - 1.915e5, - 1.8616e5, - 1.3057e5, - 2.0503e5 -}; - - const int Pure_Water = 0, - Pure_Nitrogen = 1, - Pure_Methane = 2, - Pure_Hydrogen = 3, - Pure_Oxygen = 4; - - class PureSubError { - public: - PureSubError(int i) { - cerr << "**** ERROR: unknown pure substance flag (" - << i << ")" << endl; - } - }; - - - /** - * Pure substances based on TPX substance models. - */ - class PureSubstance : public Mixture { - public: - PureSubstance(int sub) { - EOS_TPX* eos = new EOS_TPX(sub, h0[sub], s0[sub]); - setEquationOfState(eos); - setSpeciesThermo(new NoSpeciesThermo()); - m_tmin = eos->Tmin(); - m_tmax = eos->Tmax(); - } - protected: - }; - - - static PureSubstance* newNitrogen() { - PureSubstance* n2 = new PureSubstance(Pure_Nitrogen); - n2->addUniqueElement("N"); - vector_fp comp; - comp.push_back(2.0); - vector_fp coeff; - n2->addSpecies("N2", PURE_FLUID, comp, 0, coeff); - n2->freezeSpecies(); - n2->setState_TP(298.15, 1.01325e5); - return n2; - } - - - static PureSubstance* newWater() { - PureSubstance* sub = new PureSubstance(Pure_Water); - sub->addUniqueElement("H"); - sub->addUniqueElement("O"); - vector_fp comp; - comp.push_back(2.0); - comp.push_back(1.0); - vector_fp coeff; - sub->addSpecies("H2O", PURE_FLUID, comp, 0, coeff); - sub->freezeSpecies(); - sub->setState_TP(298.15, 1.01325e5); - return sub; - } - - - static PureSubstance* newMethane() { - PureSubstance* sub = new PureSubstance(Pure_Methane); - sub->addUniqueElement("C"); - sub->addUniqueElement("H"); - vector_fp comp; - comp.push_back(1.0); - comp.push_back(4.0); - vector_fp coeff; - sub->addSpecies("CH4", PURE_FLUID, comp, 0, coeff); - sub->freezeSpecies(); - sub->setState_TP(298.15, 1.01325e5); - return sub; - } - - static PureSubstance* newHydrogen() { - PureSubstance* sub = new PureSubstance(Pure_Hydrogen); - sub->addUniqueElement("H"); - vector_fp comp; - comp.push_back(2.0); - vector_fp coeff; - sub->addSpecies("H2", PURE_FLUID, comp, 0, coeff); - sub->freezeSpecies(); - sub->setState_TP(298.15, 1.01325e5); - return sub; - } - - static PureSubstance* newOxygen() { - PureSubstance* sub = new PureSubstance(Pure_Oxygen); - sub->addUniqueElement("O"); - vector_fp comp; - comp.push_back(2.0); - vector_fp coeff; - sub->addSpecies("O2", PURE_FLUID, comp, 0, coeff); - sub->freezeSpecies(); - sub->setState_TP(298.15, 1.01325e5); - return sub; - } - - inline PureSubstance* newSubstance(int isub) { - switch(isub) { - case (Pure_Water): return newWater(); - case (Pure_Nitrogen): return newNitrogen(); - case (Pure_Methane): return newMethane(); - case (Pure_Hydrogen): return newHydrogen(); - case (Pure_Oxygen): return newOxygen(); - default: throw PureSubError(isub); - } - } -} - -#endif - diff --git a/Cantera/src/surfKinetics.h b/Cantera/src/surfKinetics.h deleted file mode 100755 index f9d773bda..000000000 --- a/Cantera/src/surfKinetics.h +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @file SurfKinetics.h - */ - - -/* - * $Author$ - * $Revision$ - * $Date$ - * - * Copyright 2001 California Institute of Technology - */ - -#ifndef CT_SURFKINETICS_H -#define CT_SURFKINETICS_H - -#include -#include -#include -#include - -#include "mix_defs.h" -#include "Kinetics.h" - -#include "utilities.h" -#include "RateCoeffMgr.h" -#include "SurfPhase.h" - -namespace Cantera { - - // forward references - class ImplicitSurfChem; - class ReactionData; - - /** - * Holds mechanism-specific data. - * @ingroup kineticsGroup - */ - class SurfKineticsData { - public: - SurfKineticsData() : - m_ROP_ok(false), - m_temp(0.0) - {} - virtual ~SurfKineticsData(){} - - vector_fp m_ropf; - bool m_ROP_ok; - - doublereal m_temp; - vector_fp m_rfn; - doublereal m_s0; - }; - - - /** - * A kinetics manager for elementary surface chemistry. - */ - class SurfKinetics : public Kinetics { - - public: - - /// Constructor. - SurfKinetics() : Kinetics() {} - SurfKinetics(SurfacePhase* surfphase, thermo_t* th1, - thermo_t* th2, string fname="", string id=""); - - /// Destructor. - virtual ~SurfKinetics(){delete m_kdata; delete m_xml;} - - virtual int ID() { return 10; } - void import(string fname, string id); - - /** - * The surface phase for which this is a kinetics manager. - */ - SurfacePhase& sphase() { return *m_surfphase; } - - /** - * Total number of species on the surface and in both phases. - */ - int nTotal() { return m_ktot; } - - /** - * Return a reference to one of the bulk phases. - */ - Phase* bulkPhase(int n) { - return m_phase[n]; - } - - /** - * Get the forward rates of progress for all surface reactions. - */ - virtual void getFwdRatesOfProgress(doublereal* fwdROP) { - updateROP(); - copy(m_kdata->m_ropf.begin(), m_kdata->m_ropf.end(), fwdROP); - } - - /** - * Get the reverse rates of progress for all surface reactions. - * All reactions are currently modeled as irreversible, so this - * returns all zeros. - */ - virtual void getRevRatesOfProgress(doublereal* revROP) { - int i; - for (i = 0; i < m_ii; i++) - revROP[i] = 0.0; - } - - virtual void getNetRatesOfProgress(doublereal* netROP) { - getFwdRatesOfProgress(netROP); - } - - virtual void getNetProductionRates(doublereal* net); - virtual void getCreationRates(doublereal* cdot); - virtual void getDestructionRates(doublereal* ddot); - virtual void getChemRates(doublereal* rtau); - - virtual void init(); - - virtual void integrate(doublereal dt); - - /// Add a reaction to the mechanism. - void addReaction(const vector_int& r, const vector_int& rstoich, - const vector_int& order, const vector_int& p, - const vector_int& pstoich, - const vector_fp& rateParams); - - void saveReactionData(const vector_int& r, const vector_int& rstoich, - const vector_int& order, const vector_int& p, - const vector_int& pstoich, - const vector_fp& rateParams); - - virtual void finalize(); - virtual bool ready() const; - - void updateROP(); - - virtual int reactionType(int i) const {return SURFACE_RXN;} - virtual bool isReversible(int i) {return false;} - void save(string fname, string idtag, string comment); - - protected: - - SurfacePhase* m_surfphase; - SurfKineticsData* m_kdata; - - // objects for bulk phase 2. Those for bulk phase 1 - // are declared in Kinetics - phase_t* m_phase2; - thermo_t* m_thermo2; - - int m_kk; // number of surface species - int m_kk1; // number of bulk phase 1 species - int m_kk2; // number of bulk phase 2 species - int m_ktot; // total number of species - - Rate1 m_rates; - - vector_int m_irrev; - int m_nirrev; - - //mutable vector > m_rrxn; - //mutable vector > m_prxn; - - //map > m_rstoich; - //map > m_pstoich; - - vector m_order; - vector m_rst; - vector m_pst; - vector_int m_nr, m_np; - - vector_fp m_conc; - - ImplicitSurfChem* m_integrator; - map m_bsp1, m_bsp2; - - private: - - void _update_rates_T(); - void _update_rates_C(); - XML_Node* m_xml; - bool m_twobulk; - - bool m_finalized; - }; -} - -#endif diff --git a/Cantera/src/transportModels.h b/Cantera/src/transportModels.h deleted file mode 100755 index aedb15ba7..000000000 --- a/Cantera/src/transportModels.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef CT_TRANSPORT_MODELS_H -#define CT_TRANSPORT_MODELS_H - - -#include "TransportFactory.h" - -namespace Cantera { - - inline Transport* MultiTransport(mixture_t& mix, string file, - int loglevel=0) { - TransportFactory* f = TransportFactory::factory(); - Transport* t = f->newTransport(Multicomponent, file, mix, loglevel); - mix->setTransport(t); - } - -} diff --git a/Cantera/src/xml.cpp b/Cantera/src/xml.cpp index e1cadb61c..a9d6f37bf 100755 --- a/Cantera/src/xml.cpp +++ b/Cantera/src/xml.cpp @@ -74,12 +74,17 @@ namespace Cantera { //////////////////// XML_Reader methods /////////////////////// - + /// Get a single character from the input stream. If the character + /// is a new-line character, then increment the line count. void XML_Reader::getchr(char& ch) { m_s.get(ch); if (ch == '\n') m_line++; } + + /// Returns string 'aline' stripped of leading and trailing white + /// space. + /// @todo why is this a class method? string XML_Reader::strip(const string& aline) { int len = static_cast(aline.size()); int i, j; @@ -90,6 +95,11 @@ namespace Cantera { return aline.substr(j, i - j + 1); } + + /// Looks for a substring within 'aline' enclosed in double + /// quotes, and returns this substring (without the quotes) if + /// found. If not, an empty string is returned. + /// @todo why is this a class method? string XML_Reader::inquotes(const string& aline) { int len = static_cast(aline.size()); int i, j; @@ -189,13 +199,11 @@ namespace Cantera { // get attributes while (1) { iloc = s.find('='); - if (iloc == string::npos) break; + if (iloc == string::npos) break; attr = strip(s.substr(0,iloc)); if (attr == "") break; s = strip(s.substr(iloc+1,s.size())); - //iloc = s.find(' '); - //if (iloc < 0) iloc = s.size(); - iloc = findQuotedString(s, val); + iloc = findQuotedString(s, val); attribs[attr] = val; if (iloc != string::npos) { if (iloc < s.size()) @@ -707,77 +715,6 @@ namespace Cantera { } -// #ifdef FIND_XML -// /* -// * Find a particular XML element by a fairly complicated hierarchal -// * search objective. -// * -// * HKM -Note: Right now this routine contains a memory leak. -// * A "new" operation is conditionally carried out and -// * the pointer may or may not be returned to the calling -// * program. Therefore, it can't be deleted in the -// * calling program. This -// * eventually needs to be fixed by extracting the xml -// * malloc and build operation from the search operation. -// */ -// XML_Node* find_XML(string src, XML_Node* root, string id, string loc, -// string name) { -// string file, id2; -// split(src, file, id2); -// src = file; -// if (id2 != "") id = id2; - -// XML_Node *doc = 0, *r = 0; -// if (src != "") { -// doc = new XML_Node("doc"); -// string spath = findInputFile(src); -// ifstream fin(spath.c_str()); -// if (!fin) -// throw CanteraError("find_XML","could not open file "+src+ -// " for input."); -// doc->build(fin); -// root = 0; -// } -// else if (root) { -// doc = root; -// } -// else { -// throw CanteraError("find_XML", -// "either root or src must be specified."); -// } - -// try { -// if (id != "") -// r = doc->findID(id); -// else if (loc != "") -// r = &doc->child(loc); -// else if (name != "") -// r = doc->findByName(name); -// if (!r) { -// string opt = " src="+src+", loc="+loc+", id=" -// +id+", name="+name; -// throw CanteraError("find_XML", "XML element with "+opt+ -// " not found."); -// } -// return r; -// } -// catch (CanteraError) { - -// // root was used, but element was not found. Try src. -// if (root && src != "") { -// return find_XML(src, 0, id, loc, name); -// } -// else { -// string opt = " src="+src+", loc="+loc+", id=" -// +id+", name="+name; -// throw CanteraError("find_XML", "XML element with "+opt+ -// " not found."); -// return 0; -// } -// } -// } -// #endif - XML_Node * findXMLPhase(XML_Node *root, const string &idtarget) {