diff --git a/Cantera/src/kinetics/AqueousKinetics.cpp b/Cantera/src/kinetics/AqueousKinetics.cpp index 7f392c528..799d90043 100644 --- a/Cantera/src/kinetics/AqueousKinetics.cpp +++ b/Cantera/src/kinetics/AqueousKinetics.cpp @@ -111,7 +111,6 @@ namespace Cantera { * reversible or not. */ void AqueousKinetics::getEquilibriumConstants(doublereal* kc) { - int i; _update_rates_T(); vector_fp& rkc = m_kdata->m_rkcn; @@ -127,7 +126,7 @@ namespace Cantera { m_rxnstoich->getReactionDelta(m_ii, &m_grt[0], &rkc[0]); doublereal rrt = 1.0/(GasConstant * thermo().temperature()); - for (i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { kc[i] = exp(-rkc[i]*rrt); } @@ -254,7 +253,7 @@ namespace Cantera { */ thermo().getEnthalpy_RT(&m_grt[0]); doublereal RT = thermo().temperature() * GasConstant; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_grt[k] *= RT; } /* @@ -283,7 +282,7 @@ namespace Cantera { */ thermo().getEntropy_R(&m_grt[0]); doublereal R = GasConstant; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_grt[k] *= R; } /* @@ -362,7 +361,7 @@ namespace Cantera { // multiply by perturbation factor multiply_each(ropf.begin(), ropf.end(), m_perturb.begin()); - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { kfwd[i] = ropf[i]; } } @@ -390,7 +389,7 @@ namespace Cantera { if (doIrreversible) { doublereal *tmpKc = &m_kdata->m_ropnet[0]; getEquilibriumConstants(tmpKc); - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { krev[i] /= tmpKc[i]; } } else { @@ -398,7 +397,7 @@ namespace Cantera { * m_rkc[] is zero for irreversibly reactions */ const vector_fp& m_rkc = m_kdata->m_rkcn; - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { krev[i] *= m_rkc[i]; } } diff --git a/Cantera/src/kinetics/AqueousKinetics.h b/Cantera/src/kinetics/AqueousKinetics.h index 87af09607..e8fd27af0 100644 --- a/Cantera/src/kinetics/AqueousKinetics.h +++ b/Cantera/src/kinetics/AqueousKinetics.h @@ -348,8 +348,8 @@ namespace Cantera { std::vector m_fwdOrder; - int m_nirrev; - int m_nrev; + size_t m_nirrev; + size_t m_nrev; std::map > m_rgroups; std::map > m_pgroups; diff --git a/Cantera/src/kinetics/GasKinetics.cpp b/Cantera/src/kinetics/GasKinetics.cpp index 536ad640f..e707ef212 100644 --- a/Cantera/src/kinetics/GasKinetics.cpp +++ b/Cantera/src/kinetics/GasKinetics.cpp @@ -121,7 +121,6 @@ namespace Cantera { * reversible or not. */ void GasKinetics::getEquilibriumConstants(doublereal* kc) { - int i; _update_rates_T(); vector_fp& rkc = m_kdata->m_rkcn; //thermo().getGibbs_RT(m_grt.begin()); @@ -133,7 +132,7 @@ namespace Cantera { doublereal logStandConc = m_kdata->m_logStandConc; doublereal rrt = 1.0/(GasConstant * thermo().temperature()); - for (i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { kc[i] = exp(-rkc[i]*rrt + m_dn[i]*logStandConc); } @@ -260,7 +259,7 @@ namespace Cantera { */ thermo().getEnthalpy_RT(&m_grt[0]); doublereal RT = thermo().temperature() * GasConstant; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_grt[k] *= RT; } /* @@ -289,7 +288,7 @@ namespace Cantera { */ thermo().getEntropy_R(&m_grt[0]); doublereal R = GasConstant; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_grt[k] *= R; } /* @@ -300,8 +299,6 @@ namespace Cantera { } void GasKinetics::processFalloffReactions() { - - int i; const vector_fp& fc = m_kdata->concm_falloff_values; const array_fp& m_rf_low = m_kdata->m_rfn_low; const array_fp& m_rf_high = m_kdata->m_rfn_high; @@ -311,7 +308,7 @@ namespace Cantera { array_fp& ropf = m_kdata->m_ropf; - for (i = 0; i < m_nfall; i++) { + for (size_t i = 0; i < m_nfall; i++) { pr[i] = fc[i] * m_rf_low[i] / m_rf_high[i]; } @@ -319,7 +316,7 @@ namespace Cantera { (m_kdata->falloff_work.empty()) ? 0 : &m_kdata->falloff_work[0]; m_falloffn.pr_to_falloff(&pr[0], falloff_work); - for (i = 0; i < m_nfall; i++) { + for (size_t i = 0; i < m_nfall; i++) { pr[i] *= m_rf_high[i]; } @@ -414,7 +411,7 @@ namespace Cantera { // multiply by perturbation factor multiply_each(ropf.begin(), ropf.end(), m_perturb.begin()); - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { kfwd[i] = ropf[i]; } } @@ -442,7 +439,7 @@ namespace Cantera { if (doIrreversible) { doublereal *tmpKc = &m_kdata->m_ropnet[0]; getEquilibriumConstants(tmpKc); - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { krev[i] /= tmpKc[i]; } } else { @@ -450,7 +447,7 @@ namespace Cantera { * m_rkc[] is zero for irreversibly reactions */ const vector_fp& m_rkc = m_kdata->m_rkcn; - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { krev[i] *= m_rkc[i]; } } diff --git a/Cantera/src/kinetics/GasKinetics.h b/Cantera/src/kinetics/GasKinetics.h index cf83048f1..e190cb9b9 100644 --- a/Cantera/src/kinetics/GasKinetics.h +++ b/Cantera/src/kinetics/GasKinetics.h @@ -360,8 +360,8 @@ namespace Cantera { std::vector m_fwdOrder; - int m_nirrev; - int m_nrev; + size_t m_nirrev; + size_t m_nrev; std::map > m_rgroups; std::map > m_pgroups; diff --git a/Cantera/src/kinetics/ImplicitSurfChem.cpp b/Cantera/src/kinetics/ImplicitSurfChem.cpp index 01ba658a2..ca4a65071 100644 --- a/Cantera/src/kinetics/ImplicitSurfChem.cpp +++ b/Cantera/src/kinetics/ImplicitSurfChem.cpp @@ -270,7 +270,7 @@ namespace Cantera { * are below zero. */ bool rset = false; - for (int k = 0; k < m_nv; k++) { + for (size_t k = 0; k < m_nv; k++) { if (m_concSpecies[k] < 0.0) { rset = true; m_concSpecies[k] = 0.0; diff --git a/Cantera/src/kinetics/InterfaceKinetics.cpp b/Cantera/src/kinetics/InterfaceKinetics.cpp index 06eee7690..5112fd5ef 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.cpp +++ b/Cantera/src/kinetics/InterfaceKinetics.cpp @@ -64,7 +64,7 @@ namespace Cantera { if (m_integrator) { delete m_integrator; } - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { delete m_rxnPhaseIsReactant[i]; delete m_rxnPhaseIsProduct[i]; } @@ -116,13 +116,12 @@ namespace Cantera { */ InterfaceKinetics& InterfaceKinetics:: operator=(const InterfaceKinetics &right) { - int i; /* * Check for self assignment. */ if (this == &right) return *this; - for (i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { delete (m_rxnPhaseIsReactant[i]); delete (m_rxnPhaseIsProduct[i]); } @@ -168,10 +167,10 @@ namespace Cantera { m_rxnPhaseIsReactant.resize(m_ii, 0); m_rxnPhaseIsProduct.resize(m_ii, 0); size_t np = nPhases(); - for (i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { m_rxnPhaseIsReactant[i] = new bool[np]; m_rxnPhaseIsProduct[i] = new bool[np]; - for (int p = 0; p < np; p++) { + for (size_t p = 0; p < np; p++) { m_rxnPhaseIsReactant[i][p] = right.m_rxnPhaseIsReactant[i][p]; m_rxnPhaseIsProduct[i][p] = right.m_rxnPhaseIsProduct[i][p]; } @@ -588,7 +587,7 @@ namespace Cantera { if (doIrreversible) { doublereal *tmpKc = DATA_PTR(m_kdata->m_ropnet); getEquilibriumConstants(tmpKc); - for (int i = 0; i < m_ii; i++) { + for (size_t i = 0; i < m_ii; i++) { krev[i] /= tmpKc[i]; } } @@ -647,7 +646,7 @@ namespace Cantera { // do global reactions //m_globalReactantStoich.power(m_conc.begin(), ropf.begin()); - for (int j = 0; j != m_ii; ++j) { + for (size_t j = 0; j != m_ii; ++j) { ropnet[j] = ropf[j] - ropr[j]; } @@ -658,15 +657,15 @@ namespace Cantera { * phases that are stoichiometric phases containing one species with a unity activity */ if (m_phaseExistsCheck) { - for (int j = 0; j != m_ii; ++j) { + for (size_t j = 0; j != m_ii; ++j) { if ((ropr[j] > ropf[j]) && (ropr[j] > 0.0)) { - for (int p = 0; p < nPhases(); p++) { + for (size_t p = 0; p < nPhases(); p++) { if (m_rxnPhaseIsProduct[j][p]) { if (! m_phaseExists[p]) { ropnet[j] = 0.0; ropr[j] = ropf[j]; if (ropf[j] > 0.0) { - for (int rp = 0; rp < nPhases(); rp++) { + for (size_t rp = 0; rp < nPhases(); rp++) { if (m_rxnPhaseIsReactant[j][rp]) { if (! m_phaseExists[rp]) { ropnet[j] = 0.0; @@ -679,13 +678,13 @@ namespace Cantera { } } } else if ((ropf[j] > ropr[j]) && (ropf[j] > 0.0)) { - for (int p = 0; p < nPhases(); p++) { + for (size_t p = 0; p < nPhases(); p++) { if (m_rxnPhaseIsReactant[j][p]) { if (! m_phaseExists[p]) { ropnet[j] = 0.0; ropf[j] = ropr[j]; if (ropf[j] > 0.0) { - for (int rp = 0; rp < nPhases(); rp++) { + for (size_t rp = 0; rp < nPhases(); rp++) { if (m_rxnPhaseIsProduct[j][rp]) { if (! m_phaseExists[rp]) { ropnet[j] = 0.0; @@ -912,7 +911,7 @@ namespace Cantera { m_rxnPhaseIsReactant[i] = new bool[np]; m_rxnPhaseIsProduct[i] = new bool[np]; - for (int p = 0; p < np; p++) { + for (size_t p = 0; p < np; p++) { m_rxnPhaseIsReactant[i][p] = false; m_rxnPhaseIsProduct[i][p] = false; } diff --git a/Cantera/src/kinetics/ReactionPath.cpp b/Cantera/src/kinetics/ReactionPath.cpp index 829278049..a2922ab92 100644 --- a/Cantera/src/kinetics/ReactionPath.cpp +++ b/Cantera/src/kinetics/ReactionPath.cpp @@ -701,7 +701,6 @@ namespace Cantera { m_ns = kin.nTotalSpecies(); //ph.nSpecies(); m_nr = kin.nReactions(); - int m, i; //for (m = 0; m < m_nel; m++) { // m_elementSymbols.push_back(ph.elementName(m)); //} @@ -711,7 +710,7 @@ namespace Cantera { // mod 8/18/01 dgg vector > allProducts; vector > allReactants; - for (i = 0; i < m_nr; i++) { + for (size_t i = 0; i < m_nr; i++) { allReactants.push_back(kin.reactants(i)); allProducts.push_back(kin.products(i)); } @@ -733,7 +732,7 @@ namespace Cantera { size_t nmol; map net; - for (i = 0; i < m_nr; i++) { + for (size_t i = 0; i < m_nr; i++) { // construct the lists of reactant and product indices, not // including molecules that appear on both sides. @@ -791,11 +790,11 @@ namespace Cantera { // that element among the products. int nar, nap; - for (i = 0; i < m_nr; i++) { + for (size_t i = 0; i < m_nr; i++) { nr = m_reac[i].size(); np = m_prod[i].size(); m_determinate[i] = true; - for (m = 0; m < m_nel; m++) { + for (size_t m = 0; m < m_nel; m++) { nar = 0; nap = 0; for (size_t j = 0; j < nr; j++) { diff --git a/Cantera/src/kinetics/importKinetics.cpp b/Cantera/src/kinetics/importKinetics.cpp index a1cfc9e09..8b5f5e179 100644 --- a/Cantera/src/kinetics/importKinetics.cpp +++ b/Cantera/src/kinetics/importKinetics.cpp @@ -334,7 +334,7 @@ namespace Cantera { doublereal sc; // loop over the reactants - for (int n = 0; n < nr; n++) { + for (size_t n = 0; n < nr; n++) { k = r.reactants[n]; order = r.rorder[n]; // stoich coeff @@ -392,7 +392,7 @@ namespace Cantera { doublereal e; string spname; if (nc > 0) { - for (int n = 0; n < nc; n++) { + for (size_t n = 0; n < nc; n++) { const XML_Node& cnode = *cov[n]; spname = cnode["species"]; k = surfphase.speciesIndex(spname); @@ -690,9 +690,7 @@ namespace Cantera { if (r.hasChild("equation")) { eqn = r("equation"); } - int eqlen = static_cast(eqn.size()); - int nn; - for (nn = 0; nn < eqlen; nn++) { + for (size_t nn = 0; nn < eqn.size(); nn++) { if (eqn[nn] == '[') eqn[nn] = '<'; if (eqn[nn] == ']') eqn[nn] = '>'; } @@ -832,13 +830,13 @@ namespace Cantera { map rxnstoich; rxnstoich.clear(); - for (nn = 0; nn < rdata.reactants.size(); nn++) { + for (size_t nn = 0; nn < rdata.reactants.size(); nn++) { rxnstoich[-1 - int(rdata.reactants[nn])] -= rdata.rstoich[nn]; } - for (nn = 0; nn < rdata.products.size(); nn++) { + for (size_t nn = 0; nn < rdata.products.size(); nn++) { rxnstoich[int(rdata.products[nn])+1] += rdata.pstoich[nn]; } - for (nn = 0; nn < m_rdata.size(); nn++) { + for (size_t nn = 0; nn < m_rdata.size(); nn++) { if ((rdata.reactants.size() == m_nr[nn]) && (rdata.reactionType == m_typ[nn])) { c = isDuplicateReaction(rxnstoich, m_rdata[nn]); diff --git a/Cantera/src/kinetics/solveSP.cpp b/Cantera/src/kinetics/solveSP.cpp index fd410c1c7..af89abbdc 100644 --- a/Cantera/src/kinetics/solveSP.cpp +++ b/Cantera/src/kinetics/solveSP.cpp @@ -212,8 +212,7 @@ namespace Cantera { if (ifunc == SFLUX_JACOBIAN) { EXTRA_ACCURACY *= 0.001; } - int k, irow; - int jcol, info = 0; + int info = 0; int label_t=-1; /* Species IDs for time control */ int label_d; /* Species IDs for damping control */ int label_t_old=-1; @@ -263,7 +262,7 @@ namespace Cantera { SurfPhase *sf_ptr = m_ptrsSurfPhase[n]; sf_ptr->getConcentrations(DATA_PTR(m_numEqn1)); size_t nsp = m_nSpeciesSurfPhase[n]; - for (k = 0; k 1) { @@ -418,7 +417,7 @@ namespace Cantera { iter,t_real, 1.0/inv_t); printf("solveSurfProb: init guess, current concentration," "and prod rate:\n"); - for (jcol = 0; jcol < m_neq; jcol++) { + for (size_t jcol = 0; jcol < m_neq; jcol++) { printf("\t%d %g %g %g\n", jcol, m_CSolnSPInit[jcol], m_CSolnSP[jcol], m_netProductionRatesSave[m_kinSpecIndex[jcol]]); } @@ -453,8 +452,8 @@ namespace Cantera { * Update the solution vector and real time * Crop the concentrations to zero. */ - for (irow = 0; irow < m_neq; irow++) m_CSolnSP[irow] -= damp * m_resid[irow]; - for (irow = 0; irow < m_neq; irow++) { + for (size_t irow = 0; irow < m_neq; irow++) m_CSolnSP[irow] -= damp * m_resid[irow]; + for (size_t irow = 0; irow < m_neq; irow++) { m_CSolnSP[irow] = MAX(0.0, m_CSolnSP[irow]); } updateState( DATA_PTR(m_CSolnSP)); @@ -1135,7 +1134,7 @@ namespace Cantera { printf("\n================================ INITIAL GUESS " "========================================\n"); int kindexSP = 0; - for (int isp = 0; isp < m_numSurfPhases; isp++) { + for (size_t isp = 0; isp < m_numSurfPhases; isp++) { InterfaceKinetics *m_kin = m_objects[isp]; int surfIndex = m_kin->surfacePhaseIndex(); int nPhases = m_kin->nPhases(); @@ -1243,7 +1242,7 @@ namespace Cantera { printf("\t---------------------------------------------------------" "-----------------------------\n"); int kindexSP = 0; - for (int isp = 0; isp < m_numSurfPhases; isp++) { + for (size_t isp = 0; isp < m_numSurfPhases; isp++) { int nsp = m_nSpeciesSurfPhase[isp]; InterfaceKinetics *m_kin = m_objects[isp]; //int surfPhaseIndex = m_kinObjPhaseIDSurfPhase[isp]; @@ -1332,7 +1331,7 @@ namespace Cantera { printf("---------------------------------------------------------------" "---------------------------------------------\n"); int kindexSP = 0; - for (int isp = 0; isp < m_numSurfPhases; isp++) { + for (size_t isp = 0; isp < m_numSurfPhases; isp++) { int nsp = m_nSpeciesSurfPhase[isp]; InterfaceKinetics *m_kin = m_objects[isp]; //int surfPhaseIndex = m_kinObjPhaseIDSurfPhase[isp]; @@ -1361,7 +1360,7 @@ namespace Cantera { "---------------------------------------------\n"); doublereal *XMolKinSpecies = DATA_PTR(m_numEqn2); kindexSP = 0; - for (int isp = 0; isp < m_numSurfPhases; isp++) { + for (size_t isp = 0; isp < m_numSurfPhases; isp++) { InterfaceKinetics *m_kin = m_objects[isp]; int surfIndex = m_kin->surfacePhaseIndex(); int nPhases = m_kin->nPhases();