diff --git a/include/cantera/base/xml.h b/include/cantera/base/xml.h index 1e5f7ab2a..202404935 100644 --- a/include/cantera/base/xml.h +++ b/include/cantera/base/xml.h @@ -510,7 +510,7 @@ public: * @param discardComments If true comments are discarded when adding up the number of children. * Defaults to false. */ - int nChildren(bool discardComments = false) const; + size_t nChildren(bool discardComments = false) const; //! Boolean function indicating whether a comment bool isComment() const; diff --git a/include/cantera/numerics/BandMatrix.h b/include/cantera/numerics/BandMatrix.h index f9b758ce2..052e5af0e 100644 --- a/include/cantera/numerics/BandMatrix.h +++ b/include/cantera/numerics/BandMatrix.h @@ -96,7 +96,7 @@ public: * * Returns a changeable reference to the matrix entry */ - doublereal& operator()(int i, int j); + doublereal& operator()(size_t i, size_t j); //! Constant index into the (i,j) element @@ -106,7 +106,7 @@ public: * * Returns an unchangeable reference to the matrix entry */ - doublereal operator()(int i, int j) const; + doublereal operator()(size_t i, size_t j) const; //! Return a changeable reference to element (i,j). /*! @@ -118,7 +118,7 @@ public: * * @return Returns a reference to the value of the matrix entry */ - doublereal& value(int i, int j); + doublereal& value(size_t i, size_t j); //! Return the value of element (i,j). @@ -129,7 +129,7 @@ public: * * @return Returns the value of the matrix entry */ - doublereal value(int i, int j) const; + doublereal value(size_t i, size_t j) const; //! Returns the location in the internal 1D array corresponding to the (i,j) element in the banded array /*! @@ -138,7 +138,7 @@ public: * * @return Returns the index of the matrix entry */ - int index(int i, int j) const; + size_t index(size_t i, size_t j) const; //! Return the value of the (i,j) element for (i,j) within the bandwidth. /*! @@ -150,7 +150,7 @@ public: * * @return Returns the value of the matrix entry */ - doublereal _value(int i, int j) const; + doublereal _value(size_t i, size_t j) const; //! Returns the number of rows virtual size_t nRows() const; @@ -168,16 +168,16 @@ public: virtual size_t nRowsAndStruct(int* const iStruct = 0) const; //! Number of columns - int nColumns() const; + size_t nColumns() const; //! Number of subdiagonals - int nSubDiagonals() const; + size_t nSubDiagonals() const; //! Number of superdiagonals - int nSuperDiagonals() const; + size_t nSuperDiagonals() const; //! Return the number of rows of storage needed for the band storage - int ldim() const; + size_t ldim() const; //! Return a reference to the pivot vector /*! @@ -337,7 +337,7 @@ public: * * @return Returns a pointer to the top of the column */ - virtual doublereal* ptrColumn(int j); + virtual doublereal* ptrColumn(size_t j); //! Return a vector of const pointers to the columns /*! @@ -347,7 +347,7 @@ public: * @return returns a vector of pointers to the top of the columns * of the matrices. */ - virtual doublereal* const* colPts(); + virtual doublereal* const* colPts(); //! Copy the data from one array into another without doing any checking /*! @@ -369,7 +369,7 @@ public: * * @return index of the row that is most nearly zero */ - virtual int checkRows(doublereal& valueSmall) const; + virtual size_t checkRows(doublereal& valueSmall) const; //! Check to see if we have any zero columns in the jacobian /*! @@ -380,7 +380,7 @@ public: * * @return index of the column that is most nearly zero */ - virtual int checkColumns(doublereal& valueSmall) const; + virtual size_t checkColumns(doublereal& valueSmall) const; protected: @@ -394,13 +394,13 @@ protected: bool m_factored; //! Number of rows and columns of the matrix - int m_n; + size_t m_n; //! Number of subdiagonals of the matrix - int m_kl; + size_t m_kl; //! Number of super diagonals of the matrix - int m_ku; + size_t m_ku; //! value of zero doublereal m_zero; diff --git a/include/cantera/numerics/GeneralMatrix.h b/include/cantera/numerics/GeneralMatrix.h index b9942b52b..25430f74a 100644 --- a/include/cantera/numerics/GeneralMatrix.h +++ b/include/cantera/numerics/GeneralMatrix.h @@ -163,7 +163,7 @@ public: * * @return Returns a pointer to the top of the column */ - virtual doublereal* ptrColumn(int j) = 0; + virtual doublereal* ptrColumn(size_t j) = 0; //! Index into the (i,j) element /*! @@ -172,7 +172,7 @@ public: * * Returns a changeable reference to the matrix entry */ - virtual doublereal& operator()(int i, int j) = 0; + virtual doublereal& operator()(size_t i, size_t j) = 0; //! Constant Index into the (i,j) element @@ -182,7 +182,7 @@ public: * * Returns an unchangeable reference to the matrix entry */ - virtual doublereal operator()(int i, int j) const = 0; + virtual doublereal operator()(size_t i, size_t j) const = 0; //! Copy the data from one array into another without doing any checking /*! @@ -195,7 +195,7 @@ public: /*! * We might drop this later */ - virtual vector_fp::iterator begin() = 0; + virtual vector_fp::iterator begin() = 0; //! Return a const iterator pointing to the first element /*! @@ -211,7 +211,7 @@ public: * @return returns a vector of pointers to the top of the columns * of the matrices. */ - virtual doublereal* const* colPts() = 0; + virtual doublereal* const* colPts() = 0; //! Check to see if we have any zero rows in the jacobian /*! @@ -222,7 +222,7 @@ public: * * @return index of the row that is most nearly zero */ - virtual int checkRows(doublereal& valueSmall) const = 0; + virtual size_t checkRows(doublereal& valueSmall) const = 0; //! Check to see if we have any zero columns in the jacobian /*! @@ -233,7 +233,7 @@ public: * * @return index of the column that is most nearly zero */ - virtual int checkColumns(doublereal& valueSmall) const = 0; + virtual size_t checkColumns(doublereal& valueSmall) const = 0; //! Matrix type /*! diff --git a/include/cantera/numerics/SquareMatrix.h b/include/cantera/numerics/SquareMatrix.h index fdd059b4a..69b745d7f 100644 --- a/include/cantera/numerics/SquareMatrix.h +++ b/include/cantera/numerics/SquareMatrix.h @@ -46,7 +46,7 @@ public: * @param n size of the square matrix * @param v intial value of all matrix components. */ - SquareMatrix(int n, doublereal v = 0.0); + SquareMatrix(size_t n, doublereal v = 0.0); //! Copy Constructor /*! @@ -76,7 +76,7 @@ public: * @param m Number of columns * @param v double to fill the new space (defaults to zero) */ - void resize(int n, int m, doublereal v = 0.0); + void resize(size_t n, size_t m, doublereal v = 0.0); /** * Zero the matrix @@ -171,7 +171,7 @@ public: * * @return Returns a pointer to the top of the column */ - virtual doublereal* ptrColumn(int j); + virtual doublereal* ptrColumn(size_t j); //! Index into the (i,j) element /*! @@ -182,7 +182,7 @@ public: * * Returns a changeable reference to the matrix entry */ - virtual doublereal& operator()(int i, int j) { + virtual doublereal& operator()(size_t i, size_t j) { return Array2D::operator()(i, j); } @@ -200,7 +200,7 @@ public: * * Returns an unchangeable reference to the matrix entry */ - virtual doublereal operator()(int i, int j) const { + virtual doublereal operator()(size_t i, size_t j) const { return Array2D::operator()(i, j); } @@ -240,7 +240,7 @@ public: * @return returns a vector of pointers to the top of the columns * of the matrices. */ - virtual doublereal* const* colPts(); + virtual doublereal* const* colPts(); //! Check to see if we have any zero rows in the jacobian /*! @@ -251,7 +251,7 @@ public: * * @return index of the row that is most nearly zero */ - virtual int checkRows(doublereal& valueSmall) const; + virtual size_t checkRows(doublereal& valueSmall) const; //! Check to see if we have any zero columns in the jacobian /*! @@ -262,7 +262,7 @@ public: * * @return index of the column that is most nearly zero */ - virtual int checkColumns(doublereal& valueSmall) const; + virtual size_t checkColumns(doublereal& valueSmall) const; protected: diff --git a/include/cantera/numerics/ctlapack.h b/include/cantera/numerics/ctlapack.h index 44adf855c..81b0f69c8 100644 --- a/include/cantera/numerics/ctlapack.h +++ b/include/cantera/numerics/ctlapack.h @@ -409,14 +409,14 @@ inline void ct_dgeqrf(int m, int n, doublereal* a, int lda, doublereal* tau, //==================================================================================================================== inline void ct_dormqr(ctlapack::side_t rlside, ctlapack::transpose_t trans, int m, int n, int k, doublereal* a, int lda, doublereal* tau, doublereal* c, int ldc, - doublereal* work, int lwork, int& info) + doublereal* work, size_t lwork, int& info) { char side = left_right[rlside]; char tr = no_yes[trans]; integer f_m = m; integer f_n = n; integer f_k = k; - integer f_lwork = lwork; + integer f_lwork = static_cast(lwork); integer f_lda = lda; integer f_ldc = ldc; integer f_info = info; diff --git a/include/cantera/numerics/solveProb.h b/include/cantera/numerics/solveProb.h index ca80dd582..88437e4ba 100644 --- a/include/cantera/numerics/solveProb.h +++ b/include/cantera/numerics/solveProb.h @@ -373,7 +373,7 @@ private: /*! * Note, this can be zero, and frequently is */ - int m_neq; + size_t m_neq; //! m_atol is the absolute tolerance in real units. vector_fp m_atol; diff --git a/include/cantera/thermo/MixedSolventElectrolyte.h b/include/cantera/thermo/MixedSolventElectrolyte.h index 6e88e2d89..57be8bffd 100644 --- a/include/cantera/thermo/MixedSolventElectrolyte.h +++ b/include/cantera/thermo/MixedSolventElectrolyte.h @@ -891,7 +891,7 @@ protected: //! number of binary interaction expressions - int numBinaryInteractions_; + size_t numBinaryInteractions_; //! Enthalpy term for the binary mole fraction interaction of the //! excess gibbs free energy expression diff --git a/include/cantera/thermo/MolarityIonicVPSSTP.h b/include/cantera/thermo/MolarityIonicVPSSTP.h index f7419aa0c..4567c9ffa 100644 --- a/include/cantera/thermo/MolarityIonicVPSSTP.h +++ b/include/cantera/thermo/MolarityIonicVPSSTP.h @@ -507,10 +507,10 @@ protected: int PBType_; //! Number of pseudo binary species - int numPBSpecies_; + size_t numPBSpecies_; //! index of special species - int indexSpecialSpecies_; + size_t indexSpecialSpecies_; mutable std::vector PBMoleFractions_; @@ -518,15 +518,14 @@ protected: std::vector cationList_; //! Number of cations in the mixture - int numCationSpecies_; + size_t numCationSpecies_; std::vector anionList_; - int numAnionSpecies_; + size_t numAnionSpecies_; std::vector passThroughList_; - int numPassThroughSpecies_; - int neutralPBindexStart; - + size_t numPassThroughSpecies_; + size_t neutralPBindexStart; mutable std::vector moleFractionsTmp_; diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index 339e7c46d..315720db4 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -284,7 +284,7 @@ public: * @return Returns the index of the species. If the name is not found, * the value of -1 is returned. */ - int speciesIndex(std::string name) const; + size_t speciesIndex(std::string name) const; //! Returns the expanded species name of a species, including the phase name /*! diff --git a/include/cantera/thermo/PhaseCombo_Interaction.h b/include/cantera/thermo/PhaseCombo_Interaction.h index 21db23f03..9dec6b998 100644 --- a/include/cantera/thermo/PhaseCombo_Interaction.h +++ b/include/cantera/thermo/PhaseCombo_Interaction.h @@ -887,7 +887,7 @@ protected: //! number of binary interaction expressions - int numBinaryInteractions_; + size_t numBinaryInteractions_; //! Enthalpy term for the binary mole fraction interaction of the //! excess gibbs free energy expression @@ -944,14 +944,14 @@ protected: * Each Margules excess Gibbs free energy term involves two species, A and B. * This vector identifies species A. */ - vector_int m_pSpecies_A_ij; + std::vector m_pSpecies_A_ij; //! vector of species indices representing species B in the interaction /*! * Each Margules excess Gibbs free energy term involves two species, A and B. * This vector identifies species B. */ - vector_int m_pSpecies_B_ij; + std::vector m_pSpecies_B_ij; //! form of the Margules interaction expression /*! diff --git a/include/cantera/thermo/PureFluidPhase.h b/include/cantera/thermo/PureFluidPhase.h index 97018298d..9b992da79 100644 --- a/include/cantera/thermo/PureFluidPhase.h +++ b/include/cantera/thermo/PureFluidPhase.h @@ -162,7 +162,7 @@ public: void getElectrochemPotentials(doublereal* mu) const { getChemPotentials(mu); double ve = Faraday * electricPotential(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { mu[k] += ve*charge(k); } } diff --git a/src/base/xml.cpp b/src/base/xml.cpp index c18da5733..f47b9e8a5 100644 --- a/src/base/xml.cpp +++ b/src/base/xml.cpp @@ -945,10 +945,10 @@ const std::vector& XML_Node::children() const /* * @param discardComments Bool indicating whether we should ignore comments in the count. defaults to false */ -int XML_Node::nChildren(const bool discardComments) const +size_t XML_Node::nChildren(const bool discardComments) const { if (discardComments) { - int count = 0; + size_t count = 0; for (size_t i = 0; i < m_nchildren; i++) { XML_Node* xc = m_children[i]; if (!(xc->isComment())) { @@ -1077,7 +1077,7 @@ XML_Node* XML_Node::findNameIDIndex(const std::string& nameTarget, } } } - for (int n = 0; n < m_nchildren; n++) { + for (size_t n = 0; n < m_nchildren; n++) { sc = m_children[n]; if (sc->name() == nameTarget) { ii = sc->attrib("index"); diff --git a/src/equil/MultiPhase.cpp b/src/equil/MultiPhase.cpp index 9cb9a49b7..46d62fc48 100644 --- a/src/equil/MultiPhase.cpp +++ b/src/equil/MultiPhase.cpp @@ -664,13 +664,11 @@ doublereal MultiPhase::volume() const doublereal MultiPhase::equilibrate(int XY, doublereal err, int maxsteps, int maxiter, int loglevel) { - doublereal error; bool strt = false; doublereal dt; doublereal h0; int n; - bool start; - doublereal ferr, hnow, herr = 1.0; + doublereal hnow, herr = 1.0; doublereal snow, serr = 1.0, s0; doublereal Tlow = -1.0, Thigh = -1.0; doublereal Hlow = Undef, Hhigh = Undef, tnew; @@ -694,7 +692,7 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, // create an equilibrium manager e = new MultiPhaseEquil(this); try { - error = e->equilibrate(XY, err, maxsteps, loglevel); + e->equilibrate(XY, err, maxsteps, loglevel); } catch (CanteraError& err) { if (loglevel > 0) { endLogGroup(); @@ -730,7 +728,7 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, } try { - error = e->equilibrate(TP, err, maxsteps, loglevel); + e->equilibrate(TP, err, maxsteps, loglevel); hnow = enthalpy(); // the equilibrium enthalpy monotonically increases with T; // if the current value is below the target, the we know the @@ -797,7 +795,7 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, } - catch (CanteraError err) { + catch (CanteraError& err) { if (!strt) { if (loglevel > 0) addLogEntry("no convergence", @@ -828,7 +826,6 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, "No convergence for T"); } else if (XY == SP) { s0 = entropy(); - start = true; Tlow = 1.0; // m_Tmin; // lower bound on T Thigh = 1.0e6; // m_Tmax; // upper bound on T if (loglevel > 0) { @@ -842,17 +839,12 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, delete e; } e = new MultiPhaseEquil(this, strt); - ferr = 0.1; - if (fabs(dt) < 1.0) { - ferr = err; - } - //start = false; if (loglevel > 0) { beginLogGroup("iteration "+int2str(n)); } try { - error = e->equilibrate(TP, err, maxsteps, loglevel); + e->equilibrate(TP, err, maxsteps, loglevel); snow = entropy(); if (snow < s0) { if (m_temp > Tlow) { @@ -895,7 +887,7 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, } } - catch (CanteraError err) { + catch (CanteraError& err) { if (!strt) { if (loglevel > 0) { addLogEntry("no convergence", @@ -930,14 +922,14 @@ doublereal MultiPhase::equilibrate(int XY, doublereal err, doublereal dVdP; int n; bool start = true; - doublereal error, vnow, pnow, verr; + doublereal vnow, pnow, verr; for (n = 0; n < maxiter; n++) { pnow = pressure(); MultiPhaseEquil e(this, start); start = false; beginLogGroup("iteration "+int2str(n)); - error = e.equilibrate(TP, err, maxsteps, loglevel); + e.equilibrate(TP, err, maxsteps, loglevel); vnow = volume(); verr = fabs((v0 - vnow)/v0); addLogEntry("P",fp2str(pressure())); diff --git a/src/equil/vcs_MultiPhaseEquil.cpp b/src/equil/vcs_MultiPhaseEquil.cpp index 69680c416..3f2be29a7 100644 --- a/src/equil/vcs_MultiPhaseEquil.cpp +++ b/src/equil/vcs_MultiPhaseEquil.cpp @@ -1578,7 +1578,6 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int addLogEntry("Temperature", T); addLogEntry("Pressure", pres); - /* * Print out the problem specification from the point of * view of the vprob object. @@ -1588,12 +1587,6 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int /* * Call the thermo Program */ - int ip1 = m_printLvl; - if (m_printLvl >= 3) { - ip1 = m_printLvl - 2; - } else { - ip1 = 0; - } if (!m_vsolvePtr) { m_vsolvePtr = new VCS_SOLVE(); } @@ -1651,7 +1644,7 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int plogf(" (J/kmol)\n"); } plogf("-------------------------------------------------------------\n"); - for (int i = 0; i < m_vprob->nspecies; i++) { + for (size_t i = 0; i < m_vprob->nspecies; i++) { plogf("%-12s", m_vprob->SpName[i].c_str()); if (m_vprob->SpeciesUnknownType[i] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { plogf(" %15.3e %15.3e ", 0.0, m_vprob->mf[i]); @@ -1659,13 +1652,7 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int } else { plogf(" %15.3e %15.3e ", m_vprob->w[i], m_vprob->mf[i]); if (m_vprob->w[i] <= 0.0) { - int iph = m_vprob->PhaseID[i]; - vcs_VolPhase* VPhase = m_vprob->VPhaseList[iph]; - //if (VPhase->nSpecies() > 1) { - // plogf(" -1.000e+300\n"); - //} else { plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]); - //} } else { plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]); } diff --git a/src/equil/vcs_VolPhase.h b/src/equil/vcs_VolPhase.h index 9a7f12bd4..c586068fa 100644 --- a/src/equil/vcs_VolPhase.h +++ b/src/equil/vcs_VolPhase.h @@ -677,7 +677,7 @@ public: * 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 @@ -863,7 +863,7 @@ private: bool m_useCanteraCalls; /** * If we are using Cantera, this is the - * pointer to the ThermoPhase object. If not, this is null. + * pointer to the ThermoPhase object. If not, this is null. */ Cantera::ThermoPhase* TP_ptr; diff --git a/src/equil/vcs_inest.cpp b/src/equil/vcs_inest.cpp index 49b17b486..4b0cb3bba 100644 --- a/src/equil/vcs_inest.cpp +++ b/src/equil/vcs_inest.cpp @@ -65,14 +65,13 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm, #ifdef ALTLINPROG vcs_setMolesLinProg(); #else - int j, jj; std::vector ax(m_numElemConstraints*nspecies, 0.0); std::vector bb(m_numElemConstraints, 0.0); std::vector cc(nspecies, 0.0); int neActive = 0; - jj = 0; - for (j = 0; j < m_numElemConstraints; j++) { + size_t jj = 0; + for (size_t j = 0; j < m_numElemConstraints; j++) { if (m_elementActive[j]) { neActive++; bb[jj] = m_elemAbundancesGoal[j]; @@ -82,7 +81,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm, for (kspec = 0; kspec < nspecies; ++kspec) { cc[kspec] = -m_SSfeSpecies[kspec]; jj = 0; - for (j = 0; j < m_numElemConstraints; ++j) { + for (size_t j = 0; j < m_numElemConstraints; ++j) { if (m_elementActive[j]) { ax[jj + kspec * neActive] = m_formulaMatrix[j][kspec]; jj++; diff --git a/src/equil/vcs_phaseStability.cpp b/src/equil/vcs_phaseStability.cpp index d03078889..3fceb9384 100644 --- a/src/equil/vcs_phaseStability.cpp +++ b/src/equil/vcs_phaseStability.cpp @@ -89,12 +89,12 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const * component. */ //printf("WE are here at new logic - CHECK\n"); - for (int jrxn = 0; jrxn < m_numRxnRdc; jrxn++) { + for (size_t jrxn = 0; jrxn < m_numRxnRdc; jrxn++) { bool foundJrxn = false; // First, if the component is a product of the reaction if (m_stoichCoeffRxnMatrix[jrxn][kspec] > 0.0) { foundJrxn = true; - for (int kcomp = 0; kcomp < m_numComponents; kcomp++) { + for (size_t kcomp = 0; kcomp < m_numComponents; kcomp++) { if (m_stoichCoeffRxnMatrix[jrxn][kcomp] < 0.0) { if (m_molNumSpecies_old[kcomp] <= VCS_DELETE_ELEMENTABS_CUTOFF*0.5) { foundJrxn = false; @@ -114,7 +114,7 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const foundJrxn = false; continue; } - for (int kcomp = 0; kcomp < m_numComponents; kcomp++) { + for (size_t kcomp = 0; kcomp < m_numComponents; kcomp++) { if (m_stoichCoeffRxnMatrix[jrxn][kcomp] > 0.0) { if (m_molNumSpecies_old[kcomp] <= VCS_DELETE_ELEMENTABS_CUTOFF*0.5) { foundJrxn = false; @@ -155,12 +155,8 @@ int inList(const std::vector &list, int val) */ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() { - int nfound = 0; - int irxn, kspec; vcs_VolPhase* Vphase = 0; - int iph, j, k; - int nsp; double stoicC; double molComp; std::vector linkedPhases; @@ -180,15 +176,15 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() /* * The logic below calculates zeroedComponentLinkedPhasePops */ - for (j = 0; j < m_numComponents; j++) { + for (size_t j = 0; j < m_numComponents; j++) { if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) { molComp = m_molNumSpecies_old[j]; if (molComp <= 0.0) { std::vector &jList = zeroedComponentLinkedPhasePops[j]; - iph = m_phaseID[j]; + size_t iph = m_phaseID[j]; jList.push_back(iph); - for (irxn = 0; irxn < m_numRxnTot; irxn++) { - kspec = irxn + m_numComponents; + for (size_t irxn = 0; irxn < m_numRxnTot; irxn++) { + size_t kspec = irxn + m_numComponents; iph = m_phaseID[kspec]; Vphase = m_VolPhaseList[iph]; int existence = Vphase->exists(); @@ -214,7 +210,7 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() /* * The logic below calculates zeroedPhaseLinkedZeroComponents */ - for (iph = 0; iph < m_numPhases; iph++) { + for (size_t iph = 0; iph < m_numPhases; iph++) { std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; iphList.clear(); Vphase = m_VolPhaseList[iph]; @@ -222,23 +218,22 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() if (existence < 0) { linkedPhases.clear(); - nsp = Vphase->nSpecies(); - for (k = 0; k < nsp; k++) { + size_t nsp = Vphase->nSpecies(); + for (size_t k = 0; k < nsp; k++) { + size_t kspec = Vphase->spGlobalIndexVCS(k); + size_t irxn = kspec - m_numComponents; - kspec = Vphase->spGlobalIndexVCS(k); - irxn = kspec - m_numComponents; - - for (j = 0; j < m_numComponents; j++) { + for (size_t j = 0; j < m_numComponents; j++) { if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) { molComp = m_molNumSpecies_old[j]; if (molComp <= 0.0) { stoicC = m_stoichCoeffRxnMatrix[irxn][j]; if (stoicC < 0.0) { bool foundPos = false; - for (int kk = 0; kk < nsp; kk++) { - int kkspec = Vphase->spGlobalIndexVCS(kk); - int iirxn = kkspec - m_numComponents; - if (iirxn >= 0) { + for (size_t kk = 0; kk < nsp; kk++) { + size_t kkspec = Vphase->spGlobalIndexVCS(kk); + if (kkspec >= m_numComponents) { + size_t iirxn = kkspec - m_numComponents; if (m_stoichCoeffRxnMatrix[iirxn][j] > 0.0) { foundPos = true; } @@ -261,15 +256,15 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() * Now fill in the phasePopProblemLists_ list. * */ - for (iph = 0; iph < m_numPhases; iph++) { + for (size_t iph = 0; iph < m_numPhases; iph++) { Vphase = m_VolPhaseList[iph]; int existence = Vphase->exists(); if (existence < 0) { std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; std::vector popProblem(0); popProblem.push_back(iph); - for (int i = 0; i < (int) iphList.size(); i++) { - j = iphList[i]; + for (size_t i = 0; i < iphList.size(); i++) { + size_t j = iphList[i]; std::vector &jList = zeroedComponentLinkedPhasePops[j]; for (int jjl = 0; jjl < (int) jList.size(); jjl++) { int jph = jList[jjl]; @@ -295,7 +290,6 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() int VCS_SOLVE::vcs_popPhaseID(std::vector & phasePopPhaseIDs) { int iphasePop = -1; - int iph; int irxn, kspec; doublereal FephaseMax = -1.0E30; doublereal Fephase = -1.0E30; diff --git a/src/equil/vcs_rxnadj.cpp b/src/equil/vcs_rxnadj.cpp index 60733f531..d0c38d14c 100644 --- a/src/equil/vcs_rxnadj.cpp +++ b/src/equil/vcs_rxnadj.cpp @@ -43,7 +43,7 @@ namespace VCSnonideal */ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) { - int j, irxn, kspec, iph; + size_t kspec, iph; int iphDel = -1; double s, xx, dss; size_t k = 0; @@ -78,7 +78,7 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) ******** LOOP OVER THE FORMATION REACTIONS ***************************** ************************************************************************/ - for (irxn = 0; irxn < m_numRxnRdc; ++irxn) { + for (size_t irxn = 0; irxn < m_numRxnRdc; ++irxn) { #ifdef DEBUG_MODE sprintf(ANOTE,"Normal Calc"); #endif @@ -198,14 +198,14 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) } else { s = 1.0 / m_molNumSpecies_old[kspec] ; } - for (j = 0; j < m_numComponents; ++j) { + for (size_t j = 0; j < m_numComponents; ++j) { if (!m_SSPhase[j]) { if (m_molNumSpecies_old[j] > 0.0) { s += SQUARE(m_stoichCoeffRxnMatrix[irxn][j]) / m_molNumSpecies_old[j]; } } } - for (j = 0; j < m_numPhases; j++) { + for (size_t j = 0; j < m_numPhases; j++) { Vphase = m_VolPhaseList[j]; if (! Vphase->m_singleSpecies) { if (m_tPhaseMoles_old[j] > 0.0) { @@ -232,7 +232,7 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) m_deltaMolNumSpecies[kspec] = -m_deltaGRxn_new[irxn] / s; // New section to do damping of the m_deltaMolNumSpecies[] - for (j = 0; j < m_numComponents; ++j) { + for (size_t j = 0; j < m_numComponents; ++j) { double stoicC = m_stoichCoeffRxnMatrix[irxn][j]; if (stoicC != 0.0) { double negChangeComp = - stoicC * m_deltaMolNumSpecies[kspec]; @@ -281,7 +281,7 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) if (m_deltaGRxn_new[irxn] > 0.0) { dss = m_molNumSpecies_old[kspec]; k = kspec; - for (j = 0; j < m_numComponents; ++j) { + for (size_t j = 0; j < m_numComponents; ++j) { if (m_stoichCoeffRxnMatrix[irxn][j] > 0.0) { xx = m_molNumSpecies_old[j] / m_stoichCoeffRxnMatrix[irxn][j]; if (xx < dss) { @@ -293,7 +293,7 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) dss = -dss; } else { dss = 1.0e10; - for (j = 0; j < m_numComponents; ++j) { + for (size_t j = 0; j < m_numComponents; ++j) { if (m_stoichCoeffRxnMatrix[irxn][j] < 0.0) { xx = -m_molNumSpecies_old[j] / m_stoichCoeffRxnMatrix[irxn][j]; if (xx < dss) { @@ -360,11 +360,11 @@ int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) } #else - for (j = 0; j < m_numSpeciesTot; j++) { + for (size_t j = 0; j < m_numSpeciesTot; j++) { m_deltaMolNumSpecies[j] = 0.0; } m_deltaMolNumSpecies[kspec] = dss; - for (j = 0; j < m_numComponents; ++j) { + for (size_t j = 0; j < m_numComponents; ++j) { m_deltaMolNumSpecies[j] = dss * m_stoichCoeffRxnMatrix[irxn][j]; } diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index f4eb9aab9..f7574f18c 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -109,18 +109,16 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) int finalElemAbundAttempts = 0; bool uptodate_minors = true; bool justDeletedMultiPhase = false; - bool MajorSpeciesHaveConverged; bool usedZeroedSpecies; /* return flag from basopt indicating that one of the components had a zero concentration */ size_t doPhaseDeleteIph = npos; - size_t doPhaseDeleteKspec = npos; vcs_VolPhase* Vphase; double* sc_irxn = NULL; /* Stoichiometric coefficients for cur rxn */ double* dnPhase_irxn; double atomComp; size_t iphasePop; int forceComponentCalc = 1; - int iphaseDelete; /* integer that determines which phase is being deleted */ + size_t iphaseDelete; /* integer that determines which phase is being deleted */ std::vector phasePopPhaseIDs(0); #ifdef DEBUG_MODE char ANOTE[128]; @@ -297,7 +295,6 @@ L_COMPONENT_CALC: goto L_RETURN_BLOCK; } it1 = 1; - MajorSpeciesHaveConverged = false; /*************************************************************************/ /************** EVALUATE INITIAL SPECIES STATUS VECTOR *******************/ @@ -457,7 +454,6 @@ L_MAINLOOP_ALL_SPECIES: #endif lec = false; doPhaseDeleteIph = npos; - doPhaseDeleteKspec = npos; /* * Zero out the net change in moles of multispecies phases */ @@ -657,7 +653,6 @@ L_MAINLOOP_ALL_SPECIES: } #endif m_speciesStatus[kspec] = VCS_SPECIES_MAJOR; - MajorSpeciesHaveConverged = false; allMinorZeroedSpecies = false; } else { #ifdef DEBUG_MODE @@ -905,7 +900,6 @@ L_MAINLOOP_ALL_SPECIES: */ m_molNumSpecies_new[kspec] = 0.0; doPhaseDeleteIph = iph; - doPhaseDeleteKspec = kspec; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { @@ -920,7 +914,7 @@ L_MAINLOOP_ALL_SPECIES: ++m_numRxnMinorZeroed; allMinorZeroedSpecies = (m_numRxnMinorZeroed == m_numRxnRdc); - for (int kk = 0; kk < m_numSpeciesTot; kk++) { + for (size_t kk = 0; kk < m_numSpeciesTot; kk++) { m_deltaMolNumSpecies[kk] = 0.0; m_molNumSpecies_new[kk] = m_molNumSpecies_old[kk]; } @@ -1021,7 +1015,7 @@ L_MAIN_LOOP_END: L_MAIN_LOOP_END_NO_PRINT: ; #endif - if (doPhaseDeleteIph != -1) { + if (doPhaseDeleteIph != npos) { #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" --- "); @@ -1670,12 +1664,7 @@ L_EQUILIB_CHECK: plogf("%s failed\n", m_speciesName[m_indexRxnToSpecies[irxn]].c_str()); } #endif - /* - * Set MajorSpeciesHaveConverged to false to indicate that - * convergence amongst - * major species has not been achieved - */ - MajorSpeciesHaveConverged = false; + // Convergence amongst major species has not been achieved /* * Go back and do another iteration with variable ITI */ @@ -1702,11 +1691,8 @@ L_EQUILIB_CHECK: } } #endif - /* - * Set MajorSpeciesHaveConverged to true to indicate - * that convergence amongst major species has been achieved - */ - MajorSpeciesHaveConverged = true; + // Convergence amongst major species has been achieved + /*************************************************************************/ /*************** EQUILIBRIUM CHECK FOR MINOR SPECIES *********************/ /*************************************************************************/ @@ -1920,7 +1906,6 @@ L_RECHECK_DELETED: * If we have found something to add, recalculate everything * for minor species and go back to do a full iteration */ - MajorSpeciesHaveConverged = true; vcs_setFlagsVolPhases(false, VCS_STATECALC_OLD); vcs_dfe(VCS_STATECALC_OLD, 1, 0, m_numSpeciesRdc); vcs_deltag(0, false, VCS_STATECALC_OLD); @@ -1941,7 +1926,6 @@ L_RETURN_BLOCK: * If we have found something to add, recalculate everything * for minor species and go back to do a full iteration */ - MajorSpeciesHaveConverged = true; vcs_setFlagsVolPhases(false, VCS_STATECALC_OLD); vcs_dfe(VCS_STATECALC_OLD, 1, 0, m_numSpeciesRdc); vcs_deltag(0, false, VCS_STATECALC_OLD); @@ -1958,7 +1942,6 @@ L_RETURN_BLOCK_B: */ npb = vcs_add_all_deleted(); if (npb > 0) { - MajorSpeciesHaveConverged = true; iti = 0; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 1) { @@ -2092,7 +2075,6 @@ double VCS_SOLVE::vcs_minor_alt_calc(size_t kspec, size_t irxn, bool* do_delete double wTrial, tmp; double dg_irxn = m_deltaGRxn_old[irxn]; doublereal s; - vcs_VolPhase* Vphase = 0; size_t iph = m_phaseID[kspec]; *do_delete = false; @@ -2123,7 +2105,6 @@ double VCS_SOLVE::vcs_minor_alt_calc(size_t kspec, size_t irxn, bool* do_delete /* * get the diagonal of the activity coefficent jacobian */ - Vphase = m_VolPhaseList[iph]; s = m_dLnActCoeffdMolNum[kspec][kspec]; // s *= (m_tPhaseMoles_old[iph]); /* @@ -2901,7 +2882,7 @@ size_t VCS_SOLVE::vcs_add_all_deleted() * Recalculate the DeltaG's of the formation reactions for the deleted species in the mechanism */ vcs_deltag(0, true, VCS_STATECALC_NEW); - for (int irxn = m_numRxnRdc; irxn < m_numRxnTot; ++irxn) { + for (size_t irxn = m_numRxnRdc; irxn < m_numRxnTot; ++irxn) { kspec = m_indexRxnToSpecies[irxn]; iph = m_phaseID[kspec]; if (m_tPhaseMoles_old[iph] > 0.0) { @@ -4621,25 +4602,23 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const { double mfValue = 1.0; bool zeroedPhase = false; - int kspec; + size_t kspec; const double* molNum = VCS_DATA_PTR(m_molNumSpecies_old); - const double* tPhMoles_ptr = VCS_DATA_PTR(m_tPhaseMoles_old); const double* actCoeff_ptr = VCS_DATA_PTR(m_actCoeffSpecies_old); if (stateCalc == VCS_STATECALC_NEW) { - tPhMoles_ptr = VCS_DATA_PTR(m_tPhaseMoles_new); actCoeff_ptr = VCS_DATA_PTR(m_actCoeffSpecies_new); molNum = VCS_DATA_PTR(m_molNumSpecies_new); } double* tMoles = VCS_DATA_PTR(m_TmpPhase); const double* tPhInertMoles = VCS_DATA_PTR(TPhInertMoles); - for (int iph = 0; iph < m_numPhases; iph++) { + for (size_t iph = 0; iph < m_numPhases; iph++) { tMoles[iph] = tPhInertMoles[iph]; } for (kspec = 0; kspec < m_numSpeciesTot; kspec++) { if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { - int iph = m_phaseID[kspec]; + size_t iph = m_phaseID[kspec]; tMoles[iph] += molNum[kspec]; } } @@ -4652,7 +4631,7 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const for (kspec = 0; kspec < m_numSpeciesTot; ++kspec) { mfValue = 1.0; - int iphase = m_phaseID[kspec]; + size_t iphase = m_phaseID[kspec]; const vcs_VolPhase* Vphase = m_VolPhaseList[iphase]; if ((m_speciesStatus[kspec] == VCS_SPECIES_ZEROEDMS) || (m_speciesStatus[kspec] == VCS_SPECIES_ZEROEDPHASE) || @@ -5271,7 +5250,7 @@ void VCS_SOLVE::vcs_deltag(const int l, const bool doDeleted, //==================================================================================================================== void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) { - int j; + size_t j; double* deltaGRxn = VCS_DATA_PTR(m_deltaGRxn_old); double* feSpecies = VCS_DATA_PTR(m_feSpecies_old); double* molNumSpecies = VCS_DATA_PTR(m_molNumSpecies_old); @@ -5301,7 +5280,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) } //plogf("| m_scSize"); plogf("\n"); - for (int i = 0; i < m_numRxnTot; i++) { + for (size_t i = 0; i < m_numRxnTot; i++) { plogf(" --- %3d ", m_indexRxnToSpecies[i]); plogf("%-10.10s", m_speciesName[m_indexRxnToSpecies[i]].c_str()); plogf("|%10.3g|", m_molNumSpecies_old[m_indexRxnToSpecies[i]]); @@ -5323,7 +5302,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) printf(" "); vcs_print_line("-", 132); - for (int kspec = 0; kspec < m_numSpeciesTot; kspec++) { + for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) { int irxn = kspec - m_numComponents; @@ -5715,7 +5694,6 @@ void VCS_SOLVE::vcs_switch_pos(const bool ifunc, const size_t k1, const size_t k double VCS_SOLVE::vcs_birthGuess(const int kspec) { size_t irxn = kspec - m_numComponents; - int soldel = false; double dx = 0.0; if (m_speciesUnknownType[kspec] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { return dx; @@ -5743,7 +5721,6 @@ double VCS_SOLVE::vcs_birthGuess(const int kspec) #else double dxm = vcs_minor_alt_calc(kspec, irxn, &soldel_ret); #endif - soldel = soldel_ret; dx = w_kspec + dxm; if (dx > 1.0E-15) { dx = 1.0E-15; diff --git a/src/equil/vcs_solve_phaseStability.cpp b/src/equil/vcs_solve_phaseStability.cpp index 61100f730..0f669539a 100644 --- a/src/equil/vcs_solve_phaseStability.cpp +++ b/src/equil/vcs_solve_phaseStability.cpp @@ -113,8 +113,6 @@ int VCS_SOLVE::vcs_PS(VCS_PROB* vprob, int iphase, int printLvl, double& feStabl return VCS_PUB_BAD; } - - int iconv; /* * Store the temperature and pressure in the private global variables */ @@ -124,7 +122,7 @@ int VCS_SOLVE::vcs_PS(VCS_PROB* vprob, int iphase, int printLvl, double& feStabl * Evaluate the standard state free energies * at the current temperatures and pressures. */ - iconv = vcs_evalSS_TP(printLvl, printLvl, m_temperature, m_pressurePA); + vcs_evalSS_TP(printLvl, printLvl, m_temperature, m_pressurePA); /* * Prepare the problem data: @@ -207,11 +205,9 @@ int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc, double& funcVal, int printLvl) { - int retn = 0; double test = -1.0E-10; bool usedZeroedSpecies; std::vector phasePopPhaseIDs(0); - int iphasePop; int iStab = 0; std::vector sm(m_numElemConstraints*m_numElemConstraints, 0.0); @@ -222,9 +218,9 @@ int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc, std::vector wx(m_numElemConstraints, 0.0); - retn = vcs_basopt(false, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), - VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), - test, &usedZeroedSpecies); + vcs_basopt(false, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), + VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), + test, &usedZeroedSpecies); vcs_evaluate_speciesType(); vcs_dfe(VCS_STATECALC_OLD, 0, 0, m_numSpeciesRdc); @@ -238,7 +234,7 @@ int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc, } vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_Deficient), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); phasePopPhaseIDs.clear(); - iphasePop = vcs_popPhaseID(phasePopPhaseIDs); + vcs_popPhaseID(phasePopPhaseIDs); funcVal = vcs_phaseStabilityTest(iph); if (funcVal > 0.0) { iStab = 1; diff --git a/src/equil/vcs_util.cpp b/src/equil/vcs_util.cpp index 78aaf759f..a79424ca7 100644 --- a/src/equil/vcs_util.cpp +++ b/src/equil/vcs_util.cpp @@ -480,20 +480,17 @@ static void vcsUtil_mlequ_preprocess(double* c, int idem, int n, double* b, int */ int vcsUtil_mlequ(double* c, size_t idem, size_t n, double* b, size_t m) { + size_t k; #ifdef DEBUG_HKM // mlequ_matrixDump(c, idem, n); #endif vcsUtil_mlequ_preprocess(c, idem, n, b, m); #ifdef DEBUG_HKM // mlequ_matrixDump(c, idem, n); -#endif - int dmatrix = 0; -#ifdef DEBUG_HKM static int s_numCalls = 0; s_numCalls++; #endif - int i, j, k, l; double R; if (n > idem || n <= 0) { plogf("vcsUtil_mlequ ERROR: badly dimensioned matrix: %d %d\n", n, idem); @@ -501,9 +498,10 @@ int vcsUtil_mlequ(double* c, size_t idem, size_t n, double* b, size_t m) } #ifdef DEBUG_HKM - for (i = 0; i < n; ++i) { + int dmatrix = 0; + for (size_t i = 0; i < n; ++i) { bool notFound = true; - for (j = 0; j < n; ++j) { + for (size_t j = 0; j < n; ++j) { if (c[i + j * idem] != 0.0) { notFound = false; } @@ -512,9 +510,9 @@ int vcsUtil_mlequ(double* c, size_t idem, size_t n, double* b, size_t m) printf(" vcsUtil_mlequ ERROR(): row %d is identically zero\n", i); } } - for (j = 0; j < n; ++j) { + for (size_t j = 0; j < n; ++j) { bool notFound = true; - for (i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { if (c[i + j * idem] != 0.0) { notFound = false; } diff --git a/src/numerics/BEulerInt.cpp b/src/numerics/BEulerInt.cpp index 7e414b9d7..1d2fbb3f5 100644 --- a/src/numerics/BEulerInt.cpp +++ b/src/numerics/BEulerInt.cpp @@ -1911,7 +1911,7 @@ void BEulerInt::doNewtonSolve(double time_curr, double* y_curr, double BEulerInt::boundStep(const double* const y, const double* const step0, int loglevel) { - int i, i_lower = -1, i_fbounds, ifbd = 0, i_fbd = 0; + int i, i_lower = -1, ifbd = 0, i_fbd = 0; double fbound = 1.0, f_lowbounds = 1.0, f_delta_bounds = 1.0; double ff, y_new, ff_alt; for (i = 0; i < m_neq; i++) { @@ -1945,7 +1945,6 @@ double BEulerInt::boundStep(const double* const y, } if (ff < f_delta_bounds) { f_delta_bounds = ff; - i_fbounds = i; i_fbd = ifbd; } f_delta_bounds = MIN(f_delta_bounds, ff); @@ -2173,7 +2172,6 @@ int BEulerInt::solve_nonlinear_problem(double* const y_comm, int& num_backtracks, int loglevel) { - bool m_residCurrent = false; int m = 0; bool forceNewJac = false; double s1=1.e30; @@ -2218,12 +2216,10 @@ int BEulerInt::solve_nonlinear_problem(double* const y_comm, } beuler_jac(jac, m_resid, time_curr, CJ, y_curr, ydot_curr, num_newt_its); - m_residCurrent = true; } else { if (loglevel > 1) { printf("\t\t\tSolving system with old jacobian\n"); } - m_residCurrent = false; } // compute the undamped Newton step diff --git a/src/numerics/BandMatrix.cpp b/src/numerics/BandMatrix.cpp index ad1481b05..eac5659a7 100644 --- a/src/numerics/BandMatrix.cpp +++ b/src/numerics/BandMatrix.cpp @@ -129,40 +129,40 @@ void BandMatrix::zero() m_factored = false; } //==================================================================================================================== -doublereal& BandMatrix::operator()(int i, int j) +doublereal& BandMatrix::operator()(size_t i, size_t j) { return value(i,j); } //==================================================================================================================== -doublereal BandMatrix::operator()(int i, int j) const +doublereal BandMatrix::operator()(size_t i, size_t j) const { return value(i,j); } //==================================================================================================================== -doublereal& BandMatrix::value(int i, int j) +doublereal& BandMatrix::value(size_t i, size_t j) { m_factored = false; - if (i < j - m_ku || i > j + m_kl) { + if (i + m_ku < j || i > j + m_kl) { return m_zero; } return data[index(i,j)]; } //==================================================================================================================== -doublereal BandMatrix::value(int i, int j) const +doublereal BandMatrix::value(size_t i, size_t j) const { - if (i < j - m_ku || i > j + m_kl) { + if (i + m_ku < j || i > j + m_kl) { return 0.0; } return data[index(i,j)]; } //==================================================================================================================== -int BandMatrix::index(int i, int j) const +size_t BandMatrix::index(size_t i, size_t j) const { - int rw = m_kl + m_ku + i - j; + size_t rw = m_kl + m_ku + i - j; return (2*m_kl + m_ku + 1)*j + rw; } //==================================================================================================================== -doublereal BandMatrix::_value(int i, int j) const +doublereal BandMatrix::_value(size_t i, size_t j) const { return data[index(i,j)]; } @@ -184,24 +184,24 @@ size_t BandMatrix::nRowsAndStruct(int* const iStruct) const } //==================================================================================================================== // Number of columns -int BandMatrix::nColumns() const +size_t BandMatrix::nColumns() const { return m_n; } //==================================================================================================================== // Number of subdiagonals -int BandMatrix::nSubDiagonals() const +size_t BandMatrix::nSubDiagonals() const { return m_kl; } //==================================================================================================================== // Number of superdiagonals -int BandMatrix::nSuperDiagonals() const +size_t BandMatrix::nSuperDiagonals() const { return m_ku; } //==================================================================================================================== -int BandMatrix::ldim() const +size_t BandMatrix::ldim() const { return 2*m_kl + m_ku + 1; } @@ -221,7 +221,7 @@ void BandMatrix::mult(const doublereal* const b, doublereal* const prod) const for (size_t m = 0; m < nr; m++) { sum = 0.0; for (size_t j = m - m_kl; j <= m + m_ku; j++) { - if (j >= 0 && j < m_n) { + if (j < m_n) { sum += _value(m,j) * b[j]; } } @@ -239,7 +239,7 @@ void BandMatrix::leftMult(const doublereal* const b, doublereal* const prod) con for (size_t n = 0; n < nc; n++) { sum = 0.0; for (size_t i = n - m_ku; i <= n + m_kl; i++) { - if (i >= 0 && i < m_n) { + if (i < m_n) { sum += _value(i,n) * b[i]; } } @@ -373,10 +373,10 @@ doublereal BandMatrix::rcond(doublereal a1norm) { int printLevel = 0; int useReturnErrorCode = 0; - if ((int) iwork_.size() < m_n) { + if (iwork_.size() < m_n) { iwork_.resize(m_n); } - if ((int) work_.size() < 3 * m_n) { + if (work_.size() < 3 * m_n) { work_.resize(3 * m_n); } doublereal rcond = 0.0; @@ -420,10 +420,10 @@ int BandMatrix::factorAlgorithm() const doublereal BandMatrix::oneNorm() const { doublereal value = 0.0; - for (int j = 0; j < m_n; j++) { + for (size_t j = 0; j < m_n; j++) { doublereal sum = 0.0; doublereal* colP = m_colPtrs[j]; - for (int i = j - m_ku; i <= j + m_kl; i++) { + for (size_t i = j - m_ku; i <= j + m_kl; i++) { sum += fabs(colP[m_kl + m_ku + i - j]); } if (sum > value) { @@ -433,14 +433,14 @@ doublereal BandMatrix::oneNorm() const return value; } //==================================================================================================================== -int BandMatrix::checkRows(doublereal& valueSmall) const +size_t BandMatrix::checkRows(doublereal& valueSmall) const { valueSmall = 1.0E300; - int iSmall = -1; + size_t iSmall = npos; double vv; - for (int i = 0; i < m_n; i++) { + for (size_t i = 0; i < m_n; i++) { double valueS = 0.0; - for (int j = i - m_kl; j <= i + m_ku; j++) { + for (size_t j = i - m_kl; j <= i + m_ku; j++) { if (j >= 0 && (j < m_n)) { vv = fabs(value(i,j)); if (vv > valueS) { @@ -459,14 +459,14 @@ int BandMatrix::checkRows(doublereal& valueSmall) const return iSmall; } //==================================================================================================================== -int BandMatrix::checkColumns(doublereal& valueSmall) const +size_t BandMatrix::checkColumns(doublereal& valueSmall) const { valueSmall = 1.0E300; - int jSmall = -1; + size_t jSmall = npos; double vv; - for (int j = 0; j < m_n; j++) { + for (size_t j = 0; j < m_n; j++) { double valueS = 0.0; - for (int i = j - m_ku; i <= j + m_kl; i++) { + for (size_t i = j - m_ku; i <= j + m_kl; i++) { if (i >= 0 && (i < m_n)) { vv = fabs(value(i,j)); if (vv > valueS) { @@ -502,7 +502,7 @@ bool BandMatrix::factored() const * * @return Returns a pointer to the top of the column */ -doublereal* BandMatrix::ptrColumn(int j) +doublereal* BandMatrix::ptrColumn(size_t j) { return m_colPtrs[j]; } @@ -515,7 +515,7 @@ doublereal* BandMatrix::ptrColumn(int j) * @return returns a vector of pointers to the top of the columns * of the matrices. */ -doublereal* const* BandMatrix::colPts() +doublereal* const* BandMatrix::colPts() { return &(m_colPtrs[0]); } diff --git a/src/numerics/DenseMatrix.cpp b/src/numerics/DenseMatrix.cpp index 0f8ef4a2e..160736097 100644 --- a/src/numerics/DenseMatrix.cpp +++ b/src/numerics/DenseMatrix.cpp @@ -52,7 +52,7 @@ DenseMatrix::DenseMatrix(const DenseMatrix& y) : { m_ipiv = y.ipiv(); m_colPts.resize(m_ncols); - for (int j = 0; j < m_ncols; j++) { + for (size_t j = 0; j < m_ncols; j++) { m_colPts[j] = &(m_data[m_nrows*j]); } } @@ -66,7 +66,7 @@ DenseMatrix& DenseMatrix::operator=(const DenseMatrix& y) Array2D::operator=(y); m_ipiv = y.ipiv(); m_colPts.resize(m_ncols); - for (int j = 0; j < m_ncols; j++) { + for (size_t j = 0; j < m_ncols; j++) { m_colPts[j] = &(m_data[m_nrows*j]); } m_useReturnErrorCode = y.m_useReturnErrorCode; @@ -84,7 +84,7 @@ void DenseMatrix::resize(int n, int m, doublereal v) Array2D::resize(n,m,v); m_ipiv.resize(max(n,m)); m_colPts.resize(m_ncols); - for (int j = 0; j < m_ncols; j++) { + for (size_t j = 0; j < m_ncols; j++) { m_colPts[j] = &(m_data[m_nrows*j]); } } diff --git a/src/numerics/NonlinearSolver.cpp b/src/numerics/NonlinearSolver.cpp index 03f8724ed..c82ab7823 100644 --- a/src/numerics/NonlinearSolver.cpp +++ b/src/numerics/NonlinearSolver.cpp @@ -1141,9 +1141,7 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const if (s_doBothSolvesAndCompare) { doHessian = true; } - bool useNewton = false; if (m_conditionNumber < 1.0E7) { - useNewton = true; if (m_print_flag >= 4) { printf("\t\t doAffineNewtonSolve: Condition number = %g during regular solve\n", m_conditionNumber); } @@ -1170,7 +1168,6 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const } else { if (jac.matrixType_ == 1) { - useNewton = true; newtonGood = true; if (m_print_flag >= 3) { printf("\t\t doAffineNewtonSolve() WARNING: Condition number too large, %g, But Banded Hessian solve " @@ -1561,7 +1558,6 @@ doublereal NonlinearSolver::doCauchyPointSolve(GeneralMatrix& jac) //=================================================================================================================== void NonlinearSolver::descentComparison(doublereal time_curr, doublereal* ydot0, doublereal* ydot1, int& numTrials) { - int info; doublereal ff = 1.0E-5; doublereal ffNewt = 1.0E-5; doublereal* y_n_1 = DATA_PTR(m_wksp); @@ -1580,9 +1576,9 @@ void NonlinearSolver::descentComparison(doublereal time_curr, doublereal* ydot0 * -> m_resid[] contains the result of the residual calculation */ if (solnType_ != NSOLN_TYPE_STEADY_STATE) { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); } else { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); } doublereal normResid02 = m_normResid_0 * m_normResid_0 * neq_; @@ -1605,9 +1601,9 @@ void NonlinearSolver::descentComparison(doublereal time_curr, doublereal* ydot0 * -> m_resid[] contains the result of the residual calculation */ if (solnType_ != NSOLN_TYPE_STEADY_STATE) { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); } else { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); } doublereal residNewt = residErrorNorm(DATA_PTR(m_resid)); doublereal residNewt2 = residNewt * residNewt * neq_; @@ -1670,9 +1666,9 @@ void NonlinearSolver::descentComparison(doublereal time_curr, doublereal* ydot0 } numTrials += 1; if (solnType_ != NSOLN_TYPE_STEADY_STATE) { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot1, Base_LaggedSolutionComponents); } else { - info = doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); + doResidualCalc(time_curr, solnType_, y_n_1, ydot0, Base_LaggedSolutionComponents); } residNewt = residErrorNorm(DATA_PTR(m_resid)); residNewt2 = residNewt * residNewt * neq_; @@ -2709,7 +2705,6 @@ int NonlinearSolver::dampDogLeg(const doublereal time_curr, const doublereal* y_ int info; bool success = false; - int retn = 0; bool haveASuccess = false; doublereal trustDeltaOld = trustDelta_; doublereal* stepLastGood = DATA_PTR(m_wksp); @@ -2781,7 +2776,6 @@ int NonlinearSolver::dampDogLeg(const doublereal time_curr, const doublereal* y_ doublereal stepNorm = solnErrorNorm(DATA_PTR(step_1)); printf("\t\t dampDogLeg: Current direction rejected, update became too small %g\n", stepNorm); success = false; - retn = NSOLN_RETN_FAIL_STEPTOOSMALL; break; } } @@ -2789,7 +2783,6 @@ int NonlinearSolver::dampDogLeg(const doublereal time_curr, const doublereal* y_ if (m_print_flag >= 1) { printf("\t\t dampDogLeg: current trial step and damping led to LAPACK ERROR %d. Bailing\n", info); success = false; - retn = NSOLN_RETN_MATRIXINVERSIONERROR; break; } } @@ -2886,7 +2879,6 @@ int NonlinearSolver::decideStep(const doublereal time_curr, int leg, doublereal doublereal trustDeltaOld) { int retn = 2; - bool goodStep = false; int info; doublereal ll; // Calculate the solution step length @@ -2941,7 +2933,6 @@ int NonlinearSolver::decideStep(const doublereal time_curr, int leg, doublereal doublereal acceptableDelF = funcDecreaseSDExp * stepNorm * 1.0E-4; if (funcDecrease < acceptableDelF) { m_normResid_1 = m_normResidTrial; - goodStep = true; m_normResid_1 = m_normResidTrial; retn = 0; if (m_print_flag >= 4) { @@ -3072,7 +3063,6 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c solnType_ = SolnType; int info = 0; - bool m_residCurrent = false; num_linear_solves -= m_numTotalLinearSolves; int retnDamp = 0; int retnCode = 0; @@ -3206,12 +3196,10 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c retnDamp = NSOLN_RETN_JACOBIANFORMATIONERROR ; goto done; } - m_residCurrent = true; } else { if (m_print_flag > 1) { printf("\t solve_nonlinear_problem(): Solving system with old jacobian\n"); } - m_residCurrent = false; } /* * Go get new scales diff --git a/src/numerics/RootFind.cpp b/src/numerics/RootFind.cpp index c8bda69dc..317bb0a94 100644 --- a/src/numerics/RootFind.cpp +++ b/src/numerics/RootFind.cpp @@ -92,6 +92,8 @@ static void print_funcEval(FILE* fp, doublereal xval, doublereal fval, int its) * @param n Number of rows and columns * @param b right hand side * @param m Number of right hand sides + * + * @todo This function is never used, and should be removed. */ static int smlequ(doublereal* c, int idem, int n, doublereal* b, int m) { @@ -354,7 +356,7 @@ int RootFind::solve(doublereal xmin, doublereal xmax, int itmax, doublereal& fun #endif int doFinalFuncCall = 0; doublereal x1, x2, xnew, f1, f2, fnew, slope; - doublereal deltaX1 = 0.0, deltaX2 = 0.0, deltaXnew = 0.0; + doublereal deltaX2 = 0.0, deltaXnew = 0.0; int posStraddle = 0; int retn = ROOTFIND_FAILEDCONVERGENCE; @@ -366,7 +368,7 @@ int RootFind::solve(doublereal xmin, doublereal xmax, int itmax, doublereal& fun doublereal xNegF = 0.0; doublereal fNegF = -1.0E300; doublereal fnorm; /* A valid norm for the making the function value dimensionless */ - doublereal x0 = 0.0, f0 = 0.0, xDelMin; + doublereal xDelMin; doublereal sgn; doublereal dtmp; doublereal fnoise = 0.0; @@ -943,8 +945,6 @@ int RootFind::solve(doublereal xmin, doublereal xmax, int itmax, doublereal& fun } } - x0 = x1; - f0 = f1; x1 = x2; f1 = f2; @@ -1035,7 +1035,6 @@ int RootFind::solve(doublereal xmin, doublereal xmax, int itmax, doublereal& fun AssertThrow((f1* f2 <= 0.0), "F1 and F2 aren't bounding"); } - deltaX1 = deltaX2; deltaX2 = deltaXnew; deltaXnew = x2 - x1; deltaXConverged_ = 0.5 * deltaXConverged_ + 0.5 * (m_rtolx * 0.5 * (fabs(x2) + fabs(x1)) + m_atolx); diff --git a/src/numerics/SquareMatrix.cpp b/src/numerics/SquareMatrix.cpp index 1788a5a4d..4a57ac083 100644 --- a/src/numerics/SquareMatrix.cpp +++ b/src/numerics/SquareMatrix.cpp @@ -49,7 +49,7 @@ SquareMatrix::SquareMatrix() : * @param n size of the square matrix * @param v intial value of all matrix components. */ -SquareMatrix::SquareMatrix(int n, doublereal v) : +SquareMatrix::SquareMatrix(size_t n, doublereal v) : DenseMatrix(n, n, v), GeneralMatrix(0), m_factored(0), @@ -133,9 +133,9 @@ int SquareMatrix::solve(doublereal* b) */ void SquareMatrix::zero() { - int n = static_cast(nRows()); + size_t n = nRows(); if (n > 0) { - int nn = n * n; + size_t nn = n * n; double* sm = &m_data[0]; /* * Using memset is the fastest way to zero a contiguous @@ -145,7 +145,7 @@ void SquareMatrix::zero() } } //==================================================================================================================== -void SquareMatrix::resize(int n, int m, doublereal v) +void SquareMatrix::resize(size_t n, size_t m, doublereal v) { DenseMatrix::resize(n, m, v); } @@ -213,7 +213,7 @@ void SquareMatrix::setFactorFlag() //===================================================================================================================== int SquareMatrix::factorQR() { - if ((int) tau.size() < m_nrows) { + if (tau.size() < m_nrows) { tau.resize(m_nrows, 0.0); work.resize(8 * m_nrows, 0.0); } @@ -255,7 +255,7 @@ int SquareMatrix::solveQR(doublereal* b) } } - int lwork = work.size(); + size_t lwork = work.size(); if (lwork < m_nrows) { work.resize(8 * m_nrows, 0.0); lwork = 8 * m_nrows; @@ -274,7 +274,7 @@ int SquareMatrix::solveQR(doublereal* b) throw CELapackError("SquareMatrix::solveQR()", "DORMQR returned INFO = " + int2str(info)); } } - int lworkOpt = work[0]; + size_t lworkOpt = static_cast(work[0]); if (lworkOpt > lwork) { work.resize(lworkOpt); } @@ -298,10 +298,10 @@ int SquareMatrix::solveQR(doublereal* b) doublereal SquareMatrix::rcond(doublereal anorm) { - if ((int) iwork_.size() < m_nrows) { + if (iwork_.size() < m_nrows) { iwork_.resize(m_nrows); } - if ((int) work.size() <4 * m_nrows) { + if (work.size() <4 * m_nrows) { work.resize(4 * m_nrows); } doublereal rcond = 0.0; @@ -334,10 +334,10 @@ doublereal SquareMatrix::oneNorm() const doublereal SquareMatrix::rcondQR() { - if ((int) iwork_.size() < m_nrows) { + if (iwork_.size() < m_nrows) { iwork_.resize(m_nrows); } - if ((int) work.size() <3 * m_nrows) { + if (work.size() <3 * m_nrows) { work.resize(3 * m_nrows); } doublereal rcond = 0.0; @@ -380,7 +380,7 @@ bool SquareMatrix::factored() const * * @return Returns a pointer to the top of the column */ -doublereal* SquareMatrix::ptrColumn(int j) +doublereal* SquareMatrix::ptrColumn(size_t j) { return Array2D::ptrColumn(j); } @@ -438,13 +438,13 @@ doublereal* const* SquareMatrix::colPts() } //===================================================================================================================== -int SquareMatrix::checkRows(doublereal& valueSmall) const +size_t SquareMatrix::checkRows(doublereal& valueSmall) const { valueSmall = 1.0E300; - int iSmall = -1; - for (int i = 0; i < m_nrows; i++) { + size_t iSmall = npos; + for (size_t i = 0; i < m_nrows; i++) { double valueS = 0.0; - for (int j = 0; j < m_nrows; j++) { + for (size_t j = 0; j < m_nrows; j++) { if (fabs(value(i,j)) > valueS) { valueS = fabs(value(i,j)); } @@ -457,13 +457,13 @@ int SquareMatrix::checkRows(doublereal& valueSmall) const return iSmall; } //===================================================================================================================== -int SquareMatrix::checkColumns(doublereal& valueSmall) const +size_t SquareMatrix::checkColumns(doublereal& valueSmall) const { valueSmall = 1.0E300; - int jSmall = -1; - for (int j = 0; j < m_nrows; j++) { + size_t jSmall = npos; + for (size_t j = 0; j < m_nrows; j++) { double valueS = 0.0; - for (int i = 0; i < m_nrows; i++) { + for (size_t i = 0; i < m_nrows; i++) { if (fabs(value(i,j)) > valueS) { valueS = fabs(value(i,j)); } diff --git a/src/numerics/solveProb.cpp b/src/numerics/solveProb.cpp index d0a5c58b4..844fe4c80 100644 --- a/src/numerics/solveProb.cpp +++ b/src/numerics/solveProb.cpp @@ -110,12 +110,11 @@ int solveProb::solve(int ifunc, doublereal time_scale, if (ifunc == SOLVEPROB_JACOBIAN) { EXTRA_ACCURACY *= 0.001; } - int 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; - doublereal label_factor = 1.0; + int label_t_old = -1; + doublereal label_factor = 1.0; int iter=0; // iteration number on numlinear solver int iter_max=1000; // maximum number of nonlinear iterations int nrhs=1; @@ -288,7 +287,7 @@ int solveProb::solve(int ifunc, doublereal time_scale, printf("solveSurfSS: Zero pivot, assuming converged: %g (%d)\n", resid_norm, info); } - for (jcol = 0; jcol < m_neq; jcol++) { + for (size_t jcol = 0; jcol < m_neq; jcol++) { m_resid[jcol] = 0.0; } @@ -333,7 +332,7 @@ int solveProb::solve(int ifunc, doublereal time_scale, * Update the solution vector and real time * Crop the concentrations to zero. */ - for (irow = 0; irow < m_neq; irow++) { + for (size_t irow = 0; irow < m_neq; irow++) { m_CSolnSP[irow] -= damp * m_resid[irow]; } @@ -458,7 +457,6 @@ void solveProb::resjac_eval(std::vector &JacCol, const doublereal CSolnOld[], const bool do_time, const doublereal deltaT) { - int i, kCol; doublereal dc, cSave, sd; doublereal* col_j; /* @@ -469,7 +467,7 @@ void solveProb::resjac_eval(std::vector &JacCol, * Now we will look over the columns perturbing each unknown. */ - for (kCol = 0; kCol < m_neq; kCol++) { + for (size_t kCol = 0; kCol < m_neq; kCol++) { cSave = CSoln[kCol]; sd = fabs(cSave) + fabs(CSoln[kCol]) + m_atol[kCol] * 1.0E6; if (sd < 1.0E-200) { @@ -479,7 +477,7 @@ void solveProb::resjac_eval(std::vector &JacCol, CSoln[kCol] += dc; fun_eval(DATA_PTR(m_numEqn2), CSoln, CSolnOld, do_time, deltaT); col_j = JacCol[kCol]; - for (i = 0; i < m_neq; i++) { + for (size_t i = 0; i < m_neq; i++) { col_j[i] = (m_numEqn2[i] - resid[i])/dc; } CSoln[kCol] = cSave; @@ -606,12 +604,11 @@ static doublereal calcWeightedNorm(const doublereal wtX[], const doublereal dx[] void solveProb::calcWeights(doublereal wtSpecies[], doublereal wtResid[], const doublereal CSoln[]) { - int k, jcol; /* * First calculate the weighting factor */ - for (k = 0; k < m_neq; k++) { + for (size_t k = 0; k < m_neq; k++) { wtSpecies[k] = m_atol[k] + m_rtol * fabs(CSoln[k]); } /* @@ -620,9 +617,9 @@ void solveProb::calcWeights(doublereal wtSpecies[], doublereal wtResid[], * change in a solution variable does to each residual. * This is a row sum scale operation. */ - for (k = 0; k < m_neq; k++) { + for (size_t k = 0; k < m_neq; k++) { wtResid[k] = 0.0; - for (jcol = 0; jcol < m_neq; jcol++) { + for (size_t jcol = 0; jcol < m_neq; jcol++) { wtResid[k] += fabs(m_Jac(k,jcol) * wtSpecies[jcol]); } } @@ -643,9 +640,8 @@ doublereal solveProb:: calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[], int* label, int* label_old, doublereal* label_factor, int ioflag) { - int k, kspSpecial; doublereal tmp, inv_timeScale=0.0; - for (k = 0; k < m_neq; k++) { + for (size_t k = 0; k < m_neq; k++) { if (Csoln[k] <= 1.0E-10) { tmp = 1.0E-10; } else { @@ -660,8 +656,6 @@ calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[], if (tmp > inv_timeScale) { inv_timeScale = tmp; *label = k; - - kspSpecial = k; } } @@ -704,7 +698,7 @@ calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[], */ void solveProb::setBounds(const doublereal botBounds[], const doublereal topBounds[]) { - for (int k = 0; k < m_neq; k++) { + for (size_t k = 0; k < m_neq; k++) { m_botBounds[k] = botBounds[k]; m_topBounds[k] = topBounds[k]; } @@ -1027,14 +1021,14 @@ printIterationHeader(int ioflag, doublereal damp,doublereal inv_t, doublereal t_ //================================================================================================ void solveProb::setAtol(const doublereal atol[]) { - for (int k = 0; k < m_neq; k++, k++) { + for (size_t k = 0; k < m_neq; k++, k++) { m_atol[k] = atol[k]; } } //================================================================================================ void solveProb::setAtolConst(const doublereal atolconst) { - for (int k = 0; k < m_neq; k++, k++) { + for (size_t k = 0; k < m_neq; k++, k++) { m_atol[k] = atolconst; } } diff --git a/src/thermo/Constituents.cpp b/src/thermo/Constituents.cpp index 03cfd7d93..dd3db686d 100644 --- a/src/thermo/Constituents.cpp +++ b/src/thermo/Constituents.cpp @@ -514,7 +514,7 @@ int Constituents::addUniqueElementAfterFreeze(const std::string& symbol, doubler if (m_kk > 0) { vector_fp old(m_speciesComp); m_speciesComp.resize(m_kk*m_mm, 0.0); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { int m_old = m_mm - 1; for (int m = 0; m < m_old; m++) { m_speciesComp[k * m_mm + m] = old[k * (m_old) + m]; diff --git a/src/thermo/GibbsExcessVPSSTP.cpp b/src/thermo/GibbsExcessVPSSTP.cpp index 695adae63..8c15ee34c 100644 --- a/src/thermo/GibbsExcessVPSSTP.cpp +++ b/src/thermo/GibbsExcessVPSSTP.cpp @@ -257,7 +257,7 @@ void GibbsExcessVPSSTP::getActivityCoefficients(doublereal* const ac) const getLnActivityCoefficients(ac); // Protect against roundoff when taking exponentials - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (ac[k] > 700.) { ac[k] = exp(700.0); } else if (ac[k] < -700.) { diff --git a/src/thermo/HMWSoln_input.cpp b/src/thermo/HMWSoln_input.cpp index 12ce5aa80..8bcfe2e12 100644 --- a/src/thermo/HMWSoln_input.cpp +++ b/src/thermo/HMWSoln_input.cpp @@ -854,7 +854,7 @@ void HMWSoln::readXMLMunnnNeutral(XML_Node& BinSalt) "neutral charge problem"); } - for (int i = 0; i < BinSalt.nChildren(); i++) { + for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); stemp = xmlChild.name(); string nodeName = lowercase(stemp); @@ -1660,20 +1660,20 @@ initThermoXML(XML_Node& phaseNode, std::string id) do { double sum = 0.0; - int kMaxC = -1; + size_t kMaxC = npos; double MaxC = 0.0; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sum += mf[k] * m_speciesCharge[k]; if (fabs(mf[k] * m_speciesCharge[k]) > MaxC) { kMaxC = k; } } - int kHp = speciesIndex("H+"); - int kOHm = speciesIndex("OH-"); + size_t kHp = speciesIndex("H+"); + size_t kOHm = speciesIndex("OH-"); if (fabs(sum) > 1.0E-30) { - if (kHp >= 0) { + if (kHp != npos) { if (mf[kHp] > sum * 1.1) { mf[kHp] -= sum; mf[0] += sum; @@ -1687,7 +1687,7 @@ initThermoXML(XML_Node& phaseNode, std::string id) } } if (notDone) { - if (kOHm >= 0) { + if (kOHm != npos) { if (mf[kOHm] > -sum * 1.1) { mf[kOHm] += sum; mf[0] -= sum; @@ -1701,7 +1701,7 @@ initThermoXML(XML_Node& phaseNode, std::string id) } } if (notDone) { - if (kMaxC >= 0) { + if (kMaxC != npos) { if (mf[kMaxC] > (1.1 * sum / m_speciesCharge[kMaxC])) { mf[kMaxC] -= sum / m_speciesCharge[kMaxC]; mf[0] += sum / m_speciesCharge[kMaxC]; diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index 2eb5cf9d2..c179d3db8 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -583,7 +583,7 @@ void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_ s_update_lnActCoeff(); s_update_dlnActCoeff_dlnN_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k]; } } @@ -593,8 +593,8 @@ void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActC s_update_lnActCoeff(); s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); - for (int k = 0; k < m_kk; k++) { - for (int m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m]; } } @@ -818,9 +818,6 @@ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const */ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal* const dx, doublereal* const dy) const { - int k, icat, jNeut; - doublereal sumCat; - doublereal sumAnion; doublereal fmij; vector_fp y; y.resize(numNeutralMoleculeSpecies_,0.0); @@ -847,8 +844,8 @@ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal* const case cIonSolnType_SINGLEANION: for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation - icat = cationList_[k]; - jNeut = fm_invert_ionForNeutral[icat]; + size_t icat = cationList_[k]; + size_t jNeut = fm_invert_ionForNeutral[icat]; if (jNeut != npos) { fmij = fm_neutralMolec_ions_[icat + jNeut * m_kk]; AssertTrace(fmij != 0.0); @@ -858,8 +855,8 @@ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal* const } for (size_t k = 0; k < numPassThroughSpecies_; k++) { - icat = passThroughList_[k]; - jNeut = fm_invert_ionForNeutral[icat]; + size_t icat = passThroughList_[k]; + size_t jNeut = fm_invert_ionForNeutral[icat]; fmij = fm_neutralMolec_ions_[ icat + jNeut * m_kk]; dy[jNeut] += dx[icat] / fmij; y[jNeut] += moleFractions_[icat] / fmij; @@ -1672,7 +1669,7 @@ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN_diag() const */ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const { - int k, m, kcat, kNeut, mcat, mNeut; + size_t kcat, kNeut, mcat, mNeut; doublereal fmij, mfmij; dlnActCoeffdlnN_.zero(); /* @@ -1691,8 +1688,8 @@ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const case cIonSolnType_SINGLEANION: // Do the cation list - for (k = 0; k < (int) cationList_.size(); k++) { - for (m = 0; m < (int) cationList_.size(); m++) { + for (size_t k = 0; k < cationList_.size(); k++) { + for (size_t m = 0; m < cationList_.size(); m++) { kcat = cationList_[k]; kNeut = fm_invert_ionForNeutral[kcat]; @@ -1706,7 +1703,7 @@ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const dlnActCoeffdlnN_(kcat,mcat) = dlnActCoeffdlnN_NeutralMolecule_(kNeut,mNeut) * mfmij / fmij; } - for (m = 0; m < numPassThroughSpecies_; m++) { + for (size_t m = 0; m < numPassThroughSpecies_; m++) { mcat = passThroughList_[m]; mNeut = fm_invert_ionForNeutral[mcat]; dlnActCoeffdlnN_(kcat, mcat) = dlnActCoeffdlnN_NeutralMolecule_(kNeut, mNeut) / fmij; @@ -1716,25 +1713,25 @@ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const // Do the anion list -> anion activity coefficient is one kcat = anionList_[0]; kNeut = fm_invert_ionForNeutral[kcat]; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_(kcat, k) = 0.0; dlnActCoeffdlnN_(k, kcat) = 0.0; } // Do the list of neutral molecules - for (k = 0; k < numPassThroughSpecies_; k++) { + for (size_t k = 0; k < numPassThroughSpecies_; k++) { kcat = passThroughList_[k]; kNeut = fm_invert_ionForNeutral[kcat]; dlnActCoeffdlnN_diag_[kcat] = dlnActCoeffdlnN_diag_NeutralMolecule_[kNeut]; - for (m = 0; m < m_kk; m++) { + for (size_t m = 0; m < m_kk; m++) { mcat = passThroughList_[m]; mNeut = fm_invert_ionForNeutral[mcat]; dlnActCoeffdlnN_(kcat, mcat) = dlnActCoeffdlnN_NeutralMolecule_(kNeut, mNeut); } - for (m = 0; m < (int) cationList_.size(); m++) { + for (size_t m = 0; m < cationList_.size(); m++) { mcat = cationList_[m]; mNeut = fm_invert_ionForNeutral[mcat]; mfmij = fm_neutralMolec_ions_[mcat + mNeut * m_kk]; diff --git a/src/thermo/LatticePhase.cpp b/src/thermo/LatticePhase.cpp index 5e352b23b..a8d8d1d67 100644 --- a/src/thermo/LatticePhase.cpp +++ b/src/thermo/LatticePhase.cpp @@ -330,7 +330,7 @@ void LatticePhase::getPartialMolarEntropies(doublereal* sbar) const const array_fp& _s = entropy_R_ref(); doublereal r = GasConstant; doublereal xx; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(SmallNumber, moleFraction(k)); sbar[k] = r * (_s[k] - log(xx)); } @@ -339,7 +339,7 @@ void LatticePhase::getPartialMolarEntropies(doublereal* sbar) const void LatticePhase::getPartialMolarCp(doublereal* cpbar) const { getCp_R(cpbar); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -360,7 +360,7 @@ void LatticePhase::getPureGibbs(doublereal* gpure) const const array_fp& gibbsrt = gibbs_RT_ref(); doublereal delta_p = (m_Pcurrent - m_Pref); double RT = GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { gpure[k] = RT * gibbsrt[k] + delta_p * m_speciesMolarVolume[k]; } } @@ -385,7 +385,7 @@ void LatticePhase::getGibbs_RT(doublereal* grt) const const array_fp& gibbsrt = gibbs_RT_ref(); doublereal RT = _RT(); doublereal delta_prt = (m_Pcurrent - m_Pref)/ RT; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { grt[k] = gibbsrt[k] + delta_prt * m_speciesMolarVolume[k]; } } @@ -393,7 +393,7 @@ void LatticePhase::getGibbs_RT(doublereal* grt) const void LatticePhase::getGibbs_ref(doublereal* g) const { getGibbs_RT_ref(g); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { g[k] *= GasConstant * temperature(); } } @@ -436,7 +436,7 @@ const array_fp& LatticePhase::gibbs_RT_ref() const void LatticePhase::getGibbs_RT_ref(doublereal* grt) const { _updateThermo(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { grt[k] = m_g0_RT[k]; } } @@ -527,7 +527,7 @@ void LatticePhase::initThermoXML(XML_Node& phaseNode, std::string id) XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"], &phaseNode.root()); const std::vector &sss = speciesNames(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_speciesMolarVolume[k] = m_site_density; XML_Node* s = speciesDB->findByAttr("name", sss[k]); if (!s) { diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index d9f29d1a7..6dcc83743 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -89,7 +89,7 @@ LatticeSolidPhase::operator=(const LatticeSolidPhase& right) LatticeSolidPhase::~LatticeSolidPhase() { // We own the sublattices. So we have to delete the sublattices - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { delete m_lattice[n]; m_lattice[n] = 0; } @@ -125,7 +125,7 @@ ThermoPhase* LatticeSolidPhase::duplMyselfAsThermoPhase() const doublereal LatticeSolidPhase::minTemp(int k) const { if (k >= 0) { - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { if (lkstart_[n+1] < k) { double ml = (m_lattice[n])->minTemp(k-lkstart_[n]); return ml; @@ -133,7 +133,7 @@ doublereal LatticeSolidPhase::minTemp(int k) const } } doublereal mm = 1.0E300; - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { double ml = (m_lattice[n])->minTemp(-1); mm = MIN(mm, ml); } @@ -155,7 +155,7 @@ doublereal LatticeSolidPhase::minTemp(int k) const doublereal LatticeSolidPhase::maxTemp(int k) const { if (k >= 0) { - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { if (lkstart_[n+1] < k) { double ml = (m_lattice[n])->maxTemp(k - lkstart_[n]); return ml; @@ -163,7 +163,7 @@ doublereal LatticeSolidPhase::maxTemp(int k) const } } doublereal mm = -1.0E300; - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { double ml = (m_lattice[n])->maxTemp(-1); mm = MAX(mm, ml); } @@ -266,7 +266,7 @@ doublereal LatticeSolidPhase::logStandardConc(size_t k) const void LatticeSolidPhase::setPressure(doublereal p) { m_press = p; - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { m_lattice[n]->setPressure(m_press); } calcDensity(); @@ -287,7 +287,7 @@ void LatticeSolidPhase::setPressure(doublereal p) doublereal LatticeSolidPhase::calcDensity() { double sum = 0.0; - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { sum += theta_[n] * m_lattice[n]->density(); } State::setDensity(sum); @@ -309,13 +309,13 @@ doublereal LatticeSolidPhase::calcDensity() */ void LatticeSolidPhase::setMoleFractions(const doublereal* const x) { - int nsp, strt = 0; - for (int n = 0; n < m_nlattice; n++) { + size_t nsp, strt = 0; + for (size_t n = 0; n < m_nlattice; n++) { nsp = m_lattice[n]->nSpecies(); m_lattice[n]->setMoleFractions(x + strt); strt += nsp; } - for (int k = 0; k < strt; k++) { + for (size_t k = 0; k < strt; k++) { m_x[k] = x[k] / m_nlattice; } State::setMoleFractions(DATA_PTR(m_x)); @@ -331,17 +331,17 @@ void LatticeSolidPhase::setMoleFractions(const doublereal* const x) */ void LatticeSolidPhase::getMoleFractions(doublereal* const x) const { - int nsp, strt = 0; + size_t nsp, strt = 0; // the ifdef block should be the way we calculate this.!!!!! State::getMoleFractions(x); doublereal sum; - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { nsp = m_lattice[n]->nSpecies(); sum = 0.0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { sum += (x + strt)[k]; } - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { (x + strt)[k] /= sum; } /* @@ -350,7 +350,7 @@ void LatticeSolidPhase::getMoleFractions(doublereal* const x) const */ #ifdef DEBUG_MODE m_lattice[n]->getMoleFractions(&(m_x[strt])); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { if (fabs((x + strt)[k] - m_x[strt+k]) > 1.0E-14) { throw CanteraError("LatticeSolidPhase::getMoleFractions()", "internal error"); @@ -386,9 +386,9 @@ void LatticeSolidPhase::getChemPotentials(doublereal* mu) const void LatticeSolidPhase::getPartialMolarEnthalpies(doublereal* hbar) const { _updateThermo(); - int strt = 0; - for (int n = 0; n < m_nlattice; n++) { - int nlsp = m_lattice[n]->nSpecies(); + size_t strt = 0; + for (size_t n = 0; n < m_nlattice; n++) { + size_t nlsp = m_lattice[n]->nSpecies(); m_lattice[n]->getPartialMolarEnthalpies(hbar + strt); strt += nlsp; } @@ -397,9 +397,9 @@ void LatticeSolidPhase::getPartialMolarEnthalpies(doublereal* hbar) const void LatticeSolidPhase::getPartialMolarEntropies(doublereal* sbar) const { _updateThermo(); - int strt = 0; - for (int n = 0; n < m_nlattice; n++) { - int nlsp = m_lattice[n]->nSpecies(); + size_t strt = 0; + for (size_t n = 0; n < m_nlattice; n++) { + size_t nlsp = m_lattice[n]->nSpecies(); m_lattice[n]->getPartialMolarEntropies(sbar + strt); strt += nlsp; } @@ -408,9 +408,9 @@ void LatticeSolidPhase::getPartialMolarEntropies(doublereal* sbar) const void LatticeSolidPhase::getPartialMolarCp(doublereal* cpbar) const { _updateThermo(); - int strt = 0; - for (int n = 0; n < m_nlattice; n++) { - int nlsp = m_lattice[n]->nSpecies(); + size_t strt = 0; + for (size_t n = 0; n < m_nlattice; n++) { + size_t nlsp = m_lattice[n]->nSpecies(); m_lattice[n]->getPartialMolarCp(cpbar + strt); strt += nlsp; } @@ -419,9 +419,9 @@ void LatticeSolidPhase::getPartialMolarCp(doublereal* cpbar) const void LatticeSolidPhase::getPartialMolarVolumes(doublereal* vbar) const { _updateThermo(); - int strt = 0; - for (int n = 0; n < m_nlattice; n++) { - int nlsp = m_lattice[n]->nSpecies(); + size_t strt = 0; + for (size_t n = 0; n < m_nlattice; n++) { + size_t nlsp = m_lattice[n]->nSpecies(); m_lattice[n]->getPartialMolarVolumes(vbar + strt); strt += nlsp; } @@ -453,7 +453,7 @@ void LatticeSolidPhase::getStandardChemPotentials(doublereal* mu0) const void LatticeSolidPhase::getGibbs_RT_ref(doublereal* grt) const { _updateThermo(); - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]); } } @@ -461,7 +461,7 @@ void LatticeSolidPhase::getGibbs_RT_ref(doublereal* grt) const void LatticeSolidPhase::getGibbs_ref(doublereal* g) const { getGibbs_RT_ref(g); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { g[k] *= GasConstant * temperature(); } } @@ -474,9 +474,8 @@ void LatticeSolidPhase::getGibbs_ref(doublereal* g) const */ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) { - int m, k; - int kk = 0; - int kstart = 0; + size_t kk = 0; + size_t kstart = 0; SpeciesThermoFactory* spFactory = SpeciesThermoFactory::factory(); SpeciesThermo* spthermo_ptr = new GeneralSpeciesThermo(); setSpeciesThermo(spthermo_ptr); @@ -486,17 +485,17 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) XML_Node& la = eosdata.child("LatticeArray"); std::vector lattices; la.getChildren("phase",lattices); - for (int n = 0; n < m_nlattice; n++) { + for (size_t n = 0; n < m_nlattice; n++) { LatticePhase* lp = m_lattice[n]; XML_Node* phaseNode_ptr = lattices[n]; - int nsp = lp->nSpecies(); + size_t nsp = lp->nSpecies(); vector constArr(lp->nElements()); const vector_fp& aws = lp->atomicWeights(); - for (int es = 0; es < lp->nElements(); es++) { + for (size_t es = 0; es < lp->nElements(); es++) { string esName = lp->elementName(es); double wt = aws[es]; int an = lp->atomicNumber(es); - int e298 = lp->entropyElement298(es); + int e298 = lp->entropyElement298(es); //! @todo Why is this an int instead of a double? int et = lp->elementType(es); addUniqueElementAfterFreeze(esName, wt, an, e298, et); } @@ -504,13 +503,13 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) kstart = kk; - for (k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { std::string sname = lp->speciesName(k); std::map comp; lp->getAtoms(k, DATA_PTR(constArr)); - int nel = nElements(); + size_t nel = nElements(); vector_fp ecomp(nel, 0.0); - for (m = 0; m < lp->nElements(); m++) { + for (size_t m = 0; m < lp->nElements(); m++) { if (constArr[m] != 0.0) { std::string oldEname = lp->elementName(m); int newIndex = elementIndex(oldEname); @@ -538,12 +537,12 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) int m = addUniqueElementAfterFreeze(econ, 0.0, 0, 0.0, CT_ELEM_TYPE_LATTICERATIO); m_mm = nElements(); LatticePhase* lp0 = m_lattice[0]; - int nsp0 = lp0->nSpecies(); - for (k = 0; k < nsp0; k++) { + size_t nsp0 = lp0->nSpecies(); + for (size_t k = 0; k < nsp0; k++) { m_speciesComp[k * m_mm + m] = -theta_[0]; } - for (k = 0; k < nsp; k++) { - int ks = kstart + k; + for (size_t k = 0; k < nsp; k++) { + size_t ks = kstart + k; m_speciesComp[ks * m_mm + m] = theta_[n]; } } @@ -622,10 +621,10 @@ void LatticeSolidPhase::_updateThermo() const void LatticeSolidPhase::setLatticeMoleFractionsByName(int nn, std::string x) { m_lattice[nn]->setMoleFractionsByName(x); - int loc=0, nsp; + size_t loc = 0; doublereal ndens; for (size_t n = 0; n < m_nlattice; n++) { - nsp = m_lattice[n]->nSpecies(); + size_t nsp = m_lattice[n]->nSpecies(); ndens = m_lattice[n]->molarDensity(); for (size_t k = 0; k < nsp; k++) { m_x[loc] = ndens * m_lattice[n]->moleFraction(k); @@ -663,7 +662,7 @@ void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata) for (int i = 0; i < np; i++) { double val = fpValueCheck(pval[i]); bool found = false; - for (int j = 0; j < nl; j++) { + for (size_t j = 0; j < nl; j++) { ThermoPhase& tp = *(m_lattice[j]); string idj = tp.id(); if (idj == pnam[i]) { diff --git a/src/thermo/MargulesVPSSTP.cpp b/src/thermo/MargulesVPSSTP.cpp index d00483f63..b1f841b59 100644 --- a/src/thermo/MargulesVPSSTP.cpp +++ b/src/thermo/MargulesVPSSTP.cpp @@ -513,13 +513,13 @@ void MargulesVPSSTP::getPartialMolarCp(doublereal* cpbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -803,7 +803,7 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dT() const void MargulesVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k]; } } @@ -834,7 +834,7 @@ void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* size_t iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1, dXA, dXB; + double XA, XB, g0 , g1, dXA, dXB; double T = temperature(); double RT = GasConstant*T; @@ -842,8 +842,6 @@ void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* s_update_dlnActCoeff_dT(); for (iK = 0; iK < m_kk; iK++) { - - XK = moleFractions_[iK]; dlnActCoeffds[iK] = 0.0; for (size_t i = 0; i < numBinaryInteractions_; i++) { @@ -950,7 +948,7 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dlnN() const { size_t iA, iB; doublereal delAK, delBK; - double XA, XB, g0 , g1, XK,XM; + double XA, XB, g0, g1,XM; double T = temperature(); double RT = GasConstant*T; @@ -961,11 +959,10 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dlnN() const /* * Loop over the activity coefficient gamma_k */ - for (int iK = 0; iK < m_kk; iK++) { - XK = moleFractions_[iK]; - for (int iM = 0; iM < m_kk; iM++) { + for (size_t iK = 0; iK < m_kk; iK++) { + for (size_t iM = 0; iM < m_kk; iM++) { XM = moleFractions_[iM]; - 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]; @@ -1017,26 +1014,19 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dlnN() const //==================================================================================================================== void MargulesVPSSTP::s_update_dlnActCoeff_dlnX_diag() const { - - int iA, iB; - doublereal XA, XB, g0 , g1; doublereal T = temperature(); - dlnActCoeffdlnX_diag_.assign(m_kk, 0.0); - doublereal RT = GasConstant * T; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; - for (int i = 0; i < numBinaryInteractions_; i++) { + doublereal XA = moleFractions_[iA]; + doublereal XB = moleFractions_[iB]; - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; - - XA = moleFractions_[iA]; - XB = moleFractions_[iB]; - - g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT; - g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT; + doublereal g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT; + doublereal g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT; dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB); dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB); @@ -1047,7 +1037,7 @@ void MargulesVPSSTP::s_update_dlnActCoeff_dlnX_diag() const void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const { s_update_dlnActCoeff_dlnN_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k]; } } @@ -1055,7 +1045,7 @@ void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) c void MargulesVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const { s_update_dlnActCoeff_dlnX_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k]; } } @@ -1064,8 +1054,8 @@ void MargulesVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdln { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); - for (int k = 0; k < m_kk; k++) { - for (int m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m]; } } diff --git a/src/thermo/MixedSolventElectrolyte.cpp b/src/thermo/MixedSolventElectrolyte.cpp index be81adeb4..f40f5c64d 100644 --- a/src/thermo/MixedSolventElectrolyte.cpp +++ b/src/thermo/MixedSolventElectrolyte.cpp @@ -360,7 +360,7 @@ void MixedSolventElectrolyte::getActivityCoefficients(doublereal* ac) const /* * take the exp of the internally storred coefficients. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { ac[k] = exp(lnActCoeff_Scaled_[k]); } } @@ -375,7 +375,7 @@ void MixedSolventElectrolyte::getElectrochemPotentials(doublereal* mu) const { getChemPotentials(mu); double ve = Faraday * electricPotential(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { mu[k] += ve*charge(k); } } @@ -399,7 +399,7 @@ void MixedSolventElectrolyte::getChemPotentials(doublereal* mu) const * */ doublereal RT = GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); mu[k] += RT * (log(xx) + lnActCoeff_Scaled_[k]); } @@ -408,11 +408,11 @@ void MixedSolventElectrolyte::getChemPotentials(doublereal* mu) const /// Molar enthalpy. Units: J/kmol. doublereal MixedSolventElectrolyte::enthalpy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double h = 0; vector_fp hbar(kk); getPartialMolarEnthalpies(&hbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { h += moleFractions_[i]*hbar[i]; } return h; @@ -421,11 +421,11 @@ doublereal MixedSolventElectrolyte::enthalpy_mole() const /// Molar entropy. Units: J/kmol. doublereal MixedSolventElectrolyte::entropy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double s = 0; vector_fp sbar(kk); getPartialMolarEntropies(&sbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { s += moleFractions_[i]*sbar[i]; } return s; @@ -434,11 +434,11 @@ doublereal MixedSolventElectrolyte::entropy_mole() const /// Molar heat capacity at constant pressure. Units: J/kmol/K. doublereal MixedSolventElectrolyte::cp_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double cp = 0; vector_fp cpbar(kk); getPartialMolarCp(&cpbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { cp += moleFractions_[i]*cpbar[i]; } return cp; @@ -475,7 +475,7 @@ void MixedSolventElectrolyte::getPartialMolarEnthalpies(doublereal* hbar) const */ double T = temperature(); double RT = GasConstant * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] *= RT; } /* @@ -485,7 +485,7 @@ void MixedSolventElectrolyte::getPartialMolarEnthalpies(doublereal* hbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); double RTT = RT * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] -= RTT * dlnActCoeffdT_Scaled_[k]; } } @@ -518,13 +518,13 @@ void MixedSolventElectrolyte::getPartialMolarCp(doublereal* cpbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -558,14 +558,14 @@ void MixedSolventElectrolyte::getPartialMolarEntropies(doublereal* sbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sbar[k] *= GasConstant; } } @@ -586,9 +586,8 @@ void MixedSolventElectrolyte::getPartialMolarEntropies(doublereal* sbar) const */ void MixedSolventElectrolyte::getPartialMolarVolumes(doublereal* vbar) const { - - int iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1; + int delAK, delBK; + double XA, XB, g0 , g1; double T = temperature(); /* @@ -596,15 +595,12 @@ void MixedSolventElectrolyte::getPartialMolarVolumes(doublereal* vbar) const */ getStandardVolumes(vbar); - - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { delAK = 0; delBK = 0; - XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; if (iA==iK) { delAK = 1; @@ -746,16 +742,15 @@ void MixedSolventElectrolyte::initThermoXML(XML_Node& phaseNode, std::string id) */ void MixedSolventElectrolyte::s_update_lnActCoeff() const { - int iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1; + int delAK, delBK; + double XA, XB, g0, g1; double T = temperature(); double RT = GasConstant*T; lnActCoeff_Scaled_.assign(m_kk, 0.0); - for (iK = 0; iK < m_kk; iK++) { - XK = moleFractions_[iK]; - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t iK = 0; iK < m_kk; iK++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; if (iA==iK) { @@ -781,16 +776,16 @@ void MixedSolventElectrolyte::s_update_lnActCoeff() const */ void MixedSolventElectrolyte::s_update_dlnActCoeff_dT() const { - int iA, iB, iK, delAK, delBK; + int delAK, delBK; doublereal XA, XB, g0, g1; doublereal T = temperature(); doublereal RTT = GasConstant*T*T; dlnActCoeffdT_Scaled_.assign(m_kk, 0.0); d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0); - for (iK = 0; iK < m_kk; iK++) { - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t iK = 0; iK < m_kk; iK++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; if (iA==iK) { @@ -812,7 +807,7 @@ void MixedSolventElectrolyte::s_update_dlnActCoeff_dT() const void MixedSolventElectrolyte::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k]; } } @@ -820,7 +815,7 @@ void MixedSolventElectrolyte::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const void MixedSolventElectrolyte::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k]; } } @@ -840,25 +835,20 @@ void MixedSolventElectrolyte::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) co void MixedSolventElectrolyte::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const { - - - int iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1, dXA, dXB; + int delAK, delBK; + double XA, XB, g0, g1, dXA, dXB; double T = temperature(); double RT = GasConstant*T; //fvo_zero_dbl_1(dlnActCoeff, m_kk); s_update_dlnActCoeff_dT(); - for (iK = 0; iK < m_kk; iK++) { - - XK = moleFractions_[iK]; + for (size_t iK = 0; iK < m_kk; iK++) { dlnActCoeffds[iK] = 0.0; + for (size_t i = 0; i < numBinaryInteractions_; i++) { - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; @@ -894,21 +884,21 @@ void MixedSolventElectrolyte::getdlnActCoeffds(const doublereal dTds, const dou */ void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnN_diag() const { - int iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1; + int delAK, delBK; + double XA, XB, XK, g0, g1; double T = temperature(); double RT = GasConstant*T; dlnActCoeffdlnN_diag_.assign(m_kk, 0); - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { 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]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; @@ -957,27 +947,24 @@ void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnN_diag() const */ void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnN() const { - int iA, iB; doublereal delAK, delBK; - double XA, XB, g0 , g1, XK,XM; + double XA, XB, g0, g1,XM; double T = temperature(); double RT = GasConstant*T; doublereal delAM, delBM; - dlnActCoeffdlnN_.zero(); /* * Loop over the activity coefficient gamma_k */ - for (int iK = 0; iK < m_kk; iK++) { - XK = moleFractions_[iK]; - for (int iM = 0; iM < m_kk; iM++) { + for (size_t iK = 0; iK < m_kk; iK++) { + for (size_t iM = 0; iM < m_kk; iM++) { XM = moleFractions_[iM]; - 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]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0.0; delBK = 0.0; @@ -1026,20 +1013,16 @@ void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnN() const //==================================================================================================================== void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnX_diag() const { - - int iA, iB; doublereal XA, XB, g0 , g1; doublereal T = temperature(); dlnActCoeffdlnX_diag_.assign(m_kk, 0); - doublereal RT = GasConstant * T; + for (size_t i = 0; i < numBinaryInteractions_; i++) { - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; @@ -1056,7 +1039,7 @@ void MixedSolventElectrolyte::s_update_dlnActCoeff_dlnX_diag() const void MixedSolventElectrolyte::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const { s_update_dlnActCoeff_dlnN_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k]; } } @@ -1064,7 +1047,7 @@ void MixedSolventElectrolyte::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdln void MixedSolventElectrolyte::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const { s_update_dlnActCoeff_dlnX_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k]; } } @@ -1073,8 +1056,8 @@ void MixedSolventElectrolyte::getdlnActCoeffdlnN(const int ld, doublereal* dlnAc { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); - for (int k = 0; k < m_kk; k++) { - for (int m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m]; } } diff --git a/src/thermo/MixtureFugacityTP.cpp b/src/thermo/MixtureFugacityTP.cpp index 44ed21f5c..41d93b921 100644 --- a/src/thermo/MixtureFugacityTP.cpp +++ b/src/thermo/MixtureFugacityTP.cpp @@ -231,7 +231,7 @@ void MixtureFugacityTP::getChemPotentials_RT(doublereal* muRT) const { getChemPotentials(muRT); doublereal invRT = 1.0 / _RT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { muRT[k] *= invRT; } } @@ -245,7 +245,7 @@ void MixtureFugacityTP::getStandardChemPotentials(doublereal* g) const copy(m_g0_RT.begin(), m_g0_RT.end(), g); doublereal RT = _RT(); double tmp = log(pressure() /m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { g[k] = RT * (g[k] + tmp); } } @@ -281,7 +281,7 @@ void MixtureFugacityTP::getEntropy_R(doublereal* sr) const _updateReferenceStateThermo(); copy(m_s0_R.begin(), m_s0_R.end(), sr); double tmp = log(pressure() /m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sr[k] -= tmp; } } @@ -295,7 +295,7 @@ void MixtureFugacityTP::getGibbs_RT(doublereal* grt) const _updateReferenceStateThermo(); copy(m_g0_RT.begin(), m_g0_RT.end(), grt); double tmp = log(pressure() /m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { grt[k] += tmp; } } @@ -311,7 +311,7 @@ void MixtureFugacityTP::getPureGibbs(doublereal* g) const scale(m_g0_RT.begin(), m_g0_RT.end(), g, _RT()); double tmp = log(pressure() /m_spthermo->refPressure()); tmp *= _RT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { g[k] += tmp; } } @@ -328,7 +328,7 @@ void MixtureFugacityTP::getIntEnergy_RT(doublereal* urt) const doublereal p = pressure(); doublereal tmp = p / _RT(); doublereal v0 = _RT() / p; - for (int i = 0; i < m_kk; i++) { + for (size_t i = 0; i < m_kk; i++) { urt[i] -= tmp * v0; } } @@ -356,7 +356,7 @@ void MixtureFugacityTP::getStandardVolumes(doublereal* vol) const { _updateReferenceStateThermo(); doublereal v0 = _RT() / pressure(); - for (int i = 0; i < m_kk; i++) { + for (size_t i = 0; i < m_kk; i++) { vol[i]= v0; } } @@ -443,7 +443,7 @@ void MixtureFugacityTP::getStandardVolumes_ref(doublereal* vol) const _updateReferenceStateThermo(); double pp = refPressure(); doublereal v0 = _RT() / pp; - for (int i = 0; i < m_kk; i++) { + for (size_t i = 0; i < m_kk; i++) { vol[i]= v0; } } @@ -1165,7 +1165,6 @@ doublereal MixtureFugacityTP::calculatePsat(doublereal TKelvin, doublereal& mola double tempSave = temperature(); double pres; doublereal mw = meanMolecularWeight(); - bool conv = false; if (TKelvin < tcrit) { pres = psatEst(TKelvin); @@ -1341,7 +1340,7 @@ startIteration: if (fabs(delGRT) < 1.0E-8) { - conv = true; + // converged break; } } @@ -1406,8 +1405,7 @@ void MixtureFugacityTP::_updateReferenceStateThermo() const m_Tlast_ref = Tnow; // update the species Gibbs functions - int k; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k]; } doublereal pref = refPressure(); diff --git a/src/thermo/MolarityIonicVPSSTP.cpp b/src/thermo/MolarityIonicVPSSTP.cpp index b3bddf66f..443b6eb9f 100644 --- a/src/thermo/MolarityIonicVPSSTP.cpp +++ b/src/thermo/MolarityIonicVPSSTP.cpp @@ -308,7 +308,7 @@ void MolarityIonicVPSSTP::getLnActivityCoefficients(doublereal* lnac) const /* * take the exp of the internally storred coefficients. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { lnac[k] = lnActCoeff_Scaled_[k]; } } @@ -331,7 +331,7 @@ void MolarityIonicVPSSTP::getChemPotentials(doublereal* mu) const * */ doublereal RT = GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); mu[k] += RT * (log(xx) + lnActCoeff_Scaled_[k]); } @@ -342,7 +342,7 @@ void MolarityIonicVPSSTP::getElectrochemPotentials(doublereal* mu) const { getChemPotentials(mu); double ve = Faraday * electricPotential(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { mu[k] += ve*charge(k); } } @@ -373,7 +373,7 @@ void MolarityIonicVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const */ double T = temperature(); double RT = GasConstant * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] *= RT; } /* @@ -383,7 +383,7 @@ void MolarityIonicVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); double RTT = RT * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] -= RTT * dlnActCoeffdT_Scaled_[k]; } } @@ -416,13 +416,13 @@ void MolarityIonicVPSSTP::getPartialMolarCp(doublereal* cpbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -456,14 +456,14 @@ void MolarityIonicVPSSTP::getPartialMolarEntropies(doublereal* sbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sbar[k] *= GasConstant; } } @@ -479,22 +479,20 @@ void MolarityIonicVPSSTP::getPartialMolarEntropies(doublereal* sbar) const */ void MolarityIonicVPSSTP::getPartialMolarVolumes(doublereal* vbar) const { - int iK; /* * Get the standard state values in m^3 kmol-1 */ getStandardVolumes(vbar); - for (iK = 0; iK < m_kk; iK++) { - + for (size_t iK = 0; iK < m_kk; iK++) { vbar[iK] += 0.0; } } //==================================================================================================================== void MolarityIonicVPSSTP::calcPseudoBinaryMoleFractions() const { - int k; - int kCat; - int kMax; + size_t k; + size_t kCat; + size_t kMax; doublereal sumCat; doublereal sumAnion; doublereal chP, chM; @@ -514,7 +512,7 @@ void MolarityIonicVPSSTP::calcPseudoBinaryMoleFractions() const } kMax = -1; sumMax = 0.0; - for (k = 0; k < (int) cationList_.size(); k++) { + for (k = 0; k < cationList_.size(); k++) { kCat = cationList_[k]; chP = m_speciesCharge[kCat]; if (moleFractions_[kCat] > sumMax) { @@ -580,8 +578,7 @@ void MolarityIonicVPSSTP::calcPseudoBinaryMoleFractions() const */ void MolarityIonicVPSSTP::s_update_lnActCoeff() const { - int k; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { lnActCoeff_Scaled_[k] = 0.0; } } @@ -642,7 +639,7 @@ void MolarityIonicVPSSTP::initThermo() cationList_.clear(); anionList_.clear(); passThroughList_.clear(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { ch = m_speciesCharge[k]; if (ch > 0.0) { cationList_.push_back(k); diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index e0d8eb6d4..a33524ed4 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -165,14 +165,14 @@ void Phase::setIndex(size_t m) * @return Returns the index of the species. If the name is not found, * the value of -1 is returned. */ -int Phase::speciesIndex(std::string nameStr) const +size_t Phase::speciesIndex(std::string nameStr) const { std::string pn; std::string sn = parseSpeciesName(nameStr, pn); if (pn == "" || pn == m_name || pn == m_id) { return Constituents::speciesIndex(sn); } - return -1; + return npos; } std::string Phase::speciesSPName(int k) const diff --git a/src/thermo/PhaseCombo_Interaction.cpp b/src/thermo/PhaseCombo_Interaction.cpp index 0a810a7f3..7f9bf3984 100644 --- a/src/thermo/PhaseCombo_Interaction.cpp +++ b/src/thermo/PhaseCombo_Interaction.cpp @@ -372,7 +372,7 @@ void PhaseCombo_Interaction::getActivityCoefficients(doublereal* ac) const /* * take the exp of the internally storred coefficients. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { ac[k] = exp(lnActCoeff_Scaled_[k]); } } @@ -387,7 +387,7 @@ void PhaseCombo_Interaction::getElectrochemPotentials(doublereal* mu) const { getChemPotentials(mu); double ve = Faraday * electricPotential(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { mu[k] += ve*charge(k); } } @@ -411,7 +411,7 @@ void PhaseCombo_Interaction::getChemPotentials(doublereal* mu) const * */ doublereal RT = GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); mu[k] += RT * (log(xx) + lnActCoeff_Scaled_[k]); } @@ -420,11 +420,11 @@ void PhaseCombo_Interaction::getChemPotentials(doublereal* mu) const // Molar enthalpy. Units: J/kmol. doublereal PhaseCombo_Interaction::enthalpy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double h = 0; vector_fp hbar(kk); getPartialMolarEnthalpies(&hbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { h += moleFractions_[i]*hbar[i]; } return h; @@ -433,11 +433,11 @@ doublereal PhaseCombo_Interaction::enthalpy_mole() const // Molar entropy. Units: J/kmol. doublereal PhaseCombo_Interaction::entropy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double s = 0; vector_fp sbar(kk); getPartialMolarEntropies(&sbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { s += moleFractions_[i]*sbar[i]; } return s; @@ -446,11 +446,11 @@ doublereal PhaseCombo_Interaction::entropy_mole() const // Molar heat capacity at constant pressure. Units: J/kmol/K. doublereal PhaseCombo_Interaction::cp_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double cp = 0; vector_fp cpbar(kk); getPartialMolarCp(&cpbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { cp += moleFractions_[i]*cpbar[i]; } return cp; @@ -487,7 +487,7 @@ void PhaseCombo_Interaction::getPartialMolarEnthalpies(doublereal* hbar) const */ double T = temperature(); double RT = GasConstant * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] *= RT; } /* @@ -497,7 +497,7 @@ void PhaseCombo_Interaction::getPartialMolarEnthalpies(doublereal* hbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); double RTT = RT * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] -= RTT * dlnActCoeffdT_Scaled_[k]; } } @@ -529,13 +529,13 @@ void PhaseCombo_Interaction::getPartialMolarCp(doublereal* cpbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -569,14 +569,14 @@ void PhaseCombo_Interaction::getPartialMolarEntropies(doublereal* sbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); sbar[k] += - lnActCoeff_Scaled_[k] - log(xx) - T * dlnActCoeffdT_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sbar[k] *= GasConstant; } } @@ -596,9 +596,8 @@ void PhaseCombo_Interaction::getPartialMolarEntropies(doublereal* sbar) const */ void PhaseCombo_Interaction::getPartialMolarVolumes(doublereal* vbar) const { - - int iA, iB, iK, delAK, delBK; - double XA, XB, XK, g0 , g1; + int delAK, delBK; + double XA, XB, g0, g1; double T = temperature(); /* @@ -606,14 +605,13 @@ void PhaseCombo_Interaction::getPartialMolarVolumes(doublereal* vbar) const */ getStandardVolumes(vbar); - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { 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]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; if (iA==iK) { delAK = 1; @@ -755,14 +753,14 @@ void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, std::string id) */ void PhaseCombo_Interaction::s_update_lnActCoeff() const { - int iA, iB, iK, delAK, delBK; + int delAK, delBK; doublereal XA, XB, g0 , g1; doublereal xx; doublereal T = temperature(); doublereal RT = GasConstant*T; lnActCoeff_Scaled_.assign(m_kk, 0.0); - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { /* * We never sample the end of the mole fraction domains */ @@ -775,9 +773,9 @@ void PhaseCombo_Interaction::s_update_lnActCoeff() const /* * Then add in the Margules interaction terms. that's it! */ - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; if (iA==iK) { @@ -805,16 +803,16 @@ void PhaseCombo_Interaction::s_update_lnActCoeff() const */ void PhaseCombo_Interaction::s_update_dlnActCoeff_dT() const { - int iA, iB, iK, delAK, delBK; + int delAK, delBK; doublereal XA, XB, g0, g1; doublereal T = temperature(); doublereal RTT = GasConstant*T*T; dlnActCoeffdT_Scaled_.assign(m_kk, 0.0); d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0); - for (iK = 0; iK < m_kk; iK++) { - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t iK = 0; iK < m_kk; iK++) { + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; if (iA==iK) { @@ -840,7 +838,7 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dT() const void PhaseCombo_Interaction::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k]; } } @@ -852,7 +850,7 @@ void PhaseCombo_Interaction::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const void PhaseCombo_Interaction::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k]; } } @@ -874,10 +872,8 @@ void PhaseCombo_Interaction::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) con void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const { - - - int iA, iB, iK, delAK, delBK; - doublereal XA, XB, XK, g0 , g1, dXA, dXB; + int delAK, delBK; + doublereal XA, XB, g0 , g1, dXA, dXB; doublereal T = temperature(); doublereal RT = GasConstant*T; doublereal xx; @@ -885,10 +881,7 @@ void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doub //fvo_zero_dbl_1(dlnActCoeff, m_kk); s_update_dlnActCoeff_dT(); - for (iK = 0; iK < m_kk; iK++) { - - XK = moleFractions_[iK]; - + for (size_t iK = 0; iK < m_kk; iK++) { /* * We never sample the end of the mole fraction domains */ @@ -900,10 +893,9 @@ void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doub dlnActCoeffds[iK] += - 1.0 / xx; } - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; @@ -943,7 +935,7 @@ void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doub */ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN_diag() const { - int iA, iB, iK, delAK, delBK; + int delAK, delBK; doublereal XA, XB, XK, g0 , g1; doublereal T = temperature(); doublereal RT = GasConstant*T; @@ -951,7 +943,7 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN_diag() const dlnActCoeffdlnN_diag_.assign(m_kk, 0.0); - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { XK = moleFractions_[iK]; /* @@ -966,10 +958,9 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN_diag() const dlnActCoeffdlnN_diag_[iK] = - 1.0 + xx; } - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0; delBK = 0; @@ -1003,9 +994,8 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN_diag() const */ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN() const { - int iA, iB; doublereal delAK, delBK; - double XA, XB, g0 , g1, XK, XM; + double XA, XB, g0, g1, XM; double xx , delKM; double T = temperature(); double RT = GasConstant*T; @@ -1017,14 +1007,13 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN() const /* * Loop over the activity coefficient gamma_k */ - for (int iK = 0; iK < m_kk; iK++) { - XK = moleFractions_[iK]; + for (size_t iK = 0; iK < m_kk; iK++) { /* * We never sample the end of the mole fraction domains */ xx = fmaxx(moleFractions_[iK], xxSmall); - for (int iM = 0; iM < m_kk; iM++) { + for (size_t iM = 0; iM < m_kk; iM++) { XM = moleFractions_[iM]; if (xx > xxSmall) { @@ -1036,11 +1025,9 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN() const dlnActCoeffdlnN_(iK,iM) += - delKM/XM + 1.0; } - - for (int i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; delAK = 0.0; delBK = 0.0; @@ -1084,7 +1071,7 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag() const 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]; @@ -1109,7 +1096,7 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag() const void PhaseCombo_Interaction::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const { s_update_dlnActCoeff_dlnN_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k]; } } @@ -1121,7 +1108,7 @@ void PhaseCombo_Interaction::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN void PhaseCombo_Interaction::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const { s_update_dlnActCoeff_dlnX_diag(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k]; } } @@ -1134,8 +1121,8 @@ void PhaseCombo_Interaction::getdlnActCoeffdlnN(const int ld, doublereal* dlnAct { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); - for (int k = 0; k < m_kk; k++) { - for (int m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m]; } } diff --git a/src/thermo/RedlichKisterVPSSTP.cpp b/src/thermo/RedlichKisterVPSSTP.cpp index 47eb22494..7353775df 100644 --- a/src/thermo/RedlichKisterVPSSTP.cpp +++ b/src/thermo/RedlichKisterVPSSTP.cpp @@ -364,7 +364,7 @@ void RedlichKisterVPSSTP::getLnActivityCoefficients(doublereal* lnac) const /* * take the exp of the internally storred coefficients. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { lnac[k] = lnActCoeff_Scaled_[k]; } } @@ -377,7 +377,7 @@ void RedlichKisterVPSSTP::getElectrochemPotentials(doublereal* mu) const { getChemPotentials(mu); double ve = Faraday * electricPotential(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { mu[k] += ve*charge(k); } } @@ -400,7 +400,7 @@ void RedlichKisterVPSSTP::getChemPotentials(doublereal* mu) const * */ doublereal RT = GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); mu[k] += RT * (log(xx) + lnActCoeff_Scaled_[k]); } @@ -476,7 +476,7 @@ void RedlichKisterVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const */ double T = temperature(); double RT = GasConstant * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] *= RT; } /* @@ -486,7 +486,7 @@ void RedlichKisterVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); double RTT = RT * T; - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { hbar[k] -= RTT * dlnActCoeffdT_Scaled_[k]; } } @@ -519,13 +519,13 @@ void RedlichKisterVPSSTP::getPartialMolarCp(doublereal* cpbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { cpbar[k] *= GasConstant; } } @@ -559,14 +559,14 @@ void RedlichKisterVPSSTP::getPartialMolarEntropies(doublereal* sbar) const s_update_lnActCoeff(); s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { xx = fmaxx(moleFractions_[k], xxSmall); sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k]; } /* * dimensionalize it. */ - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { sbar[k] *= GasConstant; } } @@ -587,12 +587,11 @@ void RedlichKisterVPSSTP::getPartialMolarEntropies(doublereal* sbar) const */ void RedlichKisterVPSSTP::getPartialMolarVolumes(doublereal* vbar) const { - int iK; /* * Get the standard state values in m^3 kmol-1 */ getStandardVolumes(vbar); - for (iK = 0; iK < m_kk; iK++) { + for (size_t iK = 0; iK < m_kk; iK++) { vbar[iK] += 0.0; } @@ -708,7 +707,6 @@ void RedlichKisterVPSSTP::initThermoXML(XML_Node& phaseNode, std::string id) */ void RedlichKisterVPSSTP::s_update_lnActCoeff() const { - int iA, iB, m, k; doublereal XA, XB; doublereal T = temperature(); doublereal RT = GasConstant * T; @@ -721,9 +719,9 @@ void RedlichKisterVPSSTP::s_update_lnActCoeff() const * dimensionless terms help. */ - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; doublereal deltaX = XA - XB; @@ -735,7 +733,7 @@ void RedlichKisterVPSSTP::s_update_lnActCoeff() const doublereal sum = 0.0; doublereal sumMm1 = 0.0; doublereal sum2 = 0.0; - for (m = 0; m < N; m++) { + for (int m = 0; m < N; m++) { doublereal A_ge = (he_vec[m] - T * se_vec[m]) / RT; sum += A_ge * poly; sum2 += A_ge * (m + 1) * poly; @@ -747,7 +745,7 @@ void RedlichKisterVPSSTP::s_update_lnActCoeff() const } doublereal oneMXA = 1.0 - XA; doublereal oneMXB = 1.0 - XB; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (iA == k) { lnActCoeff_Scaled_[k] += (oneMXA * XB * sum) + (XA * XB * sumMm1 * (oneMXA + XB)); } else if (iB == k) { @@ -762,7 +760,7 @@ void RedlichKisterVPSSTP::s_update_lnActCoeff() const double lnB = 0.0; double polyk = 1.0; double fac = 2.0 * XA - 1.0; - for (m = 0; m < N; m++) { + for (int m = 0; m < N; m++) { doublereal A_ge = (he_vec[m] - T * se_vec[m]) / RT; lnA += A_ge * oneMXA * oneMXA * polyk * (1.0 + 2.0 * XA * m / fac); lnB += A_ge * XA * XA * polyk * (1.0 - 2.0 * oneMXA * m / fac); @@ -787,16 +785,15 @@ void RedlichKisterVPSSTP::s_update_lnActCoeff() const */ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dT() const { - int iA, iB, m, k; doublereal XA, XB; // doublereal T = temperature(); dlnActCoeffdT_Scaled_.assign(m_kk, 0.0); d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0); - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; doublereal deltaX = XA - XB; @@ -808,7 +805,7 @@ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dT() const doublereal sumMm1 = 0.0; doublereal polyMm1 = 1.0; doublereal sum2 = 0.0; - for (m = 0; m < N; m++) { + for (int m = 0; m < N; m++) { doublereal A_ge = - se_vec[m]; sum += A_ge * poly; sum2 += A_ge * (m + 1) * poly; @@ -820,7 +817,7 @@ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dT() const } doublereal oneMXA = 1.0 - XA; doublereal oneMXB = 1.0 - XB; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (iA == k) { dlnActCoeffdT_Scaled_[k] += (oneMXA * XB * sum) + (XA * XB * sumMm1 * (oneMXA + XB)); } else if (iB == k) { @@ -835,7 +832,7 @@ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dT() const void RedlichKisterVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k]; } } @@ -843,24 +840,21 @@ void RedlichKisterVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const void RedlichKisterVPSSTP::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const { s_update_dlnActCoeff_dT(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k]; } } //==================================================================================================================== void RedlichKisterVPSSTP::s_update_dlnActCoeff_dX_() const { - - - int iA, iB, m, k; doublereal XA, XB; doublereal T = temperature(); dlnActCoeff_dX_.zero(); - for (int i = 0; i < numBinaryInteractions_; i++) { - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + for (size_t i = 0; i < numBinaryInteractions_; i++) { + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; doublereal deltaX = XA - XB; @@ -875,7 +869,7 @@ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dX_() const doublereal sum2 = 0.0; doublereal sum2Mm1 = 0.0; doublereal sumMm2 = 0.0; - for (m = 0; m < N; m++) { + for (int m = 0; m < N; m++) { doublereal A_ge = he_vec[m] - T * se_vec[m]; sum += A_ge * poly; sum2 += A_ge * (m + 1) * poly; @@ -891,7 +885,7 @@ void RedlichKisterVPSSTP::s_update_dlnActCoeff_dX_() const } } - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { if (iA == k) { dlnActCoeff_dX_(k, iA) += (- XB * sum + (1.0 - XA) * XB * sumMm1 @@ -938,9 +932,9 @@ void RedlichKisterVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublere { s_update_dlnActCoeff_dT(); s_update_dlnActCoeff_dX_(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffds[k] = dlnActCoeffdT_Scaled_[k] * dTds; - for (int l = 0; l < m_kk; l++) { + for (size_t l = 0; l < m_kk; l++) { dlnActCoeffds[k] += dlnActCoeff_dX_(k, l) * dXds[l]; } } @@ -950,9 +944,9 @@ void RedlichKisterVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublere void RedlichKisterVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const { s_update_dlnActCoeff_dX_(); - for (int l = 0; l < m_kk; l++) { + for (size_t l = 0; l < m_kk; l++) { dlnActCoeffdlnN_diag[l] = dlnActCoeff_dX_(l, l); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN_diag[k] -= dlnActCoeff_dX_(l, k) * moleFractions_[k]; } } @@ -961,7 +955,7 @@ void RedlichKisterVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_di void RedlichKisterVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const { s_update_dlnActCoeff_dX_(); - for (int k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k]; } } @@ -970,8 +964,8 @@ void RedlichKisterVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoe { s_update_dlnActCoeff_dX_(); double* data = & dlnActCoeffdlnN_(0,0); - for (int k = 0; k < m_kk; k++) { - for (int m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m]; } } diff --git a/src/thermo/RedlichKisterVPSSTP.h b/src/thermo/RedlichKisterVPSSTP.h index 5777e07a4..a06ffb996 100644 --- a/src/thermo/RedlichKisterVPSSTP.h +++ b/src/thermo/RedlichKisterVPSSTP.h @@ -878,7 +878,7 @@ private: protected: //! number of binary interaction expressions - int numBinaryInteractions_; + size_t numBinaryInteractions_; //! vector of species indices representing species A in the interaction /*! diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index ef062dbc5..18b06d570 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -1161,10 +1161,8 @@ bool ThermoPhase::getElementPotentials(doublereal* lambda) const */ void ThermoPhase::getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) { - - - for (int m = 0; m < m_kk; m++) { - for (int k = 0; k < m_kk; k++) { + for (size_t m = 0; m < m_kk; m++) { + for (size_t k = 0; k < m_kk; k++) { dlnActCoeffdlnN[ld * k + m] = 0.0; } } @@ -1173,8 +1171,6 @@ void ThermoPhase::getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeff //==================================================================================================================== void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dlnActCoeffdlnN) { - - int k, j; double deltaMoles_j = 0.0; double pres = pressure(); @@ -1195,7 +1191,7 @@ void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dl /* * Loop over the columns species to be deltad */ - for (j = 0; j < m_kk; j++) { + for (size_t j = 0; j < m_kk; j++) { /* * Calculate a value for the delta moles of species j * -> NOte Xmol_[] and Tmoles are always positive or zero @@ -1210,7 +1206,7 @@ void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dl * mole fractions based on this. */ v_totalMoles = TMoles_base + deltaMoles_j; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { Xmol[k] = Xmol_Base[k] * TMoles_base / v_totalMoles; } Xmol[j] = (moles_j_base + deltaMoles_j) / v_totalMoles; @@ -1226,7 +1222,7 @@ void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dl * Calculate the column of the matrix */ double* const lnActCoeffCol = dlnActCoeffdlnN + ld * j; - for (k = 0; k < m_kk; k++) { + for (size_t k = 0; k < m_kk; k++) { lnActCoeffCol[k] = (2*moles_j_base + deltaMoles_j) *(ActCoeff[k] - ActCoeff_Base[k]) / ((ActCoeff[k] + ActCoeff_Base[k]) * deltaMoles_j); } diff --git a/src/transport/LiquidTransport.cpp b/src/transport/LiquidTransport.cpp index d82ba4702..a4edf1a6e 100644 --- a/src/transport/LiquidTransport.cpp +++ b/src/transport/LiquidTransport.cpp @@ -221,19 +221,19 @@ LiquidTransport::~LiquidTransport() { //These are constructed in TransportFactory::newLTP - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { if (m_viscTempDep_Ns[k]) { delete m_viscTempDep_Ns[k]; } if (m_ionCondTempDep_Ns[k]) { delete m_ionCondTempDep_Ns[k]; } - for (int l = 0; l < m_nsp; l++) { + for (size_t l = 0; l < m_nsp; l++) { if (m_selfDiffTempDep_Ns[l][k]) { delete m_selfDiffTempDep_Ns[l][k]; } } - for (int l=0; l < m_nsp2; l++) { + for (size_t l=0; l < m_nsp2; l++) { if (m_mobRatTempDep_Ns[l][k]) { delete m_mobRatTempDep_Ns[l][k]; } @@ -253,7 +253,7 @@ LiquidTransport::~LiquidTransport() } } - for (int k = 0; k < m_nsp2; k++) { + for (size_t k = 0; k < m_nsp2; k++) { if (m_mobRatMixModel[k]) { delete m_mobRatMixModel[k]; } @@ -289,7 +289,6 @@ LiquidTransport::~LiquidTransport() bool LiquidTransport::initLiquid(LiquidTransportParams& tr) { - int k; // constant substance attributes m_thermo = tr.thermo; tr.thermo = 0; @@ -319,10 +318,10 @@ bool LiquidTransport::initLiquid(LiquidTransportParams& tr) m_selfDiffMixModel.resize(m_nsp); m_selfDiffSpecies.resize(m_nsp, m_nsp, 0.0); m_selfDiffMix.resize(m_nsp,0.0); - for (k=0; k < m_nsp; k++) { + for (size_t k=0; k < m_nsp; k++) { m_selfDiffTempDep_Ns[k].resize(m_nsp, 0); } - for (k=0; k < m_nsp2; k++) { + for (size_t k=0; k < m_nsp2; k++) { m_mobRatTempDep_Ns[k].resize(m_nsp, 0); } m_lambdaSpecies.resize(m_nsp, 0.0); @@ -331,27 +330,27 @@ bool LiquidTransport::initLiquid(LiquidTransportParams& tr) m_radiusTempDep_Ns.resize(m_nsp, 0); //first populate mixing rules and indices - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_selfDiffMixModel[k] = tr.selfDiffusion[k]; tr.selfDiffusion[k] = 0; } - for (k = 0; k < m_nsp2; k++) { + for (size_t k = 0; k < m_nsp2; k++) { m_mobRatMixModel[k] = tr.mobilityRatio[k]; tr.mobilityRatio[k] = 0; } //for each species, assign viscosity model and coefficients - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { Cantera::LiquidTransportData& ltd = tr.LTData[k]; m_viscTempDep_Ns[k] = ltd.viscosity; ltd.viscosity = 0; m_ionCondTempDep_Ns[k] = ltd.ionConductivity; ltd.ionConductivity = 0; - for (int j = 0; j < m_nsp2; j++) { + for (size_t j = 0; j < m_nsp2; j++) { m_mobRatTempDep_Ns[j][k] = ltd.mobilityRatio[j]; ltd.mobilityRatio[j] = 0; } - for (int j = 0; j < m_nsp; j++) { + for (size_t j = 0; j < m_nsp; j++) { m_selfDiffTempDep_Ns[j][k] = ltd.selfDiffusion[j]; ltd.selfDiffusion[j] = 0; } @@ -371,7 +370,7 @@ bool LiquidTransport::initLiquid(LiquidTransportParams& tr) */ m_diffTempDep_Ns.resize(m_nsp, 0); //for each species, assign viscosity model and coefficients - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { Cantera::LiquidTransportData& ltd = tr.LTData[k]; if (ltd.speciesDiffusivity != 0) { cout << "Warning: diffusion coefficient data for " @@ -425,7 +424,7 @@ bool LiquidTransport::initLiquid(LiquidTransportParams& tr) m_concentrations.resize(m_nsp, 0.0); m_actCoeff.resize(m_nsp, 0.0); m_chargeSpecies.resize(m_nsp, 0.0); - for (int i = 0; i < m_nsp; i++) { + for (size_t i = 0; i < m_nsp; i++) { m_chargeSpecies[i] = m_thermo->charge(i); } m_volume_spec.resize(m_nsp, 0.0); @@ -581,7 +580,7 @@ void LiquidTransport:: mobilityRatio(doublereal* mobRat) // LiquidTranInteraction method if (!m_mobRat_mix_ok) { - for (int k = 0; k < m_nsp2; k++) { + for (size_t k = 0; k < m_nsp2; k++) { if (m_mobRatMixModel[k]) { m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp(m_mobRatTempDep_Ns[k]); if (m_mobRatMix[k] > 0.0) { @@ -590,7 +589,7 @@ void LiquidTransport:: mobilityRatio(doublereal* mobRat) } } } - for (int k = 0; k < m_nsp2; k++) { + for (size_t k = 0; k < m_nsp2; k++) { mobRat[k] = m_mobRatMix[k]; } } @@ -648,11 +647,11 @@ void LiquidTransport::selfDiffusion(doublereal* const selfDiff) update_T(); update_C(); if (!m_selfDiff_mix_ok) { - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffTempDep_Ns[k]); } } - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { selfDiff[k] = m_selfDiffMix[k]; } } @@ -672,8 +671,8 @@ void LiquidTransport::getSpeciesSelfDiffusion(doublereal** selfDiff) if (!m_selfDiff_temp_ok) { updateSelfDiffusion_T(); } - for (int k=0; kgetSpeciesTransProp() ; } m_lambda_temp_ok = true; @@ -1419,7 +1415,6 @@ void LiquidTransport::updateCond_T() // wrt T using calls to the appropriate LTPspecies subclass void LiquidTransport::updateDiff_T() { - m_diffMixModel->getMatrixTransProp(m_bdiff); m_diff_temp_ok = true; m_diff_mix_ok = false; @@ -1448,9 +1443,7 @@ void LiquidTransport::updateViscosities_C() */ void LiquidTransport::updateViscosity_T() { - int k; - - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_viscSpecies[k] = m_viscTempDep_Ns[k]->getSpeciesTransProp() ; } m_visc_temp_ok = true; @@ -1472,9 +1465,7 @@ void LiquidTransport::updateIonConductivity_C() */ void LiquidTransport::updateIonConductivity_T() { - int k; - - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_ionCondSpecies[k] = m_ionCondTempDep_Ns[k]->getSpeciesTransProp() ; } m_ionCond_temp_ok = true; @@ -1495,11 +1486,8 @@ void LiquidTransport::updateMobilityRatio_C() */ void LiquidTransport::updateMobilityRatio_T() { - int k; - int j; - - for (k = 0; k < m_nsp2; k++) { - for (j = 0; j < m_nsp; j++) { + for (size_t k = 0; k < m_nsp2; k++) { + for (size_t j = 0; j < m_nsp; j++) { m_mobRatSpecies(k,j) = m_mobRatTempDep_Ns[k][j]->getSpeciesTransProp(); } } @@ -1522,11 +1510,8 @@ void LiquidTransport::updateSelfDiffusion_C() */ void LiquidTransport::updateSelfDiffusion_T() { - int k; - int j; - - for (k = 0; k < m_nsp2; k++) { - for (j = 0; j < m_nsp; j++) { + for (size_t k = 0; k < m_nsp2; k++) { + for (size_t j = 0; j < m_nsp; j++) { m_selfDiffSpecies(k,j) = m_selfDiffTempDep_Ns[k][j]->getSpeciesTransProp() ; } } @@ -1544,9 +1529,7 @@ void LiquidTransport::updateHydrodynamicRadius_C() // appropriate LTPspecies subclass void LiquidTransport::updateHydrodynamicRadius_T() { - int k; - - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_hydrodynamic_radius[k] = m_radiusTempDep_Ns[k]->getSpeciesTransProp() ; } m_radi_temp_ok = true; @@ -1555,9 +1538,6 @@ void LiquidTransport::updateHydrodynamicRadius_T() void LiquidTransport::update_Grad_lnAC() { - - int k; - doublereal grad_T; vector_fp grad_lnAC(m_nsp), grad_X(m_nsp); // IonsFromNeutralVPSSTP * tempIons = dynamic_cast m_thermo; @@ -1565,11 +1545,11 @@ void LiquidTransport::update_Grad_lnAC() //m_thermo->getdlnActCoeffdlnX( DATA_PTR(grad_lnAC) ); - for (k = 0; k < m_nDim; k++) { + for (size_t k = 0; k < m_nDim; k++) { grad_T = m_Grad_T[k]; grad_X.assign(m_Grad_X.begin()+m_nsp*k,m_Grad_X.begin()+m_nsp*(k+1)); m_thermo->getdlnActCoeffds(grad_T, DATA_PTR(grad_X), DATA_PTR(grad_lnAC)); - for (int i = 0; i < m_nsp; i++) + for (size_t i = 0; i < m_nsp; i++) if (m_molefracs[i] < 1.e-15) { grad_lnAC[i] = 0; } else { @@ -1709,9 +1689,9 @@ void LiquidTransport::stefan_maxwell_solve() } else if (m_velocityBasis == VB_MASSAVG) { m_A(0,j) = m_massfracs_tran[j]; } else if ((m_velocityBasis >= 0) - && (m_velocityBasis < m_nsp)) + && (m_velocityBasis < static_cast(m_nsp))) // use species number m_velocityBasis as reference velocity - if (m_velocityBasis == j) { + if (m_velocityBasis == static_cast(j)) { m_A(0,j) = 1.0; } else { m_A(0,j) = 0.0; @@ -1772,9 +1752,9 @@ void LiquidTransport::stefan_maxwell_solve() } else if (m_velocityBasis == VB_MASSAVG) { m_A(0,j) = m_massfracs_tran[j]; } else if ((m_velocityBasis >= 0) - && (m_velocityBasis < m_nsp)) + && (m_velocityBasis < static_cast(m_nsp))) // use species number m_velocityBasis as reference velocity - if (m_velocityBasis == j) { + if (m_velocityBasis == static_cast(j)) { m_A(0,j) = 1.0; } else { m_A(0,j) = 0.0; @@ -1816,9 +1796,9 @@ void LiquidTransport::stefan_maxwell_solve() } else if (m_velocityBasis == VB_MASSAVG) { m_A(0,j) = m_massfracs_tran[j]; } else if ((m_velocityBasis >= 0) - && (m_velocityBasis < m_nsp)) + && (m_velocityBasis < static_cast(m_nsp))) // use species number m_velocityBasis as reference velocity - if (m_velocityBasis == j) { + if (m_velocityBasis == static_cast(j)) { m_A(0,j) = 1.0; } else { m_A(0,j) = 0.0; diff --git a/src/transport/SimpleTransport.cpp b/src/transport/SimpleTransport.cpp index a88c49059..1471f00e4 100644 --- a/src/transport/SimpleTransport.cpp +++ b/src/transport/SimpleTransport.cpp @@ -650,8 +650,8 @@ void SimpleTransport::getSpeciesVdiff(int ndim, getSpeciesFluxesExt(m_nsp, DATA_PTR(Vdiff)); - for (int n = 0; n < m_nDim; n++) { - for (int k = 0; k < m_nsp; k++) { + for (size_t n = 0; n < m_nDim; n++) { + for (size_t k = 0; k < m_nsp; k++) { if (y[k] > 1.0E-200) { Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]); } else { @@ -700,8 +700,8 @@ void SimpleTransport::getSpeciesVdiffES(int ndim, const doublereal* grad_T, getSpeciesFluxesExt(m_nsp, DATA_PTR(Vdiff)); - for (int n = 0; n < m_nDim; n++) { - for (int k = 0; k < m_nsp; k++) { + for (size_t n = 0; n < m_nDim; n++) { + for (size_t k = 0; k < m_nsp; k++) { if (y[k] > 1.0E-200) { Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]); } else { diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index abb477dd7..436fb343a 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -986,10 +986,10 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vector::iterator it; // Store the number of species in the phase - int nsp = trParam.nsp_; + size_t nsp = trParam.nsp_; // Store the number of off-diagonal symmetric interactions between species in the phase - int nBinInt = nsp*(nsp-1)/2; + size_t nBinInt = nsp*(nsp-1)/2; // read all entries in database into 'datatable' and check for // errors. Note that this procedure validates all entries, not @@ -1026,19 +1026,19 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vectorspeciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str()); + size_t index = temp_thermo->speciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str()); data.mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo); }; }; break; case TP_SELFDIFFUSION: { - for (int iSpec = 0; iSpec< nsp; iSpec++) { + for (size_t iSpec = 0; iSpec< nsp; iSpec++) { XML_Node& propSpecNode = xmlChild.child(iSpec); std::string specName = propSpecNode.name(); int index = temp_thermo->speciesIndex(specName.c_str()); @@ -1084,7 +1084,7 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vector