From 2d136647432b9530ebd8a841c6410d44d67f98d0 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 23 Oct 2008 01:13:35 +0000 Subject: [PATCH] A few algorithm changes. Starting to use the m_speciesStatus[] spots for component species. --- Cantera/src/equil/vcs_elem.cpp | 8 +--- Cantera/src/equil/vcs_solve.h | 2 +- Cantera/src/equil/vcs_solve_TP.cpp | 67 ++++++++++++++---------------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/Cantera/src/equil/vcs_elem.cpp b/Cantera/src/equil/vcs_elem.cpp index 19bef9c9e..0d6d37ef8 100644 --- a/Cantera/src/equil/vcs_elem.cpp +++ b/Cantera/src/equil/vcs_elem.cpp @@ -307,7 +307,6 @@ namespace VCSnonideal { int elType = m_elType[i]; if (elType == VCS_ELEM_TYPE_ABSPOS) { for (kspec = 0; kspec < m_numSpeciesTot; kspec++) { - // int irxn = kspec - m_numComponents; if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { double atomComp = m_formulaMatrix[i][kspec]; if (atomComp > 0.0) { @@ -327,17 +326,14 @@ namespace VCSnonideal { if (m_molNumSpecies_old[kspec] < VCS_DELETE_MINORSPECIES_CUTOFF) { m_molNumSpecies_old[kspec] = 0.0; if (m_SSPhase[kspec]) { - // m_rxnStatus[kspec] = VCS_SPECIES_ZEROEDSS; - m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDSS; + m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDSS; } else { - // m_rxnStatus[kspec] = VCS_SPECIES_ZEROEDMS; - m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDMS; + m_speciesStatus[kspec] = VCS_SPECIES_ACTIVEBUTZERO; } #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" --- vcs_elcorr: Zeroed species %s and changed " "status to %d due to max bounds constraint\n", - // m_speciesName[kspec].c_str(), m_rxnStatus[irxn]); m_speciesName[kspec].c_str(), m_speciesStatus[kspec]); } #endif diff --git a/Cantera/src/equil/vcs_solve.h b/Cantera/src/equil/vcs_solve.h index c31ea4d0f..b9b71e7c9 100644 --- a/Cantera/src/equil/vcs_solve.h +++ b/Cantera/src/equil/vcs_solve.h @@ -1531,7 +1531,7 @@ public: /*! * m_deltaMolNumPhase[irxn][iphase] = k = nc + irxn */ - DoubleStarStar m_deltaMolNumPhase; + DoubleStarStar m_deltaMolNumPhase; //! This is 1 if the phase, iphase, participates in the formation reaction //! irxn, and zero otherwise. PhaseParticipation[irxn][iphase] diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index d1d75a7e7..3ad233746 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -2453,51 +2453,47 @@ namespace VCSnonideal { } #endif - - - /* - * Loop over all of the active noncomponent species in the phase. + * Loop over all of the species in the phase. */ for (kspec = m_numComponents; kspec < m_numSpeciesRdc; ++kspec) { if (m_phaseID[kspec] == iph) { if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { - irxn = kspec - m_numComponents; - /* - * calculate an extent of rxn, dx, that zeroes out the species. - */ - dx = - (m_molNumSpecies_old[kspec]); - double dxTent = dx; + /* + * calculate an extent of rxn, dx, that zeroes out the species. + */ + dx = - (m_molNumSpecies_old[kspec]); + double dxTent = dx; - int retn = delta_species(kspec, &dxTent); - if (retn != 1) { - successful = false; + int retn = delta_species(kspec, &dxTent); + if (retn != 1) { + successful = false; #ifdef DEBUG_MODE - if (m_debug_print_lvl >= 2) { - plogf(" --- delete_multiphase %d, %s ERROR problems deleting species %s\n", - iph, Vphase->PhaseName.c_str(), m_speciesName[kspec].c_str() ); - plogf(" --- delta attempted: %g achieved: %g " - " Zeroing it manually\n", dx, dxTent); - } -#endif - m_molNumSpecies_old[kspec] = 0.0; - m_molNumSpecies_new[kspec] = 0.0; - m_deltaMolNumSpecies[kspec] = 0.0; - // recover the total phase moles. - vcs_tmoles(); - } else { - /* - * Set the mole number of that species to zero. - */ - m_molNumSpecies_old[kspec] = 0.0; - m_molNumSpecies_new[kspec] = 0.0; - m_deltaMolNumSpecies[kspec] = 0.0; + if (m_debug_print_lvl >= 2) { + plogf(" --- delete_multiphase %d, %s ERROR problems deleting species %s\n", + iph, Vphase->PhaseName.c_str(), m_speciesName[kspec].c_str() ); + plogf(" --- delta attempted: %g achieved: %g " + " Zeroing it manually\n", dx, dxTent); } +#endif + m_molNumSpecies_old[kspec] = 0.0; + m_molNumSpecies_new[kspec] = 0.0; + m_deltaMolNumSpecies[kspec] = 0.0; + // recover the total phase moles. + vcs_tmoles(); + } else { /* - * Change the status flag of the species to that of an - * zeroed phase + * Set the mole number of that species to zero. */ - m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDMS; + m_molNumSpecies_old[kspec] = 0.0; + m_molNumSpecies_new[kspec] = 0.0; + m_deltaMolNumSpecies[kspec] = 0.0; + } + /* + * Change the status flag of the species to that of an + * zeroed phase + */ + m_speciesStatus[kspec] = VCS_SPECIES_ZEROEDMS; } } } @@ -2554,6 +2550,7 @@ namespace VCSnonideal { #endif m_molNumSpecies_old[kcomp] = 0.0; } + m_speciesStatus[kcomp] = VCS_SPECIES_ZEROEDMS; } }