From 6844a24c67d854a1bfc59fb381552ee3b304f33f Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Mon, 25 Jul 2005 03:53:24 +0000 Subject: [PATCH] support for fractional stoich coefficients --- Cantera/src/converters/CKReader.cpp | 14 ++++++++------ Cantera/src/converters/CKReader.h | 2 +- Cantera/src/converters/ck2ct.cpp | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Cantera/src/converters/CKReader.cpp b/Cantera/src/converters/CKReader.cpp index 91f55e5c5..f01e649cd 100755 --- a/Cantera/src/converters/CKReader.cpp +++ b/Cantera/src/converters/CKReader.cpp @@ -227,7 +227,6 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, for (k = 0; k < nsp; k++) { Species s; s.name = undef[k]; - cout << k << " " << s.name << endl; species.push_back(s); } } @@ -637,7 +636,7 @@ bool checkThermo(ostream& log, speciesList& sp, double tol) { * @todo use reaction number stored in reaction object */ bool checkBalance(ostream& f, speciesTable& speciesData, - reactionList& r, vector& unbalanced) + reactionList& r, vector& unbalanced, double tolerance) { int nrxn = static_cast(r.size()); string rname, pname; @@ -674,12 +673,15 @@ bool checkThermo(ostream& log, speciesList& sp, double tol) { atoms[elements[m].name] += stoichCoeff * elements[m].number; } } + double atms; getMapKeys(atoms, elementSyms); for (m = 0; m < elementSyms.size(); m++) { - if (atoms[elementSyms[m]] != 0.0) { - //cout << "unbalanced element: " - // << elementSyms[m] << " " - // << atoms[elementSyms[m]] << endl; + atms = atoms[elementSyms[m]]; + if (fabs(atms) > tolerance) { + //if (atoms[elementSyms[m]] != 0.0) { + // cout << "Reaction " << i+1 << " has an unbalanced element: " + // << elementSyms[m] << " " + // << atoms[elementSyms[m]] << endl; unbalanced.push_back(i+1); break; } } diff --git a/Cantera/src/converters/CKReader.h b/Cantera/src/converters/CKReader.h index e6be407fc..37b5bad4f 100755 --- a/Cantera/src/converters/CKReader.h +++ b/Cantera/src/converters/CKReader.h @@ -107,7 +107,7 @@ namespace ckr { bool checkBalance(ostream& f, speciesTable& speciesData, reactionList& r, - vector& unbalanced); + vector& unbalanced, double tolerance=1.0e-3); bool checkThermo(ostream& f, speciesList& species, double tol); bool filter(const string& infile, const string& database, diff --git a/Cantera/src/converters/ck2ct.cpp b/Cantera/src/converters/ck2ct.cpp index 36384d1b6..fd7095c82 100644 --- a/Cantera/src/converters/ck2ct.cpp +++ b/Cantera/src/converters/ck2ct.cpp @@ -274,7 +274,21 @@ namespace pip { fprintf(f," [%10.5E, %g, %g]", rxn.kf.A, rxn.kf.n, rxn.kf.E); } } - + + // reaction orders + cout << "checking for rxn orders..." << endl; + int nord = static_cast(rxn.fwdOrder.size()); + cout << nord << endl; + if (nord > 0) { + cout << "processing order..." << endl; + map::const_iterator b = rxn.fwdOrder.begin(), + e = rxn.fwdOrder.end(); + string estr = ""; + for (; b != e; ++b) { + estr += " "+b->first+":"+fp2str(b->second)+" "; + } + fprintf(f, ",\n order = \"%s\"", estr.c_str()); + } int ne = static_cast(rxn.e3b.size()); if (rxn.thirdBody != "") {