Fixed a UMR in Reaction.h that was causing optimized versions
of ck2cti to hang or seg fault sometimes. Added some exceptions that captures cases where the thermo parameters for a molecule were not found in the database. Now, an error exit occurs, instead of before, where misc garbage but written to the output file.
This commit is contained in:
parent
a68e8f734d
commit
3ea77c5187
4 changed files with 36 additions and 7 deletions
|
|
@ -93,13 +93,18 @@ namespace ckr {
|
|||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//! Specifies the Units for all reactions
|
||||
/**
|
||||
* Specifies the units for all reactions.
|
||||
* The default units are Cal per gmol for the activivation units
|
||||
* and the default number type is assumed to be gmol.
|
||||
*/
|
||||
|
||||
class ReactionUnits {
|
||||
public:
|
||||
ReactionUnits() :
|
||||
ActEnergy(ckr::Cal_per_Mole),
|
||||
Quantity(ckr::Moles) { }
|
||||
|
||||
int ActEnergy; ///< Activation energy unit flag
|
||||
int Quantity; ///< Moles or molecules unit flag
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace ckr {
|
|||
*/
|
||||
class RxnSpecies {
|
||||
public:
|
||||
RxnSpecies() :
|
||||
number(0) {}
|
||||
string name; //!< The name of the object.
|
||||
double number; //!< The number of units (molecules, etc.).
|
||||
grouplist_t groups;
|
||||
|
|
|
|||
|
|
@ -190,11 +190,15 @@ namespace pip {
|
|||
}
|
||||
|
||||
/**
|
||||
* addSpecies():
|
||||
* Write out a species cti block to the output file.
|
||||
*
|
||||
*/
|
||||
static void addSpecies(FILE* f, string idtag, const ckr::Species& sp) {
|
||||
string spname = sp.name;
|
||||
if (spname.size() == 0) {
|
||||
throw CanteraError("addSpecies",
|
||||
"Species name is empty");
|
||||
}
|
||||
fprintf(f,"\nspecies(name = \"%s\",\n",spname.c_str());
|
||||
int nel = static_cast<int>(sp.elements.size());
|
||||
int m, num;
|
||||
|
|
@ -226,6 +230,18 @@ namespace pip {
|
|||
}
|
||||
|
||||
fprintf(f," atoms = \"%s\",\n", str.c_str());
|
||||
if (sp.lowCoeffs.size() == 0) {
|
||||
throw CanteraError("addSpecies",
|
||||
"Low Nasa Thermo Polynomial was not found");
|
||||
}
|
||||
if (sp.highCoeffs.size() == 0) {
|
||||
throw CanteraError("addSpecies",
|
||||
"High Nasa Thermo Polynomial was not found");
|
||||
}
|
||||
if (sp.tlow >= sp.thigh) {
|
||||
throw CanteraError("addSpecies",
|
||||
"Low temp limit is greater or equal to high temp limit");
|
||||
}
|
||||
addNASA(f, sp.lowCoeffs, sp.highCoeffs,
|
||||
sp.tlow, sp.tmid, sp.thigh);
|
||||
|
||||
|
|
@ -277,7 +293,10 @@ namespace pip {
|
|||
else {
|
||||
if (rxn.kf.type == ckr::Arrhenius) {
|
||||
fprintf(f," [%10.5E, %g, %g]", rxn.kf.A, rxn.kf.n, rxn.kf.E);
|
||||
}
|
||||
} else {
|
||||
throw CanteraError("addReaction",
|
||||
"unknown kf_type to reaction: " + int2str(rxn.kf.type));
|
||||
}
|
||||
}
|
||||
|
||||
// reaction orders
|
||||
|
|
@ -346,7 +365,7 @@ namespace pip {
|
|||
doublereal version = 1.0;
|
||||
|
||||
fprintf(f, "units(length = \"cm\", time = \"s\", quantity = \"mol\", ");
|
||||
string e_unit;
|
||||
string e_unit = " ";
|
||||
int eunit = r.units.ActEnergy;
|
||||
if (eunit == ckr::Cal_per_Mole)
|
||||
e_unit = "cal/mol";
|
||||
|
|
@ -443,7 +462,7 @@ namespace pip {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static int fixtext(string infile, string outfile) {
|
||||
ifstream fin(infile.c_str());
|
||||
ofstream fout(outfile.c_str());
|
||||
|
|
@ -474,6 +493,7 @@ namespace pip {
|
|||
fout.close();
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
int convert_ck(const char* in_file, const char* db_file,
|
||||
const char* tr_file, const char* id_tag, bool debug, bool validate) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ namespace ckr {
|
|||
/** @name Activation Energy Units
|
||||
* These constants specify the supported units for the activation energy of
|
||||
* a reaction
|
||||
* The default is to assume Cal_per_Mole for unspecified units in the activation energy
|
||||
* as this was the original default
|
||||
*/
|
||||
//@{
|
||||
const int Cal_per_Mole = 1,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue