From 255f1f9b9f8a5fc383cf9ecb08caeedb2df5bd32 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 17 Jan 2012 04:10:43 +0000 Subject: [PATCH] Fixing compiler warnings, part 3 --- Cantera/src/base/ct_defs.h | 2 +- Cantera/src/converters/CKParser.cpp | 24 ++- Cantera/src/converters/CKReader.cpp | 4 +- Cantera/src/converters/NASA9Parser.cpp | 13 +- Cantera/src/converters/Species.cpp | 6 +- Cantera/src/converters/ck2ct.cpp | 13 +- Cantera/src/converters/writelog.cpp | 8 +- Cantera/src/equil/BasisOptimize.cpp | 75 ++++---- Cantera/src/equil/ChemEquil.cpp | 35 ++-- Cantera/src/equil/ChemEquil.h | 6 +- Cantera/src/equil/MultiPhase.cpp | 26 ++- Cantera/src/equil/MultiPhase.h | 20 +- Cantera/src/equil/MultiPhaseEquil.cpp | 4 +- Cantera/src/equil/MultiPhaseEquil.h | 2 +- Cantera/src/equil/vcs_DoubleStarStar.cpp | 34 ++-- Cantera/src/equil/vcs_DoubleStarStar.h | 16 +- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 41 ++--- Cantera/src/equil/vcs_SpeciesProperties.cpp | 4 +- Cantera/src/equil/vcs_SpeciesProperties.h | 2 +- Cantera/src/equil/vcs_VolPhase.cpp | 61 +++--- Cantera/src/equil/vcs_VolPhase.h | 46 ++--- Cantera/src/equil/vcs_elem_rearrange.cpp | 2 +- Cantera/src/equil/vcs_internal.h | 2 +- Cantera/src/equil/vcs_prep.cpp | 4 +- Cantera/src/equil/vcs_prob.cpp | 6 +- Cantera/src/equil/vcs_prob.h | 16 +- Cantera/src/equil/vcs_util.cpp | 8 +- Cantera/src/kinetics/AqueousKinetics.cpp | 22 +-- Cantera/src/kinetics/AqueousKinetics.h | 8 +- Cantera/src/kinetics/GasKinetics.cpp | 29 ++- Cantera/src/kinetics/GasKinetics.h | 12 +- Cantera/src/kinetics/Group.cpp | 8 +- Cantera/src/kinetics/Group.h | 34 ++-- Cantera/src/kinetics/ImplicitSurfChem.cpp | 56 +++--- Cantera/src/kinetics/ImplicitSurfChem.h | 14 +- Cantera/src/kinetics/InterfaceKinetics.cpp | 111 +++++------ Cantera/src/kinetics/InterfaceKinetics.h | 6 +- Cantera/src/kinetics/Kinetics.cpp | 28 ++- Cantera/src/kinetics/Kinetics.h | 48 ++--- Cantera/src/kinetics/RateCoeffMgr.h | 14 +- Cantera/src/kinetics/ReactionData.h | 4 +- Cantera/src/kinetics/ReactionPath.cpp | 131 ++++++------- Cantera/src/kinetics/ReactionPath.h | 14 +- Cantera/src/kinetics/ReactionStoichMgr.cpp | 47 +++-- Cantera/src/kinetics/ReactionStoichMgr.h | 10 +- Cantera/src/kinetics/RxnRates.h | 2 +- Cantera/src/kinetics/StoichManager.h | 174 +++++++++--------- Cantera/src/kinetics/importKinetics.cpp | 61 +++--- Cantera/src/kinetics/importKinetics.h | 4 +- Cantera/src/kinetics/solveSP.cpp | 4 +- Cantera/src/kinetics/solveSP.h | 2 +- Cantera/src/numerics/sort.cpp | 22 +-- Cantera/src/oneD/boundaries1D.cpp | 3 +- Cantera/src/thermo/ConstCpPoly.cpp | 4 +- Cantera/src/thermo/ConstCpPoly.h | 8 +- Cantera/src/thermo/ConstDensityThermo.cpp | 4 +- Cantera/src/thermo/ConstDensityThermo.h | 4 +- Cantera/src/thermo/DebyeHuckel.cpp | 6 +- Cantera/src/thermo/DebyeHuckel.h | 4 +- Cantera/src/thermo/GeneralSpeciesThermo.cpp | 30 +-- Cantera/src/thermo/GeneralSpeciesThermo.h | 20 +- Cantera/src/thermo/GibbsExcessVPSSTP.cpp | 4 +- Cantera/src/thermo/GibbsExcessVPSSTP.h | 4 +- Cantera/src/thermo/HMWSoln.cpp | 4 +- Cantera/src/thermo/HMWSoln.h | 4 +- Cantera/src/thermo/IdealGasPhase.cpp | 4 +- Cantera/src/thermo/IdealGasPhase.h | 4 +- Cantera/src/thermo/IdealMolalSoln.cpp | 4 +- Cantera/src/thermo/IdealMolalSoln.h | 4 +- Cantera/src/thermo/IdealSolidSolnPhase.cpp | 4 +- Cantera/src/thermo/IdealSolidSolnPhase.h | 4 +- Cantera/src/thermo/IdealSolnGasVPSS.cpp | 4 +- Cantera/src/thermo/IdealSolnGasVPSS.h | 4 +- Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp | 116 ++++++------ Cantera/src/thermo/IonsFromNeutralVPSSTP.h | 18 +- Cantera/src/thermo/LatticePhase.cpp | 4 +- Cantera/src/thermo/LatticePhase.h | 4 +- Cantera/src/thermo/LatticeSolidPhase.cpp | 4 +- Cantera/src/thermo/LatticeSolidPhase.h | 8 +- Cantera/src/thermo/MargulesVPSSTP.cpp | 33 ++-- Cantera/src/thermo/MargulesVPSSTP.h | 4 +- Cantera/src/thermo/MetalPhase.h | 19 +- Cantera/src/thermo/MetalSHEelectrons.cpp | 4 +- Cantera/src/thermo/MetalSHEelectrons.h | 4 +- Cantera/src/thermo/MineralEQ3.cpp | 4 +- Cantera/src/thermo/MineralEQ3.h | 4 +- Cantera/src/thermo/MolalityVPSSTP.cpp | 6 +- Cantera/src/thermo/MolalityVPSSTP.h | 6 +- Cantera/src/thermo/Mu0Poly.cpp | 6 +- Cantera/src/thermo/Mu0Poly.h | 10 +- Cantera/src/thermo/Nasa9Poly1.cpp | 6 +- Cantera/src/thermo/Nasa9Poly1.h | 8 +- .../src/thermo/Nasa9PolyMultiTempRegion.cpp | 6 +- Cantera/src/thermo/Nasa9PolyMultiTempRegion.h | 6 +- Cantera/src/thermo/NasaPoly1.h | 8 +- Cantera/src/thermo/NasaPoly2.h | 8 +- Cantera/src/thermo/NasaThermo.h | 40 ++-- Cantera/src/thermo/PDSS.cpp | 4 +- Cantera/src/thermo/PDSS.h | 6 +- Cantera/src/thermo/PDSS_ConstVol.cpp | 10 +- Cantera/src/thermo/PDSS_ConstVol.h | 10 +- Cantera/src/thermo/PDSS_HKFT.cpp | 12 +- Cantera/src/thermo/PDSS_HKFT.h | 12 +- Cantera/src/thermo/PDSS_IdealGas.cpp | 6 +- Cantera/src/thermo/PDSS_IdealGas.h | 6 +- Cantera/src/thermo/PDSS_IonsFromNeutral.cpp | 50 ++--- Cantera/src/thermo/PDSS_IonsFromNeutral.h | 10 +- Cantera/src/thermo/Phase.cpp | 4 +- Cantera/src/thermo/PseudoBinaryVPSSTP.cpp | 4 +- Cantera/src/thermo/PseudoBinaryVPSSTP.h | 4 +- Cantera/src/thermo/PureFluidPhase.cpp | 2 +- Cantera/src/thermo/ShomatePoly.h | 16 +- Cantera/src/thermo/ShomateThermo.h | 38 ++-- Cantera/src/thermo/SimpleThermo.h | 34 ++-- Cantera/src/thermo/SpeciesThermo.h | 16 +- Cantera/src/thermo/SpeciesThermoFactory.cpp | 22 +-- Cantera/src/thermo/SpeciesThermoFactory.h | 4 +- .../src/thermo/SpeciesThermoInterpType.cpp | 6 +- Cantera/src/thermo/SpeciesThermoInterpType.h | 12 +- Cantera/src/thermo/SpeciesThermoMgr.h | 70 +++---- Cantera/src/thermo/State.cpp | 3 +- Cantera/src/thermo/StoichSubstance.cpp | 4 +- Cantera/src/thermo/StoichSubstance.h | 4 +- Cantera/src/thermo/StoichSubstanceSSTP.cpp | 4 +- Cantera/src/thermo/StoichSubstanceSSTP.h | 4 +- Cantera/src/thermo/SurfPhase.cpp | 17 +- Cantera/src/thermo/SurfPhase.h | 4 +- Cantera/src/thermo/ThermoFactory.cpp | 6 +- Cantera/src/thermo/ThermoFactory.h | 2 +- Cantera/src/thermo/ThermoPhase.cpp | 48 ++--- Cantera/src/thermo/ThermoPhase.h | 10 +- Cantera/src/thermo/VPSSMgr.cpp | 16 +- Cantera/src/thermo/VPSSMgr.h | 12 +- Cantera/src/thermo/VPSSMgr_ConstVol.cpp | 4 +- Cantera/src/thermo/VPSSMgr_ConstVol.h | 2 +- Cantera/src/thermo/VPSSMgr_General.cpp | 6 +- Cantera/src/thermo/VPSSMgr_General.h | 4 +- Cantera/src/thermo/VPSSMgr_IdealGas.cpp | 2 +- Cantera/src/thermo/VPSSMgr_IdealGas.h | 2 +- Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp | 2 +- Cantera/src/thermo/VPSSMgr_Water_ConstVol.h | 2 +- Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp | 2 +- Cantera/src/thermo/VPSSMgr_Water_HKFT.h | 2 +- Cantera/src/thermo/WaterSSTP.cpp | 8 +- Cantera/src/zeroD/ConstPressureReactor.cpp | 4 +- Cantera/src/zeroD/Reactor.cpp | 4 +- 146 files changed, 1135 insertions(+), 1213 deletions(-) diff --git a/Cantera/src/base/ct_defs.h b/Cantera/src/base/ct_defs.h index 6e162c94f..08c360b53 100644 --- a/Cantera/src/base/ct_defs.h +++ b/Cantera/src/base/ct_defs.h @@ -213,7 +213,7 @@ namespace Cantera { /*! * A group of species is a subset of the species in a phase. */ - typedef vector_int group_t; + typedef std::vector group_t; //! typedef for a vector of groups of species. /*! * A grouplist of species is a vector of groups. diff --git a/Cantera/src/converters/CKParser.cpp b/Cantera/src/converters/CKParser.cpp index 77fc0de99..07d6addec 100755 --- a/Cantera/src/converters/CKParser.cpp +++ b/Cantera/src/converters/CKParser.cpp @@ -173,11 +173,11 @@ namespace ckr { removeWhiteSpace(s); // break string into substrings at the '+' characters separating // species symbols - int i, nn; + bool inplus = true; vector pluses; vector sp; - for (i = n-1; i >= 0; i--) { + for (int i = n-1; i >= 0; i--) { if (!inplus && s[i] == '+') { pluses.push_back(i); inplus = true; @@ -187,9 +187,9 @@ namespace ckr { } } pluses.push_back(-1); - int np = pluses.size(); - int loc, nxt; - for (nn = 0; nn < np; nn++) { + size_t np = pluses.size(); + size_t loc, nxt; + for (size_t nn = 0; nn < np; nn++) { loc = pluses.back(); pluses.pop_back(); if (nn == np-1) nxt = s.size(); @@ -197,11 +197,10 @@ namespace ckr { sp.push_back(s.substr(loc+1,nxt-loc-1)); } - int ns = sp.size(); string r, num; - int sz, j, strt=0; + size_t sz, j, strt=0; RxnSpecies ss; - for (nn = 0; nn < ns; nn++) { + for (size_t nn = 0; nn < sp.size(); nn++) { r = sp[nn]; sz = r.size(); for (j = 0; j < sz; j++) { @@ -633,10 +632,10 @@ next: // t1 t2 t3 t4 date // when there are 3 temperature regions // - int nreg = toks.size() - 2; + size_t nreg = toks.size() - 2; if (nreg >= 1) { temp.resize(nreg+1); - for (int i = 0; i <= nreg; i++) { + for (size_t i = 0; i <= nreg; i++) { temp[i] = de_atof(toks[i]); } string defaultDate = toks[nreg+1]; @@ -984,7 +983,6 @@ next: // rxn line //string::size_type eqloc; - int eqloc; string sleft, sright; bool auxDataLine, metaDataLine; @@ -994,14 +992,14 @@ next: // increment the number of reactions, and start processing the // new reaction. - eqloc = s.find_first_of("="); + size_t eqloc = s.find_first_of("="); metaDataLine = false; auxDataLine = false; // look for a metadata line if (s[0] == '%') { metaDataLine = true; - if (eqloc > 0 && eqloc < int(s.size())) { + if (eqloc > 0 && eqloc < s.size()) { int ierr, ierp; vector rg, pg; s[eqloc] = ' '; diff --git a/Cantera/src/converters/CKReader.cpp b/Cantera/src/converters/CKReader.cpp index e05897fcf..397500aac 100755 --- a/Cantera/src/converters/CKReader.cpp +++ b/Cantera/src/converters/CKReader.cpp @@ -354,7 +354,7 @@ bool CKReader::writeReactions(std::ostream& log) { bool CKReader::validateSpecies(std::ostream& log) { int nel = static_cast(elements.size()); int nsp = static_cast(species.size()); - double nm, tol; + double tol; int j, k, m; log << newTask("validating species"); @@ -382,7 +382,7 @@ bool CKReader::validateSpecies(std::ostream& log) { Species& s = species[k]; getMapKeys(s.comp, esyms); - nm = esyms.size(); + size_t nm = esyms.size(); for (m = 0; m < nm; m++) { for (j = 0; j < nel; j++) { diff --git a/Cantera/src/converters/NASA9Parser.cpp b/Cantera/src/converters/NASA9Parser.cpp index 6b329d499..0395bfbdb 100644 --- a/Cantera/src/converters/NASA9Parser.cpp +++ b/Cantera/src/converters/NASA9Parser.cpp @@ -192,8 +192,7 @@ namespace ckr { string s; vector toks; string defaultDate=""; - int nreg = 2; - int i; + size_t nreg = 2; int nsp = static_cast(names.size()); @@ -210,10 +209,10 @@ namespace ckr { if (optionFlag == NoThermoDatabase || optionFlag == HasTempRange) { getCKLine(s, comment); getTokens(s, static_cast(s.size()), toks); - nreg = toks.size(); + size_t nreg = toks.size(); if (nreg >= 1) { temp.resize(nreg+1); - for (i = 0; i <= nreg; i++) { + for (size_t i = 0; i <= nreg; i++) { temp[i] = de_atof(toks[i]); } defaultDate = toks[nreg+1]; @@ -224,7 +223,7 @@ namespace ckr { log.precision(2); log << endl << " Default # of temperature regions: " << nreg << endl; log << " "; - for (i = 0; i <= nreg; i++) { + for (size_t i = 0; i <= nreg; i++) { log << temp[i] << " "; } log << endl; @@ -324,7 +323,7 @@ namespace ckr { // Name of the species string nameid; vector toks; - int nToks = 0; + size_t nToks = 0; // Loop forward until we get to the next nonempty line. do { @@ -343,7 +342,7 @@ namespace ckr { //------------- line 1 --------------------------- // Everything after the first 18 spaces is a comment. - int nt = s.size(); + size_t nt = s.size(); sp.m_commentsRef = s.substr(18, nt-18); // Parse the species name diff --git a/Cantera/src/converters/Species.cpp b/Cantera/src/converters/Species.cpp index 5941cde8f..6053abaed 100644 --- a/Cantera/src/converters/Species.cpp +++ b/Cantera/src/converters/Species.cpp @@ -33,8 +33,7 @@ namespace ckr { } void Species::delR() { - int iReg = region_coeffs.size(); - for (int i = 0; i < iReg; i++) { + for (size_t i = 0; i < region_coeffs.size(); i++) { if (region_coeffs[i]) { delete region_coeffs[i]; region_coeffs[i] = 0; @@ -68,8 +67,7 @@ namespace ckr { lowCoeffs = s.lowCoeffs; highCoeffs = s.highCoeffs; delR(); - int iReg = s.region_coeffs.size(); - for (int i = 0; i < iReg; i++) { + for (size_t i = 0; i < s.region_coeffs.size(); i++) { region_coeffs.push_back(new vector_fp(*(s.region_coeffs[i]))); } minTemps = s.minTemps; diff --git a/Cantera/src/converters/ck2ct.cpp b/Cantera/src/converters/ck2ct.cpp index 638f6d459..104bb585e 100644 --- a/Cantera/src/converters/ck2ct.cpp +++ b/Cantera/src/converters/ck2ct.cpp @@ -139,16 +139,16 @@ namespace pip { const std::vector ®ion_coeffs, const vector_fp &minTemps, const vector_fp &maxTemps) { - int nReg = region_coeffs.size(); - if ((int) minTemps.size() != nReg) { + size_t nReg = region_coeffs.size(); + if (minTemps.size() != nReg) { throw CanteraError("addNASA9", "incompat"); } - if ((int) maxTemps.size() != nReg) { + if (maxTemps.size() != nReg) { throw CanteraError("addNASA9", "incompat"); } fprintf(f," thermo = (\n"); - for (int i = 0; i < nReg; i++) { + for (size_t i = 0; i < nReg; i++) { double minT = minTemps[i]; double maxT = maxTemps[i]; const vector_fp &coeffs = *(region_coeffs[i]); @@ -403,11 +403,10 @@ namespace pip { if (rxn.isDuplicate) { options.push_back("duplicate"); } - int nopt = options.size(); + size_t nopt = options.size(); if (nopt > 0) { fprintf(f, ",\n options = ["); - int n; - for (n = 0; n < nopt; n++) { + for (size_t n = 0; n < nopt; n++) { fprintf(f, "\"%s\"", options[n].c_str()); if (n < nopt-1) fprintf(f, ", "); } diff --git a/Cantera/src/converters/writelog.cpp b/Cantera/src/converters/writelog.cpp index 7eaf8366a..a634f795e 100755 --- a/Cantera/src/converters/writelog.cpp +++ b/Cantera/src/converters/writelog.cpp @@ -83,14 +83,12 @@ namespace ckr { /// print the rate coefficient parameters bool writeRateCoeff(const RateCoeff& k, std::ostream& log) { - log.precision(10); log.width(0); log.flags(ios::uppercase); - int n; bool ok = true; - int nb; + size_t nb; switch (k.type) { @@ -109,7 +107,7 @@ namespace ckr { log <<" A, n, E = (" << k.A << ", " << k.n << ", " << k.E << ") *** JAN *** " << endl; nb = k.b.size(); - for (n = 0; n < nb; n++) { + for (size_t n = 0; n < nb; n++) { log << " b" << n+1 << ": " << k.b[n] << endl; } if (nb != 9) log @@ -121,7 +119,7 @@ namespace ckr { log <<" A, n, E = (" << k.A << ", " << k.n << ", " << k.E << ") *** FIT1 *** " << endl; nb = k.b.size(); - for (n = 0; n < nb; n++) { + for (size_t n = 0; n < nb; n++) { log << " b" << n+1 << ": " << k.b[n] << endl; } if (nb != 9) log diff --git a/Cantera/src/equil/BasisOptimize.cpp b/Cantera/src/equil/BasisOptimize.cpp index 3a1da8df9..4a05a71db 100644 --- a/Cantera/src/equil/BasisOptimize.cpp +++ b/Cantera/src/equil/BasisOptimize.cpp @@ -20,9 +20,9 @@ namespace Cantera { static void print_stringTrunc(const char *str, int space, int alignment); #endif -static int amax(double *x, int j, int n); -static void switch_pos(vector_int &orderVector, int jr, int kspec); -static int mlequ(double *c, int idem, int n, double *b, int m); +static size_t amax(double *x, size_t j, size_t n); +static void switch_pos(std::vector& orderVector, size_t jr, size_t kspec); +static int mlequ(double *c, size_t idem, size_t n, double *b, size_t m); //@{ #ifndef MIN @@ -75,30 +75,30 @@ static int mlequ(double *c, int idem, int n, double *b, int m); * * */ -int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, - MultiPhase *mphase, vector_int & orderVectorSpecies, - vector_int & orderVectorElements, - vector_fp & formRxnMatrix) { +size_t Cantera::BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, + MultiPhase* mphase, std::vector& orderVectorSpecies, + std::vector& orderVectorElements, + vector_fp& formRxnMatrix) { - int j, jj, k=0, kk, l, i, jl, ml; + size_t j, jj, k=0, kk, l, i, jl, ml; bool lindep; std::string ename; std::string sname; /* * Get the total number of elements defined in the multiphase object */ - int ne = mphase->nElements(); + size_t ne = mphase->nElements(); /* * Get the total number of species in the multiphase object */ - int nspecies = mphase->nSpecies(); + size_t nspecies = mphase->nSpecies(); doublereal tmp; doublereal const USEDBEFORE = -1; /* * Perhaps, initialize the element ordering */ - if ((int) orderVectorElements.size() < ne) { + if (orderVectorElements.size() < ne) { orderVectorElements.resize(ne); for (j = 0; j < ne; j++) { orderVectorElements[j] = j; @@ -108,7 +108,7 @@ int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, /* * Perhaps, initialize the species ordering */ - if ((int) orderVectorSpecies.size() != nspecies) { + if (orderVectorSpecies.size() != nspecies) { orderVectorSpecies.resize(nspecies); for (k = 0; k < nspecies; k++) { orderVectorSpecies[k] = k; @@ -158,8 +158,8 @@ int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, * It's equal to the minimum of the number of elements and the * number of total species. */ - int nComponents = MIN(ne, nspecies); - int nNonComponents = nspecies - nComponents; + size_t nComponents = MIN(ne, nspecies); + size_t nNonComponents = nspecies - nComponents; /* * Set this return variable to false */ @@ -177,7 +177,7 @@ int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, vector_fp sm(ne*ne, 0.0); vector_fp ss(ne, 0.0); vector_fp sa(ne, 0.0); - if ((int) formRxnMatrix.size() < nspecies*ne) { + if (formRxnMatrix.size() < nspecies*ne) { formRxnMatrix.resize(nspecies*ne, 0.0); } @@ -189,7 +189,7 @@ int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, #endif - int jr = -1; + size_t jr = -1; /* * Top of a loop of some sort based on the index JR. JR is the * current number of component species found. @@ -367,8 +367,8 @@ int Cantera::BasisOptimize(int *usedZeroedSpecies, bool doFormRxn, * Use Gauss-Jordon block elimination to calculate * the reaction matrix */ - j = mlequ(DATA_PTR(sm), ne, nComponents, DATA_PTR(formRxnMatrix), nNonComponents); - if (j == 1) { + int ierr = mlequ(DATA_PTR(sm), ne, nComponents, DATA_PTR(formRxnMatrix), nNonComponents); + if (ierr == 1) { writelog("ERROR: mlequ returned an error condition\n"); throw CanteraError("basopt", "mlequ returned an error condition"); } @@ -467,16 +467,15 @@ static void print_stringTrunc(const char *str, int space, int alignment) * Finds the location of the maximum component in a double vector * INPUT * x(*) - Vector to search - * j <= i < n : i is the range of indecises to search in X(*) + * j <= i < n : i is the range of indices to search in X(*) * * RETURN * return index of the greatest value on X(*) searched */ -static int amax(double *x, int j, int n) { - int i; - int largest = j; +static size_t amax(double *x, size_t j, size_t n) { + size_t largest = j; double big = x[j]; - for (i = j + 1; i < n; ++i) { + for (size_t i = j + 1; i < n; ++i) { if (x[i] > big) { largest = i; big = x[i]; @@ -486,8 +485,8 @@ static int amax(double *x, int j, int n) { } - static void switch_pos(vector_int &orderVector, int jr, int kspec) { - int kcurr = orderVector[jr]; + static void switch_pos(std::vector& orderVector, size_t jr, size_t kspec) { + size_t kcurr = orderVector[jr]; orderVector[jr] = orderVector[kspec]; orderVector[kspec] = kcurr; } @@ -520,8 +519,8 @@ static int amax(double *x, int j, int n) { * * The solution is returned in the matrix b. */ - static int mlequ(double *c, int idem, int n, double *b, int m) { - int i, j, k, l; + static int mlequ(double *c, size_t idem, size_t n, double *b, size_t m) { + size_t i, j, k, l; double R; /* @@ -603,20 +602,20 @@ static int amax(double *x, int j, int n) { * formular matrix. This guarrantees that BasisOptimize has a * nonsingular matrix to invert. */ -int Cantera::ElemRearrange(int nComponents, const vector_fp & elementAbundances, - MultiPhase *mphase, - vector_int & orderVectorSpecies, - vector_int & orderVectorElements) { - - int j, k, l, i, jl, ml, jr, ielem, jj, kk=0; +size_t Cantera::ElemRearrange(size_t nComponents, const vector_fp & elementAbundances, + MultiPhase *mphase, + std::vector& orderVectorSpecies, + std::vector& orderVectorElements) { + + size_t j, k, l, i, jl, ml, jr, ielem, jj, kk=0; bool lindep = false; - int nelements = mphase->nElements(); + size_t nelements = mphase->nElements(); std::string ename; /* * Get the total number of species in the multiphase object */ - int nspecies = mphase->nSpecies(); + size_t nspecies = mphase->nSpecies(); double test = -1.0E10; #ifdef DEBUG_MODE @@ -631,7 +630,7 @@ int Cantera::ElemRearrange(int nComponents, const vector_fp & elementAbundances, /* * Perhaps, initialize the element ordering */ - if ((int) orderVectorElements.size() < nelements) { + if (orderVectorElements.size() < nelements) { orderVectorElements.resize(nelements); for (j = 0; j < nelements; j++) { orderVectorElements[j] = j; @@ -643,7 +642,7 @@ int Cantera::ElemRearrange(int nComponents, const vector_fp & elementAbundances, * dangerous, as this ordering is assumed to yield the * component species for the problem */ - if ((int) orderVectorSpecies.size() != nspecies) { + if (orderVectorSpecies.size() != nspecies) { orderVectorSpecies.resize(nspecies); for (k = 0; k < nspecies; k++) { orderVectorSpecies[k] = k; @@ -657,7 +656,7 @@ int Cantera::ElemRearrange(int nComponents, const vector_fp & elementAbundances, * end of the element ordering. */ vector_fp eAbund(nelements,0.0); - if ((int) elementAbundances.size() != nelements) { + if (elementAbundances.size() != nelements) { for (j = 0; j < nelements; j++) { eAbund[j] = 0.0; for (k = 0; k < nspecies; k++) { diff --git a/Cantera/src/equil/ChemEquil.cpp b/Cantera/src/equil/ChemEquil.cpp index 314d82df8..0c72630b2 100755 --- a/Cantera/src/equil/ChemEquil.cpp +++ b/Cantera/src/equil/ChemEquil.cpp @@ -350,7 +350,7 @@ namespace Cantera { m_orderVectorElements, formRxnMatrix); for (size_t m = 0; m < m_nComponents; m++) { - int k = m_orderVectorSpecies[m]; + size_t k = m_orderVectorSpecies[m]; m_component[m] = k; if (xMF_est[k] < 1.0E-8) { xMF_est[k] = 1.0E-8; @@ -359,8 +359,8 @@ namespace Cantera { s.setMoleFractions(DATA_PTR(xMF_est)); s.getMoleFractions(DATA_PTR(xMF_est)); - int nct = Cantera::ElemRearrange(m_nComponents, elMolesGoal, mp, - m_orderVectorSpecies, m_orderVectorElements); + size_t nct = Cantera::ElemRearrange(m_nComponents, elMolesGoal, mp, + m_orderVectorSpecies, m_orderVectorElements); if (nct != m_nComponents) { throw CanteraError("ChemEquil::estimateElementPotentials", "confused"); @@ -494,7 +494,6 @@ namespace Cantera { { doublereal xval, yval, tmp; int fail = 0; - int m, im; if (m_p1) delete m_p1; if (m_p2) delete m_p2; @@ -581,8 +580,8 @@ namespace Cantera { xval = m_p1->value(s); yval = m_p2->value(s); - int mm = m_mm; - int nvar = mm + 1; + size_t mm = m_mm; + size_t nvar = mm + 1; DenseMatrix jac(nvar, nvar); // jacobian vector_fp x(nvar, -102.0); // solution vector vector_fp res_trial(nvar, 0.0); // residual @@ -594,8 +593,9 @@ namespace Cantera { * We choose the equation of the element with the highest element * abundance. */ + size_t m; tmp = -1.0; - for (im = 0; im < m_nComponents; im++) { + for (size_t im = 0; im < m_nComponents; im++) { m = m_orderVectorElements[im]; if (elMolesGoal[m] > tmp ) { m_skip = m; @@ -612,7 +612,7 @@ namespace Cantera { // changing the composition at this point only affects the // starting point, not the final solution. vector_fp xmm(m_kk, 0.0); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xmm[k] = s.moleFraction(k) + 1.0E-32; } s.setMoleFractions(DATA_PTR(xmm)); @@ -1115,15 +1115,14 @@ namespace Cantera { if (loglevel > 0) { beginLogGroup("ChemEquil::equilResidual"); } - int n, m; doublereal xx, yy; doublereal temp = exp(x[m_mm]); setToEquilState(s, x, temp); // residuals are the total element moles vector_fp& elmFrac = m_elementmolefracs; - for (n = 0; n < m_mm; n++) { - m = m_orderVectorElements[n]; + for (size_t n = 0; n < m_mm; n++) { + size_t m = m_orderVectorElements[n]; // drive element potential for absent elements to -1000 if (elmFracGoal[m] < m_elemFracCutoff && m != m_eloc) { resid[m] = x[m] + 1000.0; @@ -1320,9 +1319,9 @@ namespace Cantera { s.saveState(state); double tmp, sum; bool modifiedMatrix = false; - int neq = m_mm+1; + size_t neq = m_mm+1; int retn = 1; - int m, n, k, info, im; + size_t m, n, k, im; DenseMatrix a1(neq, neq, 0.0); vector_fp b(neq, 0.0); vector_fp n_i(m_kk,0.0); @@ -1484,7 +1483,7 @@ namespace Cantera { /* * Decide if we are to do a normal step or a modified step */ - int iM = -1; + size_t iM = -1; for (m = 0; m < m_mm; m++) { if (elMoles[m] > 0.001 * elMolesTotal) { if (eMolesCalc[m] > 1000. * elMoles[m]) { @@ -1571,8 +1570,8 @@ namespace Cantera { } #endif for (m = 0; m < m_mm; m++) { - int kMSp = -1; - int kMSp2 = -1; + size_t kMSp = -1; + size_t kMSp2 = -1; int nSpeciesWithElem = 0; for (k = 0; k < m_kk; k++) { if (n_i_calc[k] > nCutoff) { @@ -1815,7 +1814,7 @@ namespace Cantera { #endif try { - info = solve(a1, DATA_PTR(resid)); + int info = solve(a1, DATA_PTR(resid)); } catch (CanteraError) { addLogEntry("estimateEP_Brinkley:Jacobian is singular."); @@ -1904,7 +1903,7 @@ namespace Cantera { * */ void ChemEquil::adjustEloc(thermo_t &s, vector_fp & elMolesGoal) { - if (m_eloc < 0) return; + if (m_eloc == -1) return; if (fabs(elMolesGoal[m_eloc]) > 1.0E-20) return; s.getMoleFractions(DATA_PTR(m_molefractions)); int k; diff --git a/Cantera/src/equil/ChemEquil.h b/Cantera/src/equil/ChemEquil.h index 2f0b09c0d..595c77bd5 100755 --- a/Cantera/src/equil/ChemEquil.h +++ b/Cantera/src/equil/ChemEquil.h @@ -176,7 +176,7 @@ namespace Cantera { * This is equal to the rank of the stoichiometric coefficient * matrix when it is computed. It's initialized to m_mm. */ - int m_nComponents; + size_t m_nComponents; PropertyCalculator *m_p1, *m_p2; @@ -237,8 +237,8 @@ namespace Cantera { bool m_doResPerturb; - vector_int m_orderVectorElements; - vector_int m_orderVectorSpecies; + std::vector m_orderVectorElements; + std::vector m_orderVectorSpecies; }; diff --git a/Cantera/src/equil/MultiPhase.cpp b/Cantera/src/equil/MultiPhase.cpp index e27fe7c6e..e8cdc4a99 100644 --- a/Cantera/src/equil/MultiPhase.cpp +++ b/Cantera/src/equil/MultiPhase.cpp @@ -124,7 +124,7 @@ namespace Cantera { void MultiPhase::init() { if (m_init) return; index_t ip, kp, k = 0, nsp, m; - int mlocal; + size_t mlocal; string sym; // allocate space for the atomic composition matrix @@ -144,7 +144,7 @@ namespace Cantera { nsp = p->nSpecies(); mlocal = p->elementIndex(sym); for (kp = 0; kp < nsp; kp++) { - if (mlocal >= 0) { + if (mlocal != -1) { m_atoms(m, k) = p->nAtoms(kp, mlocal); } if (m == 0) { @@ -224,13 +224,13 @@ namespace Cantera { return sum; } - int MultiPhase::speciesIndex(std::string speciesName, std::string phaseName) { - int p = phaseIndex(phaseName); - if (p < 0) { + size_t MultiPhase::speciesIndex(std::string speciesName, std::string phaseName) { + size_t p = phaseIndex(phaseName); + if (p == -1) { throw CanteraError("MultiPhase::speciesIndex", "phase not found: " + phaseName); } - int k = m_phase[p]->speciesIndex(speciesName); - if (k < 0) { + size_t k = m_phase[p]->speciesIndex(speciesName); + if (k == -1) { throw CanteraError("MultiPhase::speciesIndex", "species not found: " + speciesName); } return m_spstart[p] + k; @@ -374,9 +374,8 @@ namespace Cantera { void MultiPhase::setPhaseMoleFractions(const index_t n, const doublereal* const x) { phase_t* p = m_phase[n]; p->setState_TPX(m_temp, m_press, x); - int nsp = p->nSpecies(); - int istart = m_spstart[n]; - for (int k = 0; k < nsp; k++) { + size_t istart = m_spstart[n]; + for (int k = 0; k < p->nSpecies(); k++) { m_moleFractions[istart+k] = x[k]; } } @@ -385,7 +384,7 @@ namespace Cantera { // species name strings to mole numbers. Mole numbers that are // less than or equal to zero will be set to zero. void MultiPhase::setMolesByName(compositionMap& xMap) { - int kk = nSpecies(); + size_t kk = nSpecies(); doublereal x; vector_fp moles(kk, 0.0); for (int k = 0; k < kk; k++) { @@ -403,8 +402,7 @@ namespace Cantera { // add an entry in the map for every species, with value -1.0. // Function parseCompString (stringUtils.cpp) uses the names // in the map to specify the allowed species. - int kk = nSpecies(); - for (int k = 0; k < kk; k++) { + for (int k = 0; k < nSpecies(); k++) { xx[speciesName(k)] = -1.0; } @@ -904,7 +902,7 @@ namespace Cantera { m_moles[n] = moles; } - int MultiPhase::speciesPhaseIndex(const index_t kGlob) const { + size_t MultiPhase::speciesPhaseIndex(const index_t kGlob) const { return m_spphase[kGlob]; } diff --git a/Cantera/src/equil/MultiPhase.h b/Cantera/src/equil/MultiPhase.h index 01c3c528f..1abe2815a 100644 --- a/Cantera/src/equil/MultiPhase.h +++ b/Cantera/src/equil/MultiPhase.h @@ -238,7 +238,7 @@ namespace Cantera { * If the species or phase name is not recognized, this routine throws * a CanteraError. */ - int speciesIndex(std::string speciesName, std::string phaseName); + size_t speciesIndex(std::string speciesName, std::string phaseName); /// Minimum temperature for which all solution phases have /// valid thermo data. Stoichiometric phases are not @@ -426,7 +426,7 @@ namespace Cantera { * @return * Returns the index of the owning phase. */ - int speciesPhaseIndex(const index_t kGlob) const; + size_t speciesPhaseIndex(const index_t kGlob) const; //! Returns the mole fraction of global species k /*! @@ -758,10 +758,10 @@ namespace Cantera { * * @ingroup equilfunctions */ - int BasisOptimize( int *usedZeroedSpecies, bool doFormRxn, - MultiPhase *mphase, vector_int & orderVectorSpecies, - vector_int & orderVectorElements, - vector_fp & formRxnMatrix); + size_t BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, + MultiPhase* mphase, std::vector& orderVectorSpecies, + std::vector& orderVectorElements, + vector_fp& formRxnMatrix); //! This subroutine handles the potential rearrangement of the constraint //! equations represented by the Formula Matrix. @@ -813,10 +813,10 @@ namespace Cantera { * * @ingroup equilfunctions */ - int ElemRearrange(int nComponents, const vector_fp & elementAbundances, - MultiPhase *mphase, - vector_int & orderVectorSpecies, - vector_int & orderVectorElements); + size_t ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, + MultiPhase* mphase, + std::vector& orderVectorSpecies, + std::vector& orderVectorElements); #ifdef DEBUG_MODE //! External int that is used to turn on debug printing for the diff --git a/Cantera/src/equil/MultiPhaseEquil.cpp b/Cantera/src/equil/MultiPhaseEquil.cpp index f93ea5c3d..3c5a83339 100644 --- a/Cantera/src/equil/MultiPhaseEquil.cpp +++ b/Cantera/src/equil/MultiPhaseEquil.cpp @@ -460,7 +460,7 @@ namespace Cantera { // The left m_nel columns of A are now upper-diagonal. Now // reduce the m_nel columns to diagonal form by back-solving for (m = nRows-1; m > 0; m--) { - for (int n = m-1; n>= 0; n--) { + for (size_t n = m-1; n != -1; n--) { if (m_A(n,m) != 0.0) { fctr = m_A(n,m); for (k = m; k < m_nsp; k++) { @@ -770,7 +770,7 @@ namespace Cantera { psum = 0.0; for (k = 0; k < m_nsp; k++) { kc = m_species[k]; - if (m_mix->speciesPhaseIndex(kc) == (int) ip) { + if (m_mix->speciesPhaseIndex(kc) == ip) { // bug fixed 7/12/06 DGG stoich = nu[k]; // nu[kc]; psum += stoich * stoich; diff --git a/Cantera/src/equil/MultiPhaseEquil.h b/Cantera/src/equil/MultiPhaseEquil.h index d9cac41a0..7dbfcbd6a 100644 --- a/Cantera/src/equil/MultiPhaseEquil.h +++ b/Cantera/src/equil/MultiPhaseEquil.h @@ -40,7 +40,7 @@ namespace Cantera { virtual ~MultiPhaseEquil() {} - int constituent(index_t m) { + size_t constituent(index_t m) { if (m < m_nel) return m_order[m]; else return -1; } diff --git a/Cantera/src/equil/vcs_DoubleStarStar.cpp b/Cantera/src/equil/vcs_DoubleStarStar.cpp index d07c0d731..e06791a31 100644 --- a/Cantera/src/equil/vcs_DoubleStarStar.cpp +++ b/Cantera/src/equil/vcs_DoubleStarStar.cpp @@ -20,14 +20,14 @@ DoubleStarStar::DoubleStarStar() : * Constructor. Create an \c m by \c n array, and initialize * all elements to \c v. */ -DoubleStarStar::DoubleStarStar(int m, int n, double v) : +DoubleStarStar::DoubleStarStar(size_t m, size_t n, double v) : m_nrows(n), m_ncols(m) { m_data.resize(n*m); std::fill(m_data.begin(), m_data.end(), v); m_colAddr.resize(m); - for (int jcol = 0; jcol < m_ncols; jcol++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { m_colAddr[jcol] = &(m_data[jcol*m_nrows]); } } @@ -39,7 +39,7 @@ DoubleStarStar::DoubleStarStar(const DoubleStarStar& y) { m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (int jcol = 0; jcol < m_ncols; jcol++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { m_colAddr[jcol] = &(m_data[jcol*m_nrows]); } } @@ -52,7 +52,7 @@ DoubleStarStar& DoubleStarStar::operator=(const DoubleStarStar& y) { m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (int jcol = 0; jcol < m_ncols; jcol++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { m_colAddr[jcol] = &(m_data[jcol*m_nrows]); } return *this; @@ -65,7 +65,7 @@ DoubleStarStar& DoubleStarStar::operator=(const DoubleStarStar& y) { * @param m This is the number of columns in the new matrix * @param v Default fill value -> defaults to zero. */ -void DoubleStarStar::resize(int m, int n, double v) { +void DoubleStarStar::resize(size_t m, size_t n, double v) { std::vector old_data; bool doCopy = false; if (m_nrows > 0 && m_ncols > 0) { @@ -77,23 +77,23 @@ void DoubleStarStar::resize(int m, int n, double v) { m_data.resize(n*m, v); if (doCopy) { if (n >= m_nrows && m >= m_ncols) { - for (int jcol = 0; jcol < m_ncols; jcol++) { - for (int irow = 0; irow < m_nrows; irow++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + for (size_t irow = 0; irow < m_nrows; irow++) { m_data[jcol*n + irow] = old_data[jcol*m_nrows + irow]; } - for (int irow = m_nrows; irow < n; irow++) { + for (size_t irow = m_nrows; irow < n; irow++) { m_data[jcol*n + irow] = v; } } - for (int jcol = m_ncols; jcol < m; jcol++) { - for (int irow = 0; irow < n; irow++) { + for (size_t jcol = m_ncols; jcol < m; jcol++) { + for (size_t irow = 0; irow < n; irow++) { m_data[jcol*n + irow] = v; } } } else { std::fill(m_data.begin(), m_data.end(), v); - for (int jcol = 0; jcol < m_ncols; jcol++) { - for (int irow = 0; irow < m_nrows; irow++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + for (size_t irow = 0; irow < m_nrows; irow++) { m_data[jcol*n + irow] = old_data[jcol*m_nrows + irow]; } } @@ -102,16 +102,16 @@ void DoubleStarStar::resize(int m, int n, double v) { m_nrows = n; m_ncols = m; m_colAddr.resize(m_ncols); - for (int jcol = 0; jcol < m_ncols; jcol++) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { m_colAddr[jcol] = &(m_data[jcol*m_nrows]); } } -double * const DoubleStarStar::operator[](int jcol) { +double * const DoubleStarStar::operator[](size_t jcol) { return m_colAddr[jcol]; } -const double * const DoubleStarStar::operator[](int jcol) const { +const double * const DoubleStarStar::operator[](size_t jcol) const { return (const double * const) m_colAddr[jcol]; } @@ -124,12 +124,12 @@ double const * const * const DoubleStarStar::constBaseDataAddr() const { } // Number of rows -int DoubleStarStar::nRows() const { +size_t DoubleStarStar::nRows() const { return m_nrows; } // Number of columns -int DoubleStarStar::nColumns() const { +size_t DoubleStarStar::nColumns() const { return m_ncols; } diff --git a/Cantera/src/equil/vcs_DoubleStarStar.h b/Cantera/src/equil/vcs_DoubleStarStar.h index 172140f9a..b5e310689 100644 --- a/Cantera/src/equil/vcs_DoubleStarStar.h +++ b/Cantera/src/equil/vcs_DoubleStarStar.h @@ -41,7 +41,7 @@ public: * @param mcol Number of columns * @param nrow Number of rows */ - DoubleStarStar(int mcol, int nrow, double v = 0.0); + DoubleStarStar(size_t mcol, size_t nrow, double v = 0.0); //! copy constructor /*! @@ -61,7 +61,7 @@ public: * @param ncol This is the number of rows * @param v Default fill value -> defaults to zero. */ - void resize(int mcol, int nrow, double v = 0.0); + void resize(size_t mcol, size_t nrow, double v = 0.0); //! Pointer to the top of the column /*! @@ -69,7 +69,7 @@ public: * * @return returns the pointer to the top of the jth column */ - double * const operator[](int jcol); + double * const operator[](size_t jcol); //! Returns a const Pointer to the top of the jth column /*! @@ -77,7 +77,7 @@ public: * * @return returns the pointer to the top of the jth column */ - const double * const operator[](int jcol) const; + const double * const operator[](size_t jcol) const; //! Returns a double ** pointer to the base address /*! @@ -96,10 +96,10 @@ public: double const * const * const constBaseDataAddr() const; //! Number of rows - int nRows() const; + size_t nRows() const; //! Number of columns - int nColumns() const; + size_t nColumns() const; private: //! Storage area @@ -112,10 +112,10 @@ private: std::vector m_colAddr; //! number of rows - int m_nrows; + size_t m_nrows; //! number of columns - int m_ncols; + size_t m_ncols; }; } diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index f0f48bc3f..7a011a7c5 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -55,17 +55,13 @@ namespace VCSnonideal { m_printLvl(printLvl), m_vsolvePtr(0) { - // Debugging level - - int nsp = mix->nSpecies(); - int nel = mix->nElements(); - int nph = mix->nPhases(); - /* * Create a VCS_PROB object that describes the equilibrium problem. * The constructor just mallocs the necessary objects and sizes them. */ - m_vprob = new VCS_PROB(nsp, nel, nph); + m_vprob = new VCS_PROB(mix->nSpecies(), + mix->nElements(), + mix->nPhases()); m_mix = mix; m_vprob->m_printLvl = m_printLvl; /* @@ -574,11 +570,11 @@ namespace VCSnonideal { int maxit = maxsteps;; clockWC tickTock; - int nsp = m_mix->nSpecies(); - int nel = m_mix->nElements(); - int nph = m_mix->nPhases(); + if (m_vprob == 0) { - m_vprob = new VCS_PROB(nsp, nel, nph); + m_vprob = new VCS_PROB(m_mix->nSpecies(), + m_mix->nElements(), + m_mix->nPhases()); } m_printLvl = printLvl; m_vprob->m_printLvl = printLvl; @@ -652,12 +648,11 @@ namespace VCSnonideal { * states. */ m_mix->uploadMoleFractionsFromPhases(); - int kGlob = 0; + size_t kGlob = 0; for (int ip = 0; ip < m_vprob->NPhase; ip++) { double phaseMole = 0.0; Cantera::ThermoPhase &tref = m_mix->phase(ip); - int nspPhase = tref.nSpecies(); - for (int k = 0; k < nspPhase; k++, kGlob++) { + for (size_t k = 0; k < tref.nSpecies(); k++, kGlob++) { phaseMole += m_vprob->w[kGlob]; } //phaseMole *= 1.0E-3; @@ -913,8 +908,8 @@ namespace VCSnonideal { /* * Calculate the total number of species and phases in the problem */ - int totNumPhases = mphase->nPhases(); - int totNumSpecies = mphase->nSpecies(); + size_t totNumPhases = mphase->nPhases(); + size_t totNumSpecies = mphase->nSpecies(); // Problem type has yet to be worked out. vprob->prob_type = 0; @@ -947,7 +942,7 @@ namespace VCSnonideal { */ iSurPhase = -1; tPhase = &(mphase->phase(iphase)); - int nelem = tPhase->nElements(); + size_t nelem = tPhase->nElements(); /* * Query Cantera for the equation of state type of the @@ -960,7 +955,7 @@ namespace VCSnonideal { /* * Find out the number of species in the phase */ - int nSpPhase = tPhase->nSpecies(); + size_t nSpPhase = tPhase->nSpecies(); /* * Find out the name of the phase */ @@ -1299,8 +1294,8 @@ namespace VCSnonideal { */ int vcs_Cantera_update_vprob(Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob) { - int totNumPhases = mphase->nPhases(); - int kT = 0; + size_t totNumPhases = mphase->nPhases(); + size_t kT = 0; std::vector tmpMoles; // Problem type has yet to be worked out. vprob->prob_type = 0; @@ -1312,7 +1307,7 @@ namespace VCSnonideal { vprob->Vol = mphase->volume(); Cantera::ThermoPhase *tPhase = 0; - for (int iphase = 0; iphase < totNumPhases; iphase++) { + for (size_t iphase = 0; iphase < totNumPhases; iphase++) { tPhase = &(mphase->phase(iphase)); vcs_VolPhase *volPhase = vprob->VPhaseList[iphase]; /* @@ -1327,10 +1322,10 @@ namespace VCSnonideal { /* * Loop through each species in the current phase */ - int nSpPhase = tPhase->nSpecies(); + size_t nSpPhase = tPhase->nSpecies(); // volPhase->TMoles = 0.0; tmpMoles.resize(nSpPhase); - for (int k = 0; k < nSpPhase; k++) { + for (size_t k = 0; k < nSpPhase; k++) { tmpMoles[k] = mphase->speciesMoles(kT); vprob->w[kT] = mphase->speciesMoles(kT); vprob->mf[kT] = mphase->moleFraction(kT); diff --git a/Cantera/src/equil/vcs_SpeciesProperties.cpp b/Cantera/src/equil/vcs_SpeciesProperties.cpp index 3a43c7549..35a3dc12d 100644 --- a/Cantera/src/equil/vcs_SpeciesProperties.cpp +++ b/Cantera/src/equil/vcs_SpeciesProperties.cpp @@ -19,8 +19,8 @@ namespace VCSnonideal { * * constructor(): */ -vcs_SpeciesProperties::vcs_SpeciesProperties(int indexPhase, - int indexSpeciesPhase, +vcs_SpeciesProperties::vcs_SpeciesProperties(size_t indexPhase, + size_t indexSpeciesPhase, vcs_VolPhase *owning) : IndexPhase(indexPhase), IndexSpeciesPhase(indexSpeciesPhase), diff --git a/Cantera/src/equil/vcs_SpeciesProperties.h b/Cantera/src/equil/vcs_SpeciesProperties.h index 793c1dffc..735be0443 100644 --- a/Cantera/src/equil/vcs_SpeciesProperties.h +++ b/Cantera/src/equil/vcs_SpeciesProperties.h @@ -48,7 +48,7 @@ public: /* * constructor and destructor */ - vcs_SpeciesProperties(int indexPhase, int indexSpeciesPhase, + vcs_SpeciesProperties(size_t indexPhase, size_t indexSpeciesPhase, vcs_VolPhase *owning); virtual ~vcs_SpeciesProperties(); diff --git a/Cantera/src/equil/vcs_VolPhase.cpp b/Cantera/src/equil/vcs_VolPhase.cpp index 15c4039db..249215f52 100644 --- a/Cantera/src/equil/vcs_VolPhase.cpp +++ b/Cantera/src/equil/vcs_VolPhase.cpp @@ -156,7 +156,7 @@ namespace VCSnonideal { m_elementNames.resize(b.m_numElemConstraints); - for (int e = 0; e < b.m_numElemConstraints; e++) { + for (size_t e = 0; e < b.m_numElemConstraints; e++) { m_elementNames[e] = b.m_elementNames[e]; } @@ -164,7 +164,7 @@ namespace VCSnonideal { m_elementType = b.m_elementType; m_formulaMatrix.resize(m_numElemConstraints, m_numSpecies, 0.0); - for (int e = 0; e < m_numElemConstraints; e++) { + for (size_t e = 0; e < m_numElemConstraints; e++) { for (int k = 0; k < m_numSpecies; k++) { m_formulaMatrix[e][k] = b.m_formulaMatrix[e][k]; } @@ -241,8 +241,8 @@ namespace VCSnonideal { } /***************************************************************************/ - void vcs_VolPhase::resize(const int phaseNum, const int nspecies, - const int numElem, const char * const phaseName, + void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies, + const size_t numElem, const char * const phaseName, const double molesInert) { #ifdef DEBUG_MODE if (nspecies <= 0) { @@ -301,7 +301,7 @@ namespace VCSnonideal { } } ListSpeciesPtr.resize(nspecies, 0); - for (int i = 0; i < nspecies; i++) { + for (size_t i = 0; i < nspecies; i++) { ListSpeciesPtr[i] = new vcs_SpeciesProperties(phaseNum, i, this); } @@ -335,7 +335,7 @@ namespace VCSnonideal { } /***************************************************************************/ - void vcs_VolPhase::elemResize(const int numElemConstraints) { + void vcs_VolPhase::elemResize(const size_t numElemConstraints) { m_elementNames.resize(numElemConstraints); @@ -376,7 +376,7 @@ namespace VCSnonideal { * return one activity coefficient. Have to recalculate them all to get * one. */ - double vcs_VolPhase::AC_calc_one(int kspec) const { + double vcs_VolPhase::AC_calc_one(size_t kspec) const { if (! m_UpToDate_AC) { _updateActCoeff(); } @@ -647,7 +647,7 @@ namespace VCSnonideal { * Update the electric potential if it is a solution variable * in the equation system */ - if (m_phiVarIndex >= 0) { + if (m_phiVarIndex != -1) { kglob = IndSpecies[m_phiVarIndex]; if (m_numSpecies == 1) { Xmol[m_phiVarIndex] = 1.0; @@ -1095,8 +1095,8 @@ namespace VCSnonideal { setState_TP(Temp, Pres); p_VCS_UnitsFormat = VCS_UNITS_MKS; m_phi = TP_ptr->electricPotential(); - int nsp = TP_ptr->nSpecies(); - int nelem = TP_ptr->nElements(); + size_t nsp = TP_ptr->nSpecies(); + size_t nelem = TP_ptr->nElements(); if (nsp != m_numSpecies) { if (m_numSpecies != 0) { plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, m_numSpecies); @@ -1279,13 +1279,13 @@ namespace VCSnonideal { } /***************************************************************************/ - int vcs_VolPhase::phiVarIndex() const { + size_t vcs_VolPhase::phiVarIndex() const { return m_phiVarIndex; } /***************************************************************************/ - void vcs_VolPhase::setPhiVarIndex(int phiVarIndex) { + void vcs_VolPhase::setPhiVarIndex(size_t phiVarIndex) { m_phiVarIndex = phiVarIndex; m_speciesUnknownType[m_phiVarIndex] = VCS_SPECIES_TYPE_INTERFACIALVOLTAGE; if (m_singleSpecies) { @@ -1302,7 +1302,7 @@ namespace VCSnonideal { * * @param kindex kth species index. */ - vcs_SpeciesProperties * vcs_VolPhase::speciesProperty(const int kindex) { + vcs_SpeciesProperties * vcs_VolPhase::speciesProperty(const size_t kindex) { return ListSpeciesPtr[kindex]; } /***************************************************************************/ @@ -1362,7 +1362,7 @@ namespace VCSnonideal { * @return Returns the VCS_SOLVE species index of the that species * This changes as rearrangements are carried out. */ - int vcs_VolPhase::spGlobalIndexVCS(const int spIndex) const { + size_t vcs_VolPhase::spGlobalIndexVCS(const size_t spIndex) const { return IndSpecies[spIndex]; } /**********************************************************************/ @@ -1375,8 +1375,8 @@ namespace VCSnonideal { * @return Returns the VCS_SOLVE species index of the that species * This changes as rearrangements are carried out. */ - void vcs_VolPhase::setSpGlobalIndexVCS(const int spIndex, - const int spGlobalIndex) { + void vcs_VolPhase::setSpGlobalIndexVCS(const size_t spIndex, + const size_t spGlobalIndex) { IndSpecies[spIndex] = spGlobalIndex; } /**********************************************************************/ @@ -1426,7 +1426,7 @@ namespace VCSnonideal { /**********************************************************************/ // Returns the global index of the local element index for the phase - void vcs_VolPhase::setElemGlobalIndex(const int eLocal, const int eGlobal) { + void vcs_VolPhase::setElemGlobalIndex(const size_t eLocal, const size_t eGlobal) { DebugAssertThrowVCS(eLocal >= 0, "vcs_VolPhase::setElemGlobalIndex"); DebugAssertThrowVCS(eLocal < m_numElemConstraints, "vcs_VolPhase::setElemGlobalIndex"); @@ -1434,12 +1434,12 @@ namespace VCSnonideal { } /**********************************************************************/ - int vcs_VolPhase::nElemConstraints() const { + size_t vcs_VolPhase::nElemConstraints() const { return m_numElemConstraints; } /**********************************************************************/ - std::string vcs_VolPhase::elementName(const int e) const { + std::string vcs_VolPhase::elementName(const size_t e) const { return m_elementNames[e]; } /**********************************************************************/ @@ -1449,8 +1449,7 @@ namespace VCSnonideal { * or not. */ static bool hasChargedSpecies(const Cantera::ThermoPhase * const tPhase) { - int nSpPhase = tPhase->nSpecies(); - for (int k = 0; k < nSpPhase; k++) { + for (size_t k = 0; k < tPhase->nSpecies(); k++) { if (tPhase->charge(k) != 0.0) { return true; } @@ -1477,15 +1476,15 @@ namespace VCSnonideal { } int vcs_VolPhase::transferElementsFM(const Cantera::ThermoPhase * const tPhase) { - int e, k, eT; + size_t e, k, eT; std::string ename; - int eFound = -2; + size_t eFound = -2; /* * */ - int nebase = tPhase->nElements(); - int ne = nebase; - int ns = tPhase->nSpecies(); + size_t nebase = tPhase->nElements(); + size_t ne = nebase; + size_t ns = tPhase->nSpecies(); /* * Decide whether we need an extra element constraint for charge @@ -1503,7 +1502,7 @@ namespace VCSnonideal { elemResize(ne); - if (ChargeNeutralityElement >= 0) { + if (ChargeNeutralityElement != -1) { m_elementType[ChargeNeutralityElement] = VCS_ELEM_TYPE_CHARGENEUTRALITY; } @@ -1611,7 +1610,7 @@ namespace VCSnonideal { /* * @param e Element index. */ - int vcs_VolPhase::elementType(const int e) const { + int vcs_VolPhase::elementType(const size_t e) const { return m_elementType[e]; } /***************************************************************************/ @@ -1621,7 +1620,7 @@ namespace VCSnonideal { * @param e Element index * @param eType type of the element. */ - void vcs_VolPhase::setElementType(const int e, const int eType) { + void vcs_VolPhase::setElementType(const size_t e, const int eType) { m_elementType[e] = eType; } /***************************************************************************/ @@ -1632,12 +1631,12 @@ namespace VCSnonideal { } /***************************************************************************/ - int vcs_VolPhase::speciesUnknownType(const int k) const { + int vcs_VolPhase::speciesUnknownType(const size_t k) const { return m_speciesUnknownType[k]; } /***************************************************************************/ - int vcs_VolPhase::elementActive(const int e) const { + int vcs_VolPhase::elementActive(const size_t e) const { return m_elementActive[e]; } /***************************************************************************/ diff --git a/Cantera/src/equil/vcs_VolPhase.h b/Cantera/src/equil/vcs_VolPhase.h index bea697bcf..d5a11ab62 100644 --- a/Cantera/src/equil/vcs_VolPhase.h +++ b/Cantera/src/equil/vcs_VolPhase.h @@ -140,11 +140,11 @@ namespace VCSnonideal { * @param phaseName String name for the phase * @param molesInert kmoles of inert in the phase (defaults to zero) */ - void resize(const int phaseNum, const int numSpecies, - const int numElem, const char * const phaseName, + void resize(const size_t phaseNum, const size_t numSpecies, + const size_t numElem, const char * const phaseName, const double molesInert = 0.0); - void elemResize(const int numElemConstraints); + void elemResize(const size_t numElemConstraints); //! Evaluate activity coefficients and return the kspec coefficient /*! @@ -153,7 +153,7 @@ namespace VCSnonideal { * * @param kspec species number */ - double AC_calc_one(int kspec) const; + double AC_calc_one(size_t kspec) const; //! Set the moles and/or mole fractions within the phase @@ -434,9 +434,9 @@ namespace VCSnonideal { //! Return the index of the species that represents the //! the voltage of the phase - int phiVarIndex() const; + size_t phiVarIndex() const; - void setPhiVarIndex(int phiVarIndex); + void setPhiVarIndex(size_t phiVarIndex); //! Retrieve the kth Species structure for the species belonging to this phase /*! @@ -444,7 +444,7 @@ namespace VCSnonideal { * * @param kindex kth species index. */ - vcs_SpeciesProperties * speciesProperty(const int kindex); + vcs_SpeciesProperties * speciesProperty(const size_t kindex); //! int indicating whether the phase exists or not /*! @@ -485,7 +485,7 @@ namespace VCSnonideal { * @return Returns the VCS_SOLVE species index of the species. * This changes as rearrangements are carried out. */ - int spGlobalIndexVCS(const int spIndex) const; + size_t spGlobalIndexVCS(const size_t spIndex) const; //! set the Global VCS index of the kth species in the phase @@ -496,7 +496,7 @@ namespace VCSnonideal { * @return Returns the VCS_SOLVE species index of the that species * This changes as rearrangements are carried out. */ - void setSpGlobalIndexVCS(const int spIndex, const int spGlobalIndex); + void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex); //! Sets the total moles of inert in the phase /*! @@ -519,29 +519,29 @@ namespace VCSnonideal { * @param eLocal Local phase element index * @param eGlobal Global phase element index */ - void setElemGlobalIndex(const int eLocal, const int eGlobal); + void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal); //! Returns the number of element constraints - int nElemConstraints() const; + size_t nElemConstraints() const; //! Name of the element constraint with index \c e. /*! * @param e Element index. */ - std::string elementName(const int e) const; + std::string elementName(const size_t e) const; //! Type of the element constraint with index \c e. /*! * @param e Element index. */ - int elementType(const int e) const; + int elementType(const size_t e) const; //! Set the element Type of the element constraint with index \c e. /*! * @param e Element index * @param eType type of the element. */ - void setElementType(const int e, const int eType); + void setElementType(const size_t e, const int eType); //! Transfer all of the element information from the //! ThermoPhase object to the vcs_VolPhase object. @@ -572,10 +572,10 @@ namespace VCSnonideal { * metal electron -> VCS_SPECIES_INTERFACIALVOLTAGE * ( unknown is the interfacial voltage (volts) */ - int speciesUnknownType(const int k) const; + int speciesUnknownType(const size_t k) const; - int elementActive(const int e) const; + int elementActive(const size_t e) const; //! Return the number of species in the phase @@ -670,7 +670,7 @@ namespace VCSnonideal { * miscibility gap, these numbers will stay the * same after the split. */ - int VP_ID; + size_t VP_ID; //! ID of the surface or volume domain in which the //! this phase exists @@ -703,7 +703,7 @@ namespace VCSnonideal { * If it has one. If it does not have a charge neutrality * constraint, then this value is equal to -1 */ - int ChargeNeutralityElement; + size_t ChargeNeutralityElement; //! Units for the chemical potential data, pressure data, volume, //! and species amounts @@ -745,7 +745,7 @@ namespace VCSnonideal { /*! * This is usually equal to the number of elements. */ - int m_numElemConstraints; + size_t m_numElemConstraints; //! vector of strings containing the element constraint names /*! @@ -791,10 +791,10 @@ namespace VCSnonideal { //! Index of the element number in the global list of elements //! storred in VCS_PROB or VCS_SOLVE - std::vector m_elemGlobalIndex; + std::vector m_elemGlobalIndex; //! Number of species in the phase - int m_numSpecies; + size_t m_numSpecies; public: //! String name for the phase @@ -843,7 +843,7 @@ namespace VCSnonideal { * Note, as part of the vcs algorithm, the order of the species * vector is changed during the algorithm */ - std::vector IndSpecies; + std::vector IndSpecies; //! Vector of Species structures for the species belonging to this phase /*! @@ -879,7 +879,7 @@ namespace VCSnonideal { //! If the potential is a solution variable in VCS, it acts as a species. //! This is the species index in the phase for the potential - int m_phiVarIndex; + size_t m_phiVarIndex; //! Total Volume of the phase /*! diff --git a/Cantera/src/equil/vcs_elem_rearrange.cpp b/Cantera/src/equil/vcs_elem_rearrange.cpp index 69753cfd0..790714b17 100644 --- a/Cantera/src/equil/vcs_elem_rearrange.cpp +++ b/Cantera/src/equil/vcs_elem_rearrange.cpp @@ -233,7 +233,7 @@ namespace VCSnonideal { */ for (int iph = 0; iph < m_numPhases; iph++) { volPhase = m_VolPhaseList[iph]; - for (int e = 0; e < volPhase->nElemConstraints(); e++) { + for (size_t e = 0; e < volPhase->nElemConstraints(); e++) { if (volPhase->elemGlobalIndex(e) == ipos) { volPhase->setElemGlobalIndex(e, jpos); } diff --git a/Cantera/src/equil/vcs_internal.h b/Cantera/src/equil/vcs_internal.h index 269520c3f..d91c91a08 100644 --- a/Cantera/src/equil/vcs_internal.h +++ b/Cantera/src/equil/vcs_internal.h @@ -494,7 +494,7 @@ namespace VCSnonideal { * - 1 right aligned * - 2 left aligned */ - void vcs_print_stringTrunc(const char *str, int space, int alignment); + void vcs_print_stringTrunc(const char *str, size_t space, int alignment); //! Simple routine to check whether two doubles are equal up to //! roundoff error diff --git a/Cantera/src/equil/vcs_prep.cpp b/Cantera/src/equil/vcs_prep.cpp index b086e15cd..154816152 100644 --- a/Cantera/src/equil/vcs_prep.cpp +++ b/Cantera/src/equil/vcs_prep.cpp @@ -130,8 +130,8 @@ namespace VCSnonideal { vcs_VolPhase *vPhase = m_VolPhaseList[pID]; vcs_SpeciesProperties *spProp = vPhase->speciesProperty(spPhIndex); double sz = 0.0; - int eSize = spProp->FormulaMatrixCol.size(); - for (int e = 0; e < eSize; e++) { + size_t eSize = spProp->FormulaMatrixCol.size(); + for (size_t e = 0; e < eSize; e++) { sz += fabs(spProp->FormulaMatrixCol[e]); } if (sz > 0.0) { diff --git a/Cantera/src/equil/vcs_prob.cpp b/Cantera/src/equil/vcs_prob.cpp index c4e0818de..09a07811c 100644 --- a/Cantera/src/equil/vcs_prob.cpp +++ b/Cantera/src/equil/vcs_prob.cpp @@ -29,7 +29,7 @@ namespace VCSnonideal { * We initialize the arrays in the structure to the appropriate sizes. * And, we initialize all of the elements of the arrays to defaults. */ - VCS_PROB::VCS_PROB(int nsp, int nel, int nph) : + VCS_PROB::VCS_PROB(size_t nsp, size_t nel, size_t nph) : prob_type(VCS_PROBTYPE_TP), nspecies(nsp), NSPECIES0(0), @@ -357,7 +357,7 @@ namespace VCSnonideal { void VCS_PROB::addPhaseElements(vcs_VolPhase *volPhase) { int e, eVP; int foundPos = -1; - int neVP = volPhase->nElemConstraints(); + size_t neVP = volPhase->nElemConstraints(); std::string en; std::string enVP; /* @@ -430,7 +430,7 @@ namespace VCSnonideal { * */ int VCS_PROB::addOnePhaseSpecies(vcs_VolPhase *volPhase, int k, int kT) { - int e, eVP; + size_t e, eVP; if (kT > nspecies) { /* * Need to expand the number of species here diff --git a/Cantera/src/equil/vcs_prob.h b/Cantera/src/equil/vcs_prob.h index 76f9e61f0..c69af3bd2 100644 --- a/Cantera/src/equil/vcs_prob.h +++ b/Cantera/src/equil/vcs_prob.h @@ -45,23 +45,23 @@ namespace VCSnonideal { int prob_type; //! Total number of species in the problems - int nspecies; + size_t nspecies; //! Species number used to malloc data structures - int NSPECIES0; + size_t NSPECIES0; //! Number of element contraints in the equilibrium problem - int ne; + size_t ne; //! Number of element constraints used to malloc data structures //! involving elements - int NE0; + size_t NE0; //! Number of phases in the problem - int NPhase; + size_t NPhase; //! Number of phases used to malloc data structures - int NPHASE0; + size_t NPHASE0; //! Vector of chemical potentials of the species /*! @@ -185,7 +185,7 @@ namespace VCSnonideal { double tolmin; //! Mapping between the species and the phases - std::vector PhaseID; + std::vector PhaseID; //! Vector of strings containing the species names std::vector SpName; @@ -250,7 +250,7 @@ namespace VCSnonideal { * @param nel number of elements * @param nph number of phases */ - VCS_PROB(int nsp, int nel, int nph); + VCS_PROB(size_t nsp, size_t nel, size_t nph); //! Destructor ~VCS_PROB(); diff --git a/Cantera/src/equil/vcs_util.cpp b/Cantera/src/equil/vcs_util.cpp index 07a5355ab..da8bf9832 100644 --- a/Cantera/src/equil/vcs_util.cpp +++ b/Cantera/src/equil/vcs_util.cpp @@ -110,7 +110,7 @@ namespace VCSnonideal { #endif double vcs_l2norm(const std::vector vec) { - int len = vec.size(); + size_t len = vec.size(); if (len == 0) { return 0.0; } @@ -483,7 +483,7 @@ namespace VCSnonideal { /************************************************************************ **/ - void vcs_print_stringTrunc(const char *str, int space, int alignment) + void vcs_print_stringTrunc(const char *str, size_t space, int alignment) /*********************************************************************** * vcs_print_stringTrunc(): @@ -499,8 +499,8 @@ namespace VCSnonideal { * 2 left aligned ***********************************************************************/ { - int i, ls=0, rs=0; - int len = strlen(str); + size_t i, ls=0, rs=0; + size_t len = strlen(str); if ((len) >= space) { for (i = 0; i < space; i++) { plogf("%c", str[i]); diff --git a/Cantera/src/kinetics/AqueousKinetics.cpp b/Cantera/src/kinetics/AqueousKinetics.cpp index 6e9fc3ac9..005c88afa 100644 --- a/Cantera/src/kinetics/AqueousKinetics.cpp +++ b/Cantera/src/kinetics/AqueousKinetics.cpp @@ -87,8 +87,7 @@ namespace Cantera { thermo().getStandardChemPotentials(&m_grt[0]); fill(m_rkc.begin(), m_rkc.end(), 0.0); - int nsp = thermo().nSpecies(); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < thermo().nSpecies(); k++) { doublereal logStandConc_k = thermo().logStandardConc(k); m_grt[k] -= rt * logStandConc_k; } @@ -120,8 +119,7 @@ namespace Cantera { thermo().getStandardChemPotentials(&m_grt[0]); fill(rkc.begin(), rkc.end(), 0.0); doublereal rt = GasConstant * m_kdata->m_temp; - int nsp = thermo().nSpecies(); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < thermo().nSpecies(); k++) { doublereal logStandConc_k = thermo().logStandardConc(k); m_grt[k] -= rt * logStandConc_k; } @@ -445,18 +443,18 @@ namespace Cantera { m_kdata->m_ropf.push_back(0.0); // extend by one for new rxn m_kdata->m_ropr.push_back(0.0); m_kdata->m_ropnet.push_back(0.0); - int n, ns, m; + size_t n, ns, m; doublereal nsFlt; doublereal reactantGlobalOrder = 0.0; doublereal productGlobalOrder = 0.0; int rnum = reactionNumber(); - vector_int rk; - int nr = r.reactants.size(); + std::vector rk; + size_t nr = r.reactants.size(); for (n = 0; n < nr; n++) { nsFlt = r.rstoich[n]; reactantGlobalOrder += nsFlt; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) { ns = 1; @@ -470,12 +468,12 @@ namespace Cantera { } m_reactants.push_back(rk); - vector_int pk; - int np = r.products.size(); + std::vector pk; + size_t np = r.products.size(); for (n = 0; n < np; n++) { nsFlt = r.pstoich[n]; productGlobalOrder += nsFlt; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((double) ns != nsFlt) { if (ns < 1) { ns = 1; @@ -506,7 +504,7 @@ namespace Cantera { } - void AqueousKinetics::installGroups(int irxn, + void AqueousKinetics::installGroups(size_t irxn, const vector& r, const vector& p) { if (!r.empty()) { diff --git a/Cantera/src/kinetics/AqueousKinetics.h b/Cantera/src/kinetics/AqueousKinetics.h index 8beeac869..41006d2c7 100644 --- a/Cantera/src/kinetics/AqueousKinetics.h +++ b/Cantera/src/kinetics/AqueousKinetics.h @@ -336,7 +336,7 @@ namespace Cantera { protected: - int m_kk, m_nfall; + size_t m_kk, m_nfall; Rate1 m_rates; @@ -346,7 +346,7 @@ namespace Cantera { ReactionStoichMgr* m_rxnstoich; - std::vector m_fwdOrder; + std::vector m_fwdOrder; int m_nirrev; int m_nrev; @@ -378,7 +378,7 @@ namespace Cantera { private: - int reactionNumber(){ return m_ii;} + size_t reactionNumber(){ return m_ii;} std::vector > m_stoich; void addElementaryReaction(const ReactionData& r); @@ -386,7 +386,7 @@ namespace Cantera { void installReagents(const ReactionData& r); - void installGroups(int irxn, const std::vector& r, + void installGroups(size_t irxn, const std::vector& r, const std::vector& p); void updateKc(); diff --git a/Cantera/src/kinetics/GasKinetics.cpp b/Cantera/src/kinetics/GasKinetics.cpp index 5f6fc65ef..31e9c6615 100644 --- a/Cantera/src/kinetics/GasKinetics.cpp +++ b/Cantera/src/kinetics/GasKinetics.cpp @@ -477,10 +477,10 @@ namespace Cantera { // install high and low rate coeff calculators - int iloc = m_falloff_high_rates.install(m_nfall, - r.rateCoeffType, - r.rateCoeffParameters.size(), - &r.rateCoeffParameters[0] ); + size_t iloc = m_falloff_high_rates.install(m_nfall, + r.rateCoeffType, + r.rateCoeffParameters.size(), + &r.rateCoeffParameters[0] ); m_falloff_low_rates.install( m_nfall, r.rateCoeffType, r.auxRateCoeffParameters.size(), @@ -520,7 +520,7 @@ namespace Cantera { void GasKinetics:: addElementaryReaction(const ReactionData& r) { - int iloc; + size_t iloc; // install rate coeff calculator iloc = m_rates.install( reactionNumber(), @@ -538,8 +538,7 @@ namespace Cantera { void GasKinetics:: addThreeBodyReaction(const ReactionData& r) { - - int iloc; + size_t iloc; // install rate coeff calculator iloc = m_rates.install( reactionNumber(), r.rateCoeffType, r.rateCoeffParameters.size(), @@ -562,18 +561,18 @@ namespace Cantera { m_kdata->m_ropf.push_back(0.0); // extend by one for new rxn m_kdata->m_ropr.push_back(0.0); m_kdata->m_ropnet.push_back(0.0); - int n, ns, m; + size_t n, ns, m; doublereal nsFlt; doublereal reactantGlobalOrder = 0.0; doublereal productGlobalOrder = 0.0; - int rnum = reactionNumber(); + size_t rnum = reactionNumber(); - vector_int rk; - int nr = r.reactants.size(); + std::vector rk; + size_t nr = r.reactants.size(); for (n = 0; n < nr; n++) { nsFlt = r.rstoich[n]; reactantGlobalOrder += nsFlt; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) { ns = 1; @@ -587,12 +586,12 @@ namespace Cantera { } m_reactants.push_back(rk); - vector_int pk; - int np = r.products.size(); + std::vector pk; + size_t np = r.products.size(); for (n = 0; n < np; n++) { nsFlt = r.pstoich[n]; productGlobalOrder += nsFlt; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((double) ns != nsFlt) { if (ns < 1) { ns = 1; diff --git a/Cantera/src/kinetics/GasKinetics.h b/Cantera/src/kinetics/GasKinetics.h index 627adbdea..883fe6173 100644 --- a/Cantera/src/kinetics/GasKinetics.h +++ b/Cantera/src/kinetics/GasKinetics.h @@ -339,7 +339,7 @@ namespace Cantera { protected: - int m_kk, m_nfall; + size_t m_kk, m_nfall; array_int m_fallindx; @@ -347,7 +347,7 @@ namespace Cantera { Rate1 m_falloff_high_rates; Rate1 m_rates; - mutable std::map > m_index; + mutable std::map > m_index; FalloffMgr m_falloffn; @@ -358,7 +358,7 @@ namespace Cantera { ReactionStoichMgr* m_rxnstoich; - std::vector m_fwdOrder; + std::vector m_fwdOrder; int m_nirrev; int m_nrev; @@ -391,7 +391,7 @@ namespace Cantera { private: - int reactionNumber(){ return m_ii;} + size_t reactionNumber(){ return m_ii;} std::vector > m_stoich; void addElementaryReaction(const ReactionData& r); @@ -404,8 +404,8 @@ namespace Cantera { const std::vector& p); void updateKc(); - void registerReaction(int rxnNumber, int type, int loc) { - m_index[rxnNumber] = std::pair(type, loc); + void registerReaction(size_t rxnNumber, int type, size_t loc) { + m_index[rxnNumber] = std::pair(type, loc); } bool m_finalized; }; diff --git a/Cantera/src/kinetics/Group.cpp b/Cantera/src/kinetics/Group.cpp index dfcf15156..f03d7a626 100644 --- a/Cantera/src/kinetics/Group.cpp +++ b/Cantera/src/kinetics/Group.cpp @@ -23,14 +23,14 @@ namespace Cantera { */ void Group::validate() { - int n = m_comp.size(); + size_t n = m_comp.size(); // if already checked and not valid, return if (m_sign == -999) return; m_sign = 0; bool ok = true; - for (int m = 0; m < n; m++) + for (size_t m = 0; m < n; m++) { if (m_comp[m] != 0) { @@ -50,8 +50,8 @@ namespace Cantera { s << "("; int nm; bool first = true; - int n = m_comp.size(); - for (int m = 0; m < n; m++) { + size_t n = m_comp.size(); + for (size_t m = 0; m < n; m++) { nm = m_comp[m]; if (nm != 0) { if (!first) s << "-"; diff --git a/Cantera/src/kinetics/Group.h b/Cantera/src/kinetics/Group.h index 9e4797501..32dd6b15d 100644 --- a/Cantera/src/kinetics/Group.h +++ b/Cantera/src/kinetics/Group.h @@ -19,11 +19,18 @@ namespace Cantera { class Group { public: Group() : m_sign(-999) { } - Group(int n) : m_sign(0) { m_comp.resize(n,0);} - Group(const vector_int& elnumbers) : + Group(size_t n) : m_sign(0) { m_comp.resize(n,0);} + Group(const std::vector& elnumbers) : m_comp(elnumbers), m_sign(0) { validate(); } + Group(const std::vector& elnumbers) : + m_comp(elnumbers.size()), m_sign(0) { + for (size_t i = 0; i < elnumbers.size(); i++) { + m_comp[i] = int(elnumbers[i]); + } + validate(); + } Group(const Group& g) : m_comp(g.m_comp), m_sign(g.m_sign) { } Group& operator=(const Group& g) { @@ -40,28 +47,24 @@ namespace Cantera { */ void operator-=(const Group& other) { verifyInputs(*this, other); - int n = m_comp.size(); - for (int m = 0; m < n; m++) + for (size_t m = 0; m < m_comp.size(); m++) m_comp[m] -= other.m_comp[m]; validate(); } void operator+=(const Group& other) { verifyInputs(*this, other); - int n = m_comp.size(); - for (int m = 0; m < n; m++) + for (size_t m = 0; m < m_comp.size(); m++) m_comp[m] += other.m_comp[m]; validate(); } void operator*=(int a) { - int n = m_comp.size(); - for (int m = 0; m < n; m++) + for (size_t m = 0; m < m_comp.size(); m++) m_comp[m] *= a; validate(); } bool operator==(const Group& other) const { verifyInputs(*this, other); - int n = m_comp.size(); - for (int m = 0; m < n; m++) { + for (size_t m = 0; m < m_comp.size(); m++) { if (m_comp[m] != other.m_comp[m]) return false; } return true; @@ -96,17 +99,18 @@ namespace Cantera { bool valid() const { return (m_sign != -999); } bool operator!() const { return (m_sign == -999); } int sign() const { return m_sign; } - int size() const { return m_comp.size(); } + size_t size() const { return m_comp.size(); } /// Number of atoms in the group (>= 0) int nAtoms() const { - int n = m_comp.size(); int sum = 0; - for (int m = 0; m < n; m++) sum += std::abs(m_comp[m]); + for (size_t m = 0; m < m_comp.size(); m++) { + sum += std::abs(m_comp[m]); + } return sum; } /// Number of atoms of element m (positive or negative) - int nAtoms(int m) const { + int nAtoms(size_t m) const { if (m_comp.empty()) return 0; return m_comp[m]; } @@ -117,7 +121,7 @@ namespace Cantera { const Group& g); private: - vector_int m_comp; + std::vector m_comp; int m_sign; }; diff --git a/Cantera/src/kinetics/ImplicitSurfChem.cpp b/Cantera/src/kinetics/ImplicitSurfChem.cpp index 76cb7183c..0a84b3a2a 100644 --- a/Cantera/src/kinetics/ImplicitSurfChem.cpp +++ b/Cantera/src/kinetics/ImplicitSurfChem.cpp @@ -33,12 +33,12 @@ namespace Cantera { m_commonTempPressForPhases(true), m_ioFlag(0) { - m_nsurf = static_cast(k.size()); - int ns, nsp; - int nt, ntmax = 0; - int kinSpIndex = 0; + m_nsurf = k.size(); + size_t ns, nsp; + size_t nt, ntmax = 0; + size_t kinSpIndex = 0; // Loop over the number of surface kinetics objects - for (int n = 0; n < m_nsurf; n++) { + for (size_t n = 0; n < m_nsurf; n++) { InterfaceKinetics *kinPtr = k[n]; m_vecKinPtrs.push_back(kinPtr); ns = k[n]->surfacePhaseIndex(); @@ -55,13 +55,13 @@ namespace Cantera { m_specStartIndex.push_back(kinSpIndex); kinSpIndex += nsp; - int nPhases = kinPtr->nPhases(); + size_t nPhases = kinPtr->nPhases(); vector_int pLocTmp(nPhases); - int imatch = -1; - for (int ip = 0; ip < nPhases; ip++) { + size_t imatch = -1; + for (size_t ip = 0; ip < nPhases; ip++) { if (ip != ns) { ThermoPhase *thPtr = & kinPtr->thermo(ip); - if ((imatch = checkMatch(m_bulkPhases, thPtr)) < 0) { + if ((imatch = checkMatch(m_bulkPhases, thPtr)) == -1) { m_bulkPhases.push_back(thPtr); m_numBulkPhases++; nsp = thPtr->nSpecies(); @@ -122,8 +122,8 @@ namespace Cantera { void ImplicitSurfChem::getInitialConditions(doublereal t0, size_t lenc, doublereal * c) { - int loc = 0; - for (int n = 0; n < m_nsurf; n++) { + size_t loc = 0; + for (size_t n = 0; n < m_nsurf; n++) { m_surf[n]->getCoverages(c + loc); loc += m_nsp[n]; } @@ -168,8 +168,8 @@ namespace Cantera { } void ImplicitSurfChem::updateState(doublereal* c) { - int loc = 0; - for (int n = 0; n < m_nsurf; n++) { + size_t loc = 0; + for (size_t n = 0; n < m_nsurf; n++) { m_surf[n]->setCoverages(c + loc); loc += m_nsp[n]; } @@ -181,17 +181,16 @@ namespace Cantera { void ImplicitSurfChem::eval(doublereal time, doublereal* y, doublereal* ydot, doublereal* p) { - int n; updateState(y); // synchronize the surface state(s) with y doublereal rs0, sum; - int loc, k, kstart; - for (n = 0; n < m_nsurf; n++) { + size_t loc, kstart; + for (size_t n = 0; n < m_nsurf; n++) { rs0 = 1.0/m_surf[n]->siteDensity(); m_vecKinPtrs[n]->getNetProductionRates(DATA_PTR(m_work)); kstart = m_vecKinPtrs[n]->kineticsSpeciesIndex(0,m_surfindex[n]); sum = 0.0; loc = 0; - for (k = 1; k < m_nsp[n]; k++) { + for (size_t k = 1; k < m_nsp[n]; k++) { ydot[k + loc] = m_work[kstart + k] * rs0 * m_surf[n]->size(k); sum -= ydot[k]; } @@ -316,18 +315,17 @@ namespace Cantera { * m_concSpecies[] */ void ImplicitSurfChem::getConcSpecies(doublereal * const vecConcSpecies) const { - int kstart; - for (int ip = 0; ip < m_nsurf; ip++) { + size_t kstart; + for (size_t ip = 0; ip < m_nsurf; ip++) { ThermoPhase * TP_ptr = m_surf[ip]; kstart = m_specStartIndex[ip]; TP_ptr->getConcentrations(vecConcSpecies + kstart); } kstart = m_nv; - for (int ip = 0; ip < m_numBulkPhases; ip++) { + for (size_t ip = 0; ip < m_numBulkPhases; ip++) { ThermoPhase * TP_ptr = m_bulkPhases[ip]; - int nsp = TP_ptr->nSpecies(); TP_ptr->getConcentrations(vecConcSpecies + kstart); - kstart += nsp; + kstart += TP_ptr->nSpecies(); } } @@ -341,18 +339,17 @@ namespace Cantera { * m_concSpecies[] */ void ImplicitSurfChem::setConcSpecies(const doublereal * const vecConcSpecies) { - int kstart; - for (int ip = 0; ip < m_nsurf; ip++) { + size_t kstart; + for (size_t ip = 0; ip < m_nsurf; ip++) { ThermoPhase * TP_ptr = m_surf[ip]; kstart = m_specStartIndex[ip]; TP_ptr->setConcentrations(vecConcSpecies + kstart); } kstart = m_nv; - for (int ip = 0; ip < m_numBulkPhases; ip++) { + for (size_t ip = 0; ip < m_numBulkPhases; ip++) { ThermoPhase * TP_ptr = m_bulkPhases[ip]; - int nsp = TP_ptr->nSpecies(); TP_ptr->setConcentrations(vecConcSpecies + kstart); - kstart += nsp; + kstart += TP_ptr->nSpecies(); } } @@ -367,12 +364,11 @@ namespace Cantera { */ void ImplicitSurfChem:: setCommonState_TP(doublereal TKelvin, doublereal PresPa) { - int nphases = m_nsurf; - for (int ip = 0; ip < nphases; ip++) { + for (size_t ip = 0; ip < m_nsurf; ip++) { ThermoPhase *TP_ptr = m_surf[ip]; TP_ptr->setState_TP(TKelvin, PresPa); } - for (int ip = 0; ip < m_numBulkPhases; ip++) { + for (size_t ip = 0; ip < m_numBulkPhases; ip++) { ThermoPhase *TP_ptr = m_bulkPhases[ip]; TP_ptr->setState_TP(TKelvin, PresPa); } diff --git a/Cantera/src/kinetics/ImplicitSurfChem.h b/Cantera/src/kinetics/ImplicitSurfChem.h index 249e9ab18..797144698 100644 --- a/Cantera/src/kinetics/ImplicitSurfChem.h +++ b/Cantera/src/kinetics/ImplicitSurfChem.h @@ -244,10 +244,10 @@ namespace Cantera { std::vector m_vecKinPtrs; //! Vector of number of species in each Surface Phase - vector_int m_nsp; + std::vector m_nsp; //! index of the surface phase in each InterfaceKinetics object - vector_int m_surfindex; + std::vector m_surfindex; vector_int m_specStartIndex; @@ -258,18 +258,18 @@ namespace Cantera { * as there is a 1-1 correspondence between InterfaceKinetics objects * and surface phases. */ - int m_nsurf; + size_t m_nsurf; //! Total number of surface species in all surface phases /*! * This is the total number of unknowns in m_mode 0 problem */ - int m_nv; + size_t m_nv; - int m_numBulkPhases; + size_t m_numBulkPhases; vector_int m_nspBulkPhases; - int m_numTotalBulkSpecies; - int m_numTotalSpecies; + size_t m_numTotalBulkSpecies; + size_t m_numTotalSpecies; std::vector pLocVec; //! Pointer to the cvode integrator diff --git a/Cantera/src/kinetics/InterfaceKinetics.cpp b/Cantera/src/kinetics/InterfaceKinetics.cpp index 8091d77fc..b4a58abf3 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.cpp +++ b/Cantera/src/kinetics/InterfaceKinetics.cpp @@ -297,22 +297,20 @@ namespace Cantera { * equilibrium constant set to zero. */ void InterfaceKinetics::updateKc() { - int i, irxn; - vector_fp& m_rkc = m_kdata->m_rkcn; fill(m_rkc.begin(), m_rkc.end(), 0.0); //static vector_fp mu(nTotalSpecies()); if (m_nrev > 0) { - int n, nsp, k, ik = 0; + size_t nsp, ik = 0; doublereal rt = GasConstant*thermo(0).temperature(); doublereal rrt = 1.0 / rt; - int np = nPhases(); - for (n = 0; n < np; n++) { + size_t np = nPhases(); + for (size_t n = 0; n < np; n++) { thermo(n).getStandardChemPotentials(DATA_PTR(m_mu0) + m_start[n]); nsp = thermo(n).nSpecies(); - for (k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { m_mu0[ik] -= rt * thermo(n).logStandardConc(k); m_mu0[ik] += Faraday * m_phi[n] * thermo(n).charge(k); ik++; @@ -323,15 +321,15 @@ namespace Cantera { m_rxnstoich.getRevReactionDelta(m_ii, DATA_PTR(m_mu0), DATA_PTR(m_rkc)); - for (i = 0; i < m_nrev; i++) { - irxn = m_revindex[i]; + for (size_t i = 0; i < m_nrev; i++) { + size_t irxn = m_revindex[i]; if (irxn < 0 || irxn >= nReactions()) { throw CanteraError("InterfaceKinetics", - "illegal value: irxn = "+int2str(irxn)); + "illegal value: irxn = "+int2str(int(irxn))); } m_rkc[irxn] = exp(m_rkc[irxn]*rrt); } - for (i = 0; i != m_nirrev; ++i) { + for (size_t i = 0; i != m_nirrev; ++i) { m_rkc[ m_irrev[i] ] = 0.0; } } @@ -350,15 +348,14 @@ namespace Cantera { if (m_nrev > 0) { doublereal rt = GasConstant*thermo(0).temperature(); cout << "T = " << thermo(0).temperature() << " " << rt << endl; - int n, nsp, k, ik=0; + size_t nsp, ik=0; //doublereal rt = GasConstant*thermo(0).temperature(); // doublereal rrt = 1.0/rt; - int np = nPhases(); doublereal delta; - for (n = 0; n < np; n++) { + for (size_t n = 0; n < nPhases(); n++) { thermo(n).getChemPotentials(DATA_PTR(dmu) + m_start[n]); nsp = thermo(n).nSpecies(); - for (k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { delta = Faraday * m_phi[n] * thermo(n).charge(k); //cout << thermo(n).speciesName(k) << " " << (delta+dmu[ik])/rt << " " << dmu[ik]/rt << endl; dmu[ik] += delta; @@ -388,16 +385,14 @@ namespace Cantera { * reversible or not. */ void InterfaceKinetics::getEquilibriumConstants(doublereal* kc) { - int i; - - int n, nsp, k, ik=0; + size_t ik=0; doublereal rt = GasConstant*thermo(0).temperature(); doublereal rrt = 1.0/rt; int np = nPhases(); - for (n = 0; n < np; n++) { + for (size_t n = 0; n < np; n++) { thermo(n).getStandardChemPotentials(DATA_PTR(m_mu0) + m_start[n]); - nsp = thermo(n).nSpecies(); - for (k = 0; k < nsp; k++) { + size_t nsp = thermo(n).nSpecies(); + for (size_t k = 0; k < nsp; k++) { m_mu0[ik] -= rt*thermo(n).logStandardConc(k); m_mu0[ik] += Faraday * m_phi[n] * thermo(n).charge(k); ik++; @@ -408,7 +403,7 @@ namespace Cantera { m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_mu0), kc); - for (i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { kc[i] = exp(-kc[i]*rrt); } } @@ -420,22 +415,20 @@ namespace Cantera { * - m_mu0 * - m_logStandardConc */ - int ik = 0; - int np = nPhases(); + size_t ik = 0; - for (int n = 0; n < np; n++) { + for (size_t n = 0; n < nPhases(); n++) { thermo(n).getStandardChemPotentials(DATA_PTR(m_mu0) + m_start[n]); - int nsp = thermo(n).nSpecies(); - for (int k = 0; k < nsp; k++) { + size_t nsp = thermo(n).nSpecies(); + for (size_t k = 0; k < nsp; k++) { m_StandardConc[ik] = thermo(n).standardConcentration(k); ik++; } } m_rxnstoich.getReactionDelta(m_ii, DATA_PTR(m_mu0), DATA_PTR(m_deltaG0)); - - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { m_ProdStanConcReac[i] = 1.0; } @@ -501,17 +494,11 @@ namespace Cantera { * the correction applied */ void InterfaceKinetics::applyButlerVolmerCorrection(doublereal* const kf) { - int i; - - int n, nsp, k, ik=0; - doublereal rt = GasConstant*thermo(0).temperature(); - doublereal rrt = 1.0/rt; - int np = nPhases(); - // compute the electrical potential energy of each species - for (n = 0; n < np; n++) { - nsp = thermo(n).nSpecies(); - for (k = 0; k < nsp; k++) { + size_t ik = 0; + for (size_t n = 0; n < nPhases(); n++) { + size_t nsp = thermo(n).nSpecies(); + for (size_t k = 0; k < nsp; k++) { m_pot[ik] = Faraday*thermo(n).charge(k)*m_phi[n]; ik++; } @@ -538,7 +525,7 @@ namespace Cantera { #endif int nct = m_beta.size(); int irxn; - for (i = 0; i < nct; i++) { + for (size_t i = 0; i < nct; i++) { irxn = m_ctrxn[i]; eamod = m_beta[i]*m_rwork[irxn]; // if (eamod != 0.0 && m_E[irxn] != 0.0) { @@ -556,6 +543,8 @@ namespace Cantera { } } #endif + doublereal rt = GasConstant*thermo(0).temperature(); + doublereal rrt = 1.0/rt; kf[irxn] *= exp(-eamod*rrt); } } @@ -939,8 +928,8 @@ namespace Cantera { m_rxnPhaseIsReactant.resize(m_ii, 0); m_rxnPhaseIsProduct.resize(m_ii, 0); - int np = nPhases(); - int i = m_ii -1; + size_t np = nPhases(); + size_t i = m_ii - 1; m_rxnPhaseIsReactant[i] = new bool[np]; m_rxnPhaseIsProduct[i] = new bool[np]; @@ -949,35 +938,31 @@ namespace Cantera { m_rxnPhaseIsProduct[i][p] = false; } - const vector_int& vr = reactants(i); - for (int ik = 0; ik < (int) vr.size(); ik++) { - int k = vr[ik]; - int p = speciesPhaseIndex(k); + const std::vector& vr = reactants(i); + for (size_t ik = 0; ik < vr.size(); ik++) { + size_t k = vr[ik]; + size_t p = speciesPhaseIndex(k); m_rxnPhaseIsReactant[i][p] = true; } - const vector_int& vp = products(i); - for (int ik = 0; ik < (int) vp.size(); ik++) { - int k = vp[ik]; - int p = speciesPhaseIndex(k); + const std::vector& vp = products(i); + for (size_t ik = 0; ik < vp.size(); ik++) { + size_t k = vp[ik]; + size_t p = speciesPhaseIndex(k); m_rxnPhaseIsProduct[i][p] = true; } } //==================================================================================================================== void InterfaceKinetics::addElementaryReaction(const ReactionData& r) { - int iloc; - // install rate coeff calculator - vector_fp rp = r.rateCoeffParameters; - int ncov = r.cov.size(); + size_t ncov = r.cov.size(); if (ncov > 3) { m_has_coverage_dependence = true; } - for (int m = 0; m < ncov; m++) { + for (size_t m = 0; m < ncov; m++) { rp.push_back(r.cov[m]); } - // iloc = m_rates.install(reactionNumber(), r.rateCoeffType, rp.size(), DATA_PTR(rp)); - iloc = m_rates.install(reactionNumber(), ARRHENIUS_REACTION_RATECOEFF_TYPE, rp.size(), DATA_PTR(rp)); + size_t iloc = m_rates.install(reactionNumber(), ARRHENIUS_REACTION_RATECOEFF_TYPE, rp.size(), DATA_PTR(rp)); // store activation energy m_E.push_back(r.rateCoeffParameters[2]); @@ -1036,7 +1021,7 @@ namespace Cantera { void InterfaceKinetics::installReagents(const ReactionData& r) { - int n, ns, m; + size_t n, ns, m; doublereal nsFlt; /* * extend temporary storage by one for this rxn. @@ -1059,11 +1044,11 @@ namespace Cantera { // faster method 'multiply' can be used to compute the rate of // progress instead of 'power'. - vector_int rk; - int nr = r.reactants.size(); + std::vector rk; + size_t nr = r.reactants.size(); for (n = 0; n < nr; n++) { nsFlt = r.rstoich[n]; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) ns = 1; } @@ -1084,11 +1069,11 @@ namespace Cantera { * of reactants for the rnum'th reaction */ m_reactants.push_back(rk); - vector_int pk; - int np = r.products.size(); + std::vector pk; + size_t np = r.products.size(); for (n = 0; n < np; n++) { nsFlt = r.pstoich[n]; - ns = (int) nsFlt; + ns = (size_t) nsFlt; if ((doublereal) ns != nsFlt) { if (ns < 1) ns = 1; } diff --git a/Cantera/src/kinetics/InterfaceKinetics.h b/Cantera/src/kinetics/InterfaceKinetics.h index 976ca3a7c..4ed107895 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.h +++ b/Cantera/src/kinetics/InterfaceKinetics.h @@ -563,7 +563,7 @@ namespace Cantera { * vector containing the reaction numbers of irreversible * reactions. */ - std::vector m_irrev; + std::vector m_irrev; //! Stoichiometric manager for the reaction mechanism /*! @@ -575,10 +575,10 @@ namespace Cantera { ReactionStoichMgr m_rxnstoich; //! Number of irreversible reactions in the mechanism - int m_nirrev; + size_t m_nirrev; //! Number of reversible reactions in the mechanism - int m_nrev; + size_t m_nrev; //! m_rrxn is a vector of maps, containing the reactant diff --git a/Cantera/src/kinetics/Kinetics.cpp b/Cantera/src/kinetics/Kinetics.cpp index abff79310..9d8e18317 100644 --- a/Cantera/src/kinetics/Kinetics.cpp +++ b/Cantera/src/kinetics/Kinetics.cpp @@ -130,10 +130,9 @@ namespace Cantera { */ void Kinetics::selectPhase(const doublereal* data, const thermo_t* phase, doublereal* phase_data) { - int n, nsp, np = nPhases(); - for (n = 0; n < np; n++) { + for (size_t n = 0; n < nPhases(); n++) { if (phase == m_thermo[n]) { - nsp = phase->nSpecies(); + size_t nsp = phase->nSpecies(); copy(data + m_start[n], data + m_start[n] + nsp, phase_data); return; @@ -153,9 +152,8 @@ namespace Cantera { * the kinetics manager. If k is out of bounds, the string * "" is returned. */ - string Kinetics::kineticsSpeciesName(int k) const { - int np = m_start.size(); - for (int n = np-1; n >= 0; n--) { + string Kinetics::kineticsSpeciesName(size_t k) const { + for (size_t n = m_start.size()-1; n >= 0; n--) { if (k >= m_start[n]) { return thermo(n).speciesName(k - m_start[n]); } @@ -179,15 +177,15 @@ namespace Cantera { * the value -1 is returned. * - If no match is found in any phase, the value -2 is returned. */ - int Kinetics::kineticsSpeciesIndex(std::string nm, std::string ph) const { - int np = static_cast(m_thermo.size()); - int k; + size_t Kinetics::kineticsSpeciesIndex(std::string nm, std::string ph) const { + size_t np = m_thermo.size(); + size_t k; string id; - for (int n = 0; n < np; n++) { + for (size_t n = 0; n < np; n++) { id = thermo(n).id(); if (ph == id) { k = thermo(n).speciesIndex(nm); - if (k < 0) return -1; + if (k == -1) return -1; return k + m_start[n]; } else if (ph == "") { @@ -209,12 +207,12 @@ namespace Cantera { * Will throw an error if the species string doesn't match. */ thermo_t& Kinetics::speciesPhase(std::string nm) { - int np = static_cast(m_thermo.size()); - int k; + size_t np = m_thermo.size(); + size_t k; string id; - for (int n = 0; n < np; n++) { + for (size_t n = 0; n < np; n++) { k = thermo(n).speciesIndex(nm); - if (k >= 0) return thermo(n); + if (k != -1) return thermo(n); } throw CanteraError("speciesPhase", "unknown species "+nm); return thermo(0); diff --git a/Cantera/src/kinetics/Kinetics.h b/Cantera/src/kinetics/Kinetics.h index f172bf7e1..7e912ac27 100644 --- a/Cantera/src/kinetics/Kinetics.h +++ b/Cantera/src/kinetics/Kinetics.h @@ -194,7 +194,7 @@ namespace Cantera { virtual int type() const; //! Number of reactions in the reaction mechanism. - int nReactions() const {return m_ii;} + size_t nReactions() const {return m_ii;} //@} @@ -210,7 +210,7 @@ namespace Cantera { * always return 1, but for a heterogeneous mechanism it will * return the total number of phases in the mechanism. */ - int nPhases() const { return static_cast(m_thermo.size()); } + size_t nPhases() const { return m_thermo.size(); } /** * Return the phase index of a phase in the list of phases @@ -221,7 +221,7 @@ namespace Cantera { * If a -1 is returned, then the phase is not defined in * the Kinetics object. */ - int phaseIndex(std::string ph) { + size_t phaseIndex(std::string ph) { if (m_phaseindex.find(ph) == m_phaseindex.end()) { return -1; } @@ -261,8 +261,8 @@ namespace Cantera { * * @param n Index of the ThermoPhase being sought. */ - thermo_t& thermo(int n=0) { return *m_thermo[n]; } - const thermo_t& thermo(int n=0) const { return *m_thermo[n]; } + thermo_t& thermo(size_t n=0) { return *m_thermo[n]; } + const thermo_t& thermo(size_t n=0) const { return *m_thermo[n]; } /** * This method returns a reference to the nth ThermoPhase @@ -272,7 +272,7 @@ namespace Cantera { * * @param n Index of the ThermoPhase being sought. */ - thermo_t& phase(int n=0) { + thermo_t& phase(size_t n=0) { deprecatedMethod("Kinetics","phase","thermo"); return *m_thermo[n]; } @@ -284,7 +284,7 @@ namespace Cantera { * * @param n Index of the ThermoPhase being sought. */ - const thermo_t& phase(int n=0) const { + const thermo_t& phase(size_t n=0) const { deprecatedMethod("Kinetics","phase","thermo"); return *m_thermo[n]; } @@ -295,10 +295,10 @@ namespace Cantera { * for use in calls to methods that return the species * production rates, for example. */ - int nTotalSpecies() const { - int n=0, np; + size_t nTotalSpecies() const { + size_t n=0, np; np = nPhases(); - for (int p = 0; p < np; p++) n += thermo(p).nSpecies(); + for (size_t p = 0; p < np; p++) n += thermo(p).nSpecies(); return n; } @@ -309,7 +309,7 @@ namespace Cantera { * @param n Return the index of first species in the nth phase * associated with the reaction mechanism. */ - int start(int n) { + size_t start(size_t n) { deprecatedMethod("Kinetics","start","kineticsSpeciesIndex(0,n)"); return m_start[n]; } @@ -337,7 +337,7 @@ namespace Cantera { * @param k species index * @param n phase index for the species */ - int kineticsSpeciesIndex(int k, int n) const { + size_t kineticsSpeciesIndex(size_t k, size_t n) const { return m_start[n] + k; } @@ -353,7 +353,7 @@ namespace Cantera { * * @param k species index */ - std::string kineticsSpeciesName(int k) const; + std::string kineticsSpeciesName(size_t k) const; /** * This routine will look up a species number based on @@ -372,7 +372,7 @@ namespace Cantera { * @param nm Input string name of the species * @param ph Input string name of the phase. Defaults to "" */ - int kineticsSpeciesIndex(std::string nm, std::string ph = "") const; + size_t kineticsSpeciesIndex(std::string nm, std::string ph = "") const; /** * This function looks up the std::string name of a species and @@ -668,7 +668,7 @@ namespace Cantera { * * @param i reaction index */ - virtual const vector_int& reactants(int i) const { + virtual const std::vector& reactants(int i) const { return m_reactants[i]; } @@ -678,7 +678,7 @@ namespace Cantera { * * @param i reaction index */ - virtual const vector_int& products(int i) const { + virtual const std::vector& products(int i) const { return m_products[i]; } @@ -900,10 +900,10 @@ namespace Cantera { //! Number of reactions in the mechanism - int m_ii; + size_t m_ii; //! Number of species in the species vector for this kinetics operator - int m_nTotalSpecies; + size_t m_nTotalSpecies; /// Vector of perturbation factors for each reaction's rate of /// progress vector. It is initialized to one. @@ -921,7 +921,7 @@ namespace Cantera { * NOTE: These vectors will be wrong if there are real * stoichiometric coefficients in the expression. */ - std::vector m_reactants; + std::vector > m_reactants; /** * This is a vector of vectors containing the products for @@ -934,7 +934,7 @@ namespace Cantera { * NOTE: These vectors will be wrong if there are real * stoichiometric coefficients in the expression. */ - std::vector m_products; + std::vector > m_products; //! m_thermo is a vector of pointers to ThermoPhase //! objects. @@ -959,7 +959,7 @@ namespace Cantera { * for the species vector for the n'th phase in the kinetics * class. */ - vector_int m_start; + std::vector m_start; /** * Mapping of the phase id, i.e., the id attribute in the xml @@ -971,18 +971,18 @@ namespace Cantera { */ std::map m_phaseindex; //! Index of the Kinetics Manager - int m_index; + size_t m_index; /** * Index in the list of phases of the one surface phase. */ - int m_surfphase; + size_t m_surfphase; /** * Index in the list of phases of the one phase where the reactions * occur. */ - int m_rxnphase; + size_t m_rxnphase; /// number of spatial dimensions of lowest-dimensional phase. int m_mindim; diff --git a/Cantera/src/kinetics/RateCoeffMgr.h b/Cantera/src/kinetics/RateCoeffMgr.h index e22386b6a..cfc74b8e8 100644 --- a/Cantera/src/kinetics/RateCoeffMgr.h +++ b/Cantera/src/kinetics/RateCoeffMgr.h @@ -35,8 +35,8 @@ namespace Cantera { * @param m length of coefficient array * @param coefficients */ - int install( int rxnNumber, int rateType, int m, - const doublereal* c ) { + size_t install(size_t rxnNumber, int rateType, size_t m, + const doublereal* c) { /* * Check to see if the current reaction rate type * is the same as the type of this class. If not, @@ -49,11 +49,11 @@ namespace Cantera { // if any coefficient other than the first is non-zero, or // if alwaysComputeRate() is true, install a rate // calculator and return the index of the calculator. - for (int i = 1; i < m; i++) { + for (size_t i = 1; i < m; i++) { if (c[i] != 0.0 || R::alwaysComputeRate() ) { m_rxn.push_back(rxnNumber); m_rates.push_back(R(m, c)); - return static_cast(m_rates.size()) - 1; + return m_rates.size() - 1; } } return -1; @@ -111,7 +111,7 @@ namespace Cantera { protected: std::vector m_rates; - std::vector m_rxn; + std::vector m_rxn; array_fp m_const; // not used }; @@ -128,8 +128,8 @@ namespace Cantera { Rate2(){} virtual ~Rate2(){} - int install( int rxnNumber, int rateType, int m, - const doublereal* c) { + int install(size_t rxnNumber, int rateType, size_t m, + const doublereal* c) { if (rateType == R1::type()) return m_r1.install(rxnNumber, rateType, m, c); else if (rateType == R2::type()) diff --git a/Cantera/src/kinetics/ReactionData.h b/Cantera/src/kinetics/ReactionData.h index 3004b9e6d..0bb0f0b5e 100644 --- a/Cantera/src/kinetics/ReactionData.h +++ b/Cantera/src/kinetics/ReactionData.h @@ -38,8 +38,8 @@ namespace Cantera { int number; int rxn_number; - vector_int reactants; - vector_int products; + std::vector reactants; + std::vector products; vector_fp rorder; vector_fp porder; vector_fp rstoich; diff --git a/Cantera/src/kinetics/ReactionPath.cpp b/Cantera/src/kinetics/ReactionPath.cpp index 2d653e3f0..89c30da93 100644 --- a/Cantera/src/kinetics/ReactionPath.cpp +++ b/Cantera/src/kinetics/ReactionPath.cpp @@ -480,20 +480,19 @@ namespace Cantera { int ReactionPathBuilder::findGroups(ostream& logfile, Kinetics& s) { m_groups.resize(m_nr); - map net; - for (int i = 0; i < m_nr; i++) // loop over reactions + for (size_t i = 0; i < m_nr; i++) // loop over reactions { logfile << endl << "Reaction " << i+1 << ": " << s.reactionString(i); - int nrnet = m_reac[i].size(); - int npnet = m_prod[i].size(); - const vector_int& r = s.reactants(i); - const vector_int& p = s.products(i); + size_t nrnet = m_reac[i].size(); + size_t npnet = m_prod[i].size(); + const std::vector& r = s.reactants(i); + const std::vector& p = s.products(i); - int nr = s.reactants(i).size(); - int np = s.products(i).size(); + size_t nr = s.reactants(i).size(); + size_t np = s.products(i).size(); Group b0, b1, bb; @@ -501,7 +500,6 @@ namespace Cantera { const vector& rgroups = s.reactantGroups(i); const vector& pgroups = s.productGroups(i); - if (m_determinate[i]) { logfile << " ... OK." << endl; @@ -509,27 +507,27 @@ namespace Cantera { else if (rgroups.size() > 0) { logfile << " ... specified groups." << endl; - int nrg = static_cast(rgroups.size()); - int npg = static_cast(pgroups.size()); - int kr, kp, ngrpr, ngrpp; + size_t nrg = rgroups.size(); + size_t npg = pgroups.size(); + size_t kr, kp, ngrpr, ngrpp; Group gr, gp; if (nrg != nr || npg != np) return -1; // loop over reactants - for (int igr = 0; igr < nrg; igr++) { + for (size_t igr = 0; igr < nrg; igr++) { kr = r[igr]; ngrpr = static_cast(rgroups[igr].size()); // loop over products - for (int igp = 0; igp < npg; igp++) { + for (size_t igp = 0; igp < npg; igp++) { kp = p[igp]; ngrpp = static_cast(pgroups[igp].size()); // loop over pairs of reactant and product groups - for (int kgr = 0; kgr < ngrpr; kgr++) { + for (size_t kgr = 0; kgr < ngrpr; kgr++) { gr = Group(rgroups[igr][kgr]); - for (int kgp = 0; kgp < ngrpp; kgp++) { + for (size_t kgp = 0; kgp < ngrpp; kgp++) { gp = Group(pgroups[igp][kgp]); if (gr == gp) { m_transfer[i][kr][kp] = gr; @@ -543,12 +541,12 @@ namespace Cantera { else if (nrnet == 2 && npnet == 2) { // indices for the two reactants - int kr0 = m_reac[i][0]; - int kr1 = m_reac[i][1]; + size_t kr0 = m_reac[i][0]; + size_t kr1 = m_reac[i][1]; // indices for the two products - int kp0 = m_prod[i][0]; - int kp1 = m_prod[i][1]; + size_t kp0 = m_prod[i][0]; + size_t kp1 = m_prod[i][1]; // references to the Group objects representing the // reactants @@ -652,14 +650,13 @@ namespace Cantera { string ename; m_enamemap.clear(); m_nel = 0; - int i, np = kin.nPhases(); + size_t np = kin.nPhases(); ThermoPhase* p; - map enamemap; - for (i = 0; i < np; i++) { + for (size_t i = 0; i < np; i++) { p = &kin.thermo(i); // iterate over the elements in this phase - int m, nel = p->nElements(); - for (m = 0; m < nel; m++) { + size_t nel = p->nElements(); + for (size_t m = 0; m < nel; m++) { ename = p->elementName(m); // if no entry is found for this element name, then @@ -675,18 +672,17 @@ namespace Cantera { } m_atoms.resize(kin.nTotalSpecies(), m_nel, 0.0); string sym; - int k, ip, nsp, mlocal, kp, m; // iterate over the elements - for (m = 0; m < m_nel; m++) { + for (size_t m = 0; m < m_nel; m++) { sym = m_elementSymbols[m]; - k = 0; + size_t k = 0; // iterate over the phases - for (ip = 0; ip < np; ip++) { + for (size_t ip = 0; ip < np; ip++) { phase_t* p = &kin.thermo(ip); - nsp = p->nSpecies(); - mlocal = p->elementIndex(sym); - for (kp = 0; kp < nsp; kp++) { - if (mlocal >= 0) { + size_t nsp = p->nSpecies(); + size_t mlocal = p->elementIndex(sym); + for (size_t kp = 0; kp < nsp; kp++) { + if (mlocal != -1) { m_atoms(k, m) = p->nAtoms(kp, mlocal); } k++; @@ -717,8 +713,8 @@ namespace Cantera { // all reactants / products, even ones appearing on both sides // of the reaction // mod 8/18/01 dgg - vector allProducts; - vector allReactants; + vector > allProducts; + vector > allReactants; for (i = 0; i < m_nr; i++) { allReactants.push_back(kin.reactants(i)); allProducts.push_back(kin.products(i)); @@ -737,9 +733,9 @@ namespace Cantera { m_x.resize(m_ns); // not currently used ? m_elatoms.resize(m_nel, m_nr); - int nr, np, n, k; - int nmol; - map net; + size_t nr, np, n, k; + size_t nmol; + map net; for (i = 0; i < m_nr; i++) { @@ -751,21 +747,21 @@ namespace Cantera { net.clear(); nr = allReactants[i].size(); np = allProducts[i].size(); - for (int ir = 0; ir < nr; ir++) net[allReactants[i][ir]]--; - for (int ip = 0; ip < np; ip++) net[allProducts[i][ip]]++; + for (size_t ir = 0; ir < nr; ir++) net[allReactants[i][ir]]--; + for (size_t ip = 0; ip < np; ip++) net[allProducts[i][ip]]++; for (k = 0; k < m_ns; k++) { if (net[k] < 0) { nmol = -net[k]; - for (int jr = 0; jr < nmol; jr++) m_reac[i].push_back(k); + for (size_t jr = 0; jr < nmol; jr++) m_reac[i].push_back(k); } else if (net[k] > 0) { nmol = net[k]; - for (int jp = 0; jp < nmol; jp++) m_prod[i].push_back(k); + for (size_t jp = 0; jp < nmol; jp++) m_prod[i].push_back(k); } } - int nrnet = m_reac[i].size(); + size_t nrnet = m_reac[i].size(); // int npnet = m_prod[i].size(); // compute number of atoms of each element in each reaction, @@ -775,7 +771,7 @@ namespace Cantera { for (n = 0; n < nrnet; n++) { k = m_reac[i][n]; - for (int m = 0; m < m_nel; m++) { + for (size_t m = 0; m < m_nel; m++) { m_elatoms(m,i) += m_atoms(k,m); //ph.nAtoms(k,m); } } @@ -784,8 +780,7 @@ namespace Cantera { // build species groups vector_int comp(m_nel); m_sgroup.resize(m_ns); - int j; - for (j = 0; j < m_ns; j++) { + for (size_t j = 0; j < m_ns; j++) { for (int m = 0; m < m_nel; m++) comp[m] = int(m_atoms(j,m)); //ph.nAtoms(j,m)); m_sgroup[j] = Group(comp); } @@ -807,11 +802,11 @@ namespace Cantera { for (m = 0; m < m_nel; m++) { nar = 0; nap = 0; - for (j = 0; j < nr; j++) { + for (size_t j = 0; j < nr; j++) { // if (ph.nAtoms(m_reac[i][j],m) > 0) nar++; if (m_atoms(m_reac[i][j],m) > 0) nar++; } - for (j = 0; j < np; j++) { + for (size_t j = 0; j < np; j++) { if (m_atoms(m_prod[i][j],m) > 0) nap++; } if (nar > 1 && nap > 1) { @@ -824,13 +819,12 @@ namespace Cantera { return 1; } - string reactionLabel(int i, int kr, int nr, const vector_int& slist, - const Kinetics& s) { + string reactionLabel(size_t i, size_t kr, size_t nr, + const std::vector& slist, const Kinetics& s) { //int np = s.nPhases(); string label = ""; - int l; - for (l = 0; l < nr; l++) { + for (size_t l = 0; l < nr; l++) { if (l != kr) label += " + "+ s.kineticsSpeciesName(slist[l]); } @@ -845,7 +839,6 @@ namespace Cantera { int ReactionPathBuilder::build(Kinetics& s, string element, ostream& output, ReactionPathDiagram& r, bool quiet) { - int i, nr, np, kr, kp, kkr, kkp; doublereal f, ropf, ropr, fwd, rev; string fwdlabel, revlabel; map warn; @@ -854,13 +847,10 @@ namespace Cantera { bool fwd_incl, rev_incl, force_incl; // const Kinetics::thermo_t& ph = s.thermo(); - int m = m_enamemap[element]-1; //ph.elementIndex(element); + size_t m = m_enamemap[element]-1; //ph.elementIndex(element); r.element = element; if (m < 0) return -1; - - //int k; - int kk = s.nTotalSpecies(); s.getFwdRatesOfProgress(DATA_PTR(m_ropf)); s.getRevRatesOfProgress(DATA_PTR(m_ropr)); @@ -876,17 +866,15 @@ namespace Cantera { // species explicitly included or excluded vector& in_nodes = r.included(); vector& out_nodes = r.excluded(); - int nin = static_cast(in_nodes.size()); - int nout = static_cast(out_nodes.size()); vector_int status; - status.resize(kk,0); - for (int ni = 0; ni < nin; ni++) + status.resize(s.nTotalSpecies(), 0); + for (size_t ni = 0; ni < in_nodes.size(); ni++) status[s.kineticsSpeciesIndex(in_nodes[ni])] = 1; - for (int ne = 0; ne < nout; ne++) + for (size_t ne = 0; ne < out_nodes.size(); ne++) status[s.kineticsSpeciesIndex(out_nodes[ne])] = -1; - for (i = 0; i < m_nr; i++) + for (size_t i = 0; i < m_nr; i++) { ropf = m_ropf[i]; ropr = m_ropr[i]; @@ -894,21 +882,20 @@ namespace Cantera { // loop over reactions involving element m if (m_elatoms(m, i) > 0) { - nr = m_reac[i].size(); - np = m_prod[i].size(); + size_t nr = m_reac[i].size(); + size_t np = m_prod[i].size(); - for (kr = 0; kr < nr; kr++) + for (size_t kr = 0; kr < nr; kr++) { - kkr = m_reac[i][kr]; - int l; + size_t kkr = m_reac[i][kr]; fwdlabel = reactionLabel(i, kr, nr, m_reac[i], s); - for (kp = 0; kp < np; kp++) + for (size_t kp = 0; kp < np; kp++) { - kkp = m_prod[i][kp]; + size_t kkp = m_prod[i][kp]; revlabel = ""; - for (l = 0; l < np; l++) { + for (size_t l = 0; l < np; l++) { if (l != kp) revlabel += " + "+ s.kineticsSpeciesName(m_prod[i][l]); } @@ -938,7 +925,7 @@ namespace Cantera { if ( (m_atoms(kkp,m) < m_elatoms(m, i)) && (m_atoms(kkr,m) < m_elatoms(m, i)) ) { - map >& g = m_transfer[i]; + map >& g = m_transfer[i]; if (g.empty()) { if (!warn[i]) { if (!quiet) { diff --git a/Cantera/src/kinetics/ReactionPath.h b/Cantera/src/kinetics/ReactionPath.h index 3431d8ca7..523f7be2e 100644 --- a/Cantera/src/kinetics/ReactionPath.h +++ b/Cantera/src/kinetics/ReactionPath.h @@ -250,23 +250,23 @@ namespace Cantera { protected: void findElements(Kinetics& kin); - int m_nr; - int m_ns; - int m_nel; + size_t m_nr; + size_t m_ns; + size_t m_nel; vector_fp m_ropf; vector_fp m_ropr; array_fp m_x; - std::vector m_reac; - std::vector m_prod; + std::vector > m_reac; + std::vector > m_prod; DenseMatrix m_elatoms; std::vector > m_groups; std::vector m_sgroup; std::vector m_elementSymbols; // std::map m_warn; - std::map > > m_transfer; + std::map > > m_transfer; std::vector m_determinate; Array2D m_atoms; - std::map m_enamemap; + std::map m_enamemap; }; } diff --git a/Cantera/src/kinetics/ReactionStoichMgr.cpp b/Cantera/src/kinetics/ReactionStoichMgr.cpp index 8f227adff..602724369 100644 --- a/Cantera/src/kinetics/ReactionStoichMgr.cpp +++ b/Cantera/src/kinetics/ReactionStoichMgr.cpp @@ -41,7 +41,8 @@ namespace Cantera { void ReactionStoichMgr:: - add(int rxn, const vector_int& reactants, const vector_int& products, + add(int rxn, const std::vector& reactants, + const std::vector& products, bool reversible) { m_reactants->add(rxn, reactants); @@ -56,15 +57,14 @@ namespace Cantera { void ReactionStoichMgr:: add(int rxn, const ReactionData& r) { - vector_int rk; + std::vector rk; doublereal frac; bool isfrac = false; - int n, ns, m, nr = r.reactants.size(); - for (n = 0; n < nr; n++) { - ns = int(r.rstoich[n]); + for (size_t n = 0; n < r.reactants.size(); n++) { + size_t ns = size_t(r.rstoich[n]); frac = r.rstoich[n] - 1.0*int(r.rstoich[n]); if (frac != 0.0) isfrac = true; - for (m = 0; m < ns; m++) { + for (size_t m = 0; m < ns; m++) { rk.push_back(r.reactants[n]); } } @@ -84,14 +84,13 @@ namespace Cantera { #endif } - vector_int pk; + std::vector pk; isfrac = false; - int np = r.products.size(); - for (n = 0; n < np; n++) { - ns = int(r.pstoich[n]); + for (size_t n = 0; n < r.products.size(); n++) { + size_t ns = size_t(r.pstoich[n]); frac = r.pstoich[n] - 1.0*int(r.pstoich[n]); if (frac != 0.0) isfrac = true; - for (m = 0; m < ns; m++) { + for (size_t m = 0; m < ns; m++) { pk.push_back(r.products[n]); } } @@ -118,7 +117,7 @@ namespace Cantera { } void ReactionStoichMgr:: - getCreationRates(int nsp, const doublereal* ropf, + getCreationRates(size_t nsp, const doublereal* ropf, const doublereal* ropr, doublereal* c) { // zero out the output array fill(c, c + nsp, 0.0); @@ -132,7 +131,7 @@ namespace Cantera { } void ReactionStoichMgr:: - getDestructionRates(int nsp, const doublereal* ropf, + getDestructionRates(size_t nsp, const doublereal* ropf, const doublereal* ropr, doublereal* d) { fill(d, d + nsp, 0.0); // the reverse direction destroys products in reversible reactions @@ -142,7 +141,7 @@ namespace Cantera { } void ReactionStoichMgr:: - getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w) { + getNetProductionRates(size_t nsp, const doublereal* ropnet, doublereal* w) { fill(w, w + nsp, 0.0); // products are created for positive net rate of progress m_revproducts->incrementSpecies(ropnet, w); @@ -196,11 +195,11 @@ namespace Cantera { writeCreationRates(ostream& f) { f << " void getCreationRates(const doublereal* rf, const doublereal* rb," << endl; f << " doublereal* c) {" << endl; - map out; + map out; m_revproducts->writeIncrementSpecies("rf",out); m_irrevproducts->writeIncrementSpecies("rf",out); m_reactants->writeIncrementSpecies("rb",out); - map::iterator b; + map::iterator b; for (b = out.begin(); b != out.end(); ++b) { string rhs = wrapString(b->second); rhs[1] = '='; @@ -213,10 +212,10 @@ namespace Cantera { writeDestructionRates(ostream& f) { f << " void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl; f << " doublereal* d) {" << endl; - map out; + map out; m_revproducts->writeIncrementSpecies("rb",out); m_reactants->writeIncrementSpecies("rf",out); - map::iterator b; + map::iterator b; for (b = out.begin(); b != out.end(); ++b) { string rhs = wrapString(b->second); rhs[1] = '='; @@ -228,11 +227,11 @@ namespace Cantera { void ReactionStoichMgr:: writeNetProductionRates(ostream& f) { f << " void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl; - map out; + map out; m_revproducts->writeIncrementSpecies("r",out); m_irrevproducts->writeIncrementSpecies("r",out); m_reactants->writeDecrementSpecies("r",out); - map::iterator b; + map::iterator b; for (b = out.begin(); b != out.end(); ++b) { string rhs = wrapString(b->second); rhs[1] = '='; @@ -244,9 +243,9 @@ namespace Cantera { void ReactionStoichMgr:: writeMultiplyReactants(ostream& f) { f << " void multiplyReactants(const doublereal* c, doublereal* r) {" << endl; - map out; + map out; m_reactants->writeMultiply("c",out); - map::iterator b; + map::iterator b; for (b = out.begin(); b != out.end(); ++b) { string rhs = b->second; f << " r[" << b->first << "] *= " << rhs << ";" << endl; @@ -257,9 +256,9 @@ namespace Cantera { void ReactionStoichMgr:: writeMultiplyRevProducts(ostream& f) { f << " void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl; - map out; + map out; m_revproducts->writeMultiply("c",out); - map::iterator b; + map::iterator b; for (b = out.begin(); b != out.end(); ++b) { string rhs = b->second; f << " r[" << b->first << "] *= " << rhs << ";" << endl; diff --git a/Cantera/src/kinetics/ReactionStoichMgr.h b/Cantera/src/kinetics/ReactionStoichMgr.h index 624761c21..fca304545 100644 --- a/Cantera/src/kinetics/ReactionStoichMgr.h +++ b/Cantera/src/kinetics/ReactionStoichMgr.h @@ -89,8 +89,8 @@ namespace Cantera { * @param products vector of integer product indices * @param reversible true if the reaction is reversible, false otherwise */ - virtual void add(int rxn, const vector_int& reactants, const vector_int& products, - bool reversible); + virtual void add(int rxn, const std::vector& reactants, + const std::vector& products, bool reversible); /** * Add a reaction with specified, possibly non-integral, reaction orders. @@ -120,7 +120,7 @@ namespace Cantera { * C = N_p Q_f + N_r Q_r. * \f] */ - virtual void getCreationRates(int nSpecies, + virtual void getCreationRates(size_t nSpecies, const doublereal* fwdRatesOfProgress, const doublereal* revRatesOfProgress, doublereal* creationRates); @@ -137,7 +137,7 @@ namespace Cantera { * Note that the stoichiometric coefficient matrices are very sparse, integer * matrices. */ - virtual void getDestructionRates(int nSpecies, + virtual void getDestructionRates(size_t nSpecies, const doublereal* fwdRatesOfProgress, const doublereal* revRatesOfProgress, doublereal* destructionRates); @@ -157,7 +157,7 @@ namespace Cantera { * W = (N_r - N_p) Q_{\rm net}, * \f] */ - virtual void getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w); + virtual void getNetProductionRates(size_t nsp, const doublereal* ropnet, doublereal* w); diff --git a/Cantera/src/kinetics/RxnRates.h b/Cantera/src/kinetics/RxnRates.h index 8fd083287..f2d9d35e7 100644 --- a/Cantera/src/kinetics/RxnRates.h +++ b/Cantera/src/kinetics/RxnRates.h @@ -37,7 +37,7 @@ namespace Cantera { m_A(0.0) {} /// Constructor with Arrhenius parameters specified with an array. - Arrhenius(int csize, const doublereal* c) : + Arrhenius(size_t csize, const doublereal* c) : m_b (c[1]), m_E (c[2]), m_A (c[0]) diff --git a/Cantera/src/kinetics/StoichManager.h b/Cantera/src/kinetics/StoichManager.h index bb68251c7..3fed96142 100644 --- a/Cantera/src/kinetics/StoichManager.h +++ b/Cantera/src/kinetics/StoichManager.h @@ -147,7 +147,7 @@ namespace Cantera { return 0.0; } - inline static std::string fmt(std::string r, int n) { return r + "[" + int2str(n) + "]"; } + inline static std::string fmt(std::string r, size_t n) { return r + "[" + int2str(int(n)) + "]"; } /** @@ -159,10 +159,10 @@ namespace Cantera { public: - C1( int rxn = 0, int ic0 = 0) + C1(size_t rxn = 0, size_t ic0 = 0) : m_rxn (rxn), m_ic0 (ic0) {} - int data(std::vector& ic) { + size_t data(std::vector& ic) { ic.resize(1); ic[0] = m_ic0; return m_rxn; @@ -188,31 +188,31 @@ namespace Cantera { R[m_rxn] -= S[m_ic0]; } - int rxnNumber() const { return m_rxn; } - int speciesIndex(int n) const { return m_ic0; } - int nSpecies() { return 1;} + size_t rxnNumber() const { return m_rxn; } + size_t speciesIndex(size_t n) const { return m_ic0; } + size_t nSpecies() { return 1;} - void writeMultiply(std::string r, std::map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0); } - void writeIncrementReaction(std::string r, std::map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0); } - void writeDecrementReaction(std::string r, std::map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0); } - void writeIncrementSpecies(std::string r, std::map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { out[m_ic0] += " + "+fmt(r, m_rxn); } - void writeDecrementSpecies(std::string r, std::map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { out[m_ic0] += " - "+fmt(r, m_rxn); } private: - int m_rxn; - int m_ic0; + size_t m_rxn; + size_t m_ic0; }; @@ -223,10 +223,10 @@ namespace Cantera { */ class C2 { public: - C2( int rxn = 0, int ic0 = 0, int ic1 = 0) + C2(size_t rxn = 0, size_t ic0 = 0, size_t ic1 = 0) : m_rxn (rxn), m_ic0 (ic0), m_ic1 (ic1) {} - int data(std::vector& ic) { + int data(std::vector& ic) { ic.resize(2); ic[0] = m_ic0; ic[1] = m_ic1; @@ -255,26 +255,26 @@ namespace Cantera { R[m_rxn] -= (S[m_ic0] + S[m_ic1]); } - int rxnNumber() const { return m_rxn; } - int speciesIndex(int n) const { return (n == 0 ? m_ic0 : m_ic1); } - int nSpecies() { return 2;} + size_t rxnNumber() const { return m_rxn; } + size_t speciesIndex(size_t n) const { return (n == 0 ? m_ic0 : m_ic1); } + size_t nSpecies() { return 2;} - void writeMultiply(std::string r, std::map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1); } - void writeIncrementReaction(std::string r, std::map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1); } - void writeDecrementReaction(std::string r, std::map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1); } - void writeIncrementSpecies(std::string r, std::map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { std::string s = " + "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; } - void writeDecrementSpecies(std::string r, std::map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { std::string s = " - "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; @@ -285,13 +285,13 @@ namespace Cantera { /** * Reaction index -> index into the ROP vector */ - int m_rxn; + size_t m_rxn; /** * Species indecise -> index into the species vector for the * two species. */ - int m_ic0, m_ic1; + size_t m_ic0, m_ic1; }; @@ -301,10 +301,10 @@ namespace Cantera { */ class C3 { public: - C3( int rxn = 0, int ic0 = 0, int ic1 = 0, int ic2 = 0) + C3(size_t rxn = 0, size_t ic0 = 0, size_t ic1 = 0, size_t ic2 = 0) : m_rxn (rxn), m_ic0 (ic0), m_ic1 (ic1), m_ic2 (ic2) {} - int data(std::vector& ic) { + int data(std::vector& ic) { ic.resize(3); ic[0] = m_ic0; ic[1] = m_ic1; @@ -336,33 +336,33 @@ namespace Cantera { R[m_rxn] -= (S[m_ic0] + S[m_ic1] + S[m_ic2]); } - int rxnNumber() const { return m_rxn; } - int speciesIndex(int n) const { return (n == 0 ? m_ic0 : (n == 1 ? m_ic1 : m_ic2)); } - int nSpecies() { return 3;} + size_t rxnNumber() const { return m_rxn; } + size_t speciesIndex(size_t n) const { return (n == 0 ? m_ic0 : (n == 1 ? m_ic1 : m_ic2)); } + size_t nSpecies() { return 3;} - void writeMultiply(std::string r, std::map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1) + " * " + fmt(r, m_ic2); } - void writeIncrementReaction(std::string r, std::map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1)+" + "+fmt(r, m_ic2); } - void writeDecrementReaction(std::string r, std::map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1)+" - "+fmt(r, m_ic2); } - void writeIncrementSpecies(std::string r, std::map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { std::string s = " + "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; out[m_ic2] += s; } - void writeDecrementSpecies(std::string r, std::map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { std::string s = " - "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; out[m_ic2] += s; } private: - int m_rxn, m_ic0, m_ic1, m_ic2; + size_t m_rxn, m_ic0, m_ic1, m_ic2; }; @@ -375,34 +375,33 @@ namespace Cantera { public: C_AnyN() : m_rxn (-1) {} - C_AnyN( int rxn, const vector_int& ic, const vector_fp& order, + C_AnyN(size_t rxn, const std::vector& ic, const vector_fp& order, const vector_fp& stoich) : m_rxn (rxn) { m_n = ic.size(); m_ic.resize(m_n); m_order.resize(m_n); m_stoich.resize(m_n); - for (int n = 0; n < m_n; n++) { + for (size_t n = 0; n < m_n; n++) { m_ic[n] = ic[n]; m_order[n] = order[n]; m_stoich[n] = stoich[n]; } } - int data(std::vector& ic) { + size_t data(std::vector& ic) { ic.resize(m_n); - int n; - for (n = 0; n < m_n; n++) ic[n] = m_ic[n]; + for (size_t n = 0; n < m_n; n++) ic[n] = m_ic[n]; return m_rxn; } - doublereal order(int n) const {return m_order[n];} - doublereal stoich(int n) const {return m_stoich[n];} - int speciesIndex(int n) const {return m_ic[n];} + doublereal order(size_t n) const {return m_order[n];} + doublereal stoich(size_t n) const {return m_stoich[n];} + size_t speciesIndex(size_t n) const {return m_ic[n];} void multiply(const doublereal* input, doublereal* output) const { doublereal oo; - for (int n = 0; n < m_n; n++) { + for (size_t n = 0; n < m_n; n++) { oo = m_order[n]; if (oo != 0.0) { output[m_rxn] *= ppow(input[m_ic[n]], oo); @@ -413,31 +412,30 @@ namespace Cantera { void incrementSpecies(const doublereal* input, doublereal* output) const { doublereal x = input[m_rxn]; - for (int n = 0; n < m_n; n++) output[m_ic[n]] += m_stoich[n]*x; + for (size_t n = 0; n < m_n; n++) output[m_ic[n]] += m_stoich[n]*x; } void decrementSpecies(const doublereal* input, doublereal* output) const { doublereal x = input[m_rxn]; - for (int n = 0; n < m_n; n++) output[m_ic[n]] -= m_stoich[n]*x; + for (size_t n = 0; n < m_n; n++) output[m_ic[n]] -= m_stoich[n]*x; } void incrementReaction(const doublereal* input, doublereal* output) const { - for (int n = 0; n < m_n; n++) output[m_rxn] + for (size_t n = 0; n < m_n; n++) output[m_rxn] += m_stoich[n]*input[m_ic[n]]; } void decrementReaction(const doublereal* input, doublereal* output) const { - for (int n = 0; n < m_n; n++) output[m_rxn] + for (size_t n = 0; n < m_n; n++) output[m_rxn] -= m_stoich[n]*input[m_ic[n]]; } - void writeMultiply(std::string r, std::map& out) { - int n; + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = ""; - for (n = 0; n < m_n; n++) { + for (size_t n = 0; n < m_n; n++) { if (m_order[n] == 1.0) out[m_rxn] += fmt(r, m_ic[n]); else @@ -446,30 +444,26 @@ namespace Cantera { out[m_rxn] += " * "; } } - void writeIncrementReaction(std::string r, std::map& out) { - int n; - for (n = 0; n < m_n; n++) { + void writeIncrementReaction(std::string r, std::map& out) { + for (size_t n = 0; n < m_n; n++) { out[m_rxn] += " + "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]); } } - void writeDecrementReaction(std::string r, std::map& out) { - int n; - for (n = 0; n < m_n; n++) { + void writeDecrementReaction(std::string r, std::map& out) { + for (size_t n = 0; n < m_n; n++) { out[m_rxn] += " - "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]); } } - void writeIncrementSpecies(std::string r, std::map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { std::string s = fmt(r, m_rxn); - int n; - for (n = 0; n < m_n; n++) { + for (size_t n = 0; n < m_n; n++) { out[m_ic[n]] += " + "+fp2str(m_stoich[n]) + "*" + s; } } - void writeDecrementSpecies(std::string r, std::map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { std::string s = fmt(r, m_rxn); - int n; - for (n = 0; n < m_n; n++) { + for (size_t n = 0; n < m_n; n++) { out[m_ic[n]] += " - "+fp2str(m_stoich[n]) + "*" + s; } } @@ -481,13 +475,13 @@ namespace Cantera { * This is the number of species which have non-zero entries in either the * reaction order matrix or the stoichiometric order matrix for this reaction. */ - int m_n; + size_t m_n; //! ID of the reaction corresponding to this stoichiometric manager /*! * This is used within the interface to select the */ - int m_rxn; + size_t m_rxn; //! Vector of species which are involved with this stoichiometric manager calculations /*! @@ -495,7 +489,7 @@ namespace Cantera { * reaction order matrix or the stoichiometric order matrix for this reaction, m_rxn. * It's used as the index into the arrays m_order[] and m_stoich[]. */ - vector_int m_ic; + std::vector m_ic; vector_fp m_order; vector_fp m_stoich; }; @@ -539,31 +533,31 @@ namespace Cantera { template inline static void _writeIncrementSpecies(InputIter begin, InputIter end, std::string r, - std::map& out) { + std::map& out) { for (; begin != end; ++begin) begin->writeIncrementSpecies(r, out); } template inline static void _writeDecrementSpecies(InputIter begin, InputIter end, std::string r, - std::map& out) { + std::map& out) { for (; begin != end; ++begin) begin->writeDecrementSpecies(r, out); } template inline static void _writeIncrementReaction(InputIter begin, InputIter end, std::string r, - std::map& out) { + std::map& out) { for (; begin != end; ++begin) begin->writeIncrementReaction(r, out); } template inline static void _writeDecrementReaction(InputIter begin, InputIter end, std::string r, - std::map& out) { + std::map& out) { for (; begin != end; ++begin) begin->writeDecrementReaction(r, out); } template inline static void _writeMultiply(InputIter begin, InputIter end, std::string r, - std::map& out) { + std::map& out) { for (; begin != end; ++begin) begin->writeMultiply(r, out); } @@ -632,13 +626,13 @@ namespace Cantera { * the order of each species in the power list expression is * set to one automatically. */ - void add(int rxn, const vector_int& k) { + void add(size_t rxn, const std::vector& k) { vector_fp order(k.size(), 1.0); vector_fp stoich(k.size(), 1.0); add(rxn, k, order, stoich); } - void add(int rxn, const vector_int& k, const vector_fp& order) { + void add(size_t rxn, const std::vector& k, const vector_fp& order) { vector_fp stoich(k.size(), 1.0); add(rxn, k, order, stoich); } @@ -661,35 +655,33 @@ namespace Cantera { * @param stoich This is used to handle fractional stoichiometric coefficients * on the product side of irreversible reactions. */ - void add(int rxn, const vector_int& k, const vector_fp& order, + void add(size_t rxn, const std::vector& k, const vector_fp& order, const vector_fp& stoich) { - m_n[rxn] = static_cast(k.size()); - int ns = stoich.size(); - int n; + m_n[rxn] = k.size(); bool frac = false; - for (n = 0; n < ns; n++) { + for (size_t n = 0; n < stoich.size(); n++) { if (stoich[n] != 1.0) frac = true; } if (frac) { - m_loc[rxn] = static_cast(m_cn_list.size()); + m_loc[rxn] = m_cn_list.size(); m_cn_list.push_back(C_AnyN(rxn, k, order, stoich)); } else { switch (k.size()) { case 1: - m_loc[rxn] = static_cast(m_c1_list.size()); + m_loc[rxn] = m_c1_list.size(); m_c1_list.push_back(C1(rxn, k[0])); break; case 2: - m_loc[rxn] = static_cast(m_c2_list.size()); + m_loc[rxn] = m_c2_list.size(); m_c2_list.push_back(C2(rxn, k[0], k[1])); break; case 3: - m_loc[rxn] = static_cast(m_c3_list.size()); + m_loc[rxn] = m_c3_list.size(); m_c3_list.push_back(C3(rxn, k[0], k[1], k[2])); break; default: - m_loc[rxn] = static_cast(m_cn_list.size()); + m_loc[rxn] = m_cn_list.size(); m_cn_list.push_back(C_AnyN(rxn, k, order, stoich)); } } @@ -730,35 +722,35 @@ namespace Cantera { _decrementReactions(m_cn_list.begin(), m_cn_list.end(), input, output); } - void writeIncrementSpecies(std::string r, std::map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { _writeIncrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out); _writeIncrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out); _writeIncrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out); _writeIncrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeDecrementSpecies(std::string r, std::map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { _writeDecrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out); _writeDecrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out); _writeDecrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out); _writeDecrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeIncrementReaction(std::string r, std::map& out) { + void writeIncrementReaction(std::string r, std::map& out) { _writeIncrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out); _writeIncrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out); _writeIncrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out); _writeIncrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeDecrementReaction(std::string r, std::map& out) { + void writeDecrementReaction(std::string r, std::map& out) { _writeDecrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out); _writeDecrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out); _writeDecrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out); _writeDecrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeMultiply(std::string r, std::map& out) { + void writeMultiply(std::string r, std::map& out) { _writeMultiply(m_c1_list.begin(), m_c1_list.end(), r, out); _writeMultiply(m_c2_list.begin(), m_c2_list.end(), r, out); _writeMultiply(m_c3_list.begin(), m_c3_list.end(), r, out); @@ -776,12 +768,12 @@ namespace Cantera { * Std::Mapping with the Reaction Number as key and the Number of species * as the value. */ - std::map m_n; + std::map m_n; /** * Std::Mapping with the Reaction Number as key and the placement in the * vector of reactions list( i.e., m_c1_list[]) as key */ - std::map m_loc; + std::map m_loc; }; #undef INCL_STOICH_WRITER diff --git a/Cantera/src/kinetics/importKinetics.cpp b/Cantera/src/kinetics/importKinetics.cpp index 035ba5225..1ec432865 100644 --- a/Cantera/src/kinetics/importKinetics.cpp +++ b/Cantera/src/kinetics/importKinetics.cpp @@ -84,7 +84,6 @@ namespace Cantera { */ void checkRxnElementBalance(Kinetics& kin, const ReactionData &rdata, doublereal errorTolerance) { - int index, klocal, n, kp, kr, m, nel; doublereal kstoich; map bal, balr, balp; @@ -92,17 +91,16 @@ namespace Cantera { balp.clear(); balr.clear(); //cout << "checking " << rdata.equation << endl; - int np = rdata.products.size(); + size_t np = rdata.products.size(); // iterate over the products - for (index = 0; index < np; index++) { - kp = rdata.products[index]; // index of the product in 'kin' - n = kin.speciesPhaseIndex(kp); // phase this product belongs to - klocal = kp - kin.kineticsSpeciesIndex(0,n); // index within this phase + for (size_t index = 0; index < np; index++) { + size_t kp = rdata.products[index]; // index of the product in 'kin' + size_t n = kin.speciesPhaseIndex(kp); // phase this product belongs to + size_t klocal = kp - kin.kineticsSpeciesIndex(0,n); // index within this phase kstoich = rdata.pstoich[index]; // product stoichiometric coeff const ThermoPhase& ph = kin.speciesPhase(kp); - nel = ph.nElements(); - for (m = 0; m < nel; m++) { + for (size_t m = 0; m < ph.nElements(); m++) { bal[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); balp[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); //cout << "product species " << ph.speciesName(klocal) << " has " << ph.nAtoms(klocal,m) @@ -110,15 +108,14 @@ namespace Cantera { } } int nr = rdata.reactants.size(); - for (index = 0; index < nr; index++) { - kr = rdata.reactants[index]; - n = kin.speciesPhaseIndex(kr); + for (size_t index = 0; index < nr; index++) { + size_t kr = rdata.reactants[index]; + size_t n = kin.speciesPhaseIndex(kr); //klocal = kr - kin.start(n); - klocal = kr - kin.kineticsSpeciesIndex(0,n); + size_t klocal = kr - kin.kineticsSpeciesIndex(0,n); kstoich = rdata.rstoich[index]; const ThermoPhase& ph = kin.speciesPhase(kr); - nel = ph.nElements(); - for (m = 0; m < nel; m++) { + for (size_t m = 0; m < ph.nElements(); m++) { bal[ph.elementName(m)] -= kstoich*ph.nAtoms(klocal,m); balr[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); //cout << "reactant species " << ph.speciesName(klocal) << " has " << ph.nAtoms(klocal,m) @@ -179,9 +176,8 @@ namespace Cantera { * and continue. */ bool getReagents(const XML_Node& rxn, kinetics_t& kin, int rp, - std::string default_phase, - vector_int& spnum, vector_fp& stoich, vector_fp& order, - int rule) { + std::string default_phase, std::vector& spnum, + vector_fp& stoich, vector_fp& order, int rule) { string rptype; @@ -203,16 +199,13 @@ namespace Cantera { vector key, val; getPairs(rg, key, val); - int ns = static_cast(key.size()); - /* * Loop over each of the pairs and process them */ - int isp; doublereal ord, stch; string ph, sp; - map speciesMap; - for (int n = 0; n < ns; n++) { + map speciesMap; + for (size_t n = 0; n < key.size(); n++) { sp = key[n]; // sp is the string name for species ph = ""; /* @@ -220,8 +213,8 @@ namespace Cantera { * member function kineticsSpeciesIndex(). We will search * for the species in all phases defined in the kinetics operator. */ - isp = kin.kineticsSpeciesIndex(sp,""); - if (isp < 0) { + size_t isp = kin.kineticsSpeciesIndex(sp,""); + if (isp == -2) { if (rule == 1) return false; else { @@ -257,13 +250,11 @@ namespace Cantera { if (rp == 1 && rxn.hasChild("order")) { vector ord; rxn.getChildren("order",ord); - int norder = static_cast(ord.size()); - int loc; doublereal forder; - for (int nn = 0; nn < norder; nn++) { + for (size_t nn = 0; nn < ord.size(); nn++) { const XML_Node& oo = *ord[nn]; string sp = oo["species"]; - loc = speciesMap[sp]; + size_t loc = speciesMap[sp]; if (loc == 0) throw CanteraError("getReagents", "reaction order specified for non-reactantt: " @@ -322,9 +313,9 @@ namespace Cantera { */ static void getStick(const XML_Node& node, Kinetics& kin, ReactionData& r, doublereal& A, doublereal& b, doublereal& E) { - int nr = r.reactants.size(); - int k, klocal, not_surf = 0; - int np = 0; + size_t nr = r.reactants.size(); + size_t k, klocal, not_surf = 0; + size_t np = 0; doublereal f = 1.0; doublereal order; /* @@ -336,9 +327,9 @@ namespace Cantera { */ string spname = node["species"]; ThermoPhase& th = kin.speciesPhase(spname); - int isp = th.speciesIndex(spname); - int ispKinetics = kin.kineticsSpeciesIndex(spname); - int ispPhaseIndex = kin.speciesPhaseIndex(ispKinetics); + size_t isp = th.speciesIndex(spname); + size_t ispKinetics = kin.kineticsSpeciesIndex(spname); + size_t ispPhaseIndex = kin.speciesPhaseIndex(ispKinetics); doublereal ispMW = th.molecularWeights()[isp]; doublereal sc; @@ -398,7 +389,7 @@ namespace Cantera { thermo_t& surfphase, ReactionData& rdata) { vector cov; node.getChildren("coverage", cov); - int k, nc = static_cast(cov.size()); + size_t k, nc = cov.size(); doublereal e; string spname; if (nc > 0) { diff --git a/Cantera/src/kinetics/importKinetics.h b/Cantera/src/kinetics/importKinetics.h index 3e3ed5cdb..75960ec90 100644 --- a/Cantera/src/kinetics/importKinetics.h +++ b/Cantera/src/kinetics/importKinetics.h @@ -93,8 +93,8 @@ namespace Cantera { */ bool getReagents(const XML_Node& rxn, kinetics_t& kin, int rp, std::string default_phase, - vector_int& spnum, vector_fp& stoich, vector_fp& order, - int rule); + std::vector& spnum, vector_fp& stoich, + vector_fp& order, int rule); //! Read the rate coefficient data from the XML file. /*! diff --git a/Cantera/src/kinetics/solveSP.cpp b/Cantera/src/kinetics/solveSP.cpp index 121dd4494..014b31864 100644 --- a/Cantera/src/kinetics/solveSP.cpp +++ b/Cantera/src/kinetics/solveSP.cpp @@ -129,8 +129,8 @@ namespace Cantera { } m_maxTotSpecies = 0; - for (int n = 0; n < m_numSurfPhases; n++) { - int tsp = m_objects[n]->nTotalSpecies(); + for (size_t n = 0; n < m_numSurfPhases; n++) { + size_t tsp = m_objects[n]->nTotalSpecies(); m_maxTotSpecies = MAX(m_maxTotSpecies, tsp); } m_maxTotSpecies = MAX(m_maxTotSpecies, m_neq); diff --git a/Cantera/src/kinetics/solveSP.h b/Cantera/src/kinetics/solveSP.h index b34110565..3c7f3c056 100644 --- a/Cantera/src/kinetics/solveSP.h +++ b/Cantera/src/kinetics/solveSP.h @@ -591,7 +591,7 @@ namespace Cantera { //! Maximum number of species in any single kinetics operator //! -> also maxed wrt the total # of solution species - int m_maxTotSpecies; + size_t m_maxTotSpecies; //! Temporary vector with length equal to max m_maxTotSpecies vector_fp m_netProductionRatesSave; diff --git a/Cantera/src/numerics/sort.cpp b/Cantera/src/numerics/sort.cpp index 69aef71b0..19648d570 100755 --- a/Cantera/src/numerics/sort.cpp +++ b/Cantera/src/numerics/sort.cpp @@ -9,12 +9,12 @@ namespace Cantera { // sort (x,y) pairs by x void heapsort(vector_fp& x, std::vector& y) { - int n = x.size(); + size_t n = x.size(); if (n < 2) return; doublereal rra; - integer rrb; - int ll = n/2; - int iret = n-1; + size_t rrb; + size_t ll = n/2; + size_t iret = n-1; while (1 > 0) { if (ll > 0) { @@ -35,8 +35,8 @@ namespace Cantera { } } - int i = ll; - int j = ll + ll + 1; + size_t i = ll; + size_t j = ll + ll + 1; while (j <= iret) { if (j < iret) { @@ -59,12 +59,12 @@ namespace Cantera { } void heapsort(vector_fp& x, vector_fp& y) { - int n = x.size(); + size_t n = x.size(); if (n < 2) return; doublereal rra; doublereal rrb; - int ll = n/2; - int iret = n-1; + size_t ll = n/2; + size_t iret = n-1; while (1 > 0) { if (ll > 0) { @@ -85,8 +85,8 @@ namespace Cantera { } } - int i = ll; - int j = ll + ll + 1; + size_t i = ll; + size_t j = ll + ll + 1; while (j <= iret) { if (j < iret) { diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index a9bb59ad6..ad72b7652 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -743,8 +743,7 @@ namespace Cantera { _init(m_nsp+1); m_fixed_cov.resize(m_nsp, 0.0); m_fixed_cov[0] = 1.0; - int nt = m_kin->nTotalSpecies(); - m_work.resize(nt, 0.0); + m_work.resize(m_kin->nTotalSpecies(), 0.0); // set bounds vector_fp lower(m_nv), upper(m_nv); diff --git a/Cantera/src/thermo/ConstCpPoly.cpp b/Cantera/src/thermo/ConstCpPoly.cpp index 021ff2bf6..d9de5eee3 100644 --- a/Cantera/src/thermo/ConstCpPoly.cpp +++ b/Cantera/src/thermo/ConstCpPoly.cpp @@ -26,7 +26,7 @@ namespace Cantera { m_index(0) { } - ConstCpPoly::ConstCpPoly(int n, doublereal tlow, doublereal thigh, + ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT (tlow), @@ -109,7 +109,7 @@ namespace Cantera { s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0); } - void ConstCpPoly::reportParameters(int &n, int &type, + void ConstCpPoly::reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { diff --git a/Cantera/src/thermo/ConstCpPoly.h b/Cantera/src/thermo/ConstCpPoly.h index 0699904a9..63c98ed4e 100644 --- a/Cantera/src/thermo/ConstCpPoly.h +++ b/Cantera/src/thermo/ConstCpPoly.h @@ -66,7 +66,7 @@ namespace Cantera { * - c[3] = \f$ {Cp}_k^o(T_0, p_{ref}) \f$ (J(kmol K) * */ - ConstCpPoly(int n, doublereal tlow, doublereal thigh, + ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs); @@ -97,7 +97,7 @@ namespace Cantera { virtual int reportType() const { return CONSTANT_CP; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial /*! @@ -154,7 +154,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - void reportParameters(int &n, int &type, + void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const; @@ -191,7 +191,7 @@ namespace Cantera { //! Reference pressure (Pa) doublereal m_Pref; //! Species Index - int m_index; + size_t m_index; private: diff --git a/Cantera/src/thermo/ConstDensityThermo.cpp b/Cantera/src/thermo/ConstDensityThermo.cpp index 8468e1af5..4205c2244 100644 --- a/Cantera/src/thermo/ConstDensityThermo.cpp +++ b/Cantera/src/thermo/ConstDensityThermo.cpp @@ -100,11 +100,11 @@ namespace Cantera { } } - doublereal ConstDensityThermo::standardConcentration(int k) const { + doublereal ConstDensityThermo::standardConcentration(size_t k) const { return molarDensity(); } - doublereal ConstDensityThermo::logStandardConc(int k) const { + doublereal ConstDensityThermo::logStandardConc(size_t k) const { return log(molarDensity()); } diff --git a/Cantera/src/thermo/ConstDensityThermo.h b/Cantera/src/thermo/ConstDensityThermo.h index 0fdc0db2d..544108fb0 100644 --- a/Cantera/src/thermo/ConstDensityThermo.h +++ b/Cantera/src/thermo/ConstDensityThermo.h @@ -196,13 +196,13 @@ namespace Cantera { * @return * Returns the standard Concentration in units of m3 kmol-1. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the Gibbs functions for the standard //! state of the species at the current T and P of the solution diff --git a/Cantera/src/thermo/DebyeHuckel.cpp b/Cantera/src/thermo/DebyeHuckel.cpp index 463f54000..e18254825 100644 --- a/Cantera/src/thermo/DebyeHuckel.cpp +++ b/Cantera/src/thermo/DebyeHuckel.cpp @@ -504,7 +504,7 @@ namespace Cantera { * based on the molality of species proportional to the * molality of the species. */ - doublereal DebyeHuckel::standardConcentration(int k) const { + doublereal DebyeHuckel::standardConcentration(size_t k) const { double mvSolvent = m_speciesSize[m_indexSolvent]; return 1.0 / mvSolvent; } @@ -513,7 +513,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal DebyeHuckel::logStandardConc(int k) const { + doublereal DebyeHuckel::logStandardConc(size_t k) const { double c_solvent = standardConcentration(k); return log(c_solvent); } @@ -1566,7 +1566,7 @@ namespace Cantera { getMap(ESTNode, msEST); map::const_iterator _b = msEST.begin(); for (; _b != msEST.end(); ++_b) { - int kk = speciesIndex(_b->first); + size_t kk = speciesIndex(_b->first); std::string est = _b->second; if ((m_electrolyteSpeciesType[kk] = interp_est(est)) == -1) { throw CanteraError("DebyeHuckel:initThermoXML", diff --git a/Cantera/src/thermo/DebyeHuckel.h b/Cantera/src/thermo/DebyeHuckel.h index a7813ec50..9267fa9d5 100644 --- a/Cantera/src/thermo/DebyeHuckel.h +++ b/Cantera/src/thermo/DebyeHuckel.h @@ -924,13 +924,13 @@ namespace Cantera { * Returns the standard Concentration in units of * m3 kmol-1. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Returns the units of the standard and generalized concentrations. /*! diff --git a/Cantera/src/thermo/GeneralSpeciesThermo.cpp b/Cantera/src/thermo/GeneralSpeciesThermo.cpp index 269209eb6..94ed8a745 100644 --- a/Cantera/src/thermo/GeneralSpeciesThermo.cpp +++ b/Cantera/src/thermo/GeneralSpeciesThermo.cpp @@ -104,7 +104,7 @@ namespace Cantera { * the parameterization. */ void GeneralSpeciesThermo::install(std::string name, - int index, + size_t index, int type, const doublereal* c, doublereal minTemp, @@ -187,13 +187,13 @@ namespace Cantera { throw CanteraError("GeneralSpeciesThermo::install_STIT", "zero pointer"); } - int index = stit_ptr->speciesIndex(); + size_t index = stit_ptr->speciesIndex(); if (index > m_kk - 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)); + "Index position isn't null, duplication of assignment: " + int2str(int(index))); /* * Now, simply assign the position */ @@ -211,7 +211,7 @@ namespace Cantera { - void GeneralSpeciesThermo::installPDSShandler(int k, PDSS *PDSS_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); @@ -221,7 +221,7 @@ namespace Cantera { * Update the properties for one species. */ void GeneralSpeciesThermo:: - update_one(int k, doublereal t, doublereal* cp_R, + 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) { @@ -255,7 +255,7 @@ namespace Cantera { * This utility function reports the type of parameterization * used for the species, index. */ - int GeneralSpeciesThermo::reportType(int index) const { + int GeneralSpeciesThermo::reportType(size_t index) const { SpeciesThermoInterpType *sp = m_sp[index]; if (sp) { return sp->reportType(); @@ -270,10 +270,10 @@ namespace Cantera { * For the NASA object, there are 15 coefficients. */ void GeneralSpeciesThermo:: - reportParams(int index, int &type, doublereal * const c, + reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const { SpeciesThermoInterpType *sp = m_sp[index]; - int n; + size_t n; if (sp) { sp->reportParameters(n, type, minTemp, maxTemp, refPressure, c); @@ -293,7 +293,7 @@ namespace Cantera { * parameters for the standard state. */ void GeneralSpeciesThermo:: - modifyParams(int index, doublereal *c) { + modifyParams(size_t index, doublereal *c) { SpeciesThermoInterpType *sp = m_sp[index]; if (sp) { sp->modifyParameters(c); @@ -308,8 +308,8 @@ namespace Cantera { * are valid. Otherwise, if an integer argument is given, the * value applies only to the species with that index. */ - doublereal GeneralSpeciesThermo::minTemp(int k) const { - if (k < 0) + doublereal GeneralSpeciesThermo::minTemp(size_t k) const { + if (k == -1) return m_tlow_max; else { SpeciesThermoInterpType *sp = m_sp[k]; @@ -320,8 +320,8 @@ namespace Cantera { return m_tlow_max; } - doublereal GeneralSpeciesThermo::maxTemp(int k) const { - if (k < 0) { + doublereal GeneralSpeciesThermo::maxTemp(size_t k) const { + if (k == -1) { return m_thigh_min; } else { SpeciesThermoInterpType *sp = m_sp[k]; @@ -332,8 +332,8 @@ namespace Cantera { return m_thigh_min; } - doublereal GeneralSpeciesThermo::refPressure(int k) const { - if (k < 0) { + doublereal GeneralSpeciesThermo::refPressure(size_t k) const { + if (k == -1) { return m_p0; } else { SpeciesThermoInterpType *sp = m_sp[k]; diff --git a/Cantera/src/thermo/GeneralSpeciesThermo.h b/Cantera/src/thermo/GeneralSpeciesThermo.h index c6d9687c7..e525ab9cd 100644 --- a/Cantera/src/thermo/GeneralSpeciesThermo.h +++ b/Cantera/src/thermo/GeneralSpeciesThermo.h @@ -82,7 +82,7 @@ namespace Cantera { * @todo Create a factory method for SpeciesThermoInterpType. * That's basically what we are doing here. */ - virtual void install(std::string name, int index, int type, + virtual void install(std::string name, size_t index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure); @@ -104,7 +104,7 @@ namespace Cantera { * @param vpssmgr_ptr Pointer to the variable pressure standard state * manager that handles the PDSS object. */ - void installPDSShandler(int k, PDSS *PDSS_ptr, VPSSMgr *vpssmgr_ptr); + void installPDSShandler(size_t k, PDSS *PDSS_ptr, VPSSMgr *vpssmgr_ptr); //! Like update(), but only updates the single species k. /*! @@ -117,7 +117,7 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void update_one(int k, doublereal T, doublereal* cp_R, + virtual void update_one(size_t k, doublereal T, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; @@ -149,7 +149,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const; + virtual doublereal minTemp(size_t k=-1) const; //! Maximum temperature. /*! @@ -161,7 +161,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal maxTemp(int k=-1) const; + virtual doublereal maxTemp(size_t k=-1) const; //! The reference-state pressure for species k. /*! @@ -176,7 +176,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal refPressure(int k = -1) const; + virtual doublereal refPressure(size_t k = -1) const; //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -184,7 +184,7 @@ namespace Cantera { * * @param index Species index */ - virtual int reportType(int index) const; + virtual int reportType(size_t index) const; //! This utility function reports back the type of //! parameterization and all of the parameters for the species, index. @@ -197,7 +197,7 @@ namespace Cantera { * @param maxTemp output - Maximum temperature * @param refPressure output - reference pressure (Pa). */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -209,7 +209,7 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c); + virtual void modifyParams(size_t index, doublereal *c); #ifdef H298MODIFY_CAPABILITY @@ -258,7 +258,7 @@ namespace Cantera { * Internal variable indicating the length of the * number of species in the phase. */ - int m_kk; + size_t m_kk; //! Make the class VPSSMgr a friend because we need to access diff --git a/Cantera/src/thermo/GibbsExcessVPSSTP.cpp b/Cantera/src/thermo/GibbsExcessVPSSTP.cpp index 62a60c904..7e86283de 100644 --- a/Cantera/src/thermo/GibbsExcessVPSSTP.cpp +++ b/Cantera/src/thermo/GibbsExcessVPSSTP.cpp @@ -191,12 +191,12 @@ namespace Cantera { */ - doublereal GibbsExcessVPSSTP::standardConcentration(int k) const { + doublereal GibbsExcessVPSSTP::standardConcentration(size_t k) const { err("standardConcentration"); return -1.0; } - doublereal GibbsExcessVPSSTP::logStandardConc(int k) const { + doublereal GibbsExcessVPSSTP::logStandardConc(size_t k) const { err("logStandardConc"); return -1.0; } diff --git a/Cantera/src/thermo/GibbsExcessVPSSTP.h b/Cantera/src/thermo/GibbsExcessVPSSTP.h index 56b444bd5..b94453ea4 100644 --- a/Cantera/src/thermo/GibbsExcessVPSSTP.h +++ b/Cantera/src/thermo/GibbsExcessVPSSTP.h @@ -235,7 +235,7 @@ namespace Cantera { * * @param k species index. Defaults to zero. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /** * Returns the natural logarithm of the standard @@ -243,7 +243,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; /** * Returns the units of the standard and generalized diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp index dd9d41407..e23e1922e 100644 --- a/Cantera/src/thermo/HMWSoln.cpp +++ b/Cantera/src/thermo/HMWSoln.cpp @@ -947,7 +947,7 @@ namespace Cantera { * all species concentrations have units of kmol/m3. * */ - doublereal HMWSoln::standardConcentration(int k) const { + doublereal HMWSoln::standardConcentration(size_t k) const { getStandardVolumes(DATA_PTR(m_tmpV)); double mvSolvent = m_tmpV[m_indexSolvent]; if (k > 0) { @@ -960,7 +960,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal HMWSoln::logStandardConc(int k) const { + doublereal HMWSoln::logStandardConc(size_t k) const { double c_solvent = standardConcentration(k); return log(c_solvent); } diff --git a/Cantera/src/thermo/HMWSoln.h b/Cantera/src/thermo/HMWSoln.h index 0bfb8044c..d05a35072 100644 --- a/Cantera/src/thermo/HMWSoln.h +++ b/Cantera/src/thermo/HMWSoln.h @@ -1704,7 +1704,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Returns the natural logarithm of the standard @@ -1712,7 +1712,7 @@ namespace Cantera { /*! * @param k Species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Returns the units of the standard and generalized concentrations. /*! diff --git a/Cantera/src/thermo/IdealGasPhase.cpp b/Cantera/src/thermo/IdealGasPhase.cpp index 8db477ef6..314f286fb 100644 --- a/Cantera/src/thermo/IdealGasPhase.cpp +++ b/Cantera/src/thermo/IdealGasPhase.cpp @@ -155,7 +155,7 @@ namespace Cantera { * Returns the standard concentration \f$ C^0_k \f$, which is used to normalize * the generalized concentration. */ - doublereal IdealGasPhase::standardConcentration(int k) const { + doublereal IdealGasPhase::standardConcentration(size_t k) const { double p = pressure(); return p/(GasConstant * temperature()); } @@ -164,7 +164,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal IdealGasPhase::logStandardConc(int k) const { + doublereal IdealGasPhase::logStandardConc(size_t k) const { _updateThermo(); double p = pressure(); double lc = std::log (p / (GasConstant * temperature())); diff --git a/Cantera/src/thermo/IdealGasPhase.h b/Cantera/src/thermo/IdealGasPhase.h index 467bfd354..4e5c350a0 100644 --- a/Cantera/src/thermo/IdealGasPhase.h +++ b/Cantera/src/thermo/IdealGasPhase.h @@ -548,14 +548,14 @@ namespace Cantera { * @return * Returns the standard Concentration in units of m3 kmol-1. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Returns the natural logarithm of the standard //! concentration of the kth species /*! * @param k index of the species. (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of non-dimensional activity coefficients at //! the current solution temperature, pressure, and solution concentration. diff --git a/Cantera/src/thermo/IdealMolalSoln.cpp b/Cantera/src/thermo/IdealMolalSoln.cpp index 858be33c5..57b91a58f 100644 --- a/Cantera/src/thermo/IdealMolalSoln.cpp +++ b/Cantera/src/thermo/IdealMolalSoln.cpp @@ -421,7 +421,7 @@ namespace Cantera { * optional parameter indicating the species. * */ - doublereal IdealMolalSoln::standardConcentration(int k) const { + doublereal IdealMolalSoln::standardConcentration(size_t k) const { double c0 = 1.0, mvSolvent; switch (m_formGC) { case 0: @@ -441,7 +441,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal IdealMolalSoln::logStandardConc(int k) const { + doublereal IdealMolalSoln::logStandardConc(size_t k) const { double c0 = standardConcentration(k); return log(c0); } diff --git a/Cantera/src/thermo/IdealMolalSoln.h b/Cantera/src/thermo/IdealMolalSoln.h index 6c5064eaf..077b0edfc 100644 --- a/Cantera/src/thermo/IdealMolalSoln.h +++ b/Cantera/src/thermo/IdealMolalSoln.h @@ -459,7 +459,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /*! * Returns the natural logarithm of the standard @@ -467,7 +467,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; /*! * Returns the units of the standard and generalized diff --git a/Cantera/src/thermo/IdealSolidSolnPhase.cpp b/Cantera/src/thermo/IdealSolidSolnPhase.cpp index d327f87bf..3e7a51f6b 100644 --- a/Cantera/src/thermo/IdealSolidSolnPhase.cpp +++ b/Cantera/src/thermo/IdealSolidSolnPhase.cpp @@ -487,7 +487,7 @@ namespace Cantera { * an optional parameter. */ doublereal IdealSolidSolnPhase:: - standardConcentration(int k) const { + standardConcentration(size_t k) const { switch (m_formGC) { case 0: return 1.0; @@ -522,7 +522,7 @@ namespace Cantera { * an optional parameter. */ doublereal IdealSolidSolnPhase:: - logStandardConc(int k) const { + logStandardConc(size_t k) const { _updateThermo(); double res; switch (m_formGC) { diff --git a/Cantera/src/thermo/IdealSolidSolnPhase.h b/Cantera/src/thermo/IdealSolidSolnPhase.h index 11c7295d6..e4bee622f 100644 --- a/Cantera/src/thermo/IdealSolidSolnPhase.h +++ b/Cantera/src/thermo/IdealSolidSolnPhase.h @@ -475,7 +475,7 @@ namespace Cantera { * a change from the ThermoPhase base class, where it was * an optional parameter. */ - virtual doublereal standardConcentration(int k) const; + virtual doublereal standardConcentration(size_t k) const; /** * The reference (ie standard) concentration \f$ C^0_k \f$ used to normalize @@ -497,7 +497,7 @@ namespace Cantera { * a change from the ThermoPhase base class, where it was * an optional parameter. */ - virtual doublereal logStandardConc(int k) const; + virtual doublereal logStandardConc(size_t k) const; /** * Returns the units of the standard and general concentrations diff --git a/Cantera/src/thermo/IdealSolnGasVPSS.cpp b/Cantera/src/thermo/IdealSolnGasVPSS.cpp index b1d8dd151..10f617f42 100644 --- a/Cantera/src/thermo/IdealSolnGasVPSS.cpp +++ b/Cantera/src/thermo/IdealSolnGasVPSS.cpp @@ -224,7 +224,7 @@ namespace Cantera { * Returns the standard concentration \f$ C^0_k \f$, which is used to normalize * the generalized concentration. */ - doublereal IdealSolnGasVPSS::standardConcentration(int k) const { + doublereal IdealSolnGasVPSS::standardConcentration(size_t k) const { if (m_idealGas) { double p = pressure(); return p/(GasConstant * temperature()); @@ -247,7 +247,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal IdealSolnGasVPSS::logStandardConc(int k) const { + doublereal IdealSolnGasVPSS::logStandardConc(size_t k) const { double c = standardConcentration(k); double lc = std::log(c); return lc; diff --git a/Cantera/src/thermo/IdealSolnGasVPSS.h b/Cantera/src/thermo/IdealSolnGasVPSS.h index e499ed7b4..4827d5a2e 100644 --- a/Cantera/src/thermo/IdealSolnGasVPSS.h +++ b/Cantera/src/thermo/IdealSolnGasVPSS.h @@ -185,14 +185,14 @@ namespace Cantera { * @return * Returns the standard Concentration in units of m3 kmol-1. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Returns the natural logarithm of the standard //! concentration of the kth species /*! * @param k index of the species. (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Returns the units of the standard and generalized concentrations. /*! diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp index 4fbd1be37..1c3eec217 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -330,7 +330,7 @@ namespace Cantera { getActivities(c); } - void IonsFromNeutralVPSSTP::getDissociationCoeffs(vector_fp& coeffs,vector_fp& charges, std::vector& neutMolIndex){ + void IonsFromNeutralVPSSTP::getDissociationCoeffs(vector_fp& coeffs,vector_fp& charges, std::vector& neutMolIndex){ coeffs = fm_neutralMolec_ions_; charges = m_speciesCharge; neutMolIndex = fm_invert_ionForNeutral; @@ -356,7 +356,7 @@ namespace Cantera { * Returns the standard concentration. The units are by definition * dependent on the ThermoPhase and kinetics manager representation. */ - doublereal IonsFromNeutralVPSSTP::standardConcentration(int k) const { + doublereal IonsFromNeutralVPSSTP::standardConcentration(size_t k) const { return 1.0; } @@ -364,7 +364,7 @@ namespace Cantera { /* * @param k index of the species (defaults to zero) */ - doublereal IonsFromNeutralVPSSTP::logStandardConc(int k) const { + doublereal IonsFromNeutralVPSSTP::logStandardConc(size_t k) const { return 0.0; } @@ -445,7 +445,7 @@ namespace Cantera { */ void IonsFromNeutralVPSSTP::getChemPotentials(doublereal* mu) const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal xx, fact2; /* * Transfer the mole fractions to the slave neutral molecule @@ -472,7 +472,7 @@ namespace Cantera { fact2 = 2.0 * RT_ * log(2.0); // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -487,7 +487,7 @@ namespace Cantera { mu[icat] = RT_ * log(xx); // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; xx = fmaxx(SmallNumber, moleFractions_[icat]); @@ -735,14 +735,14 @@ namespace Cantera { * is dumped into the anion mole number to fix the imbalance. */ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal sumCat; doublereal sumAnion; doublereal fmij; doublereal sum = 0.0; //! Zero the vector we are trying to find. - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { NeutralMolecMoleFractions_[k] = 0.0; } #ifdef DEBUG_MODE @@ -762,7 +762,7 @@ namespace Cantera { case cIonSolnType_PASSTHROUGH: - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { NeutralMolecMoleFractions_[k] = moleFractions_[k]; } break; @@ -771,11 +771,11 @@ namespace Cantera { sumCat = 0.0; sumAnion = 0.0; - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { NeutralMolecMoleFractions_[k] = 0.0; } - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -786,7 +786,7 @@ namespace Cantera { } } - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; fmij = fm_neutralMolec_ions_[ icat + jNeut * m_kk]; @@ -794,16 +794,16 @@ namespace Cantera { } #ifdef DEBUG_MODE - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { moleFractionsTmp_[k] = moleFractions_[k]; } for (jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { fmij = fm_neutralMolec_ions_[k + jNeut * m_kk]; moleFractionsTmp_[k] -= fmij * NeutralMolecMoleFractions_[jNeut]; } } - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (fabs(moleFractionsTmp_[k]) > 1.0E-13) { //! Check to see if we have in fact found the inverse. if (anionList_[0] != k) { @@ -820,10 +820,10 @@ namespace Cantera { // Normalize the Neutral Molecule mole fractions sum = 0.0; - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { sum += NeutralMolecMoleFractions_[k]; } - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { NeutralMolecMoleFractions_[k] /= sum; } @@ -863,7 +863,7 @@ namespace Cantera { * is dumped into the anion mole number to fix the imbalance. */ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal * const dx, doublereal *dy) const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal sumCat; doublereal sumAnion; doublereal fmij; @@ -874,7 +874,7 @@ namespace Cantera { //check sum dx = 0 //! Zero the vector we are trying to find. - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { dy[k] = 0.0; } @@ -885,7 +885,7 @@ namespace Cantera { case cIonSolnType_PASSTHROUGH: - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dy[k] = dx[k]; } break; @@ -895,7 +895,7 @@ namespace Cantera { sumCat = 0.0; sumAnion = 0.0; - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < (int) cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -907,7 +907,7 @@ namespace Cantera { } } - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; fmij = fm_neutralMolec_ions_[ icat + jNeut * m_kk]; @@ -916,16 +916,16 @@ namespace Cantera { } #ifdef DEBUG_MODE_NOT //check dy sum to zero - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { moleFractionsTmp_[k] = dx[k]; } for (jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { fmij = fm_neutralMolec_ions_[k + jNeut * m_kk]; moleFractionsTmp_[k] -= fmij * dy[jNeut]; } } - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (fabs(moleFractionsTmp_[k]) > 1.0E-13) { //! Check to see if we have in fact found the inverse. if (anionList_[0] != k) { @@ -942,11 +942,11 @@ namespace Cantera { // Normalize the Neutral Molecule mole fractions sumy = 0.0; sumdy = 0.0; - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { sumy += y[k]; sumdy += dy[k]; } - for (k = 0; k < numNeutralMoleculeSpecies_; k++) { + for (size_t k = 0; k < numNeutralMoleculeSpecies_; k++) { dy[k] = dy[k]/sumy - y[k]*sumdy/sumy/sumy; } @@ -1193,17 +1193,17 @@ namespace Cantera { static double factorOverlap(const std::vector& elnamesVN , const std::vector& elemVectorN, - const int nElementsN, + const size_t nElementsN, const std::vector& elnamesVI , const std::vector& elemVectorI, - const int nElementsI) + const size_t nElementsI) { double fMax = 1.0E100; - for (int mi = 0; mi < nElementsI; mi++) { + for (size_t mi = 0; mi < nElementsI; mi++) { if (elnamesVI[mi] != "E") { if (elemVectorI[mi] > 1.0E-13) { double eiNum = elemVectorI[mi]; - for (int mn = 0; mn < nElementsN; mn++) { + for (size_t mn = 0; mn < nElementsN; mn++) { if (elnamesVI[mi] == elnamesVN[mn]) { if (elemVectorN[mn] <= 1.0E-13) { return 0.0; @@ -1294,28 +1294,28 @@ namespace Cantera { std::vector elemVectorI(nElementsI); vector fm_tmp(m_kk); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { fm_invert_ionForNeutral[k] = -1; } /* for (int jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { fm_invert_ionForNeutral[jNeut] = -1; }*/ - for (int jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { - for (int m = 0; m < nElementsN; m++) { + for (size_t jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { + for (size_t m = 0; m < nElementsN; m++) { elemVectorN[m] = neutralMoleculePhase_->nAtoms(jNeut, m); } elemVectorN_orig = elemVectorN; fvo_zero_dbl_1(fm_tmp, m_kk); - for (int m = 0; m < nElementsI; m++) { + for (size_t m = 0; m < nElementsI; m++) { elemVectorI[m] = nAtoms(indexSpecialSpecies_, m); } double fac = factorOverlap(elnamesVN, elemVectorN, nElementsN, elnamesVI ,elemVectorI, nElementsI); if (fac > 0.0) { - for (int m = 0; m < nElementsN; m++) { + for (size_t m = 0; m < nElementsN; m++) { std::string mName = elnamesVN[m]; - for (int mi = 0; mi < nElementsI; mi++) { + for (size_t mi = 0; mi < nElementsI; mi++) { std::string eName = elnamesVI[mi]; if (mName == eName) { elemVectorN[m] -= fac * elemVectorI[mi]; @@ -1328,15 +1328,15 @@ namespace Cantera { for (k = 0; k < m_kk; k++) { - for (int m = 0; m < nElementsI; m++) { + for (size_t m = 0; m < nElementsI; m++) { elemVectorI[m] = nAtoms(k, m); } double fac = factorOverlap(elnamesVN, elemVectorN, nElementsN, elnamesVI ,elemVectorI, nElementsI); if (fac > 0.0) { - for (int m = 0; m < nElementsN; m++) { + for (size_t m = 0; m < nElementsN; m++) { std::string mName = elnamesVN[m]; - for (int mi = 0; mi < nElementsI; mi++) { + for (size_t mi = 0; mi < nElementsI; mi++) { std::string eName = elnamesVI[mi]; if (mName == eName) { elemVectorN[m] -= fac * elemVectorI[mi]; @@ -1345,7 +1345,7 @@ namespace Cantera { } } bool notTaken = true; - for (int iNeut = 0; iNeut < jNeut; iNeut++) { + for (size_t iNeut = 0; iNeut < jNeut; iNeut++) { if (fm_invert_ionForNeutral[k] == iNeut) { notTaken = false; } @@ -1362,7 +1362,7 @@ namespace Cantera { } // Ok check the work - for (int m = 0; m < nElementsN; m++) { + for (size_t m = 0; m < nElementsN; m++) { if (fabs(elemVectorN[m]) > 1.0E-13) { throw CanteraError("IonsFromNeutralVPSSTP::initThermoXML", "Simple formula matrix generation failed"); @@ -1390,7 +1390,7 @@ namespace Cantera { * he = X_A X_B(B + C(X_A - X_B)) */ void IonsFromNeutralVPSSTP::s_update_lnActCoeff() const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal fmij; /* * Get the activity coefficiens of the neutral molecules @@ -1403,7 +1403,7 @@ namespace Cantera { case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -1417,7 +1417,7 @@ namespace Cantera { lnActCoeff_Scaled_[icat]= 0.0; // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; lnActCoeff_Scaled_[icat] = log(gammaNeutralMolecule_[jNeut]); @@ -1442,14 +1442,14 @@ namespace Cantera { // get the gradient in the activity coefficients void IonsFromNeutralVPSSTP::getdlnActCoeff(const doublereal dT, const doublereal * const dX, doublereal *dlnActCoeff) const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal fmij; /* * Get the activity coefficients of the neutral molecules */ GibbsExcessVPSSTP *geThermo = dynamic_cast(neutralMoleculePhase_); if (!geThermo) { - for ( k = 0; k < m_kk; k++ ){ + for (size_t k = 0; k < m_kk; k++) { dlnActCoeff[k] = dX[k]/moleFractions_[k]; } return; @@ -1472,7 +1472,7 @@ namespace Cantera { case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -1486,7 +1486,7 @@ namespace Cantera { dlnActCoeff[icat]= 0.0; // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; dlnActCoeff[icat] = dlnActCoeff_NeutralMolecule[jNeut]; @@ -1512,7 +1512,7 @@ namespace Cantera { * temperature derivative of the natural logarithm of the activity coefficients */ void IonsFromNeutralVPSSTP::s_update_dlnActCoeffdT() const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal fmij; /* * Get the activity coefficients of the neutral molecules @@ -1531,7 +1531,7 @@ namespace Cantera { case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -1545,7 +1545,7 @@ namespace Cantera { dlnActCoeffdT_Scaled_[icat]= 0.0; // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; dlnActCoeffdT_Scaled_[icat] = dlnActCoeffdT_NeutralMolecule_[jNeut]; @@ -1570,7 +1570,7 @@ namespace Cantera { * temperature derivative of the natural logarithm of the activity coefficients */ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnX() const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal fmij; /* * Get the activity coefficients of the neutral molecules @@ -1589,7 +1589,7 @@ namespace Cantera { case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -1603,7 +1603,7 @@ namespace Cantera { dlnActCoeffdlnX_Scaled_[icat]= 0.0; // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; dlnActCoeffdlnX_Scaled_[icat] = dlnActCoeffdlnX_NeutralMolecule_[jNeut]; @@ -1628,7 +1628,7 @@ namespace Cantera { * temperature derivative of the natural logarithm of the activity coefficients */ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const { - int k, icat, jNeut; + size_t icat, jNeut; doublereal fmij; /* * Get the activity coefficients of the neutral molecules @@ -1647,7 +1647,7 @@ namespace Cantera { case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; @@ -1661,7 +1661,7 @@ namespace Cantera { dlnActCoeffdlnN_Scaled_[icat]= 0.0; // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { icat = passThroughList_[k]; jNeut = fm_invert_ionForNeutral[icat]; dlnActCoeffdlnN_Scaled_[icat] = dlnActCoeffdlnN_NeutralMolecule_[jNeut]; diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h index 286f8c46d..ea86c85b0 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h @@ -302,14 +302,14 @@ namespace Cantera { * Returns the standard concentration. The units are by definition * dependent on the ThermoPhase and kinetics manager representation. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Returns the units of the standard and generalized concentrations. /*! @@ -459,7 +459,7 @@ namespace Cantera { //! Get the Salt Dissociation Coefficients //! Returns the vector of dissociation coefficients and vector of charges - virtual void getDissociationCoeffs(vector_fp& coeffs, vector_fp& charges, std::vector& neutMolIndex); + virtual void getDissociationCoeffs(vector_fp& coeffs, vector_fp& charges, std::vector& neutMolIndex); virtual void getNeutralMolecMoleFractions(vector_fp& fracs){fracs=NeutralMolecMoleFractions_;} @@ -479,8 +479,8 @@ namespace Cantera { */ virtual void getNeutralMoleculeMoleGrads(const doublereal * const x, doublereal *y) const; - virtual void getCationList(std::vector& cation){cation=cationList_;} - virtual void getAnionList(std::vector& anion){anion=anionList_;} + virtual void getCationList(std::vector& cation){cation=cationList_;} + virtual void getAnionList(std::vector& anion){anion=anionList_;} virtual void getSpeciesNames(std::vector& names){names=m_speciesNames;} @@ -827,20 +827,20 @@ namespace Cantera { * then we need to do a formal inversion which takes a great * deal of time and is not currently implemented. */ - std::vector fm_invert_ionForNeutral; + std::vector fm_invert_ionForNeutral; //! Mole fractions using the Neutral Molecule Mole fraction basis mutable std::vector NeutralMolecMoleFractions_; //! List of the species in this ThermoPhase which are cation species - std::vector cationList_; + std::vector cationList_; //! Number of cation species int numCationSpecies_; //! List of the species in this ThermoPhase which are anion species - std::vector anionList_; + std::vector anionList_; //! Number of anion species int numAnionSpecies_; @@ -850,7 +850,7 @@ namespace Cantera { /*! * These have neutral charges. */ - std::vector passThroughList_; + std::vector passThroughList_; //! Number of the species in this ThermoPhase which are passed //! through to the neutralMoleculePhase ThermoPhase diff --git a/Cantera/src/thermo/LatticePhase.cpp b/Cantera/src/thermo/LatticePhase.cpp index 57abd386a..9cdc93b4d 100644 --- a/Cantera/src/thermo/LatticePhase.cpp +++ b/Cantera/src/thermo/LatticePhase.cpp @@ -125,11 +125,11 @@ namespace Cantera { } } - doublereal LatticePhase::standardConcentration(int k) const { + doublereal LatticePhase::standardConcentration(size_t k) const { return 1.0; } - doublereal LatticePhase::logStandardConc(int k) const { + doublereal LatticePhase::logStandardConc(size_t k) const { return 0.0; } diff --git a/Cantera/src/thermo/LatticePhase.h b/Cantera/src/thermo/LatticePhase.h index fc8a344fd..1ac9b03fe 100644 --- a/Cantera/src/thermo/LatticePhase.h +++ b/Cantera/src/thermo/LatticePhase.h @@ -470,14 +470,14 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Returns the natural logarithm of the standard //! concentration of the kth species /*! * @param k Species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of non-dimensional activity coefficients at //! the current solution temperature, pressure, and solution concentration. diff --git a/Cantera/src/thermo/LatticeSolidPhase.cpp b/Cantera/src/thermo/LatticeSolidPhase.cpp index aefcd5aac..8155534a7 100644 --- a/Cantera/src/thermo/LatticeSolidPhase.cpp +++ b/Cantera/src/thermo/LatticeSolidPhase.cpp @@ -137,11 +137,11 @@ namespace Cantera { } } - doublereal LatticeSolidPhase::standardConcentration(int k) const { + doublereal LatticeSolidPhase::standardConcentration(size_t k) const { return 1.0; } - doublereal LatticeSolidPhase::logStandardConc(int k) const { + doublereal LatticeSolidPhase::logStandardConc(size_t k) const { return 0.0; } diff --git a/Cantera/src/thermo/LatticeSolidPhase.h b/Cantera/src/thermo/LatticeSolidPhase.h index cfc717795..a155caf8c 100644 --- a/Cantera/src/thermo/LatticeSolidPhase.h +++ b/Cantera/src/thermo/LatticeSolidPhase.h @@ -112,8 +112,8 @@ namespace Cantera { virtual void getChemPotentials(doublereal* mu) const; virtual void getStandardChemPotentials(doublereal* mu0) const; - virtual doublereal standardConcentration(int k=0) const; - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; virtual void initThermo(); @@ -140,8 +140,8 @@ namespace Cantera { protected: - int m_mm; - int m_kk; + size_t m_mm; + size_t m_kk; mutable doublereal m_tlast; doublereal m_press; doublereal m_molar_density; diff --git a/Cantera/src/thermo/MargulesVPSSTP.cpp b/Cantera/src/thermo/MargulesVPSSTP.cpp index 1cc115709..e052d8091 100644 --- a/Cantera/src/thermo/MargulesVPSSTP.cpp +++ b/Cantera/src/thermo/MargulesVPSSTP.cpp @@ -335,12 +335,12 @@ namespace Cantera { */ - doublereal MargulesVPSSTP::standardConcentration(int k) const { + doublereal MargulesVPSSTP::standardConcentration(size_t k) const { err("standardConcentration"); return -1.0; } - doublereal MargulesVPSSTP::logStandardConc(int k) const { + doublereal MargulesVPSSTP::logStandardConc(size_t k) const { err("logStandardConc"); return -1.0; } @@ -498,7 +498,7 @@ namespace Cantera { */ void MargulesVPSSTP::getPartialMolarVolumes(doublereal* vbar) const { - int iA, iB, iK, delAK, delBK; + size_t iA, iB, iK, delAK, delBK; double XA, XB, XK, g0 , g1; double T = temperature(); @@ -514,7 +514,7 @@ namespace Cantera { delAK = 0; delBK = 0; XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; @@ -651,7 +651,7 @@ namespace Cantera { * he = X_A X_B(B + C X_B) */ void MargulesVPSSTP::s_update_lnActCoeff() const { - int iA, iB, iK, delAK, delBK; + size_t iA, iB, iK, delAK, delBK; double XA, XB, XK, g0 , g1; double T = temperature(); double RT = GasConstant*T; @@ -662,7 +662,7 @@ namespace Cantera { XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; @@ -721,7 +721,7 @@ namespace Cantera { * he = X_A X_B(B + C X_B) */ void MargulesVPSSTP::s_update_dlnActCoeff_dT() const { - int iA, iB, iK, delAK, delBK; + size_t iA, iB, iK, delAK, delBK; double XA, XB, XK, g0 , g1; double T = temperature(); double RTT = GasConstant*T*T; @@ -732,7 +732,7 @@ namespace Cantera { XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; @@ -795,7 +795,7 @@ namespace Cantera { * he = X_A X_B(B + C X_B) */ void MargulesVPSSTP::getdlnActCoeff(const doublereal dT, const doublereal * const dX, doublereal* dlnActCoeff) const { - int iA, iB, iK, delAK, delBK; + size_t iA, iB, iK, delAK, delBK; double XA, XB, XK, g0 , g1, dXA, dXB; double T = temperature(); double RT = GasConstant*T; @@ -808,7 +808,7 @@ namespace Cantera { XK = moleFractions_[iK]; dlnActCoeff[iK] = 0.0; - for (int i = 0; i < numBinaryInteractions_; i++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; @@ -842,7 +842,7 @@ namespace Cantera { * he = X_A X_B(B + C X_B) */ void MargulesVPSSTP::s_update_dlnActCoeff_dlnN() const { - int iA, iB, iK, delAK, delBK; + size_t iA, iB, iK, delAK, delBK; double XA, XB, XK, g0 , g1; double T = temperature(); double RT = GasConstant*T; @@ -853,7 +853,7 @@ namespace Cantera { XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; @@ -877,18 +877,15 @@ namespace Cantera { } void MargulesVPSSTP::s_update_dlnActCoeff_dlnX() const { - - int iA, iB; + size_t iA, iB; doublereal XA, XB, g0 , g1; doublereal T = temperature(); fvo_zero_dbl_1(dlnActCoeffdlnX_Scaled_, m_kk); doublereal RT = GasConstant * T; - - - for (int i = 0; i < numBinaryInteractions_; i++) { - + + for (size_t i = 0; i < numBinaryInteractions_; i++) { iA = m_pSpecies_A_ij[i]; iB = m_pSpecies_B_ij[i]; diff --git a/Cantera/src/thermo/MargulesVPSSTP.h b/Cantera/src/thermo/MargulesVPSSTP.h index 5f869f0df..1a0ef087b 100644 --- a/Cantera/src/thermo/MargulesVPSSTP.h +++ b/Cantera/src/thermo/MargulesVPSSTP.h @@ -488,7 +488,7 @@ namespace Cantera { * * @param k species index. Defaults to zero. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /** * Returns the natural logarithm of the standard @@ -496,7 +496,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of non-dimensional molar-based activity coefficients at //! the current solution temperature, pressure, and solution concentration. diff --git a/Cantera/src/thermo/MetalPhase.h b/Cantera/src/thermo/MetalPhase.h index d04e47ada..43a168499 100644 --- a/Cantera/src/thermo/MetalPhase.h +++ b/Cantera/src/thermo/MetalPhase.h @@ -60,35 +60,30 @@ namespace Cantera { virtual doublereal pressure() const { return m_press; } virtual void getChemPotentials(doublereal* mu) const { - int n, nsp = nSpecies(); - for (n = 0; n < nsp; n++) mu[n] = 0.0; + for (size_t n = 0; n < nSpecies(); n++) mu[n] = 0.0; } virtual void getEnthalpy_RT(doublereal* hrt) const { - int n, nsp = nSpecies(); - for (n = 0; n < nsp; n++) hrt[n] = 0.0; + for (size_t n = 0; n < nSpecies(); n++) hrt[n] = 0.0; } virtual void getEntropy_R(doublereal* sr) const { - int n, nsp = nSpecies(); - for (n = 0; n < nsp; n++) sr[n] = 0.0; + for (size_t n = 0; n < nSpecies(); n++) sr[n] = 0.0; } virtual void getStandardChemPotentials(doublereal* mu0) const { - int n, nsp = nSpecies(); - for (n = 0; n < nsp; n++) mu0[n] = 0.0; + for (size_t n = 0; n < nSpecies(); n++) mu0[n] = 0.0; } virtual void getActivityConcentrations(doublereal* c) const { - int n, nsp = nSpecies(); - for (n = 0; n < nsp; n++) c[n] = 1.0; + for (size_t n = 0; n < nSpecies(); n++) c[n] = 1.0; } - virtual doublereal standardConcentration(int k=0) const { + virtual doublereal standardConcentration(size_t k=0) const { return 1.0; } - virtual doublereal logStandardConc(int k=0) const { + virtual doublereal logStandardConc(size_t k=0) const { return 0.0; } diff --git a/Cantera/src/thermo/MetalSHEelectrons.cpp b/Cantera/src/thermo/MetalSHEelectrons.cpp index 5b7a3de7e..4d3e3e240 100644 --- a/Cantera/src/thermo/MetalSHEelectrons.cpp +++ b/Cantera/src/thermo/MetalSHEelectrons.cpp @@ -241,7 +241,7 @@ namespace Cantera { * by which the generalized concentration is normalized to produce * the activity. */ - doublereal MetalSHEelectrons::standardConcentration(int k) const { + doublereal MetalSHEelectrons::standardConcentration(size_t k) const { return 1.0; } //==================================================================================================================== @@ -249,7 +249,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal MetalSHEelectrons::logStandardConc(int k) const { + doublereal MetalSHEelectrons::logStandardConc(size_t k) const { return 0.0; } //==================================================================================================================== diff --git a/Cantera/src/thermo/MetalSHEelectrons.h b/Cantera/src/thermo/MetalSHEelectrons.h index 52da4e3f9..8c6e15fde 100644 --- a/Cantera/src/thermo/MetalSHEelectrons.h +++ b/Cantera/src/thermo/MetalSHEelectrons.h @@ -336,13 +336,13 @@ namespace Cantera { * @return * Returns The standard Concentration as 1.0 */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of chemical potentials at unit activity for the species //! at their standard states at the current T and P of the solution. diff --git a/Cantera/src/thermo/MineralEQ3.cpp b/Cantera/src/thermo/MineralEQ3.cpp index 6a7ff188b..859ca948b 100644 --- a/Cantera/src/thermo/MineralEQ3.cpp +++ b/Cantera/src/thermo/MineralEQ3.cpp @@ -232,7 +232,7 @@ namespace Cantera { * by which the generalized concentration is normalized to produce * the activity. */ - doublereal MineralEQ3::standardConcentration(int k) const { + doublereal MineralEQ3::standardConcentration(size_t k) const { return 1.0; } @@ -240,7 +240,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal MineralEQ3::logStandardConc(int k) const { + doublereal MineralEQ3::logStandardConc(size_t k) const { return 0.0; } diff --git a/Cantera/src/thermo/MineralEQ3.h b/Cantera/src/thermo/MineralEQ3.h index 972b3a654..e1368600f 100644 --- a/Cantera/src/thermo/MineralEQ3.h +++ b/Cantera/src/thermo/MineralEQ3.h @@ -311,13 +311,13 @@ namespace Cantera { * @return * Returns The standard Concentration as 1.0 */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of chemical potentials at unit activity for the species //! at their standard states at the current T and P of the solution. diff --git a/Cantera/src/thermo/MolalityVPSSTP.cpp b/Cantera/src/thermo/MolalityVPSSTP.cpp index a19b7583a..6b87475e9 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.cpp +++ b/Cantera/src/thermo/MolalityVPSSTP.cpp @@ -297,7 +297,7 @@ namespace Cantera { * preserved. */ void MolalityVPSSTP::setMolalitiesByName(compositionMap& mMap) { - int kk = nSpecies(); + size_t kk = nSpecies(); doublereal x; /* * Get a vector of mole fractions @@ -428,12 +428,12 @@ namespace Cantera { err("getActivityConcentrations"); } - doublereal MolalityVPSSTP::standardConcentration(int k) const { + doublereal MolalityVPSSTP::standardConcentration(size_t k) const { err("standardConcentration"); return -1.0; } - doublereal MolalityVPSSTP::logStandardConc(int k) const { + doublereal MolalityVPSSTP::logStandardConc(size_t k) const { err("logStandardConc"); return -1.0; } diff --git a/Cantera/src/thermo/MolalityVPSSTP.h b/Cantera/src/thermo/MolalityVPSSTP.h index c39e3731a..34a6cb224 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.h +++ b/Cantera/src/thermo/MolalityVPSSTP.h @@ -477,7 +477,7 @@ namespace Cantera { * * @param k species index. Defaults to zero. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /** * Returns the natural logarithm of the standard @@ -485,7 +485,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; /** * Returns the units of the standard and generalized @@ -873,7 +873,7 @@ namespace Cantera { * law. This is the indentity of the Cl- species for the PHSCALE_NBS * scaling */ - int m_indexCLM; + size_t m_indexCLM; //! Molecular weight of the Solvent doublereal m_weightSolvent; diff --git a/Cantera/src/thermo/Mu0Poly.cpp b/Cantera/src/thermo/Mu0Poly.cpp index ff6d5ccdf..afebb7f77 100644 --- a/Cantera/src/thermo/Mu0Poly.cpp +++ b/Cantera/src/thermo/Mu0Poly.cpp @@ -43,7 +43,7 @@ namespace Cantera { * 7 = mu3 (J/kmol) * ........ */ - Mu0Poly::Mu0Poly(int n, doublereal tlow, doublereal thigh, + Mu0Poly::Mu0Poly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_numIntervals(0), @@ -153,7 +153,7 @@ namespace Cantera { * * */ - void Mu0Poly::reportParameters(int &n, int &type, + void Mu0Poly::reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -182,7 +182,7 @@ namespace Cantera { * getting the information from an XML database. */ void installMu0ThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node* Mu0Node_ptr) { doublereal tmin, tmax; diff --git a/Cantera/src/thermo/Mu0Poly.h b/Cantera/src/thermo/Mu0Poly.h index 0322fb94e..53c8eb426 100644 --- a/Cantera/src/thermo/Mu0Poly.h +++ b/Cantera/src/thermo/Mu0Poly.h @@ -101,7 +101,7 @@ namespace Cantera { * - ........ * . */ - Mu0Poly(int n, doublereal tlow, doublereal thigh, + Mu0Poly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs); //! Copy constructor @@ -132,7 +132,7 @@ namespace Cantera { virtual int reportType() const { return MU0_INTERP; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial /*! @@ -192,7 +192,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const; @@ -249,7 +249,7 @@ namespace Cantera { doublereal m_Pref; //! Species index - int m_index; + size_t m_index; private: @@ -292,7 +292,7 @@ namespace Cantera { * @ingroup spthermo */ void installMu0ThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node* Mu0Node_ptr); } diff --git a/Cantera/src/thermo/Nasa9Poly1.cpp b/Cantera/src/thermo/Nasa9Poly1.cpp index e32bfdecd..a518c1c31 100644 --- a/Cantera/src/thermo/Nasa9Poly1.cpp +++ b/Cantera/src/thermo/Nasa9Poly1.cpp @@ -75,7 +75,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - Nasa9Poly1::Nasa9Poly1(int n, doublereal tlow, doublereal thigh, + Nasa9Poly1::Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT (tlow), @@ -148,7 +148,7 @@ namespace Cantera { } // Returns an integer representing the species index - int Nasa9Poly1::speciesIndex() const { + size_t Nasa9Poly1::speciesIndex() const { return m_index; } @@ -258,7 +258,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - void Nasa9Poly1::reportParameters(int &n, int &type, + void Nasa9Poly1::reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { diff --git a/Cantera/src/thermo/Nasa9Poly1.h b/Cantera/src/thermo/Nasa9Poly1.h index 8aaf88aa7..74d422f57 100644 --- a/Cantera/src/thermo/Nasa9Poly1.h +++ b/Cantera/src/thermo/Nasa9Poly1.h @@ -84,7 +84,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - Nasa9Poly1(int n, doublereal tlow, doublereal thigh, doublereal pref, + Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs); //! copy constructor @@ -121,7 +121,7 @@ namespace Cantera { virtual int reportType() const; //! Returns an integer representing the species index - virtual int speciesIndex() const; + virtual size_t speciesIndex() const; //! Update the properties for this species, given a temperature polynomial /*! @@ -200,7 +200,7 @@ namespace Cantera { * coeffs[2] is max temperature * coeffs[3+i] from i =0,9 are the coefficients themselves */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const; @@ -220,7 +220,7 @@ namespace Cantera { //! standard-state pressure doublereal m_Pref; //! species index - int m_index; + size_t m_index; //! array of polynomial coefficients array_fp m_coeff; }; diff --git a/Cantera/src/thermo/Nasa9PolyMultiTempRegion.cpp b/Cantera/src/thermo/Nasa9PolyMultiTempRegion.cpp index b29180556..d829e0c9d 100644 --- a/Cantera/src/thermo/Nasa9PolyMultiTempRegion.cpp +++ b/Cantera/src/thermo/Nasa9PolyMultiTempRegion.cpp @@ -216,7 +216,7 @@ namespace Cantera { // Returns an integer representing the species index - int Nasa9PolyMultiTempRegion::speciesIndex() const { + size_t Nasa9PolyMultiTempRegion::speciesIndex() const { return m_index; } @@ -332,7 +332,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - void Nasa9PolyMultiTempRegion::reportParameters(int &n, int &type, + void Nasa9PolyMultiTempRegion::reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -344,7 +344,7 @@ namespace Cantera { double ctmp[12]; coeffs[0] = double(m_numTempRegions); int index = 1; - int n_tmp = 0;; + size_t n_tmp = 0;; int type_tmp = 0; double pref_tmp = 0.0; for (size_t iReg = 0; iReg < m_numTempRegions; iReg++) { diff --git a/Cantera/src/thermo/Nasa9PolyMultiTempRegion.h b/Cantera/src/thermo/Nasa9PolyMultiTempRegion.h index 5471ca5a7..8278aa052 100644 --- a/Cantera/src/thermo/Nasa9PolyMultiTempRegion.h +++ b/Cantera/src/thermo/Nasa9PolyMultiTempRegion.h @@ -121,7 +121,7 @@ namespace Cantera { virtual int reportType() const; //! Returns an integer representing the species index - virtual int speciesIndex() const; + virtual size_t speciesIndex() const; //! Update the properties for this species, given a temperature polynomial /*! @@ -202,7 +202,7 @@ namespace Cantera { * coeffs[index+1] = maxTempZone * coeffs[index+2+i] from i =0,9 are the coefficients themselves */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const; @@ -222,7 +222,7 @@ namespace Cantera { //! standard-state pressure doublereal m_Pref; //! species index - int m_index; + size_t m_index; //! Number of temperature regions size_t m_numTempRegions; diff --git a/Cantera/src/thermo/NasaPoly1.h b/Cantera/src/thermo/NasaPoly1.h index a7ed16c95..0d2888bf6 100644 --- a/Cantera/src/thermo/NasaPoly1.h +++ b/Cantera/src/thermo/NasaPoly1.h @@ -65,7 +65,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - NasaPoly1(int n, doublereal tlow, doublereal thigh, doublereal pref, + NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT (tlow), m_highT (thigh), @@ -132,7 +132,7 @@ namespace Cantera { virtual int reportType() const { return NASA1; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial /*! @@ -226,7 +226,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -306,7 +306,7 @@ namespace Cantera { //! standard-state pressure doublereal m_Pref; //! species index - int m_index; + size_t m_index; //! array of polynomial coefficients array_fp m_coeff; diff --git a/Cantera/src/thermo/NasaPoly2.h b/Cantera/src/thermo/NasaPoly2.h index 659b98446..98c8e8d7e 100644 --- a/Cantera/src/thermo/NasaPoly2.h +++ b/Cantera/src/thermo/NasaPoly2.h @@ -72,7 +72,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - NasaPoly2(int n, doublereal tlow, doublereal thigh, doublereal pref, + NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT(tlow), m_highT(thigh), @@ -165,7 +165,7 @@ namespace Cantera { virtual int reportType() const { return NASA2; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial @@ -243,7 +243,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - void reportParameters(int &n, int &type, + void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -301,7 +301,7 @@ namespace Cantera { //! pointer to the NasaPoly1 object for the high temperature region. NasaPoly1 *mnp_high; //! species index - int m_index; + size_t m_index; //! array of polynomial coefficients array_fp m_coeff; diff --git a/Cantera/src/thermo/NasaThermo.h b/Cantera/src/thermo/NasaThermo.h index e9096f11e..79a2581b9 100644 --- a/Cantera/src/thermo/NasaThermo.h +++ b/Cantera/src/thermo/NasaThermo.h @@ -149,7 +149,7 @@ namespace Cantera { * parameterization. * @see speciesThermoTypes.h */ - virtual void install(string name, int index, int type, + virtual void install(string name, size_t index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { @@ -235,7 +235,7 @@ namespace Cantera { * (length m_kk). * */ - virtual void update_one(int k, doublereal t, doublereal* cp_R, + virtual void update_one(size_t k, doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { m_t[0] = t; @@ -245,8 +245,8 @@ namespace Cantera { m_t[4] = 1.0/t; m_t[5] = log(t); - int grp = m_group_map[k]; - int pos = m_posInGroup_map[k]; + size_t grp = m_group_map[k]; + size_t pos = m_posInGroup_map[k]; const vector &mlg = m_low[grp-1]; const NasaPoly1 *nlow = &(mlg[pos]); @@ -313,8 +313,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const { - if (k < 0) + virtual doublereal minTemp(size_t k=-1) const { + if (k == -1) return m_tlow_max; else return m_tlow[k]; @@ -330,8 +330,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal maxTemp(int k=-1) const { - if (k < 0) + virtual doublereal maxTemp(size_t k=-1) const { + if (k == -1) return m_thigh_min; else return m_thigh[k]; @@ -350,7 +350,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal refPressure(int k = -1) const { + virtual doublereal refPressure(size_t k = -1) const { return m_p0; } @@ -360,7 +360,7 @@ namespace Cantera { * * @param index Species index */ - virtual int reportType(int index) const { return NASA; } + virtual int reportType(size_t index) const { return NASA; } /*! * This utility function reports back the type of @@ -376,15 +376,15 @@ namespace Cantera { * @param maxTemp output - Maximum temperature * @param refPressure output - reference pressure (Pa). */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const { type = reportType(index); if (type == NASA) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; + size_t grp = m_group_map[index]; + size_t pos = m_posInGroup_map[index]; const vector &mlg = m_low[grp-1]; const vector &mhg = m_high[grp-1]; const NasaPoly1 *lowPoly = &(mlg[pos]); @@ -392,7 +392,7 @@ namespace Cantera { int itype = NASA; doublereal tmid = lowPoly->maxTemp(); c[0] = tmid; - int n; + size_t n; double ttemp; lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, c + 1); @@ -428,11 +428,11 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c) { + virtual void modifyParams(size_t index, doublereal *c) { int type = reportType(index); if (type == NASA) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; + size_t grp = m_group_map[index]; + size_t pos = m_posInGroup_map[index]; vector &mlg = m_low[grp-1]; vector &mhg = m_high[grp-1]; NasaPoly1 *lowPoly = &(mlg[pos]); @@ -561,17 +561,17 @@ namespace Cantera { * for that species are stored. group indecises start at 1, * so a decrement is always performed to access vectors. */ - mutable map m_group_map; + mutable map m_group_map; /*! * This map takes as its index, the species index in the phase. * It returns the position index within the group, where the * temperature polynomials for that species are storred. */ - mutable map m_posInGroup_map; + mutable map m_posInGroup_map; //! Species name as a function of the species index - mutable map m_name; + mutable map m_name; private: diff --git a/Cantera/src/thermo/PDSS.cpp b/Cantera/src/thermo/PDSS.cpp index 1bdc7f568..f7b081056 100644 --- a/Cantera/src/thermo/PDSS.cpp +++ b/Cantera/src/thermo/PDSS.cpp @@ -48,7 +48,7 @@ namespace Cantera { { } - PDSS::PDSS(VPStandardStateTP *tp, int spindex) : + PDSS::PDSS(VPStandardStateTP *tp, size_t spindex) : m_pdssType(cPDSS_UNDEF), m_temp(-1.0), m_pres(-1.0), @@ -485,7 +485,7 @@ namespace Cantera { } - void PDSS::reportParams(int &kindex, int &type, + void PDSS::reportParams(size_t &kindex, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, diff --git a/Cantera/src/thermo/PDSS.h b/Cantera/src/thermo/PDSS.h index 6671593c6..b9a7c920a 100644 --- a/Cantera/src/thermo/PDSS.h +++ b/Cantera/src/thermo/PDSS.h @@ -233,7 +233,7 @@ namespace Cantera { * @param tp Pointer to the ThermoPhase object pertaining to the phase * @param spindex Species index of the species in the phase */ - PDSS(VPStandardStateTP *tp, int spindex); + PDSS(VPStandardStateTP *tp, size_t spindex); //! Copy Constructor /*! @@ -620,7 +620,7 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - virtual void reportParams(int &kindex, int &type, doublereal * const c, + virtual void reportParams(size_t &kindex, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const; @@ -692,7 +692,7 @@ namespace Cantera { /** * Species index in the thermophase corresponding to this species. */ - int m_spindex; + size_t m_spindex; //! Pointer to the species thermodynamic property manager. /*! diff --git a/Cantera/src/thermo/PDSS_ConstVol.cpp b/Cantera/src/thermo/PDSS_ConstVol.cpp index 6e3b93457..29c6ea713 100644 --- a/Cantera/src/thermo/PDSS_ConstVol.cpp +++ b/Cantera/src/thermo/PDSS_ConstVol.cpp @@ -23,21 +23,21 @@ namespace Cantera { * Basic list of constructors and duplicators */ - PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, int spindex) : + PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, size_t spindex) : PDSS(tp, spindex) { m_pdssType = cPDSS_CONSTVOL; } - PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, int spindex, std::string inputFile, std::string id) : + PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) : PDSS(tp, spindex) { m_pdssType = cPDSS_CONSTVOL; constructPDSSFile(tp, spindex, inputFile, id); } - PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, int spindex, + PDSS_ConstVol::PDSS_ConstVol(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRoot, bool spInstalled) : @@ -93,7 +93,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void PDSS_ConstVol::constructPDSSXML(VPStandardStateTP *tp, int spindex, + void PDSS_ConstVol::constructPDSSXML(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, bool spInstalled) { PDSS::initThermo(); @@ -138,7 +138,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void PDSS_ConstVol::constructPDSSFile(VPStandardStateTP *tp, int spindex, + void PDSS_ConstVol::constructPDSSFile(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) { if (inputFile.size() == 0) { diff --git a/Cantera/src/thermo/PDSS_ConstVol.h b/Cantera/src/thermo/PDSS_ConstVol.h index 076101d5d..b8c28fe02 100644 --- a/Cantera/src/thermo/PDSS_ConstVol.h +++ b/Cantera/src/thermo/PDSS_ConstVol.h @@ -39,7 +39,7 @@ namespace Cantera { * @param tp Pointer to the ThermoPhase object pertaining to the phase * @param spindex Species index of the species in the phase */ - PDSS_ConstVol(VPStandardStateTP *tp, int spindex); + PDSS_ConstVol(VPStandardStateTP *tp, size_t spindex); //! Constructor that initializes the object by examining the input file @@ -54,7 +54,7 @@ namespace Cantera { * is the empty string, in which case the first phase in the * file is used. */ - PDSS_ConstVol(VPStandardStateTP *tp, int spindex, + PDSS_ConstVol(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id = ""); //! Constructor that initializes the object by examining the input file @@ -69,7 +69,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is installed yet * or not. */ - PDSS_ConstVol(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, + PDSS_ConstVol(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRef, bool spInstalled); //! Copy Constructur @@ -362,7 +362,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, std::string inputFile, std::string id); //! Initialization of a PDSS object using an xml tree @@ -388,7 +388,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is * already installed. */ - void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, bool spInstalled); diff --git a/Cantera/src/thermo/PDSS_HKFT.cpp b/Cantera/src/thermo/PDSS_HKFT.cpp index 3d72eb81f..d4bb8081a 100644 --- a/Cantera/src/thermo/PDSS_HKFT.cpp +++ b/Cantera/src/thermo/PDSS_HKFT.cpp @@ -25,7 +25,7 @@ namespace Cantera { /* * Basic list of constructors and duplicators */ - PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, int spindex) : + PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, size_t spindex) : PDSS(tp, spindex), m_waterSS(0), m_densWaterSS(-1.0), @@ -55,7 +55,7 @@ namespace Cantera { } - PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, int spindex, std::string inputFile, std::string id) : + PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) : PDSS(tp, spindex), m_waterSS(0), m_densWaterSS(-1.0), @@ -85,7 +85,7 @@ namespace Cantera { constructPDSSFile(tp, spindex, inputFile, id); } - PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, int spindex, const XML_Node& speciesNode, + PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRoot, bool spInstalled) : PDSS(tp, spindex), m_waterSS(0), @@ -613,7 +613,7 @@ namespace Cantera { m_waterProps = new WaterProps(m_waterSS); } - void PDSS_HKFT::constructPDSSXML(VPStandardStateTP *tp, int spindex, + void PDSS_HKFT::constructPDSSXML(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, bool spInstalled) { int hasDGO = 0; @@ -772,7 +772,7 @@ namespace Cantera { } - void PDSS_HKFT::constructPDSSFile(VPStandardStateTP *tp, int spindex, + void PDSS_HKFT::constructPDSSFile(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) { if (inputFile.size() == 0) { @@ -1272,7 +1272,7 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - void PDSS_HKFT::reportParams(int &kindex, int &type, + void PDSS_HKFT::reportParams(size_t &kindex, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, diff --git a/Cantera/src/thermo/PDSS_HKFT.h b/Cantera/src/thermo/PDSS_HKFT.h index 3fc2c2d97..4121998a4 100644 --- a/Cantera/src/thermo/PDSS_HKFT.h +++ b/Cantera/src/thermo/PDSS_HKFT.h @@ -65,7 +65,7 @@ namespace Cantera { * @param tp Pointer to the ThermoPhase object pertaining to the phase * @param spindex Species index of the species in the phase */ - PDSS_HKFT(VPStandardStateTP *tp, int spindex); + PDSS_HKFT(VPStandardStateTP *tp, size_t spindex); //! Copy Constructor /*! @@ -91,7 +91,7 @@ namespace Cantera { * is the empty string, in which case the first phase in the * file is used. */ - PDSS_HKFT(VPStandardStateTP *vptp_ptr, int spindex, + PDSS_HKFT(VPStandardStateTP *vptp_ptr, size_t spindex, std::string inputFile, std::string id = ""); //! Constructor that initializes the object by examining the input file @@ -106,7 +106,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is installed yet * or not. */ - PDSS_HKFT(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, + PDSS_HKFT(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRef, bool spInstalled); //! Destructor for the phase @@ -377,7 +377,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, std::string inputFile, std::string id); //! Initialization of a PDSS object using an xml tree @@ -403,7 +403,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is * already installed. */ - void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, bool spInstalled); @@ -468,7 +468,7 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - virtual void reportParams(int &kindex, int &type, doublereal * const c, + virtual void reportParams(size_t &kindex, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const; diff --git a/Cantera/src/thermo/PDSS_IdealGas.cpp b/Cantera/src/thermo/PDSS_IdealGas.cpp index 3104e5dac..5703c3a1b 100644 --- a/Cantera/src/thermo/PDSS_IdealGas.cpp +++ b/Cantera/src/thermo/PDSS_IdealGas.cpp @@ -40,7 +40,7 @@ namespace Cantera { - PDSS_IdealGas::PDSS_IdealGas(VPStandardStateTP *tp, int spindex, const XML_Node& speciesNode, + PDSS_IdealGas::PDSS_IdealGas(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRoot, bool spInstalled) : PDSS(tp, spindex) { @@ -104,14 +104,14 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void PDSS_IdealGas::constructPDSSXML(VPStandardStateTP *tp, int spindex, + void PDSS_IdealGas::constructPDSSXML(VPStandardStateTP *tp, size_t spindex, const XML_Node& phaseNode, std::string id) { //initThermo(); //initThermoXML(phaseNode, id); } - void PDSS_IdealGas::constructPDSSFile(VPStandardStateTP *tp, int spindex, + void PDSS_IdealGas::constructPDSSFile(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) { if (inputFile.size() == 0) { diff --git a/Cantera/src/thermo/PDSS_IdealGas.h b/Cantera/src/thermo/PDSS_IdealGas.h index 5d016a9e0..59ba91893 100644 --- a/Cantera/src/thermo/PDSS_IdealGas.h +++ b/Cantera/src/thermo/PDSS_IdealGas.h @@ -82,7 +82,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is installed yet * or not. */ - PDSS_IdealGas(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, + PDSS_IdealGas(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRef, bool spInstalled); @@ -361,7 +361,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, std::string inputFile, std::string id); //!Initialization of a PDSS object using an xml tree @@ -386,7 +386,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& phaseNode, std::string id); //! Initialization routine for the PDSS object based on the phaseNode diff --git a/Cantera/src/thermo/PDSS_IonsFromNeutral.cpp b/Cantera/src/thermo/PDSS_IonsFromNeutral.cpp index 0c7188c03..a072ee40c 100644 --- a/Cantera/src/thermo/PDSS_IonsFromNeutral.cpp +++ b/Cantera/src/thermo/PDSS_IonsFromNeutral.cpp @@ -24,7 +24,7 @@ namespace Cantera { * Basic list of constructors and duplicators */ - PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, int spindex) : + PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, size_t spindex) : PDSS(tp, spindex), neutralMoleculePhase_(0), numMult_(0), @@ -34,7 +34,7 @@ namespace Cantera { m_pdssType = cPDSS_IONSFROMNEUTRAL; } //==================================================================================================================== - PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, int spindex, + PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) : PDSS(tp, spindex), neutralMoleculePhase_(0), @@ -47,7 +47,7 @@ namespace Cantera { } //==================================================================================================================== - PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, int spindex, const XML_Node& speciesNode, + PDSS_IonsFromNeutral::PDSS_IonsFromNeutral(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRoot, bool spInstalled) : PDSS(tp, spindex), neutralMoleculePhase_(0), @@ -134,7 +134,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP *tp, int spindex, + void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP *tp, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, std::string id) { const XML_Node *tn = speciesNode.findByName("thermo"); @@ -192,7 +192,7 @@ namespace Cantera { } //==================================================================================================================== - void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP *tp, int spindex, + void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id) { if (inputFile.size() == 0) { @@ -256,8 +256,8 @@ namespace Cantera { PDSS_IonsFromNeutral::enthalpy_RT() const { neutralMoleculePhase_->getEnthalpy_RT(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; @@ -289,8 +289,8 @@ namespace Cantera { PDSS_IonsFromNeutral::entropy_R() const { neutralMoleculePhase_->getEntropy_R(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } if (add2RTln2_) { @@ -314,8 +314,8 @@ namespace Cantera { PDSS_IonsFromNeutral::gibbs_RT() const { neutralMoleculePhase_->getGibbs_RT(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } if (add2RTln2_) { @@ -338,8 +338,8 @@ namespace Cantera { PDSS_IonsFromNeutral::cp_R() const { neutralMoleculePhase_->getCp_R(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; @@ -349,8 +349,8 @@ namespace Cantera { PDSS_IonsFromNeutral::molarVolume() const { neutralMoleculePhase_->getStandardVolumes(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; @@ -377,8 +377,8 @@ namespace Cantera { PDSS_IonsFromNeutral::gibbs_RT_ref() const { neutralMoleculePhase_->getGibbs_RT_ref(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } if (add2RTln2_) { @@ -390,8 +390,8 @@ namespace Cantera { doublereal PDSS_IonsFromNeutral::enthalpy_RT_ref() const { neutralMoleculePhase_->getEnthalpy_RT_ref(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; @@ -400,8 +400,8 @@ namespace Cantera { doublereal PDSS_IonsFromNeutral::entropy_R_ref() const { neutralMoleculePhase_->getEntropy_R_ref(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } if (add2RTln2_) { @@ -413,8 +413,8 @@ namespace Cantera { doublereal PDSS_IonsFromNeutral::cp_R_ref() const { neutralMoleculePhase_->getCp_R_ref(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; @@ -423,8 +423,8 @@ namespace Cantera { doublereal PDSS_IonsFromNeutral::molarVolume_ref() const { neutralMoleculePhase_->getStandardVolumes_ref(DATA_PTR(tmpNM)); doublereal val = 0.0; - for (int i = 0; i < numMult_; i++) { - int jNeut = idNeutralMoleculeVec[i]; + for (size_t i = 0; i < numMult_; i++) { + size_t jNeut = idNeutralMoleculeVec[i]; val += factorVec[i] * tmpNM[jNeut]; } return val; diff --git a/Cantera/src/thermo/PDSS_IonsFromNeutral.h b/Cantera/src/thermo/PDSS_IonsFromNeutral.h index c2e524c54..b71439188 100644 --- a/Cantera/src/thermo/PDSS_IonsFromNeutral.h +++ b/Cantera/src/thermo/PDSS_IonsFromNeutral.h @@ -42,7 +42,7 @@ namespace Cantera { * @param tp Pointer to the ThermoPhase object pertaining to the phase * @param spindex Species index of the species in the phase */ - PDSS_IonsFromNeutral(VPStandardStateTP *tp, int spindex); + PDSS_IonsFromNeutral(VPStandardStateTP *tp, size_t spindex); //! Constructor that initializes the object by examining the input file //! of the ThermoPhase object @@ -56,7 +56,7 @@ namespace Cantera { * is the empty string, in which case the first phase in the * file is used. */ - PDSS_IonsFromNeutral(VPStandardStateTP *tp, int spindex, + PDSS_IonsFromNeutral(VPStandardStateTP *tp, size_t spindex, std::string inputFile, std::string id = ""); @@ -72,7 +72,7 @@ namespace Cantera { * @param spInstalled Boolean indicating whether the species is installed yet * or not. */ - PDSS_IonsFromNeutral(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, + PDSS_IonsFromNeutral(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseRef, bool spInstalled); //! Copy Constructor @@ -381,7 +381,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, std::string inputFile, std::string id); //!Initialization of a PDSS object using an xml tree @@ -406,7 +406,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, + void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node& speciesNode, const XML_Node& phaseNode, std::string id); diff --git a/Cantera/src/thermo/Phase.cpp b/Cantera/src/thermo/Phase.cpp index f43f5af18..4b9101aeb 100644 --- a/Cantera/src/thermo/Phase.cpp +++ b/Cantera/src/thermo/Phase.cpp @@ -19,7 +19,7 @@ namespace Cantera { Phase::Phase() : Constituents(), State(), - m_kk(-1), + m_kk(0), m_ndim(3), m_index(-1), m_xml(new XML_Node("phase")), @@ -37,7 +37,7 @@ namespace Cantera { Phase::Phase(const Phase &right) : Constituents(), State(), - m_kk(-1), + m_kk(0), m_ndim(3), m_index(-1), m_xml(new XML_Node("phase")), diff --git a/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp b/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp index ccd84c676..b84106d81 100644 --- a/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp +++ b/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp @@ -142,12 +142,12 @@ namespace Cantera { */ - doublereal PseudoBinaryVPSSTP::standardConcentration(int k) const { + doublereal PseudoBinaryVPSSTP::standardConcentration(size_t k) const { err("standardConcentration"); return -1.0; } - doublereal PseudoBinaryVPSSTP::logStandardConc(int k) const { + doublereal PseudoBinaryVPSSTP::logStandardConc(size_t k) const { err("logStandardConc"); return -1.0; } diff --git a/Cantera/src/thermo/PseudoBinaryVPSSTP.h b/Cantera/src/thermo/PseudoBinaryVPSSTP.h index 3970caeac..4eaaa7cd0 100644 --- a/Cantera/src/thermo/PseudoBinaryVPSSTP.h +++ b/Cantera/src/thermo/PseudoBinaryVPSSTP.h @@ -186,7 +186,7 @@ namespace Cantera { * * @param k species index. Defaults to zero. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /** * Returns the natural logarithm of the standard @@ -194,7 +194,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; diff --git a/Cantera/src/thermo/PureFluidPhase.cpp b/Cantera/src/thermo/PureFluidPhase.cpp index 1e1b16c9f..20ea296d3 100644 --- a/Cantera/src/thermo/PureFluidPhase.cpp +++ b/Cantera/src/thermo/PureFluidPhase.cpp @@ -459,7 +459,7 @@ namespace Cantera { csvFile.precision(8); - int kk = nSpecies(); + size_t kk = nSpecies(); std::vector x(kk, 0.0); std::vector y(kk, 0.0); std::vector mu(kk, 0.0); diff --git a/Cantera/src/thermo/ShomatePoly.h b/Cantera/src/thermo/ShomatePoly.h index 564df167d..83141fbf3 100644 --- a/Cantera/src/thermo/ShomatePoly.h +++ b/Cantera/src/thermo/ShomatePoly.h @@ -85,7 +85,7 @@ namespace Cantera { * See the class description for the polynomial representation of the * thermo functions in terms of \f$ A, \dots, G \f$. */ - ShomatePoly(int n, doublereal tlow, doublereal thigh, doublereal pref, + ShomatePoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT (tlow), m_highT (thigh), @@ -153,7 +153,7 @@ namespace Cantera { virtual int reportType() const { return SHOMATE; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial @@ -256,7 +256,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -346,7 +346,7 @@ namespace Cantera { //! Array of coeffcients array_fp m_coeff; //! Species Index - int m_index; + size_t m_index; private: @@ -423,7 +423,7 @@ namespace Cantera { * coefficients are the low temperature range Shomate coefficients. * The last 7 are the high temperature range Shomate coefficients. */ - ShomatePoly2(int n, doublereal tlow, doublereal thigh, doublereal pref, + ShomatePoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : m_lowT (tlow), m_midT(0.0), @@ -514,7 +514,7 @@ namespace Cantera { virtual int reportType() const { return SHOMATE2; } //! Returns an integer representing the species index - virtual int speciesIndex() const { return m_index; } + virtual size_t speciesIndex() const { return m_index; } //! Update the properties for this species, given a temperature polynomial /*! @@ -592,7 +592,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &n, int &type, + virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal* const coeffs) const { @@ -669,7 +669,7 @@ namespace Cantera { //! Array of the original coefficients. array_fp m_coeff; //! Species index - int m_index; + size_t m_index; }; } diff --git a/Cantera/src/thermo/ShomateThermo.h b/Cantera/src/thermo/ShomateThermo.h index 642515057..d959af4f6 100644 --- a/Cantera/src/thermo/ShomateThermo.h +++ b/Cantera/src/thermo/ShomateThermo.h @@ -159,7 +159,7 @@ namespace Cantera { * @see ShomatePoly * @see ShomatePoly2 */ - virtual void install(string name, int index, int type, + virtual void install(string name, size_t index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { @@ -230,7 +230,7 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void update_one(int k, doublereal t, doublereal* cp_R, + virtual void update_one(size_t k, doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { doublereal tt = 1.e-3*t; @@ -242,8 +242,8 @@ namespace Cantera { m_t[5] = 1.0/GasConstant; m_t[6] = 1.0/(GasConstant * t); - int grp = m_group_map[k]; - int pos = m_posInGroup_map[k]; + size_t grp = m_group_map[k]; + size_t pos = m_posInGroup_map[k]; const vector &mlg = m_low[grp-1]; const ShomatePoly *nlow = &(mlg[pos]); @@ -311,8 +311,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const { - if (k < 0) + virtual doublereal minTemp(size_t k=-1) const { + if (k == -1) return m_tlow_max; else return m_tlow[k]; @@ -328,8 +328,8 @@ namespace Cantera { * * @param k species index */ - virtual doublereal maxTemp(int k=-1) const { - if (k < 0) + virtual doublereal maxTemp(size_t k=-1) const { + if (k == -1) return m_thigh_min; else return m_thigh[k]; @@ -348,7 +348,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal refPressure(int k=-1) const { + virtual doublereal refPressure(size_t k=-1) const { return m_p0; } @@ -358,7 +358,7 @@ namespace Cantera { * * @param index Species index */ - virtual int reportType(int index) const { return SHOMATE; } + virtual int reportType(size_t index) const { return SHOMATE; } /*! * This utility function reports back the type of @@ -374,15 +374,15 @@ namespace Cantera { * @param maxTemp output - Maximum temperature * @param refPressure output - reference pressure (Pa). */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const { type = reportType(index); if (type == SHOMATE) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; + size_t grp = m_group_map[index]; + size_t pos = m_posInGroup_map[index]; int itype = SHOMATE; const vector &mlg = m_low[grp-1]; const vector &mhg = m_high[grp-1]; @@ -390,7 +390,7 @@ namespace Cantera { const ShomatePoly *highPoly = &(mhg[pos]); doublereal tmid = lowPoly->maxTemp(); c[0] = tmid; - int n; + size_t n; double ttemp; lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, c + 1); @@ -419,11 +419,11 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c) { + virtual void modifyParams(size_t index, doublereal *c) { int type = reportType(index); if (type == SHOMATE) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; + size_t grp = m_group_map[index]; + size_t pos = m_posInGroup_map[index]; vector &mlg = m_low[grp-1]; vector &mhg = m_high[grp-1]; ShomatePoly *lowPoly = &(mlg[pos]); @@ -560,14 +560,14 @@ namespace Cantera { * for that species are stored. group indecises start at 1, * so a decrement is always performed to access vectors. */ - mutable map m_group_map; + mutable map m_group_map; /*! * This map takes as its index, the species index in the phase. * It returns the position index within the group, where the * temperature polynomials for that species are storred. */ - mutable map m_posInGroup_map; + mutable map m_posInGroup_map; }; } diff --git a/Cantera/src/thermo/SimpleThermo.h b/Cantera/src/thermo/SimpleThermo.h index 7b96372f5..51026e147 100644 --- a/Cantera/src/thermo/SimpleThermo.h +++ b/Cantera/src/thermo/SimpleThermo.h @@ -146,7 +146,7 @@ namespace Cantera { * * @see ConstCpPoly */ - virtual void install(string name, int index, int type, + virtual void install(string name, size_t index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { //writelog("installing const_cp for species "+name+"\n"); @@ -211,7 +211,7 @@ namespace Cantera { */ virtual void update(doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { - int k, ki; + size_t k, ki; doublereal logt = log(t); doublereal rt = 1.0/t; for (k = 0; k < m_nspData; k++) { @@ -233,11 +233,11 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void update_one(int k, doublereal t, doublereal* cp_R, + virtual void update_one(size_t k, doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { doublereal logt = log(t); doublereal rt = 1.0/t; - int loc = m_loc[k]; + size_t loc = m_loc[k]; cp_R[k] = m_cp0_R[loc]; h_RT[k] = rt*(m_h0_R[loc] + (t - m_t0[loc]) * m_cp0_R[loc]); s_R[k] = m_s0_R[loc] + m_cp0_R[loc] * (logt - m_logt0[loc]); @@ -253,8 +253,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const { - if (k < 0) + virtual doublereal minTemp(size_t k=-1) const { + if (k == -1) return m_tlow_max; else return m_tlow[m_loc[k]]; @@ -270,8 +270,8 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal maxTemp(int k=-1) const { - if (k < 0) + virtual doublereal maxTemp(size_t k=-1) const { + if (k == -1) return m_thigh_min; else return m_thigh[m_loc[k]]; @@ -290,7 +290,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal refPressure(int k=-1) const {return m_p0;} + virtual doublereal refPressure(size_t k=-1) const {return m_p0;} //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -298,7 +298,7 @@ namespace Cantera { * * @param index Species index */ - virtual int reportType(int index) const { return SIMPLE; } + virtual int reportType(size_t index) const { return SIMPLE; } /*! * This utility function reports back the type of @@ -315,13 +315,13 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const { type = reportType(index); - int loc = m_loc[index]; + size_t loc = m_loc[index]; if (type == SIMPLE) { c[0] = m_t0[loc]; c[1] = m_h0_R[loc] * GasConstant; @@ -342,9 +342,9 @@ namespace Cantera { * parameters for the standard state. * Must be length >= 4. */ - virtual void modifyParams(int index, doublereal *c) { - int loc = m_loc[index]; - if (loc < 0) { + virtual void modifyParams(size_t index, doublereal *c) { + size_t loc = m_loc[index]; + if (loc == -1) { throw CanteraError("SimpleThermo::modifyParams", "modifying parameters for species which hasn't been set yet"); } @@ -378,14 +378,14 @@ namespace Cantera { * This index keeps track of it. * indexData = m_loc[kspec] */ - mutable map m_loc; + mutable map m_loc; //! Map between the vector index where the coefficients are kept and the species index /*! * Length is equal to the number of dataPoints. * kspec = m_index[indexData] */ - vector_int m_index; + std::vector m_index; //! Maximum value of the low temperature limit doublereal m_tlow_max; diff --git a/Cantera/src/thermo/SpeciesThermo.h b/Cantera/src/thermo/SpeciesThermo.h index 23fe6a3da..63eb0fc75 100644 --- a/Cantera/src/thermo/SpeciesThermo.h +++ b/Cantera/src/thermo/SpeciesThermo.h @@ -233,7 +233,7 @@ namespace Cantera { * parameterization. * @see speciesThermoTypes.h */ - virtual void install(std::string name, int index, int type, + virtual void install(std::string name, size_t index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure)=0; @@ -281,7 +281,7 @@ namespace Cantera { * @param s_R Vector of Dimensionless entropies. * (length m_kk). */ - virtual void update_one(int k, doublereal T, + virtual void update_one(size_t k, doublereal T, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { @@ -298,7 +298,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const =0; + virtual doublereal minTemp(size_t k=-1) const =0; //! Maximum temperature. /*! @@ -310,7 +310,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal maxTemp(int k=-1) const =0; + virtual doublereal maxTemp(size_t k=-1) const =0; //! The reference-state pressure for species k. /*! @@ -325,7 +325,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal refPressure(int k=-1) const =0; + virtual doublereal refPressure(size_t k=-1) const =0; //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -333,7 +333,7 @@ namespace Cantera { * * @param index Species index */ - virtual int reportType(int index = -1) const = 0; + virtual int reportType(size_t index = -1) const = 0; //! This utility function reports back the type of @@ -347,7 +347,7 @@ namespace Cantera { * @param maxTemp output - Maximum temperature * @param refPressure output - reference pressure (Pa). */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -359,7 +359,7 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c) = 0; + virtual void modifyParams(size_t index, doublereal *c) = 0; #ifdef H298MODIFY_CAPABILITY //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) diff --git a/Cantera/src/thermo/SpeciesThermoFactory.cpp b/Cantera/src/thermo/SpeciesThermoFactory.cpp index 421d4d1b9..410dceef5 100644 --- a/Cantera/src/thermo/SpeciesThermoFactory.cpp +++ b/Cantera/src/thermo/SpeciesThermoFactory.cpp @@ -288,7 +288,7 @@ namespace Cantera { * block is found in the XML input. */ static void installNasaThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -458,7 +458,7 @@ namespace Cantera { #endif } - static doublereal convertDGFormation(int k, ThermoPhase *th_ptr) { + static doublereal convertDGFormation(size_t k, ThermoPhase *th_ptr) { /* * Ok let's get the element compositions and conversion factors. */ @@ -483,7 +483,7 @@ namespace Cantera { static void installMinEQ3asShomateThermoFromXML(std::string speciesName, ThermoPhase *th_ptr, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node* MinEQ3node) { array_fp coef(15), c0(7, 0.0); @@ -563,7 +563,7 @@ namespace Cantera { * parameterization for species k. */ static void installShomateThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -618,7 +618,7 @@ namespace Cantera { * parameterization for species k. */ static void installSimpleThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const XML_Node& f) { doublereal tmin, tmax; tmin = fpValue(f["Tmin"]); @@ -641,7 +641,7 @@ namespace Cantera { * block is found in the XML input. */ static void installNasa9ThermoFromXML(std::string speciesName, - SpeciesThermo& sp, int k, + SpeciesThermo& sp, size_t k, const std::vector& tp) { const XML_Node * fptr = tp[0]; @@ -744,10 +744,10 @@ namespace Cantera { * information for the phase in which the species * resides */ - void SpeciesThermoFactory:: - installThermoForSpecies(int k, const XML_Node& speciesNode, ThermoPhase *th_ptr, - SpeciesThermo& spthermo, - const XML_Node *phaseNode_ptr) const { + void SpeciesThermoFactory::installThermoForSpecies + (size_t k, const XML_Node& speciesNode, ThermoPhase *th_ptr, + SpeciesThermo& spthermo, const XML_Node *phaseNode_ptr) const + { /* * Check to see that the species block has a thermo block * before processing. Throw an error if not there. @@ -851,7 +851,7 @@ namespace Cantera { * resides */ void SpeciesThermoFactory:: - installVPThermoForSpecies(int k, const XML_Node& speciesNode, + installVPThermoForSpecies(size_t k, const XML_Node& speciesNode, VPStandardStateTP *vp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr, diff --git a/Cantera/src/thermo/SpeciesThermoFactory.h b/Cantera/src/thermo/SpeciesThermoFactory.h index 10365941a..3e03e311a 100644 --- a/Cantera/src/thermo/SpeciesThermoFactory.h +++ b/Cantera/src/thermo/SpeciesThermoFactory.h @@ -172,7 +172,7 @@ namespace Cantera { * information for the phase in which the species * resides */ - void installThermoForSpecies(int k, const XML_Node& speciesNode, + void installThermoForSpecies(size_t k, const XML_Node& speciesNode, ThermoPhase *th_ptr, SpeciesThermo& spthermo, const XML_Node *phaseNode_ptr = 0) const; @@ -196,7 +196,7 @@ namespace Cantera { * information for the phase in which the species * resides */ - void installVPThermoForSpecies(int k, const XML_Node& speciesNode, + void installVPThermoForSpecies(size_t k, const XML_Node& speciesNode, VPStandardStateTP *vp_ptr, VPSSMgr *vpss_ptr, SpeciesThermo *spthermo_ptr, diff --git a/Cantera/src/thermo/SpeciesThermoInterpType.cpp b/Cantera/src/thermo/SpeciesThermoInterpType.cpp index 4f429d930..c7adc6d51 100644 --- a/Cantera/src/thermo/SpeciesThermoInterpType.cpp +++ b/Cantera/src/thermo/SpeciesThermoInterpType.cpp @@ -46,7 +46,7 @@ namespace Cantera { { } - STITbyPDSS::STITbyPDSS(int k, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr) : + STITbyPDSS::STITbyPDSS(size_t k, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr) : m_vpssmgr_ptr(vpssmgr_ptr), m_PDSS_ptr(PDSS_ptr), m_speciesIndex(k) @@ -101,7 +101,7 @@ namespace Cantera { } //! Returns an integer representing the species index - int STITbyPDSS::speciesIndex() const { + size_t STITbyPDSS::speciesIndex() const { return m_speciesIndex; } @@ -174,7 +174,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - void STITbyPDSS::reportParameters(int &index, int &type, + void STITbyPDSS::reportParameters(size_t &index, int &type, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure, doublereal* const coeffs) const { diff --git a/Cantera/src/thermo/SpeciesThermoInterpType.h b/Cantera/src/thermo/SpeciesThermoInterpType.h index d0c39870f..30be1b764 100644 --- a/Cantera/src/thermo/SpeciesThermoInterpType.h +++ b/Cantera/src/thermo/SpeciesThermoInterpType.h @@ -187,7 +187,7 @@ namespace Cantera { virtual int reportType() const = 0; //! Returns an integer representing the species index - virtual int speciesIndex() const = 0; + virtual size_t speciesIndex() const = 0; //! Update the properties for this species, given a temperature //! polynomial @@ -247,7 +247,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &index, int &type, + virtual void reportParameters(size_t &index, int &type, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure, doublereal* const coeffs) const = 0; @@ -318,7 +318,7 @@ namespace Cantera { * * @param PDSS_ptr Pointer to the PDSS object that handles calls for this object */ - STITbyPDSS(int speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr); + STITbyPDSS(size_t speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr); //! copy constructor /*! @@ -364,7 +364,7 @@ namespace Cantera { virtual int reportType() const; //! Returns an integer representing the species index - virtual int speciesIndex() const; + virtual size_t speciesIndex() const; //! Update the properties for this species, given a temperature //! polynomial @@ -424,7 +424,7 @@ namespace Cantera { * @param coeffs Vector of coefficients used to set the * parameters for the standard state. */ - virtual void reportParameters(int &index, int &type, + virtual void reportParameters(size_t &index, int &type, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure, doublereal* const coeffs) const; @@ -451,7 +451,7 @@ namespace Cantera { PDSS *m_PDSS_ptr; //! Species index within the phase - int m_speciesIndex; + size_t m_speciesIndex; }; } diff --git a/Cantera/src/thermo/SpeciesThermoMgr.h b/Cantera/src/thermo/SpeciesThermoMgr.h index d8d8be4a6..38a4bffc5 100644 --- a/Cantera/src/thermo/SpeciesThermoMgr.h +++ b/Cantera/src/thermo/SpeciesThermoMgr.h @@ -206,7 +206,7 @@ namespace Cantera { * parameterization. * @see speciesThermoTypes.h */ - virtual void install(std::string name, int sp, int type, + virtual void install(std::string name, size_t sp, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure); @@ -247,7 +247,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k = -1) const; + virtual doublereal minTemp(size_t k = -1) const; //! Maximum temperature. /*! @@ -259,7 +259,7 @@ namespace Cantera { * * @param k index for parameterization k */ - virtual doublereal maxTemp(int k = -1) const; + virtual doublereal maxTemp(size_t k = -1) const; /** * The reference-state pressure for species k. @@ -274,7 +274,7 @@ namespace Cantera { * * @param k index for parameterization k */ - virtual doublereal refPressure(int k = -1) const; + virtual doublereal refPressure(size_t k = -1) const; //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -282,7 +282,7 @@ namespace Cantera { * * @param k Species index */ - virtual int reportType(int k) const; + virtual int reportType(size_t k) const; /*! * This utility function reports back the type of @@ -298,7 +298,7 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -310,7 +310,7 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c); + virtual void modifyParams(size_t index, doublereal *c); #ifdef H298MODIFY_CAPABILITY @@ -334,7 +334,7 @@ namespace Cantera { //! Reference pressure doublereal m_p0; //! map from species to type - std::map speciesToType; + std::map speciesToType; }; //! This species thermo manager requires that all species have the @@ -396,7 +396,7 @@ namespace Cantera { * @param type species type in terms of an int * @param c Parameters for the species thermo */ - virtual void install(std::string name, int sp, int type, + virtual void install(std::string name, size_t sp, int type, const vector_fp& c); //! update the object, because the temperature changed @@ -417,26 +417,26 @@ namespace Cantera { * @param h_RT vector of dimensionless enthalpy * @param s_R vector of dimensionless entropy */ - virtual void update_one(int k, doublereal t, vector_fp& cp_R, + virtual void update_one(size_t k, doublereal t, vector_fp& cp_R, vector_fp& h_RT, vector_fp& s_R) const; //! Returns the minimum temperature /*! * @param k species index. Defaults to -1. */ - virtual doublereal minTemp(int k = -1) const; + virtual doublereal minTemp(size_t k = -1) const; //! Returns the maximum temperature /*! * @param k species index. Defaults to -1. */ - virtual doublereal maxTemp(int k = -1) const; + virtual doublereal maxTemp(size_t k = -1) const; //! returns the reference pressure /*! * @param k species index. Defaults to -1. */ - virtual doublereal refPressure(int k = -1) const; + virtual doublereal refPressure(size_t k = -1) const; //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -445,7 +445,7 @@ namespace Cantera { * * @param k Species index */ - virtual int reportType(int k) const; + virtual int reportType(size_t) const; /*! * This utility function reports back the type of @@ -460,7 +460,7 @@ namespace Cantera { * @param maxTemp output - Maximum temperature * @param refPressure output - reference pressure (Pa). */ - virtual void reportParams(int index, int &type, + virtual void reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -472,7 +472,7 @@ namespace Cantera { * @param c Vector of coefficients used to set the * parameters for the standard state. */ - virtual void modifyParams(int index, doublereal *c); + virtual void modifyParams(size_t index, doublereal *c); #ifdef H298MODIFY_CAPABILITY //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) @@ -549,7 +549,7 @@ namespace Cantera { template void - SpeciesThermoDuo::install(std::string name, int sp, int type, + SpeciesThermoDuo::install(std::string name, size_t sp, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, @@ -584,7 +584,7 @@ namespace Cantera { template doublereal - SpeciesThermoDuo::minTemp(int k) const { + SpeciesThermoDuo::minTemp(size_t k) const { doublereal tm1 = m_thermo1.minTemp(); doublereal tm2 = m_thermo2.minTemp(); return (tm1 < tm2 ? tm2 : tm1); @@ -592,7 +592,7 @@ namespace Cantera { template doublereal - SpeciesThermoDuo::maxTemp(int k) const { + SpeciesThermoDuo::maxTemp(size_t k) const { doublereal tm1 = m_thermo1.maxTemp(); doublereal tm2 = m_thermo2.maxTemp(); return (tm1 < tm2 ? tm1 : tm2); @@ -600,14 +600,14 @@ namespace Cantera { template doublereal - SpeciesThermoDuo::refPressure(int k) const { + SpeciesThermoDuo::refPressure(size_t k) const { return m_p0; } template - int - SpeciesThermoDuo::reportType(int k) const { - std::map::const_iterator p = speciesToType.find(k); + int + SpeciesThermoDuo::reportType(size_t k) const { + std::map::const_iterator p = speciesToType.find(k); if (p != speciesToType.end()) { const int type = p->second; return type; @@ -617,7 +617,7 @@ namespace Cantera { template void - SpeciesThermoDuo::reportParams(int index, int &type, + SpeciesThermoDuo::reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -636,7 +636,7 @@ namespace Cantera { template void - SpeciesThermoDuo::modifyParams(int index, doublereal *c) { + SpeciesThermoDuo::modifyParams(size_t index, doublereal *c) { int ctype = reportType(index); if (ctype == m_thermo1.ID) { m_thermo1.modifyParams(index, c); @@ -686,7 +686,7 @@ namespace Cantera { template void - SpeciesThermo1::install(std::string name, int sp, int type, const vector_fp& c) + SpeciesThermo1::install(std::string name, size_t sp, int type, const vector_fp& c) { m_thermo.push_back(SPM(sp, c)); if (m_pref) { @@ -707,15 +707,15 @@ namespace Cantera { template void - SpeciesThermo1::update_one(int k, doublereal t, vector_fp& cp_R, + SpeciesThermo1::update_one(size_t k, doublereal t, vector_fp& cp_R, vector_fp& h_RT, vector_fp& s_R) const { m_thermo[k]->update(t, cp_R, h_RT, s_R); } template doublereal - SpeciesThermo1::minTemp(int k) const { - if (k < 0) + SpeciesThermo1::minTemp(size_t k) const { + if (k == -1) return _minTemp(m_thermo.begin(), m_thermo.end()); else return m_thermo[k].minTemp(); @@ -723,8 +723,8 @@ namespace Cantera { template doublereal - SpeciesThermo1::maxTemp(int k) const { - if (k < 0) + SpeciesThermo1::maxTemp(size_t k) const { + if (k == -1) return _maxTemp(m_thermo.begin(), m_thermo.end()); else return m_thermo[k].maxTemp(); @@ -732,19 +732,19 @@ namespace Cantera { template doublereal - SpeciesThermo1::refPressure(int k) const { + SpeciesThermo1::refPressure(size_t k) const { return m_pref; } template int - SpeciesThermo1::reportType(int k) const { + SpeciesThermo1::reportType(size_t k) const { return m_thermo[k]->reportType(-1); } template void - SpeciesThermo1::reportParams(int index, int &type, + SpeciesThermo1::reportParams(size_t index, int &type, doublereal * const c, doublereal &minTemp, doublereal &maxTemp, @@ -754,7 +754,7 @@ namespace Cantera { template void - SpeciesThermo1::modifyParams(int index, doublereal *c) { + SpeciesThermo1::modifyParams(size_t index, doublereal *c) { m_thermo[index]->modifyParameters(index, c); } } diff --git a/Cantera/src/thermo/State.cpp b/Cantera/src/thermo/State.cpp index e92d28a70..47cdda2bd 100644 --- a/Cantera/src/thermo/State.cpp +++ b/Cantera/src/thermo/State.cpp @@ -249,7 +249,8 @@ namespace Cantera { for (size_t k = 0; k < m_kk; k++) { if (m_molwts[k] < 0.0) { throw CanteraError("State::init", - "negative molecular weight for species number "+int2str(k)); + "negative molecular weight for species number " + + int2str(int(k))); } /* * Some surface phases may define species representing diff --git a/Cantera/src/thermo/StoichSubstance.cpp b/Cantera/src/thermo/StoichSubstance.cpp index 777821a27..784a1ad04 100644 --- a/Cantera/src/thermo/StoichSubstance.cpp +++ b/Cantera/src/thermo/StoichSubstance.cpp @@ -160,11 +160,11 @@ namespace Cantera { c[0] = 1.0; } - doublereal StoichSubstance::standardConcentration(int k) const { + doublereal StoichSubstance::standardConcentration(size_t k) const { return 1.0; } - doublereal StoichSubstance::logStandardConc(int k) const { + doublereal StoichSubstance::logStandardConc(size_t k) const { return 0.0; } diff --git a/Cantera/src/thermo/StoichSubstance.h b/Cantera/src/thermo/StoichSubstance.h index cf8d1fb31..3e5ad5010 100644 --- a/Cantera/src/thermo/StoichSubstance.h +++ b/Cantera/src/thermo/StoichSubstance.h @@ -176,13 +176,13 @@ namespace Cantera { * by which the generalized concentration is normalized to produce * the activity. */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; /** * Returns the natural logarithm of the standard * concentration of the kth species */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; /** * Get the array of chemical potentials at unit activity diff --git a/Cantera/src/thermo/StoichSubstanceSSTP.cpp b/Cantera/src/thermo/StoichSubstanceSSTP.cpp index bb9b3c5e2..4252bcbb7 100644 --- a/Cantera/src/thermo/StoichSubstanceSSTP.cpp +++ b/Cantera/src/thermo/StoichSubstanceSSTP.cpp @@ -218,7 +218,7 @@ namespace Cantera { * by which the generalized concentration is normalized to produce * the activity. */ - doublereal StoichSubstanceSSTP::standardConcentration(int k) const { + doublereal StoichSubstanceSSTP::standardConcentration(size_t k) const { return 1.0; } @@ -226,7 +226,7 @@ namespace Cantera { * Returns the natural logarithm of the standard * concentration of the kth species */ - doublereal StoichSubstanceSSTP::logStandardConc(int k) const { + doublereal StoichSubstanceSSTP::logStandardConc(size_t k) const { return 0.0; } diff --git a/Cantera/src/thermo/StoichSubstanceSSTP.h b/Cantera/src/thermo/StoichSubstanceSSTP.h index a13817b35..a055e0b6f 100644 --- a/Cantera/src/thermo/StoichSubstanceSSTP.h +++ b/Cantera/src/thermo/StoichSubstanceSSTP.h @@ -310,13 +310,13 @@ namespace Cantera { * @return * Returns The standard Concentration as 1.0 */ - virtual doublereal standardConcentration(int k=0) const; + virtual doublereal standardConcentration(size_t k=0) const; //! Natural logarithm of the standard concentration of the kth species. /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Get the array of chemical potentials at unit activity for the species //! at their standard states at the current T and P of the solution. diff --git a/Cantera/src/thermo/SurfPhase.cpp b/Cantera/src/thermo/SurfPhase.cpp index 0e826c1b1..4da8d76cf 100644 --- a/Cantera/src/thermo/SurfPhase.cpp +++ b/Cantera/src/thermo/SurfPhase.cpp @@ -221,11 +221,11 @@ namespace Cantera { getConcentrations(c); } - doublereal SurfPhase::standardConcentration(int k) const { + doublereal SurfPhase::standardConcentration(size_t k) const { return m_n0/size(k); } - doublereal SurfPhase::logStandardConc(int k) const { + doublereal SurfPhase::logStandardConc(size_t k) const { return m_logn0 - m_logsize[k]; } @@ -292,9 +292,9 @@ namespace Cantera { } void SurfPhase::initThermo() { - if (m_kk <= 0) { + if (m_kk == 0) { throw CanteraError("SurfPhase::initThermo", - "Number of species is less than or equal to zero"); + "Number of species is equal to zero"); } m_h0.resize(m_kk); m_s0.resize(m_kk); @@ -306,7 +306,7 @@ namespace Cantera { cov[0] = 1.0; setCoverages(DATA_PTR(cov)); m_logsize.resize(m_kk); - for (int k = 0; k < m_kk; k++) + for (size_t k = 0; k < m_kk; k++) m_logsize[k] = log(size(k)); } @@ -384,17 +384,16 @@ namespace Cantera { void SurfPhase:: setCoveragesByName(std::string cov) { - int kk = nSpecies(); - int k; + size_t kk = nSpecies(); compositionMap cc; - for (k = 0; k < kk; k++) { + for (size_t k = 0; k < kk; k++) { cc[speciesName(k)] = -1.0; } parseCompString(cov, cc); doublereal c; vector_fp cv(kk, 0.0); bool ifound = false; - for (k = 0; k < kk; k++) { + for (size_t k = 0; k < kk; k++) { c = cc[speciesName(k)]; if (c > 0.0) { ifound = true; diff --git a/Cantera/src/thermo/SurfPhase.h b/Cantera/src/thermo/SurfPhase.h index 3e2f7c45b..6c0a544c6 100644 --- a/Cantera/src/thermo/SurfPhase.h +++ b/Cantera/src/thermo/SurfPhase.h @@ -337,13 +337,13 @@ namespace Cantera { * @return * Returns the standard Concentration in units of m3 kmol-1. */ - virtual doublereal standardConcentration(int k = 0) const; + virtual doublereal standardConcentration(size_t k = 0) const; //! Return the log of the standard concentration for the kth species /*! * @param k species index (default 0) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Set the equation of state parameters from the argument list /*! diff --git a/Cantera/src/thermo/ThermoFactory.cpp b/Cantera/src/thermo/ThermoFactory.cpp index 09113d6e9..41972855a 100644 --- a/Cantera/src/thermo/ThermoFactory.cpp +++ b/Cantera/src/thermo/ThermoFactory.cpp @@ -658,7 +658,7 @@ namespace Cantera { * @return * Returns true if everything is ok, false otherwise. */ - bool installSpecies(int k, const XML_Node& s, thermo_t& th, + bool installSpecies(size_t k, const XML_Node& s, thermo_t& th, SpeciesThermo *spthermo_ptr, int rule, XML_Node *phaseNode_ptr, VPSSMgr *vpss_ptr, @@ -695,9 +695,9 @@ namespace Cantera { // element in phase th. Elements not declared in the // species (i.e., not in map comp) will have zero // entries in the vector. - int m, nel = th.nElements(); + size_t nel = th.nElements(); vector_fp ecomp(nel, 0.0); - for (m = 0; m < nel; m++) { + for (size_t m = 0; m < nel; m++) { const char *es = comp[th.elementName(m)].c_str(); if (strlen(es) > 0) { ecomp[m] = atofCheck(es); diff --git a/Cantera/src/thermo/ThermoFactory.h b/Cantera/src/thermo/ThermoFactory.h index 1a7d742e1..47bf6f664 100644 --- a/Cantera/src/thermo/ThermoFactory.h +++ b/Cantera/src/thermo/ThermoFactory.h @@ -292,7 +292,7 @@ namespace Cantera { * @return * Returns true if everything is ok, false otherwise. */ - bool installSpecies(int k, const XML_Node& s, thermo_t& p, + bool installSpecies(size_t k, const XML_Node& s, thermo_t& p, SpeciesThermo* spthermo_ptr, int rule, XML_Node *phaseNode_ptr = 0, VPSSMgr *vpss_ptr = 0, diff --git a/Cantera/src/thermo/ThermoPhase.cpp b/Cantera/src/thermo/ThermoPhase.cpp index f4c501070..c8efb4bbb 100644 --- a/Cantera/src/thermo/ThermoPhase.cpp +++ b/Cantera/src/thermo/ThermoPhase.cpp @@ -146,20 +146,20 @@ namespace Cantera { return m_ssConvention; } - doublereal ThermoPhase::logStandardConc(int k) const { + doublereal ThermoPhase::logStandardConc(size_t k) const { return log(standardConcentration(k)); } void ThermoPhase::getActivities(doublereal* a) const { getActivityConcentrations(a); - int nsp = nSpecies(); - int k; - for (k = 0; k < nsp; k++) a[k] /= standardConcentration(k); + for (size_t k = 0; k < nSpecies(); k++) { + a[k] /= standardConcentration(k); + } } void ThermoPhase::getLNActivityCoefficients(doublereal *const lnac) const { getActivityCoefficients(lnac); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { lnac[k] = std::log(lnac[k]); } } @@ -177,8 +177,9 @@ namespace Cantera { void ThermoPhase::setState_TPX(doublereal t, doublereal p, const std::string& x) { compositionMap xx; - int kk = nSpecies(); - for (int k = 0; k < kk; k++) xx[speciesName(k)] = -1.0; + for (size_t k = 0; k < nSpecies(); k++) { + xx[speciesName(k)] = -1.0; + } try { parseCompString(x, xx); } @@ -202,8 +203,9 @@ namespace Cantera { void ThermoPhase::setState_TPY(doublereal t, doublereal p, const std::string& y) { compositionMap yy; - int kk = nSpecies(); - for (int k = 0; k < kk; k++) yy[speciesName(k)] = -1.0; + for (size_t k = 0; k < nSpecies(); k++) { + yy[speciesName(k)] = -1.0; + } try { parseCompString(y, yy); } @@ -795,7 +797,7 @@ namespace Cantera { void ThermoPhase::getUnitsStandardConc(double *uA, int k, int sizeUA) const { for (int i = 0; i < sizeUA; i++) { if (i == 0) uA[0] = 1.0; - if (i == 1) uA[1] = -nDim(); + if (i == 1) uA[1] = -int(nDim()); if (i == 2) uA[2] = 0.0; if (i == 3) uA[3] = 0.0; if (i == 4) uA[4] = 0.0; @@ -922,14 +924,14 @@ namespace Cantera { */ void ThermoPhase::initThermo() { // Check to see that there is at least one species defined in the phase - if (m_kk <= 0) { + if (m_kk == 0) { throw CanteraError("ThermoPhase::initThermo()", - "Number of species is less than or equal to zero"); + "Number of species is equal to zero"); } xMol_Ref.resize(m_kk, 0.0); } - void ThermoPhase::saveSpeciesData(const int k, const XML_Node* const data) { + void ThermoPhase::saveSpeciesData(const size_t k, const XML_Node* const data) { if ((int) m_speciesData.size() < (k + 1)) { m_speciesData.resize(k+1, 0); } @@ -939,7 +941,7 @@ namespace Cantera { //! Return a pointer to the XML tree containing the species /// data for this phase. const std::vector & ThermoPhase::speciesData() const { - if ((int) m_speciesData.size() != m_kk) { + if (m_speciesData.size() != m_kk) { throw CanteraError("ThermoPhase::speciesData", "m_speciesData is the wrong size"); } @@ -983,14 +985,14 @@ namespace Cantera { */ void ThermoPhase::setElementPotentials(const vector_fp& lambda) { doublereal rrt = 1.0/(GasConstant* temperature()); - int mm = nElements(); - if (lambda.size() < (size_t) mm) { + size_t mm = nElements(); + if (lambda.size() < mm) { throw CanteraError("setElementPotentials", "lambda too small"); } if (!m_hasElementPotentials) { m_lambdaRRT.resize(mm); } - for (int m = 0; m < mm; m++) { + for (size_t m = 0; m < mm; m++) { m_lambdaRRT[m] = lambda[m] * rrt; } m_hasElementPotentials = true; @@ -1005,9 +1007,8 @@ namespace Cantera { */ bool ThermoPhase::getElementPotentials(doublereal* lambda) const { doublereal rt = GasConstant* temperature(); - int mm = nElements(); if (m_hasElementPotentials) { - for (int m = 0; m < mm; m++) { + for (int m = 0; m < nElements(); m++) { lambda[m] = m_lambdaRRT[m] * rt; } } @@ -1072,7 +1073,7 @@ namespace Cantera { } } - int kk = nSpecies(); + size_t kk = nSpecies(); array_fp x(kk); array_fp y(kk); array_fp mu(kk); @@ -1080,7 +1081,6 @@ namespace Cantera { getMassFractions(&y[0]); getChemPotentials(&mu[0]); doublereal rt = GasConstant * temperature(); - int k; //if (th.nSpecies() > 1) { if (show_thermo) { @@ -1090,7 +1090,7 @@ namespace Cantera { sprintf(p, " ------------- " "------------ ------------\n"); s += p; - for (k = 0; k < kk; k++) { + for (size_t k = 0; k < kk; k++) { if (x[k] > SmallNumber) { sprintf(p, "%18s %12.6g %12.6g %12.6g\n", speciesName(k).c_str(), x[k], y[k], mu[k]/rt); @@ -1109,7 +1109,7 @@ namespace Cantera { sprintf(p, " -------------" " ------------\n"); s += p; - for (k = 0; k < kk; k++) { + for (size_t k = 0; k < kk; k++) { sprintf(p, "%18s %12.6g %12.6g\n", speciesName(k).c_str(), x[k], y[k]); s += p; @@ -1158,7 +1158,7 @@ namespace Cantera { csvFile.precision(8); - int kk = nSpecies(); + size_t kk = nSpecies(); doublereal *x = new doublereal[kk]; doublereal *y = new doublereal[kk]; doublereal *mu = new doublereal[kk]; diff --git a/Cantera/src/thermo/ThermoPhase.h b/Cantera/src/thermo/ThermoPhase.h index da4483e34..92e66c16e 100644 --- a/Cantera/src/thermo/ThermoPhase.h +++ b/Cantera/src/thermo/ThermoPhase.h @@ -767,7 +767,7 @@ namespace Cantera { * @param k index of the species. Default is -1, which will return the max of the min value * over all species. */ - doublereal minTemp(int k = -1) const { + doublereal minTemp(size_t k = -1) const { return m_spthermo->minTemp(k); } @@ -836,7 +836,7 @@ namespace Cantera { * @param k index of the species. Default is -1, which will return the min of the max value * over all species. */ - doublereal maxTemp(int k = -1) const { + doublereal maxTemp(size_t k = -1) const { return m_spthermo->maxTemp(k); } @@ -1121,7 +1121,7 @@ namespace Cantera { * Returns the standard concentration. The units are by definition * dependent on the ThermoPhase and kinetics manager representation. */ - virtual doublereal standardConcentration(int k=0) const { + virtual doublereal standardConcentration(size_t k=0) const { err("standardConcentration"); return -1.0; } @@ -1130,7 +1130,7 @@ namespace Cantera { /*! * @param k index of the species (defaults to zero) */ - virtual doublereal logStandardConc(int k=0) const; + virtual doublereal logStandardConc(size_t k=0) const; //! Returns the units of the standard and generalized concentrations. /*! @@ -1895,7 +1895,7 @@ namespace Cantera { * @param data Pointer to the XML_Node data containing * information about the species in the phase. */ - void saveSpeciesData(const int k, const XML_Node* const data); + void saveSpeciesData(const size_t k, const XML_Node* const data); //! Return a pointer to the vector of XML nodes containing the species //! data for this phase. diff --git a/Cantera/src/thermo/VPSSMgr.cpp b/Cantera/src/thermo/VPSSMgr.cpp index 0fd6bf39a..8aee417e9 100644 --- a/Cantera/src/thermo/VPSSMgr.cpp +++ b/Cantera/src/thermo/VPSSMgr.cpp @@ -410,7 +410,7 @@ namespace Cantera { #endif } - void VPSSMgr::installSTSpecies(int k, const XML_Node& s, + void VPSSMgr::installSTSpecies(size_t k, const XML_Node& s, const XML_Node *phaseNode_ptr) { SpeciesThermoFactory* f = SpeciesThermoFactory::factory(); @@ -420,7 +420,7 @@ namespace Cantera { } } - PDSS * VPSSMgr::createInstallPDSS(int k, const XML_Node& s, + PDSS * VPSSMgr::createInstallPDSS(size_t k, const XML_Node& s, const XML_Node *phaseNode_ptr) { err("VPSSMgr::createInstallPDSS"); return (PDSS *) 0; @@ -428,24 +428,24 @@ namespace Cantera { /*****************************************************************/ - doublereal VPSSMgr::minTemp(int k) const { - if (k >= 0) { + doublereal VPSSMgr::minTemp(size_t k) const { + if (k != -1) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->minTemp(); } return m_minTemp; } - doublereal VPSSMgr::maxTemp(int k) const { - if (k >= 0) { + doublereal VPSSMgr::maxTemp(size_t k) const { + if (k != -1) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->maxTemp(); } return m_maxTemp; } - doublereal VPSSMgr::refPressure(int k) const { - if (k >= 0) { + doublereal VPSSMgr::refPressure(size_t k) const { + if (k != -1) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->refPressure(); } diff --git a/Cantera/src/thermo/VPSSMgr.h b/Cantera/src/thermo/VPSSMgr.h index 402854dd7..104f9af03 100644 --- a/Cantera/src/thermo/VPSSMgr.h +++ b/Cantera/src/thermo/VPSSMgr.h @@ -657,7 +657,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(int k=-1) const ; + virtual doublereal minTemp(size_t k=-1) const ; //! Maximum temperature. /*! @@ -669,7 +669,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal maxTemp(int k=-1) const; + virtual doublereal maxTemp(size_t k=-1) const; //! The reference-state pressure for the standard state /*! @@ -685,7 +685,7 @@ namespace Cantera { * @param k Species index. Default is -1, which returns * the generic answer. */ - virtual doublereal refPressure(int k = -1) const ; + virtual doublereal refPressure(size_t k = -1) const ; //@} @@ -748,7 +748,7 @@ namespace Cantera { * @param phaseNode_ptr Pointer to the XML Node corresponding * to the phase which owns the species */ - void installSTSpecies(int k, const XML_Node& speciesNode, + void installSTSpecies(size_t k, const XML_Node& speciesNode, const XML_Node *phaseNode_ptr); //! Install specific content for species k in the standard-state @@ -762,7 +762,7 @@ namespace Cantera { * @param phaseNode_ptr Pointer to the XML Node corresponding * to the phase which owns the species */ - virtual PDSS * createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS * createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); @@ -780,7 +780,7 @@ namespace Cantera { protected: //! Number of species in the phase - int m_kk; + size_t m_kk; //! Variable pressure ThermoPhase object VPStandardStateTP *m_vptp_ptr; diff --git a/Cantera/src/thermo/VPSSMgr_ConstVol.cpp b/Cantera/src/thermo/VPSSMgr_ConstVol.cpp index c33d73197..bc0f0bb5a 100644 --- a/Cantera/src/thermo/VPSSMgr_ConstVol.cpp +++ b/Cantera/src/thermo/VPSSMgr_ConstVol.cpp @@ -153,7 +153,7 @@ namespace Cantera { //} PDSS * - VPSSMgr_ConstVol::createInstallPDSS(int k, const XML_Node& speciesNode, + VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr) { //VPSSMgr::installSpecies(k, speciesNode, phaseNode_ptr); const XML_Node *ss = speciesNode.findByName("standardState"); @@ -167,7 +167,7 @@ namespace Cantera { "standardState model for species isn't " "constant_incompressible: " + speciesNode.name()); } - if ((int) m_Vss.size() < k+1) { + if (m_Vss.size() < k+1) { m_Vss.resize(k+1, 0.0); } m_Vss[k] = getFloat(*ss, "molarVolume", "toSI"); diff --git a/Cantera/src/thermo/VPSSMgr_ConstVol.h b/Cantera/src/thermo/VPSSMgr_ConstVol.h index cbde8eb3a..ef31f3524 100644 --- a/Cantera/src/thermo/VPSSMgr_ConstVol.h +++ b/Cantera/src/thermo/VPSSMgr_ConstVol.h @@ -200,7 +200,7 @@ namespace Cantera { * @return Returns a pointer to the a newly malloced PDSS object * containing the parameterization */ - virtual PDSS* createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); //@} diff --git a/Cantera/src/thermo/VPSSMgr_General.cpp b/Cantera/src/thermo/VPSSMgr_General.cpp index dfed2a7aa..644e3fa35 100644 --- a/Cantera/src/thermo/VPSSMgr_General.cpp +++ b/Cantera/src/thermo/VPSSMgr_General.cpp @@ -162,7 +162,7 @@ namespace Cantera { } PDSS* - VPSSMgr_General::returnPDSS_ptr(int k, const XML_Node& speciesNode, + VPSSMgr_General::returnPDSS_ptr(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr, bool &doST) { PDSS *kPDSS = 0; doST = true; @@ -227,12 +227,12 @@ namespace Cantera { } PDSS * - VPSSMgr_General::createInstallPDSS(int k, const XML_Node& speciesNode, + VPSSMgr_General::createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr) { bool doST; PDSS *kPDSS = returnPDSS_ptr(k, speciesNode, phaseNode_ptr, doST); // VPSSMgr::installSTSpecies(k, speciesNode, phaseNode_ptr); - if ((int) m_PDSS_ptrs.size() < k+1) { + if (m_PDSS_ptrs.size() < k+1) { m_PDSS_ptrs.resize(k+1, 0); } m_PDSS_ptrs[k] = kPDSS; diff --git a/Cantera/src/thermo/VPSSMgr_General.h b/Cantera/src/thermo/VPSSMgr_General.h index 19e274d8f..4c05ac6ea 100644 --- a/Cantera/src/thermo/VPSSMgr_General.h +++ b/Cantera/src/thermo/VPSSMgr_General.h @@ -219,7 +219,7 @@ namespace Cantera { * * @return Returns the pointer to a malloced PDSS object */ - PDSS * returnPDSS_ptr(int k, const XML_Node& speciesNode, + PDSS * returnPDSS_ptr(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr, bool &doST); public: @@ -243,7 +243,7 @@ namespace Cantera { * * @return Returns the pointer to the malloced PDSS object */ - virtual PDSS* createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); //! This utility function reports the type of parameterization diff --git a/Cantera/src/thermo/VPSSMgr_IdealGas.cpp b/Cantera/src/thermo/VPSSMgr_IdealGas.cpp index 9de797161..d59de9497 100644 --- a/Cantera/src/thermo/VPSSMgr_IdealGas.cpp +++ b/Cantera/src/thermo/VPSSMgr_IdealGas.cpp @@ -89,7 +89,7 @@ namespace Cantera { } PDSS * - VPSSMgr_IdealGas::createInstallPDSS(int k, const XML_Node& speciesNode, + VPSSMgr_IdealGas::createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr) { //VPSSMgr::installSpecies(k, speciesNode, phaseNode_ptr); const XML_Node *ss = speciesNode.findByName("standardState"); diff --git a/Cantera/src/thermo/VPSSMgr_IdealGas.h b/Cantera/src/thermo/VPSSMgr_IdealGas.h index 37cecc763..6267be556 100644 --- a/Cantera/src/thermo/VPSSMgr_IdealGas.h +++ b/Cantera/src/thermo/VPSSMgr_IdealGas.h @@ -197,7 +197,7 @@ namespace Cantera { * @return Returns a pointer to the a newly malloced PDSS object * containing the parameterization */ - virtual PDSS* createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); diff --git a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp index 41c22d4c3..d68b2a5f0 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp +++ b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp @@ -243,7 +243,7 @@ namespace Cantera { } PDSS* - VPSSMgr_Water_ConstVol::createInstallPDSS(int k, const XML_Node& speciesNode, + VPSSMgr_Water_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr) { PDSS *kPDSS = 0; diff --git a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h index 95aed3bd9..d93defadd 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h +++ b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h @@ -274,7 +274,7 @@ namespace Cantera { * @param phaseNode_ptr Pointer to the XML Node corresponding * to the phase which owns the species */ - virtual PDSS *createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS *createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); //! This utility function reports the type of parameterization diff --git a/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp b/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp index 7042442d8..5cd5314dd 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp +++ b/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp @@ -229,7 +229,7 @@ namespace Cantera { } PDSS * - VPSSMgr_Water_HKFT::createInstallPDSS(int k, const XML_Node& speciesNode, + VPSSMgr_Water_HKFT::createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr) { PDSS *kPDSS = 0; diff --git a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h index e270dba39..fa34b9ae0 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h +++ b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h @@ -358,7 +358,7 @@ namespace Cantera { * @param phaseNode_ptr Pointer to the XML Node corresponding * to the phase which owns the species */ - virtual PDSS *createInstallPDSS(int k, const XML_Node& speciesNode, + virtual PDSS *createInstallPDSS(size_t k, const XML_Node& speciesNode, const XML_Node * const phaseNode_ptr); //@} diff --git a/Cantera/src/thermo/WaterSSTP.cpp b/Cantera/src/thermo/WaterSSTP.cpp index 8ac5b57bc..5718e221a 100644 --- a/Cantera/src/thermo/WaterSSTP.cpp +++ b/Cantera/src/thermo/WaterSSTP.cpp @@ -212,14 +212,14 @@ namespace Cantera { * atomic weights used in the Element class and calculate * a consistent H2O molecular weight based on that. */ - int nH = elementIndex("H"); - if (nH < 0) { + size_t nH = elementIndex("H"); + if (nH == -1) { throw CanteraError("WaterSSTP::initThermo", "H not an element"); } double mw_H = atomicWeight(nH); - int nO = elementIndex("O"); - if (nO < 0) { + size_t nO = elementIndex("O"); + if (nO == -1) { throw CanteraError("WaterSSTP::initThermo", "O not an element"); } diff --git a/Cantera/src/zeroD/ConstPressureReactor.cpp b/Cantera/src/zeroD/ConstPressureReactor.cpp index bd2c2fd9b..909cf4597 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.cpp +++ b/Cantera/src/zeroD/ConstPressureReactor.cpp @@ -68,8 +68,8 @@ namespace CanteraZeroD { m_pressure = m_thermo->pressure(); m_intEnergy = m_thermo->intEnergy_mass(); - int m, nt = 0, maxnt = 0; - for (m = 0; m < m_nwalls; m++) { + size_t nt = 0, maxnt = 0; + for (size_t m = 0; m < m_nwalls; m++) { if (m_wall[m]->kinetics(m_lr[m])) { nt = m_wall[m]->kinetics(m_lr[m])->nTotalSpecies(); if (nt > maxnt) maxnt = nt; diff --git a/Cantera/src/zeroD/Reactor.cpp b/Cantera/src/zeroD/Reactor.cpp index ebcd51795..668866a96 100644 --- a/Cantera/src/zeroD/Reactor.cpp +++ b/Cantera/src/zeroD/Reactor.cpp @@ -87,8 +87,8 @@ namespace CanteraZeroD { m_pressure = m_thermo->pressure(); m_intEnergy = m_thermo->intEnergy_mass(); - int m, nt = 0, maxnt = 0; - for (m = 0; m < m_nwalls; m++) { + size_t nt = 0, maxnt = 0; + for (size_t m = 0; m < m_nwalls; m++) { if (m_wall[m]->kinetics(m_lr[m])) { nt = m_wall[m]->kinetics(m_lr[m])->nTotalSpecies(); if (nt > maxnt) maxnt = nt;