added ArrheniusSum class

This commit is contained in:
Dave Goodwin 2004-07-29 22:31:33 +00:00
parent 3ec6010d51
commit 494913dfd9
5 changed files with 83 additions and 33 deletions

View file

@ -15,10 +15,6 @@
#include "utilities.h"
#include "RxnRates.h"
//#ifdef HAVE_INTEL_MKL
//#include "mkl_vml.h"
//#endif
#include "ct_defs.h"
#include "ctexceptions.h"
@ -128,31 +124,36 @@ namespace Cantera {
* This rate coefficient manager supports two parameterizations of
* any type.
*/
// template<class R1, class R2>
// class Rate2 : public RateCoeffMgr {
// public:
template<class R1, class R2>
class Rate2 {
public:
// Rate2(){}
// virtual ~Rate2(){}
Rate2(){}
virtual ~Rate2(){}
// virtual int install( int rxnNumber, int rateType, const vector_fp& c ) {
// if (rateType == R1::type())
// return m_r1.install(rxnNumber, rateType, c);
// else if (rateType == R2::type())
// return m_r2.install(rxnNumber, rateType, c);
// else
// throw UnknownRateCoefficient();
// return -1;
// }
int install( int rxnNumber, int rateType, int m,
const doublereal* c) {
if (rateType == R1::type())
return m_r1.install(rxnNumber, rateType, m, c);
else if (rateType == R2::type())
return m_r2.install(rxnNumber, rateType, m, c);
else
throw CanteraError("Rate2::install",
"unknown rate coefficient type");
return -1;
}
// virtual void update(doublereal T, doublereal logT, vector_fp& values) {
// m_r1.update(T, logT, values);
// m_r2.update(T, logT, values);
// }
// protected:
// Rate1<R1> m_r1;
// Rate1<R2> m_r2;
// };
void update(doublereal T, doublereal logT,
doublereal* values) {
m_r1.update(T, logT, values);
m_r2.update(T, logT, values);
}
protected:
Rate1<R1> m_r1;
Rate1<R2> m_r2;
};
}

View file

@ -26,6 +26,8 @@ namespace Cantera {
Arrhenius() : m_b (0.0), m_E (0.0) {}
Arrhenius( int csize, const doublereal* c )
: m_b (c[1]), m_E (c[2]) { m_logA = log(c[0]);}
Arrhenius( doublereal A, doublereal b, doublereal E)
: m_b (b), m_E (E) { m_logA = log(A);}
void update_C(const doublereal* c) {}
@ -55,6 +57,52 @@ namespace Cantera {
};
class ArrheniusSum {
public:
static int type(){ return ARRHENIUS_SUM; }
ArrheniusSum() : m_nterms(0) {}
ArrheniusSum( int csize, const doublereal* c ) {
m_nterms = 0;
addArrheniusTerm(c[0], c[1], c[2]);
}
void addArrheniusTerm(doublereal A, doublereal b, doublereal E) {
m_terms.push_back(Arrhenius(A, b, E));
m_nterms++;
}
void update_C(const doublereal* c) {}
doublereal update(doublereal logT, doublereal recipT) const {
int n;
doublereal f, fexp = 0.0;
for (n = 0; n < m_nterms; n++) {
f = m_terms[n].update(logT, recipT);
fexp += exp(f);
}
return log(fexp);
}
doublereal update_dT(doublereal logT, doublereal recipT) const {
throw CanteraError("ArrheniusSum::update_dT","not implemented.");
}
void writeUpdateRHS(ostream& s) const {
;
}
//doublereal activationEnergy_R() const {
// return m_E;
//}
static bool alwaysComputeRate() { return true;}
protected:
vector<Arrhenius> m_terms;
int m_nterms;
};
/**
* An Arrhenius rate with coverage-dependent terms.

View file

@ -572,7 +572,7 @@ namespace Cantera {
db = diag - nc;
rb[0] = xb[3]; // zero Lambda
rb[2] = xb[2] - xb[2 - nc]; // zero dT/dz
rb[2] = xb[2] - m_temp; //xb[2] - xb[2 - nc]; // zero dT/dz
for (k = 5; k < nc; k++) {
rb[k] = xb[k] - m_yres[k-4]; // fixed Y
}
@ -585,7 +585,7 @@ namespace Cantera {
XML_Node& outlt = o.addChild("domain");
outlt.addAttribute("id",id());
outlt.addAttribute("points",1);
outlt.addAttribute("type","outletcomp");
outlt.addAttribute("type","outletres");
outlt.addAttribute("components",nComponents());
}

View file

@ -67,6 +67,7 @@ namespace Cantera {
const int LANDAUTELLER = 2;
const int TSTRATE = 3;
const int SURF_ARRHENIUS = 4;
const int ARRHENIUS_SUM = 5;
//@}

View file

@ -7,7 +7,7 @@ namespace Cantera {
m_integ(0), m_time(0.0), m_init(false),
m_nv(0), m_rtol(1.0e-9), m_atols(1.0e-15),
m_maxstep(-1.0),
m_verbose(true)
m_verbose(false)
{
m_integ = new CVodeInt;
@ -59,8 +59,8 @@ namespace Cantera {
void ReactorNet::advance(doublereal time) {
if (!m_init) {
//if (m_maxstep < 0.0)
m_maxstep = time;// - m_time;
if (m_maxstep < 0.0)
m_maxstep = time - m_time;
initialize();
}
m_integ->integrate(time);
@ -70,8 +70,8 @@ namespace Cantera {
double ReactorNet::step(doublereal time) {
if (!m_init) {
//if (m_maxstep < 0.0)
m_maxstep = time;// - m_time;
if (m_maxstep < 0.0)
m_maxstep = time - m_time;
initialize();
}
m_time = m_integ->step(time);