support for fractional stoich coefficients

This commit is contained in:
Dave Goodwin 2005-07-25 03:53:24 +00:00
parent ae323fb7da
commit 6844a24c67
3 changed files with 24 additions and 8 deletions

View file

@ -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<int>& unbalanced)
reactionList& r, vector<int>& unbalanced, double tolerance)
{
int nrxn = static_cast<int>(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;
}
}

View file

@ -107,7 +107,7 @@ namespace ckr {
bool checkBalance(ostream& f, speciesTable& speciesData, reactionList& r,
vector<int>& unbalanced);
vector<int>& unbalanced, double tolerance=1.0e-3);
bool checkThermo(ostream& f, speciesList& species, double tol);
bool filter(const string& infile, const string& database,

View file

@ -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<int>(rxn.fwdOrder.size());
cout << nord << endl;
if (nord > 0) {
cout << "processing order..." << endl;
map<string, double>::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<int>(rxn.e3b.size());
if (rxn.thirdBody != "<none>") {