From 4c6533151467a4ccbacaf79822ff3cf0656c77ea Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 2 Dec 2004 22:11:28 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/python/ctml_writer.py | 7 +++-- Cantera/src/MultiPhaseEquil.cpp | 34 ++++++++++++++++++++-- Cantera/src/importCTML.cpp | 51 ++++++++++++++++++++++++--------- Cantera/src/misc.cpp | 22 +++++++++++++- 4 files changed, 94 insertions(+), 20 deletions(-) diff --git a/Cantera/python/ctml_writer.py b/Cantera/python/ctml_writer.py index ca5edb2d7..0f30b90bc 100644 --- a/Cantera/python/ctml_writer.py +++ b/Cantera/python/ctml_writer.py @@ -1025,7 +1025,7 @@ class phase: if s[0] == ',': s = s[1:] if s[-1] == ',': s = s[:-1] - if self._spmap.has_key(s): + if s <> 'all' and self._spmap.has_key(s): raise CTI_Error('Multiply-declared species '+s+' in phase '+self._name) self._spmap[s] = self._dim @@ -1495,7 +1495,10 @@ if __name__ == "__main__": # $Revision$ # $Date$ # $Log$ -# Revision 1.7 2004-11-15 02:33:21 dggoodwin +# Revision 1.8 2004-12-02 22:11:28 dggoodwin +# *** empty log message *** +# +# Revision 1.7 2004/11/15 02:33:21 dggoodwin # changed f90 mod file handling in Makefiles # # Revision 1.6 2004/09/29 11:00:39 dggoodwin diff --git a/Cantera/src/MultiPhaseEquil.cpp b/Cantera/src/MultiPhaseEquil.cpp index 502798b1f..8bb9ef4d0 100644 --- a/Cantera/src/MultiPhaseEquil.cpp +++ b/Cantera/src/MultiPhaseEquil.cpp @@ -7,6 +7,7 @@ #include using namespace std; +#define DEBUG_MULTIPHASE_EQUIL namespace Cantera { @@ -312,6 +313,22 @@ namespace Cantera { } } +#ifdef DEBUG_MULTIPHASE_EQUIL + // check + bool ok = true; + for (m = 0; m < nRows; m++) { + if (m_A(m,m) != 1.0) ok = false; + for (n = 0; n < nRows; n++) { + if (n != m && fabs(m_A(m,n)) > TINY) + ok = false; + } + } + if (!ok) { + cout << m_A << endl; + throw CanteraError("getComponents","error in A matrix"); + } +#endif + // create stoichometric coefficient matrix. for (n = 0; n < m_nsp; n++) { if (n < m_nel) @@ -385,7 +402,7 @@ namespace Cantera { index_t k, ik; if (omega < 0.0) throw CanteraError("step","negative omega"); - //cout << "entering step " << m_moles << endl << deltaN << endl; + for (ik = 0; ik < m_nel; ik++) { k = m_order[ik]; m_lastmoles[k] = m_moles[k]; @@ -445,16 +462,22 @@ namespace Cantera { // such that all if (m_dsoln[k] == 1) { - if ((m_moles[k] > MAJOR_THRESHOLD) || (ik < m_nel)) { + if ((m_moles[k] > MAJOR_THRESHOLD) ) || (ik < m_nel)) { omax = m_moles[k]*FCTR/(fabs(m_work[k]) + TINY); if (m_work[k] < 0.0 && omax < omegamax) { omegamax = omax; +#ifdef DEBUG_MULTIPHASE_EQUIL if (omegamax < 1.0e-5) { cout << m_mix->speciesName(m_species[k]) << " results in " << " omega = " << omegamax << endl; //cout << m_moles[k] << " " << m_work[k] << endl; if (ik < m_nel) cout << "component" << endl; + index_t nk; + for (nk = 0; nk < m_nel; nk++) { + cout << "component " << m_mix->speciesName(m_species[m_order[nk]]) << " " << m_moles[m_order[nk]] << endl; + } } +#endif } m_majorsp[k] = true; } @@ -467,12 +490,14 @@ namespace Cantera { omax = -m_moles[k]/m_work[k]; if (omax < omegamax) { omegamax = omax*1.000001; +#ifdef DEBUG_MULTIPHASE_EQUIL if (omegamax < 1.0e-5) { cout << m_mix->speciesName(m_species[k]) << " results in " << " omega = " << omegamax << endl; //cout << m_moles[k] << " " << m_work[k] << endl; if (ik < m_nel) cout << "component" << endl; } +#endif } } m_majorsp[k] = true; @@ -498,6 +523,9 @@ namespace Cantera { for (k = 0; k < m_nsp; k++) m_moles[k] = m_lastmoles[k]; step(omega, m_work); } + cout << m_moles << endl; + cout << m_work << endl; + cout << m_iter << " " << m_mix->elementMoles(m_element[0]) << endl; //cout << m_moles << endl; //cout << "omega: " << omega << " " << m_mix->gibbs() << " " << error() << endl; return omega; @@ -590,7 +618,7 @@ namespace Cantera { if (m_moles[m_order[m]] <= 0.0 && (m_N(m, j)*dxi[j] < 0.0)) dxi[j] = 0.0; } - //cout << reactionString(j) << " " << dxi[j] << " " << fctr << " " << dg_rt << endl; + cout << reactionString(j) << " " << dxi[j] << " " << fctr << " " << dg_rt << endl; grad += dxi[j]*dg_rt; } diff --git a/Cantera/src/importCTML.cpp b/Cantera/src/importCTML.cpp index 065a7b961..4aa5bd2b9 100755 --- a/Cantera/src/importCTML.cpp +++ b/Cantera/src/importCTML.cpp @@ -779,6 +779,10 @@ namespace Cantera { if (eskip == "undeclared") { sprule[jsp] = 1; } + string dskip = sk["species"]; + if (dskip == "duplicate") { + sprule[jsp] += 10; + } } string fname, idstr; @@ -837,28 +841,47 @@ namespace Cantera { spnames[nn] = (*allsp[nn])["name"]; } } + else if (nsp == 1 && spnames[0] == "unique") { + vector uniquesp; + db->getChildren("species",uniquesp); + nsp = static_cast(uniquesp.size()); + spnames.clear(); + spnames.resize(nsp); + string spnm; + for (int nn = 0; nn < nsp; nn++) { + spnm = (*uniquesp[nn])["name"]; + if (!declared[spnm]) spnames[nn] = spnm; + } + } string name; + bool skip; for (i = 0; i < nsp; i++) { name = spnames[i]; - + skip = false; + if (name == "") skip = true; // Check that every species is only declared once if (declared[name]) { - throw CanteraError("importPhase", - "duplicate species: "+name); + if (sprule[jsp] >= 10) + skip = true; + else + throw CanteraError("importPhase", + "duplicate species: "+name); } - declared[name] = true; + if (!skip) { + declared[name] = true; - // Find the species in the database by name. - XML_Node* s = db->findByAttr("name",spnames[i]); - if (s) { - if (installSpecies(k, *s, *th, spthermo, sprule[jsp], - spfactory)) - ++k; - } - else { - throw CanteraError("importPhase","no data for species " - +name); + // Find the species in the database by name. + XML_Node* s = db->findByAttr("name",spnames[i]); + if (s) { + if (installSpecies(k, *s, *th, spthermo, sprule[jsp], + spfactory)) + ++k; + } + else { + throw CanteraError("importPhase","no data for species " + +name); + } } } } diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index db304d4c1..a5b34175a 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -124,7 +124,27 @@ namespace Cantera { XML_Node* get_XML_File(string file) { - string path = findInputFile(file); + string path = ""; + try { + path = findInputFile(file); + } + catch (CanteraError) { + string::size_type idot = file.rfind('.'); + string ext = ""; + if (idot != string::npos) { + ext = file.substr(idot, file.size()); + string ctifile = file.substr(0,idot)+".cti"; + try { + path = findInputFile(ctifile); + } + catch (CanteraError) { + path = findInputFile(file); + } + } + else + path = findInputFile(file); + } + string ff = path; if (app()->xmlfiles.find(path) == app()->xmlfiles.end()) {