From 9b12761506b835918e732e99b7d8172cde21a4fb Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Mon, 26 Jan 2009 15:59:10 +0000 Subject: [PATCH] Added comments and a def. --- Cantera/src/equil/vcs_defs.h | 8 +++++++- Cantera/src/equil/vcs_phaseStability.cpp | 16 +++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Cantera/src/equil/vcs_defs.h b/Cantera/src/equil/vcs_defs.h index 0f2d9e672..023d6285b 100644 --- a/Cantera/src/equil/vcs_defs.h +++ b/Cantera/src/equil/vcs_defs.h @@ -84,7 +84,6 @@ namespace VCSnonideal { //! Cutoff relative mole fraction value, //! below which species are deleted from the equilibrium problem. - #ifndef VCS_RELDELETE_SPECIES_CUTOFF #define VCS_RELDELETE_SPECIES_CUTOFF 1.0e-64 #endif @@ -105,6 +104,13 @@ namespace VCSnonideal { //! from the equilibrium problem. #ifndef VCS_DELETE_PHASE_CUTOFF #define VCS_DELETE_PHASE_CUTOFF 1.0e-12 +#endif + + //! Cutoff moles below which a phase or species which + //! comprises the bulk of an element's total concentration + //! is deleted. +#ifndef VCS_DELETE_ELEMENTABS_CUTOFF +#define VCS_DELETE_ELEMENTABS_CUTOFF 1.0e-280 #endif //@} diff --git a/Cantera/src/equil/vcs_phaseStability.cpp b/Cantera/src/equil/vcs_phaseStability.cpp index 1a1dfa89c..f86e0dad2 100644 --- a/Cantera/src/equil/vcs_phaseStability.cpp +++ b/Cantera/src/equil/vcs_phaseStability.cpp @@ -27,6 +27,10 @@ namespace VCSnonideal { // Utility function that evaluates whether a phase can be popped // into existence /* + * A phase can be popped iff the stoichiometric coefficients for the + * component species, whose concentrations will be lowered during the + * process, are positive by at least a small degree. + * * @param iphasePop id of the phase, which is currently zeroed, * * @return Returns true if the phase can come into existence @@ -40,12 +44,12 @@ namespace VCSnonideal { int existence = Vphase->exists(); if (existence > 0) { printf("ERROR vcs_popPhasePossible called for a phase that exists!"); - exit(-1); + std::exit(-1); } #endif /* - * section to do damping of the m_deltaMolNumSpecies[] + * Loop through all of the species in the phase */ for (int k = 0; k < Vphase->nSpecies(); k++) { int kspec = Vphase->spGlobalIndexVCS(k); @@ -58,12 +62,14 @@ namespace VCSnonideal { double negChangeComp = - stoicC * 1.0; if (negChangeComp > 0.0) { // TODO: We may have to come up with a tolerance here - if (m_molNumSpecies_old[j] <= 1.0E-300) { + if (m_molNumSpecies_old[j] <= VCS_DELETE_ELEMENTABS_CUTOFF*0.1) { #ifdef DEBUG_MODE if (m_debug_print_lvl >= 3) { - plogf(" --- vcs_popPhasePosssible() Phase %d (%s) can't be popped\n", iphasePop, + plogf(" --- vcs_popPhasePosssible() Phase %d (%s) can't be popped\n", + iphasePop, Vphase->PhaseName.c_str()); - plogf(" --- Component %d (%s)will go negative\n", j, m_speciesName[j].c_str()); + plogf(" --- Component %d (%s)will go negative\n", + j, m_speciesName[j].c_str()); } #endif return false;