diff --git a/Cantera/src/RateCoeffMgr.h b/Cantera/src/RateCoeffMgr.h index cccfbc561..339c0ec87 100755 --- a/Cantera/src/RateCoeffMgr.h +++ b/Cantera/src/RateCoeffMgr.h @@ -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 Rate2 : public RateCoeffMgr { -// public: + template + 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 m_r1; -// Rate1 m_r2; -// }; + void update(doublereal T, doublereal logT, + doublereal* values) { + m_r1.update(T, logT, values); + m_r2.update(T, logT, values); + } + + protected: + + Rate1 m_r1; + Rate1 m_r2; + }; } diff --git a/Cantera/src/RxnRates.h b/Cantera/src/RxnRates.h index e4418e4a7..62eea65a8 100755 --- a/Cantera/src/RxnRates.h +++ b/Cantera/src/RxnRates.h @@ -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 m_terms; + int m_nterms; + }; + + /** * An Arrhenius rate with coverage-dependent terms. diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index 089ba18e9..71552be4f 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -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()); } diff --git a/Cantera/src/reaction_defs.h b/Cantera/src/reaction_defs.h index c078412fa..bac39a1ce 100755 --- a/Cantera/src/reaction_defs.h +++ b/Cantera/src/reaction_defs.h @@ -67,6 +67,7 @@ namespace Cantera { const int LANDAUTELLER = 2; const int TSTRATE = 3; const int SURF_ARRHENIUS = 4; + const int ARRHENIUS_SUM = 5; //@} diff --git a/Cantera/src/zeroD/ReactorNet.cpp b/Cantera/src/zeroD/ReactorNet.cpp index fd1a8b771..1bf91e9f3 100644 --- a/Cantera/src/zeroD/ReactorNet.cpp +++ b/Cantera/src/zeroD/ReactorNet.cpp @@ -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);