From 799b9c02e26b18a1414c151b895475a7857515f2 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Sat, 6 May 2006 15:34:18 +0000 Subject: [PATCH] support for constant-pressure reactors --- Cantera/clib/src/ctreactor.cpp | 3 +++ Cantera/cxx/include/zerodim.h | 3 +++ Cantera/python/Cantera/Reactor.py | 32 ++++++++++++++++++++++++++ Cantera/src/CVodesIntegrator.cpp | 16 +++++++++++++ Cantera/src/CVodesIntegrator.h | 1 + Cantera/src/FuncEval.h | 6 +++-- Cantera/src/Makefile.in | 4 ++++ Cantera/src/Mu0Poly.h | 5 ++-- Cantera/src/NasaPoly1.h | 6 ++--- Cantera/src/ShomatePoly.h | 2 +- Cantera/src/StoichManager.h | 2 +- Cantera/src/importCTML.h | 8 +------ Cantera/src/transport/MixTransport.cpp | 2 +- 13 files changed, 73 insertions(+), 17 deletions(-) diff --git a/Cantera/clib/src/ctreactor.cpp b/Cantera/clib/src/ctreactor.cpp index 9ce89676d..06d34d58e 100755 --- a/Cantera/clib/src/ctreactor.cpp +++ b/Cantera/clib/src/ctreactor.cpp @@ -2,6 +2,7 @@ // Cantera includes #include "zeroD/Reactor.h" #include "zeroD/FlowReactor.h" +#include "zeroD/ConstPressureReactor.h" #include "zeroD/ReactorNet.h" #include "zeroD/Reservoir.h" #include "zeroD/Wall.h" @@ -74,6 +75,8 @@ extern "C" { r = new Reactor(); else if (type == FlowReactorType) r = new FlowReactor(); + else if (type == ConstPressureReactorType) + r = new ConstPressureReactor(); else if (type == ReservoirType) r = new Reservoir(); else diff --git a/Cantera/cxx/include/zerodim.h b/Cantera/cxx/include/zerodim.h index c6673d03a..7f36d37ba 100644 --- a/Cantera/cxx/include/zerodim.h +++ b/Cantera/cxx/include/zerodim.h @@ -5,6 +5,9 @@ #include "kernel/zeroD/Reservoir.h" #include "kernel/zeroD/Wall.h" #include "kernel/zeroD/flowControllers.h" +#include "kernel/zeroD/FlowReactor.h" +#include "kernel/zeroD/ConstPressureReactor.h" + using namespace CanteraZeroD; #endif diff --git a/Cantera/python/Cantera/Reactor.py b/Cantera/python/Cantera/Reactor.py index e45917a5a..8317e3038 100644 --- a/Cantera/python/Cantera/Reactor.py +++ b/Cantera/python/Cantera/Reactor.py @@ -417,6 +417,38 @@ class FlowReactor(ReactorBase): _cantera.flowReactor_setMassFlowRate(self.__reactor_id, mdot) +class ConstPressureReactor(ReactorBase): + """ + """ + def __init__(self, contents = None, name = '', + volume = 1.0, energy = 'on', + mdot = -1.0, + verbose = 0): + """ + contents - Reactor contents. If not specified, the reactor is + initially empty. In this case, call method 'insert' to specify + the contents. + + name - Used only to identify this reactor in output. If not + specified, defaults to 'Reactor_n', where n is an integer + assigned in the order Reactor objects are created. + + volume - Initial reactor volume. Defaults to 1 m^3. + + energy - Set to 'on' or 'off'. If set to 'off', the energy + equation is not solved, and the temperature is held at its + initial value. The default in 'on'. + + verbose - if set to a non-zero value, additional diagnostic + information will be printed. + """ + global _reactorcount + if name == '': + name = 'ConstPressureReactor_'+`_reactorcount` + _reactorcount += 1 + ReactorBase.__init__(self, contents = contents, name = name, + volume = volume, energy = energy, + verbose = verbose, type = 4) class Reservoir(ReactorBase): diff --git a/Cantera/src/CVodesIntegrator.cpp b/Cantera/src/CVodesIntegrator.cpp index 9fe7b2c85..6f509b5b1 100644 --- a/Cantera/src/CVodesIntegrator.cpp +++ b/Cantera/src/CVodesIntegrator.cpp @@ -11,8 +11,10 @@ #include using namespace std; +#define OLD_SUNDIALS // sundials includes +#ifdef OLD_SUNDIALS #include #include #include @@ -21,6 +23,16 @@ using namespace std; #include #include #include +#else +#include +#include +#include +#include +#include +#include +//#include +#include +#endif inline static N_Vector nv(void* x) { return reinterpret_cast(x); @@ -109,7 +121,11 @@ namespace Cantera { if (m_cvode_mem) { if (m_np > 0) CVodeSensFree(m_cvode_mem); +#ifdef OLD_SUNDIALS CVodeFree(m_cvode_mem); +#else + CVodeFree(&m_cvode_mem); +#endif } if (m_y) N_VDestroy_Serial(nv(m_y)); if (m_abstol) N_VDestroy_Serial(nv(m_abstol)); diff --git a/Cantera/src/CVodesIntegrator.h b/Cantera/src/CVodesIntegrator.h index 1753d2b44..7a5b997c1 100644 --- a/Cantera/src/CVodesIntegrator.h +++ b/Cantera/src/CVodesIntegrator.h @@ -26,6 +26,7 @@ #include #include + namespace Cantera { class FuncData; diff --git a/Cantera/src/FuncEval.h b/Cantera/src/FuncEval.h index 196df8b98..d88181533 100755 --- a/Cantera/src/FuncEval.h +++ b/Cantera/src/FuncEval.h @@ -23,7 +23,7 @@ namespace Cantera { * Classes derived from FuncEval evaluate the right-hand-side function * \f$ \vec{F}(t,\vec{y})\f$ in * \f[ - * \dot\vec{y} = \vec{F}(t,\vec{y}). + * \dot{\vec{y}} = \vec{F}(t,\vec{y}). * \f] * @ingroup odeGroup */ @@ -50,7 +50,9 @@ namespace Cantera { */ virtual void getInitialConditions(double t0, size_t leny, double* y)=0; - /** Number of equations. */ + /** + * Number of equations. + */ virtual int neq()=0; /// Number of parameters. diff --git a/Cantera/src/Makefile.in b/Cantera/src/Makefile.in index fb5aaf856..deb6fb116 100755 --- a/Cantera/src/Makefile.in +++ b/Cantera/src/Makefile.in @@ -216,7 +216,9 @@ clean: (if test -d SunWS_cache ; then \ $(RM) -rf SunWS_cache ; \ fi ) +ifeq (@WITH_REACTORS@, 1) cd zeroD; @MAKE@ clean +endif cd oneD; @MAKE@ clean cd converters; @MAKE@ clean cd transport; @MAKE@ clean @@ -226,7 +228,9 @@ depends: $(DEPENDS) cat *.d > .depends $(RM) $(DEPENDS) cd oneD; @MAKE@ depends +ifeq (@WITH_REACTORS@, 1) cd zeroD; @MAKE@ depends +endif cd converters; @MAKE@ depends cd transport; @MAKE@ depends ifeq (@COMPILE_CATHERMO@, 1) diff --git a/Cantera/src/Mu0Poly.h b/Cantera/src/Mu0Poly.h index ddb3f09d1..9da8ba1ae 100644 --- a/Cantera/src/Mu0Poly.h +++ b/Cantera/src/Mu0Poly.h @@ -1,7 +1,8 @@ /** * @file Mu0Poly.h - * - * $Author$ + */ + +/* $Author$ * $Revision$ * $Date$ */ diff --git a/Cantera/src/NasaPoly1.h b/Cantera/src/NasaPoly1.h index dcfce287a..d639d7269 100755 --- a/Cantera/src/NasaPoly1.h +++ b/Cantera/src/NasaPoly1.h @@ -1,3 +1,6 @@ +#ifndef CT_NASAPOLY1_H +#define CT_NASAPOLY1_H + /** * @file NasaPoly1.h */ @@ -10,9 +13,6 @@ // Copyright 2001 California Institute of Technology -#ifndef CT_NASAPOLY1_H -#define CT_NASAPOLY1_H - #include "global.h" #include "SpeciesThermoInterpType.h" diff --git a/Cantera/src/ShomatePoly.h b/Cantera/src/ShomatePoly.h index fe979d424..4c5815256 100755 --- a/Cantera/src/ShomatePoly.h +++ b/Cantera/src/ShomatePoly.h @@ -25,7 +25,7 @@ namespace Cantera { * \hat c_p(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2} * \f] * \f[ - * \hat h^0(T)} = A t + \frac{B t^2}{2} + \frac{C t^3}{3} + * \hat h^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3} + \frac{D t^4}{4} - \frac{E}{t} + F. * \f] * \f[ diff --git a/Cantera/src/StoichManager.h b/Cantera/src/StoichManager.h index d80068a68..c8e7f5e94 100755 --- a/Cantera/src/StoichManager.h +++ b/Cantera/src/StoichManager.h @@ -43,7 +43,7 @@ namespace Cantera { * \f[ * \dot C_k = \sum_k \nu^{(p)}_{k,i} R_i * \f] - * where \f$ \nu^{(p)_{k,i}}$ is the product-side stoichiometric + * where \f$ \nu^{(p)_{k,i}} \f$ is the product-side stoichiometric * coefficient of species \a k in reaction \a i. * This could be done be straightforward matrix multiplication, but would be inefficient, since most of the matrix elements of \f$ \nu^{(p)}_{k,i} \f$ are zero. We could do better by using sparse-matrix algorithms to compute this product. diff --git a/Cantera/src/importCTML.h b/Cantera/src/importCTML.h index e5dd00547..0e871c8ef 100755 --- a/Cantera/src/importCTML.h +++ b/Cantera/src/importCTML.h @@ -54,13 +54,7 @@ namespace Cantera { */ void checkRxnElementBalance(Kinetics& kin, const ReactionData &rdata, doublereal errorTolerance = 1.0e-3); - /** - * Extract the rate coefficient for a reaction from the xml node, kf. - * kf should point to a XML element named "rateCoeff". - * rdata is the partially filled ReactionData object for the reaction. - * This function will fill in more fields in the ReactionData object. - * - */ + void getRateCoefficient(const XML_Node& kf, kinetics_t& kin, ReactionData& rdata, int negA); diff --git a/Cantera/src/transport/MixTransport.cpp b/Cantera/src/transport/MixTransport.cpp index df336cc84..79c9b3251 100755 --- a/Cantera/src/transport/MixTransport.cpp +++ b/Cantera/src/transport/MixTransport.cpp @@ -133,7 +133,7 @@ namespace Cantera { * and * \f[ * \Phi_{k,j} = \frac{\left[1 - * + \sqrt\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}\right)}\right]^2} + * + \sqrt\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)\right]^2} * {\sqrt{8}\sqrt{1 + M_k/M_j}} * \f] * @see updateViscosity_T();