Merged changes from LiquidTransportDevelopment

There were two changes:

Additions to support some reversible reactions which have fractional
stoichiometries. These were not allowed previously. However, if
the species with fractional stoichiometries are in single-species
phases, this is ok, and actually necessary for some solid-phase
reactions.

Removed comments from DEBUG_MODE about about too high or low an activation
for electrode reactions.
This commit is contained in:
Harry Moffat 2009-12-10 23:20:44 +00:00
parent 20c74f21af
commit 9b90beb0e0
36 changed files with 1782 additions and 1700 deletions

View file

@ -11,8 +11,8 @@
* U.S. Government retains certain rights in this software.
*/
/*
* $Date: 2009/02/11 01:50:54 $
* $Revision: 1.1 $
* $Date$
* $Revision$
*/

View file

@ -3,9 +3,9 @@
*
* @ingroup chemkinetics
*
* $Author: hkmoffa $
* $Revision: 1.1 $
* $Date: 2009/02/11 01:50:57 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -5,9 +5,9 @@
* @ingroup electrochem
*/
/* $Author: hkmoffa $
* $Revision: 1.4 $
* $Date: 2008/12/16 20:32:18 $
/* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -2,9 +2,9 @@
* @file Enhanced3BConc.h
*/
/* $Author: dggoodwin $
* $Date: 2007/05/04 14:27:23 $
* $Revision: 1.1 $
/* $Author$
* $Date$
* $Revision$
*/
// Copyright 2001 California Institute of Technology

View file

@ -2,9 +2,9 @@
* @file FalloffFactory.cpp
*/
/* $Author: hkmoffa $
* $Date: 2008/12/29 21:34:08 $
* $Revision: 1.6 $
/* $Author$
* $Date$
* $Revision$
*/
// Copyright 2001 California Institute of Technology

View file

@ -6,8 +6,8 @@
*/
/*
* $Date: 2008/12/29 21:34:08 $
* $Revision: 1.4 $
* $Date$
* $Revision$
*/
// Copyright 2001 California Institute of Technology

View file

@ -1,9 +1,9 @@
/**
* @file FalloffMgr.h
*
* $Author: dggoodwin $
* $Date: 2007/05/10 03:28:32 $
* $Revision: 1.2 $
* $Author$
* $Date$
* $Revision$
*/
// Copyright 2001 California Institute of Technology

View file

@ -3,9 +3,9 @@
*
* @ingroup chemkinetics
*
* $Author: hkmoffa $
* $Revision: 1.8 $
* $Date: 2008/12/29 21:34:08 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -2,9 +2,9 @@
*
* @file GasKineticsWriter.h
*
* $Author: hkmoffa $
* $Revision: 1.3 $
* $Date: 2008/12/17 17:09:37 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -3,9 +3,9 @@
*
* Implementation file for the Group class used in reaction path analysis.
*
* $Author: hkmoffa $
* $Revision: 1.2 $
* $Date: 2008/12/29 21:34:08 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -1,9 +1,9 @@
/**
* @file Group.h
*
* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
* $Author$
* $Revision$
* $Date$
*/

View file

@ -2,9 +2,9 @@
* @file ImplicitChem.cpp
*/
/* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
/* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -1,9 +1,9 @@
/**
* @file ImplicitChem.h
*
* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -6,9 +6,9 @@
*/
/*
* $Author: hkmoffa $
* $Revision: 1.4 $
* $Date: 2007/08/29 19:57:48 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -6,9 +6,9 @@
*/
/*
* $Author: hkmoffa $
* $Revision: 1.3 $
* $Date: 2007/08/23 21:43:07 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

File diff suppressed because it is too large Load diff

View file

@ -4,9 +4,9 @@
* @ingroup chemkinetics
*/
/*
* $Author: hkmoffa $
* $Revision: 1.11 $
* $Date: 2008/12/17 17:09:37 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -7,8 +7,8 @@
* Kinetics managers calculate rates of progress of species due to homogeneous or heterogeneous kinetics.
*/
/*
* $Date: 2008/12/16 20:32:18 $
* $Revision: 1.3 $
* $Date$
* $Revision$
*/
// Copyright 2001-2004 California Institute of Technology

View file

@ -4,8 +4,8 @@
* module documentation (see \ref kineticsmgr and class
* \link Cantera::Kinetics Kinetics\endlink).
*
* $Date: 2008/12/16 20:32:18 $
* $Revision: 1.8 $
* $Date$
* $Revision$
*/
// Copyright 2001-2004 California Institute of Technology

View file

@ -3,9 +3,9 @@
*/
/*
* $Author: hkmoffa $
* $Revision: 1.4 $
* $Date: 2009/02/11 20:01:45 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -3,9 +3,9 @@
*/
/*
* $Author: hkmoffa $
* $Revision: 1.3 $
* $Date: 2009/02/11 01:50:58 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2009/02/11 01:50:58 $
# $Revision: 1.10 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2002 California Institute of Technology
#

View file

@ -3,9 +3,9 @@
*/
/*
* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -3,9 +3,9 @@
*
*/
/*
* $Author: hkmoffa $
* $Revision: 1.2 $
* $Date: 2007/06/04 23:05:07 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology
@ -18,48 +18,52 @@
namespace Cantera {
class ReactionData {
public:
ReactionData() {
reactionType = ELEMENTARY_RXN;
number = 0;
rxn_number = 0;
reversible = true;
rateCoeffType = ARRHENIUS;
falloffType = NONE;
error = 0;
equation = "";
default_3b_eff = 1.0;
global = false;
beta = 0.0;
}
virtual ~ReactionData(){}
class ReactionData {
public:
ReactionData() {
reactionType = ELEMENTARY_RXN;
number = 0;
rxn_number = 0;
reversible = true;
rateCoeffType = ARRHENIUS;
falloffType = NONE;
error = 0;
equation = "";
default_3b_eff = 1.0;
global = false;
isReversibleWithFrac = false;
beta = 0.0;
}
~ReactionData(){}
int reactionType;
int number, rxn_number;
vector_int reactants;
vector_int products;
vector_fp order;
vector_fp rstoich;
vector_fp pstoich;
std::vector<grouplist_t> rgroups;
std::vector<grouplist_t> pgroups;
std::map<int, doublereal> thirdBodyEfficiencies;
int reactionType;
int number;
int rxn_number;
vector_int reactants;
vector_int products;
vector_fp rorder;
vector_fp porder;
vector_fp rstoich;
vector_fp pstoich;
std::vector<grouplist_t> rgroups;
std::vector<grouplist_t> pgroups;
std::map<int, doublereal> thirdBodyEfficiencies;
//! True if the current reaction is reversible. False otherwise
bool reversible;
int rateCoeffType;
vector_fp rateCoeffParameters;
vector_fp auxRateCoeffParameters;
int falloffType;
vector_fp falloffParameters;
int error;
std::string equation;
doublereal default_3b_eff;
vector_fp cov;
bool global;
doublereal beta; // for electrochemical reactions
};
//! True if the current reaction is reversible. False otherwise
bool reversible;
int rateCoeffType;
vector_fp rateCoeffParameters;
vector_fp auxRateCoeffParameters;
int falloffType;
vector_fp falloffParameters;
int error;
std::string equation;
doublereal default_3b_eff;
vector_fp cov;
bool global;
bool isReversibleWithFrac;
doublereal beta; // for electrochemical reactions
};
}
#endif

View file

@ -4,9 +4,9 @@
*/
/*
* $Author: dggoodwin $
* $Revision: 1.2 $
* $Date: 2008/02/05 23:36:12 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -3,9 +3,9 @@
*
* Classes for reaction path analysis.
*
* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -5,9 +5,9 @@
///
//------------------------------------------------
// $Author: dggoodwin $
// $Revision: 1.1 $
// $Date: 2007/05/04 15:48:44 $
// $Author$
// $Revision$
// $Date$
// turn off warnings under Windows
#ifdef WIN32
@ -67,216 +67,214 @@ namespace Cantera {
void ReactionStoichMgr::
add(int rxn, const ReactionData& r) {
vector_int rk;
doublereal frac;
bool isfrac = false;
int n, ns, m, nr = r.reactants.size();
for (n = 0; n < nr; n++) {
ns = int(r.rstoich[n]);
frac = r.rstoich[n] - 1.0*int(r.rstoich[n]);
if (frac != 0.0) isfrac = true;
for (m = 0; m < ns; m++) {
rk.push_back(r.reactants[n]);
}
}
vector_int rk;
doublereal frac;
bool isfrac = false;
int n, ns, m, nr = r.reactants.size();
for (n = 0; n < nr; n++) {
ns = int(r.rstoich[n]);
frac = r.rstoich[n] - 1.0*int(r.rstoich[n]);
if (frac != 0.0) isfrac = true;
for (m = 0; m < ns; m++) {
rk.push_back(r.reactants[n]);
}
}
// if the reaction has fractional stoichiometric coefficients
// or specified reaction orders, then add it in a ma
if (isfrac || r.global || rk.size() > 3) {
m_reactants->add(rxn, r.reactants, r.order, r.rstoich);
// if the reaction has fractional stoichiometric coefficients
// or specified reaction orders, then add it in a general reaction
if (isfrac || r.global || rk.size() > 3) {
m_reactants->add(rxn, r.reactants, r.rorder, r.rstoich);
#ifdef INCL_STOICH_WRITER
if (m_rwriter) m_rwriter->add(rxn, r.reactants, r.order, r.rstoich);
if (m_rwriter) m_rwriter->add(rxn, r.reactants, r.order, r.rstoich);
#endif
}
else {
m_reactants->add( rxn, rk);
}
else {
m_reactants->add( rxn, rk);
#ifdef INCL_STOICH_WRITER
if (m_rwriter) m_rwriter->add(rxn, rk);
if (m_rwriter) m_rwriter->add(rxn, rk);
#endif
}
}
vector_int pk;
isfrac = false;
int np = r.products.size();
for (n = 0; n < np; n++) {
ns = int(r.pstoich[n]);
frac = r.pstoich[n] - 1.0*int(r.pstoich[n]);
if (frac != 0.0) isfrac = true;
for (m = 0; m < ns; m++) {
pk.push_back(r.products[n]);
}
}
vector_int pk;
isfrac = false;
int np = r.products.size();
for (n = 0; n < np; n++) {
ns = int(r.pstoich[n]);
frac = r.pstoich[n] - 1.0*int(r.pstoich[n]);
if (frac != 0.0) isfrac = true;
for (m = 0; m < ns; m++) {
pk.push_back(r.products[n]);
}
}
if (r.reversible) {
if (isfrac) {
throw CanteraError("ReactionStoichMgr::add",
"fractional product stoichiometric coefficients only allowed "
"\nfor irreversible reactions");
}
if (pk.size() > 3) {
// mod dgg 10/31/06
m_revproducts->add(rxn, r.products, r.pstoich, r.pstoich);
//m_revproducts->add(rxn, r.products, m_dummy, r.pstoich);
}
else {
m_revproducts->add(rxn, pk);
}
}
else if (isfrac || pk.size() > 3) {
m_irrevproducts->add(rxn, r.products, m_dummy, r.pstoich);
}
else {
m_irrevproducts->add(rxn, pk);
}
if (r.reversible) {
if (isfrac && !r.isReversibleWithFrac) {
throw CanteraError("ReactionStoichMgr::add",
"Fractional product stoichiometric coefficients only allowed "
"\nfor irreversible reactions and most reversible reactions");
}
if (pk.size() > 3 || r.isReversibleWithFrac) {
m_revproducts->add(rxn, r.products, r.porder, r.pstoich);
}
else {
m_revproducts->add(rxn, pk);
}
}
else if (isfrac || pk.size() > 3) {
m_irrevproducts->add(rxn, r.products, r.porder, r.pstoich);
}
else {
m_irrevproducts->add(rxn, pk);
}
}
void ReactionStoichMgr::
getCreationRates(int nsp, const doublereal* ropf,
const doublereal* ropr, doublereal* c) {
// zero out the output array
fill(c, c + nsp, 0.0);
const doublereal* ropr, doublereal* c) {
// zero out the output array
fill(c, c + nsp, 0.0);
// the forward direction creates product species
m_revproducts->incrementSpecies(ropf, c);
m_irrevproducts->incrementSpecies(ropf, c);
// the forward direction creates product species
m_revproducts->incrementSpecies(ropf, c);
m_irrevproducts->incrementSpecies(ropf, c);
// the reverse direction creates reactant species
m_reactants->incrementSpecies(ropr, c);
// the reverse direction creates reactant species
m_reactants->incrementSpecies(ropr, c);
}
void ReactionStoichMgr::
getDestructionRates(int nsp, const doublereal* ropf,
const doublereal* ropr, doublereal* d) {
fill(d, d + nsp, 0.0);
// the reverse direction destroys products in reversible reactions
m_revproducts->incrementSpecies(ropr, d);
// the forward direction destroys reactants
m_reactants->incrementSpecies(ropf, d);
}
void ReactionStoichMgr::
getDestructionRates(int nsp, const doublereal* ropf,
const doublereal* ropr, doublereal* d) {
fill(d, d + nsp, 0.0);
// the reverse direction destroys products in reversible reactions
m_revproducts->incrementSpecies(ropr, d);
// the forward direction destroys reactants
m_reactants->incrementSpecies(ropf, d);
}
void ReactionStoichMgr::
getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w) {
fill(w, w + nsp, 0.0);
// products are created for positive net rate of progress
m_revproducts->incrementSpecies(ropnet, w);
m_irrevproducts->incrementSpecies(ropnet, w);
// reactants are destroyed for positive net rate of progress
m_reactants->decrementSpecies(ropnet, w);
}
void ReactionStoichMgr::
getNetProductionRates(int nsp, const doublereal* ropnet, doublereal* w) {
fill(w, w + nsp, 0.0);
// products are created for positive net rate of progress
m_revproducts->incrementSpecies(ropnet, w);
m_irrevproducts->incrementSpecies(ropnet, w);
// reactants are destroyed for positive net rate of progress
m_reactants->decrementSpecies(ropnet, w);
}
void ReactionStoichMgr::
getReactionDelta(int nr, const doublereal* g, doublereal* dg) {
fill(dg, dg + nr, 0.0);
// products add
m_revproducts->incrementReactions(g, dg);
m_irrevproducts->incrementReactions(g, dg);
// reactants subtract
m_reactants->decrementReactions(g, dg);
}
void ReactionStoichMgr::
getReactionDelta(int nr, const doublereal* g, doublereal* dg) {
fill(dg, dg + nr, 0.0);
// products add
m_revproducts->incrementReactions(g, dg);
m_irrevproducts->incrementReactions(g, dg);
// reactants subtract
m_reactants->decrementReactions(g, dg);
}
void ReactionStoichMgr::
getRevReactionDelta(int nr, const doublereal* g, doublereal* dg) {
fill(dg, dg + nr, 0.0);
m_revproducts->incrementReactions(g, dg);
m_reactants->decrementReactions(g, dg);
}
void ReactionStoichMgr::
getRevReactionDelta(int nr, const doublereal* g, doublereal* dg) {
fill(dg, dg + nr, 0.0);
m_revproducts->incrementReactions(g, dg);
m_reactants->decrementReactions(g, dg);
}
void ReactionStoichMgr::
multiplyReactants(const doublereal* c, doublereal* r) {
m_reactants->multiply(c, r);
}
void ReactionStoichMgr::
multiplyReactants(const doublereal* c, doublereal* r) {
m_reactants->multiply(c, r);
}
void ReactionStoichMgr::
multiplyRevProducts(const doublereal* c, doublereal* r) {
m_revproducts->multiply(c, r);
}
void ReactionStoichMgr::
multiplyRevProducts(const doublereal* c, doublereal* r) {
m_revproducts->multiply(c, r);
}
void ReactionStoichMgr::
write(string filename) {
ofstream f(filename.c_str());
f << "namespace mech {" << endl;
writeCreationRates(f);
writeDestructionRates(f);
writeNetProductionRates(f);
writeMultiplyReactants(f);
writeMultiplyRevProducts(f);
f << "} // namespace mech" << endl;
f.close();
void ReactionStoichMgr::
write(string filename) {
ofstream f(filename.c_str());
f << "namespace mech {" << endl;
writeCreationRates(f);
writeDestructionRates(f);
writeNetProductionRates(f);
writeMultiplyReactants(f);
writeMultiplyRevProducts(f);
f << "} // namespace mech" << endl;
f.close();
}
void ReactionStoichMgr::
writeCreationRates(ostream& f) {
f << " void getCreationRates(const doublereal* rf, const doublereal* rb," << endl;
f << " doublereal* c) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("rf",out);
m_irrevproducts->writeIncrementSpecies("rf",out);
m_reactants->writeIncrementSpecies("rb",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " c[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeCreationRates(ostream& f) {
f << " void getCreationRates(const doublereal* rf, const doublereal* rb," << endl;
f << " doublereal* c) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("rf",out);
m_irrevproducts->writeIncrementSpecies("rf",out);
m_reactants->writeIncrementSpecies("rb",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " c[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeDestructionRates(ostream& f) {
f << " void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl;
f << " doublereal* d) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("rb",out);
m_reactants->writeIncrementSpecies("rf",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " d[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
void ReactionStoichMgr::
writeDestructionRates(ostream& f) {
f << " void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl;
f << " doublereal* d) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("rb",out);
m_reactants->writeIncrementSpecies("rf",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " d[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeNetProductionRates(ostream& f) {
f << " void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("r",out);
m_irrevproducts->writeIncrementSpecies("r",out);
m_reactants->writeDecrementSpecies("r",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " w[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
void ReactionStoichMgr::
writeNetProductionRates(ostream& f) {
f << " void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl;
map<int, string> out;
m_revproducts->writeIncrementSpecies("r",out);
m_irrevproducts->writeIncrementSpecies("r",out);
m_reactants->writeDecrementSpecies("r",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = wrapString(b->second);
rhs[1] = '=';
f << " w[" << b->first << "] " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeMultiplyReactants(ostream& f) {
f << " void multiplyReactants(const doublereal* c, doublereal* r) {" << endl;
map<int, string> out;
m_reactants->writeMultiply("c",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = b->second;
f << " r[" << b->first << "] *= " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeMultiplyReactants(ostream& f) {
f << " void multiplyReactants(const doublereal* c, doublereal* r) {" << endl;
map<int, string> out;
m_reactants->writeMultiply("c",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = b->second;
f << " r[" << b->first << "] *= " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeMultiplyRevProducts(ostream& f) {
f << " void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl;
map<int, string> out;
m_revproducts->writeMultiply("c",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = b->second;
f << " r[" << b->first << "] *= " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
void ReactionStoichMgr::
writeMultiplyRevProducts(ostream& f) {
f << " void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl;
map<int, string> out;
m_revproducts->writeMultiply("c",out);
map<int, string>::iterator b;
for (b = out.begin(); b != out.end(); ++b) {
string rhs = b->second;
f << " r[" << b->first << "] *= " << rhs << ";" << endl;
}
f << " }" << endl << endl << endl;
}
}

View file

@ -5,9 +5,9 @@
*/
/*
* $Author: hkmoffa $
* $Revision: 1.2 $
* $Date: 2007/06/12 14:20:02 $
* $Author$
* $Revision$
* $Date$
*/
#ifndef CT_RXN_STOICH

View file

@ -3,9 +3,9 @@
*
*/
/* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
/* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
/**
* @file ThirdBodyMgr.h
*
* $Author: dggoodwin $
* $Revision: 1.1 $
* $Date: 2007/05/04 14:27:23 $
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology

View file

@ -10,9 +10,9 @@
* from the ctml tree structures.
*/
/* $Author: hkmoffa $
* $Revision: 1.10 $
* $Date: 2009/03/13 03:23:20 $
/* $Author$
* $Revision$
* $Date$
*/
// Copyright 2002 California Institute of Technology
@ -50,32 +50,32 @@ using namespace std;
namespace Cantera {
//! these are all used to check for duplicate reactions
class rxninfo {
public:
//! rdata
std::vector< std::map<int, doublereal> > m_rdata;
//! string name
std::vector<std::string> m_eqn;
//! string vector of ints
std::vector<int> m_dup;
//! string vector of ints
std::vector<int> m_nr;
//! string vector of ints
std::vector<int> m_typ;
//! vector of bools.
std::vector<bool> m_rev;
~rxninfo() {
m_eqn.clear();
m_dup.clear();
m_nr.clear();
m_typ.clear();
m_rdata.clear();
}
bool installReaction(int i, const XML_Node& r, Kinetics* k,
std::string default_phase, int rule,
bool validate_rxn) ;
};
//! these are all used to check for duplicate reactions
class rxninfo {
public:
//! rdata
std::vector< std::map<int, doublereal> > m_rdata;
//! string name
std::vector<std::string> m_eqn;
//! string vector of ints
std::vector<int> m_dup;
//! string vector of ints
std::vector<int> m_nr;
//! string vector of ints
std::vector<int> m_typ;
//! vector of bools.
std::vector<bool> m_rev;
~rxninfo() {
m_eqn.clear();
m_dup.clear();
m_nr.clear();
m_typ.clear();
m_rdata.clear();
}
bool installReaction(int i, const XML_Node& r, Kinetics* k,
std::string default_phase, int rule,
bool validate_rxn) ;
};
@ -266,29 +266,29 @@ public:
* Check to see if reaction orders have been specified.
*/
if (rp == 1 && rxn.hasChild("order")) {
vector<XML_Node*> ord;
rxn.getChildren("order",ord);
int norder = static_cast<int>(ord.size());
int loc;
doublereal forder;
for (int nn = 0; nn < norder; nn++) {
const XML_Node& oo = *ord[nn];
string sp = oo["species"];
loc = speciesMap[sp];
if (loc == 0)
throw CanteraError("getReagents",
"reaction order specified for non-reactantt: "
+sp);
forder = fpValue(oo());
if (forder < 0.0) {
throw CanteraError("getReagents",
"reaction order must be non-negative");
}
// replace the stoichiometric coefficient
// stored above in 'order' with the specified
// reaction order
order[loc-1] = forder;
}
vector<XML_Node*> ord;
rxn.getChildren("order",ord);
int norder = static_cast<int>(ord.size());
int loc;
doublereal forder;
for (int nn = 0; nn < norder; nn++) {
const XML_Node& oo = *ord[nn];
string sp = oo["species"];
loc = speciesMap[sp];
if (loc == 0)
throw CanteraError("getReagents",
"reaction order specified for non-reactantt: "
+sp);
forder = fpValue(oo());
if (forder < 0.0) {
throw CanteraError("getReagents",
"reaction order must be non-negative");
}
// replace the stoichiometric coefficient
// stored above in 'order' with the specified
// reaction order
order[loc-1] = forder;
}
}
return true;
}
@ -314,117 +314,117 @@ public:
E /= GasConstant;
}
/**
* getStick() processes the XML element called Stick that specifies
* the sticking coefficient reaction. This routine will
* translate the sticking coefficient value into a "normal"
* rate constant for the surface reaction.
*
* Output
* -----------
* Output is the normal Arrhenius expressions for a surface
* reaction rate constant.
*
* A - units such that rate of rxn has kmol/m^2/s when
* A is multiplied by activity concentrations of
* reactants in the normal manner.
* n - unitless
* E - Units 1/Kelvin
/**
* getStick() processes the XML element called Stick that specifies
* the sticking coefficient reaction. This routine will
* translate the sticking coefficient value into a "normal"
* rate constant for the surface reaction.
*
* Output
* -----------
* Output is the normal Arrhenius expressions for a surface
* reaction rate constant.
*
* A - units such that rate of rxn has kmol/m^2/s when
* A is multiplied by activity concentrations of
* reactants in the normal manner.
* n - unitless
* E - Units 1/Kelvin
*/
static void getStick(const XML_Node& node, Kinetics& kin,
ReactionData& r, doublereal& A, doublereal& b, doublereal& E) {
int nr = r.reactants.size();
int k, klocal, not_surf = 0;
int np = 0;
doublereal f = 1.0;
doublereal order;
/*
* species is the name of the special reactant whose surface
* flux rate will be calculated.
* isp = species # in the local phase
* ispKinetics = species # in the kinetics object
* ispPhaseIndex = phase # of the special species
*/
static void getStick(const XML_Node& node, Kinetics& kin,
ReactionData& r, doublereal& A, doublereal& b, doublereal& E) {
int nr = r.reactants.size();
int k, klocal, not_surf = 0;
int np = 0;
doublereal f = 1.0;
doublereal order;
/*
* species is the name of the special reactant whose surface
* flux rate will be calculated.
* isp = species # in the local phase
* ispKinetics = species # in the kinetics object
* ispPhaseIndex = phase # of the special species
*/
string spname = node["species"];
ThermoPhase& th = kin.speciesPhase(spname);
int isp = th.speciesIndex(spname);
int ispKinetics = kin.kineticsSpeciesIndex(spname);
int ispPhaseIndex = kin.speciesPhaseIndex(ispKinetics);
string spname = node["species"];
ThermoPhase& th = kin.speciesPhase(spname);
int isp = th.speciesIndex(spname);
int ispKinetics = kin.kineticsSpeciesIndex(spname);
int ispPhaseIndex = kin.speciesPhaseIndex(ispKinetics);
double ispMW = th.molecularWeights()[isp];
double sc;
double ispMW = th.molecularWeights()[isp];
double sc;
// loop over the reactants
for (int n = 0; n < nr; n++) {
k = r.reactants[n];
order = r.order[n]; // stoich coeff
// loop over the reactants
for (int n = 0; n < nr; n++) {
k = r.reactants[n];
order = r.rorder[n]; // stoich coeff
// get the phase species k belongs to
np = kin.speciesPhaseIndex(k);
const ThermoPhase& p = kin.thermo(np);
// get the phase species k belongs to
np = kin.speciesPhaseIndex(k);
const ThermoPhase& p = kin.thermo(np);
// get the local index of species k in this phase
klocal = p.speciesIndex(kin.kineticsSpeciesName(k));
// get the local index of species k in this phase
klocal = p.speciesIndex(kin.kineticsSpeciesName(k));
// if it is a surface species, divide f by the standard
// concentration for this species, in order to convert
// from concentration units used in the law of mass action
// to coverages used in the sticking probability
// expression
if (p.eosType() == cSurf || p.eosType() == cEdge) {
sc = p.standardConcentration(klocal);
f /= pow(sc, order);
}
// Otherwise:
else {
// We only allow one species to be in the phase
// containing the special sticking coefficient
// species.
if (ispPhaseIndex == np) {
not_surf++;
}
// Other bulk phase species on the other side
// of ther interface are treated like surface
// species.
else {
sc = p.standardConcentration(klocal);
f /= pow(sc, order);
}
}
}
if (not_surf != 1) {
throw CanteraError("getStick",
"reaction probabilities can only be used in "
"reactions with exactly 1 gas/liquid species.");
}
doublereal cbar = sqrt(8.0*GasConstant/(Pi*ispMW));
A = 0.25 * getFloat(node, "A", "toSI") * cbar * f;
b = getFloat(node, "b") + 0.5;
E = getFloat(node, "E", "actEnergy");
E /= GasConstant;
}
static void getCoverageDependence(const node_t& node,
thermo_t& surfphase, ReactionData& rdata) {
vector<XML_Node*> cov;
node.getChildren("coverage", cov);
int k, nc = static_cast<int>(cov.size());
doublereal e;
string spname;
if (nc > 0) {
for (int n = 0; n < nc; n++) {
const XML_Node& cnode = *cov[n];
spname = cnode["species"];
k = surfphase.speciesIndex(spname);
rdata.cov.push_back(doublereal(k));
rdata.cov.push_back(getFloat(cnode, "a"));
rdata.cov.push_back(getFloat(cnode, "m"));
e = getFloat(cnode, "e", "actEnergy");
rdata.cov.push_back(e/GasConstant);
}
}
// if it is a surface species, divide f by the standard
// concentration for this species, in order to convert
// from concentration units used in the law of mass action
// to coverages used in the sticking probability
// expression
if (p.eosType() == cSurf || p.eosType() == cEdge) {
sc = p.standardConcentration(klocal);
f /= pow(sc, order);
}
// Otherwise:
else {
// We only allow one species to be in the phase
// containing the special sticking coefficient
// species.
if (ispPhaseIndex == np) {
not_surf++;
}
// Other bulk phase species on the other side
// of ther interface are treated like surface
// species.
else {
sc = p.standardConcentration(klocal);
f /= pow(sc, order);
}
}
}
if (not_surf != 1) {
throw CanteraError("getStick",
"reaction probabilities can only be used in "
"reactions with exactly 1 gas/liquid species.");
}
doublereal cbar = sqrt(8.0*GasConstant/(Pi*ispMW));
A = 0.25 * getFloat(node, "A", "toSI") * cbar * f;
b = getFloat(node, "b") + 0.5;
E = getFloat(node, "E", "actEnergy");
E /= GasConstant;
}
static void getCoverageDependence(const node_t& node,
thermo_t& surfphase, ReactionData& rdata) {
vector<XML_Node*> cov;
node.getChildren("coverage", cov);
int k, nc = static_cast<int>(cov.size());
doublereal e;
string spname;
if (nc > 0) {
for (int n = 0; n < nc; n++) {
const XML_Node& cnode = *cov[n];
spname = cnode["species"];
k = surfphase.speciesIndex(spname);
rdata.cov.push_back(doublereal(k));
rdata.cov.push_back(getFloat(cnode, "a"));
rdata.cov.push_back(getFloat(cnode, "m"));
e = getFloat(cnode, "e", "actEnergy");
rdata.cov.push_back(e/GasConstant);
}
}
}
//! Get falloff parameters for a reaction.
@ -434,9 +434,9 @@ public:
*
*
* @verbatim
<falloff type="Troe"> 0.5 73.2 5000. 9999. </falloff>
@endverbatim
*/
<falloff type="Troe"> 0.5 73.2 5000. 9999. </falloff>
@endverbatim
*/
static void getFalloff(const node_t& f, ReactionData& rdata) {
string type = f["type"];
vector<string> p;
@ -469,7 +469,7 @@ public:
}
else {
throw CanteraError("getFalloff()", "Troe parameterization is specified by number of pararameters, "
+ int2str(np) + ", is not equal to 3 or 4");
+ int2str(np) + ", is not equal to 3 or 4");
}
} else if (type == "SRI") {
if (np == 5) {
@ -487,7 +487,7 @@ public:
}
} else {
throw CanteraError("getFalloff()", "SRI parameterization is specified by number of pararameters, "
+ int2str(np) + ", is not equal to 3 or 5");
+ int2str(np) + ", is not equal to 3 or 5");
}
}
rdata.falloffParameters = c;
@ -645,8 +645,8 @@ public:
* @ingroup kineticsmgr
*/
bool rxninfo::installReaction(int i, const XML_Node& r, Kinetics* k,
string default_phase, int rule,
bool validate_rxn) {
string default_phase, int rule,
bool validate_rxn) {
Kinetics& kin = *k;
@ -701,7 +701,7 @@ public:
// get the reactants
bool ok = getReagents(r, kin, 1, default_phase, rdata.reactants,
rdata.rstoich, rdata.order, rule);
rdata.rstoich, rdata.rorder, rule);
//cout << "Reactants: " << endl;
//int npp = rdata.reactants.size();
//int nj;
@ -712,9 +712,8 @@ public:
/*
* Get the products. We store the id of products in rdata.products
*/
vector_fp dummy;
ok = ok && getReagents(r, kin, -1, default_phase, rdata.products,
rdata.pstoich, dummy, rule);
rdata.pstoich, rdata.porder, rule);
//cout << "Products: " << endl;npp = rdata.products.size();
//for (nj = 0; nj < npp; nj++) {
// cout << rdata.products[nj] << " " << rdata.pstoich[nj] << endl;
@ -749,6 +748,55 @@ public:
rdata.global = true;
}
/*
* Some reactions can be elementary reactions but have fractional
* stoichiometries wrt to some products and reactants. An
* example of these are solid reactions involving phase transformations.
* Species with fractional stoichiometries must be from single-species
* phases with unity activities. For these reactions set
* the bool isReversibleWithFrac to true.
*/
if (rdata.reversible == true) {
int np = rdata.products.size();
for (int i = 0; i < np; i++) {
int k = rdata.products[i];
double po = rdata.porder[i];
AssertTrace(po == rdata.pstoich[i]);
double chk = po - 1.0 * int(po);
if (chk != 0.0) {
/*
* put in a check here that k is a single species phase.
*/
thermo_t &thref = kin.speciesPhase(k);
if (thref.nSpecies() == 1) {
rdata.porder[i] = 0.0;
}
rdata.isReversibleWithFrac = true;
}
}
int nr = rdata.reactants.size();
for (int i = 0; i < nr; i++) {
int k = rdata.reactants[i];
double ro = rdata.rorder[i];
AssertTrace(ro == rdata.rstoich[i]);
double chk = ro - 1.0 * int(ro);
if (chk != 0.0) {
/*
* put in a check here that k is a single species phase.
*/
thermo_t &thref = kin.speciesPhase(k);
if (thref.nSpecies() == 1) {
rdata.rorder[i] = 0.0;
}
rdata.isReversibleWithFrac = true;
}
}
}
/*
* Search the reaction element for the attribute "type".
* If found, then branch on the type, to fill in appropriate
@ -934,7 +982,7 @@ public:
const XML_Node* r = allrxns[i];
if (r) {
if (_rxns->installReaction(itot, *r, &kin,
default_phase, rxnrule, check_for_duplicates)) ++itot;
default_phase, rxnrule, check_for_duplicates)) ++itot;
}
}
}
@ -968,7 +1016,7 @@ public:
*/
if ((rxid >= imin) && (rxid <= imax)) {
if (_rxns->installReaction(itot, *r, &kin,
default_phase, rxnrule, check_for_duplicates)) ++itot;
default_phase, rxnrule, check_for_duplicates)) ++itot;
}
}
}

View file

@ -10,9 +10,9 @@
* from the ctml tree structures.
*/
/*
* $Author: hkmoffa $
* $Revision: 1.2 $
* $Date: 2007/06/04 23:09:19 $
* $Author$
* $Revision$
* $Date$
*
*/

View file

@ -4,9 +4,9 @@
*/
/*
* $Author: dggoodwin $
* $Date: 2007/05/04 14:27:24 $
* $Revision: 1.1 $
* $Author$
* $Date$
* $Revision$
*
*/

View file

@ -2,7 +2,7 @@
* @file: solveSP.cpp Implicit surface site concentration solver
*/
/*
* $Id: solveSP.cpp,v 1.4 2008/12/17 17:09:37 hkmoffa Exp $
* $Id$
*/
/*
* Copywrite 2004 Sandia Corporation. Under the terms of Contract

View file

@ -4,7 +4,7 @@
* (see \ref chemkinetics and class \link Cantera::solveSP solveSP\endlink).
*/
/*
* $Id: solveSP.h,v 1.3 2007/12/30 04:19:38 dggoodwin Exp $
* $Id$
*/
/*
* Copywrite 2004 Sandia Corporation. Under the terms of Contract