From 4cdb8aa015b8890d62ecd3b673857e92ad84c11e Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 28 Aug 2003 14:22:15 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/python/Cantera/gases.py | 14 ++++++--- Cantera/python/examples/flame1.py | 2 +- Cantera/python/examples/flame2.py | 2 +- Cantera/python/examples/reactor1.py | 2 +- Cantera/python/examples/stflame1.py | 2 +- Cantera/python/examples/stflame2.py | 2 +- Cantera/src/oneD/MultiJac.cpp | 3 +- Cantera/src/oneD/MultiJac.h | 2 +- Cantera/src/oneD/StFlow.cpp | 2 +- Cantera/src/zeroD/Reactor.cpp | 6 ++-- Cantera/src/zeroD/ReactorBase.cpp | 12 ++------ Cantera/src/zeroD/ReactorBase.h | 38 +++++++++---------------- Cantera/src/zeroD/Wall.cpp | 44 ++++++++++++++++++++++------- Cantera/src/zeroD/Wall.h | 8 ++++-- 14 files changed, 79 insertions(+), 60 deletions(-) diff --git a/Cantera/python/Cantera/gases.py b/Cantera/python/Cantera/gases.py index 7fc6f1dec..a40d4c768 100755 --- a/Cantera/python/Cantera/gases.py +++ b/Cantera/python/Cantera/gases.py @@ -35,18 +35,24 @@ def IdealGasMix(src="", id = ""): ## ext = '' return Solution(src=src,id=id) -def GRI30(): +def GRI30(transport = ""): """Return a Solution instance implementing reaction mechanism GRI-Mech 3.0.""" - return Solution(src="gri30.xml", id="gri30_hw") + if transport == "": + return Solution(src="gri30.cti", id="gri30") + elif transport == "Mix": + return Solution(src="gri30.cti", id="gri30_mix") + elif transport == "Multi": + return Solution(src="gri30.cti", id="gri30_multi") + def Air(): """Return a Solution instance implementing the O/N/Ar portion of reaction mechanism GRI-Mech 3.0. The initial composition is set to that of air""" - return Solution(src="air.xml", id="air") + return Solution(src="air.cti", id="air") def Argon(): """Return a Solution instance representing pure argon.""" - return Solution(src="argon.xml#argon") + return Solution(src="argon.cti", id="argon") diff --git a/Cantera/python/examples/flame1.py b/Cantera/python/examples/flame1.py index 98c0f0151..7517d7347 100755 --- a/Cantera/python/examples/flame1.py +++ b/Cantera/python/examples/flame1.py @@ -9,7 +9,7 @@ import os from Cantera import units from Cantera.flame import * -gas = IdealGasMix(src = 'h2o2.xml', transport='Mix') +gas = IdealGasMix(src = 'h2o2.cti') # create a burner-stabilized flame in the domain z = 0 to z = 20 cm, # define the fuel to be pure hydrogen, and the oxidizer to be diff --git a/Cantera/python/examples/flame2.py b/Cantera/python/examples/flame2.py index 3702bcf4e..2fe12cec9 100755 --- a/Cantera/python/examples/flame2.py +++ b/Cantera/python/examples/flame2.py @@ -7,7 +7,7 @@ from Cantera import units #from Cantera.gases import H_O_AR -gas = GRI30(transport = 'Mix') +gas = GRI30(transport='Mix') flame = BurnerFlame( domain = (0, 0.01), diff --git a/Cantera/python/examples/reactor1.py b/Cantera/python/examples/reactor1.py index 53de392a3..e8610bd19 100644 --- a/Cantera/python/examples/reactor1.py +++ b/Cantera/python/examples/reactor1.py @@ -29,6 +29,6 @@ for n in range(100): env.advance(time) print '%10.3e %10.3f %10.3f %14.6e' % (r.time(), r.temperature(), r.pressure(), r.intEnergy_mass()) + print env.pressure() -#print gri3 diff --git a/Cantera/python/examples/stflame1.py b/Cantera/python/examples/stflame1.py index 9053d6431..a4ecbc68a 100644 --- a/Cantera/python/examples/stflame1.py +++ b/Cantera/python/examples/stflame1.py @@ -11,7 +11,7 @@ from Cantera.flame import * # Import the hydrogen/oxygen reaction mechanism # The input file is in directory 'data/inputs'. -gas = IdealGasMix(src = 'h2o2.xml', transport='Mix') +gas = IdealGasMix('h2o2.cti') # Create a stagnation-point flame in the domain z = 0 (the inlet) to z diff --git a/Cantera/python/examples/stflame2.py b/Cantera/python/examples/stflame2.py index bb7cc903e..e1b444abf 100644 --- a/Cantera/python/examples/stflame2.py +++ b/Cantera/python/examples/stflame2.py @@ -11,7 +11,7 @@ from Cantera.flame import * from Cantera import units # start with only a hydrogen/oxygen mechanism -gas = IdealGasMix('h2o2.xml', transport='Mix') +gas = IdealGasMix('h2o2.cti') flame = StagnationFlame( domain = (0, 0.02), diff --git a/Cantera/src/oneD/MultiJac.cpp b/Cantera/src/oneD/MultiJac.cpp index 2687b3838..f23b483fa 100644 --- a/Cantera/src/oneD/MultiJac.cpp +++ b/Cantera/src/oneD/MultiJac.cpp @@ -43,6 +43,7 @@ namespace Cantera { ff *= 0.5; } m_atol = sqrt(ff); + m_rtol = 1.0e-5; } void MultiJac::updateTransient(doublereal rdt, integer* mask) { @@ -76,7 +77,7 @@ namespace Cantera { // perturb x(n) xsave = x0[ipt]; - dx = m_atol; + dx = m_atol + fabs(xsave)*m_rtol; x0[ipt] = xsave + dx; dx = x0[ipt] - xsave; rdx = 1.0/dx; diff --git a/Cantera/src/oneD/MultiJac.h b/Cantera/src/oneD/MultiJac.h index caf228722..cfb8e5f85 100644 --- a/Cantera/src/oneD/MultiJac.h +++ b/Cantera/src/oneD/MultiJac.h @@ -81,7 +81,7 @@ namespace Cantera { OneDim* m_resid; vector_fp m_r1; - doublereal m_atol; + doublereal m_rtol, m_atol; doublereal m_elapsed; vector_fp m_ssdiag; vector_int m_mask; diff --git a/Cantera/src/oneD/StFlow.cpp b/Cantera/src/oneD/StFlow.cpp index 7d76a0302..96749b43f 100644 --- a/Cantera/src/oneD/StFlow.cpp +++ b/Cantera/src/oneD/StFlow.cpp @@ -1047,7 +1047,7 @@ namespace Cantera { throw CanteraError("StFlow::restore","No solution with id = "+id); } - const XML_Node& flow = f->child("flowfield"); + const XML_Node& flow = f->child("domain"); f = &flow; //if (f->name() != "flowfield") { diff --git a/Cantera/src/zeroD/Reactor.cpp b/Cantera/src/zeroD/Reactor.cpp index 0e888530f..28d67c52f 100644 --- a/Cantera/src/zeroD/Reactor.cpp +++ b/Cantera/src/zeroD/Reactor.cpp @@ -277,7 +277,8 @@ namespace Cantera { for (n = 0; n < m_nsp; n++) { ydot[2+n] -= mdot_out * mf[n]; } - ydot[0] -= mdot_out * enthalpy; + if (m_energy) + ydot[0] -= mdot_out * enthalpy; } @@ -289,7 +290,8 @@ namespace Cantera { for (n = 0; n < m_nsp; n++) { ydot[2+n] += m_inlet[i]->massFlowRate(n); } - ydot[0] += mdot_in * m_inlet[i]->enthalpy_mass(); + if (m_energy) + ydot[0] += mdot_in * m_inlet[i]->enthalpy_mass(); } } } diff --git a/Cantera/src/zeroD/ReactorBase.cpp b/Cantera/src/zeroD/ReactorBase.cpp index 41a613983..7fe79270e 100644 --- a/Cantera/src/zeroD/ReactorBase.cpp +++ b/Cantera/src/zeroD/ReactorBase.cpp @@ -35,20 +35,12 @@ namespace Cantera { m_nwalls(0) {} -// void ReactorBase::setMixture(phase_t& mix, thermo_t& thermo){ -// m_mix = &mix; -// m_thermo = &thermo; -// m_nsp = m_mix->nSpecies(); +// void ReactorBase::resetState() { // m_mix->saveState(m_state); // m_enthalpy = m_thermo->enthalpy_mass(); // m_intEnergy = m_thermo->intEnergy_mass(); // m_pressure = m_thermo->pressure(); -// } - -// void ReactorBase::setPhase(phase_t& ph){ -// m_mix = &ph; -// m_nsp = m_mix->nSpecies(); -// m_mix->saveState(m_state); +// m_init = false; // } void ReactorBase::setThermoMgr(thermo_t& thermo){ diff --git a/Cantera/src/zeroD/ReactorBase.h b/Cantera/src/zeroD/ReactorBase.h index 43da1e3d9..c5ab3f9a7 100644 --- a/Cantera/src/zeroD/ReactorBase.h +++ b/Cantera/src/zeroD/ReactorBase.h @@ -75,8 +75,6 @@ namespace Cantera { * a pointer to this substance is stored, and as the integration * proceeds, the state of the substance is modified. */ - //void setMixture(phase_t& mix, thermo_t& thermo); - //void setPhase(phase_t& phase); void setThermoMgr(thermo_t& thermo); void addInlet(FlowDevice& inlet); @@ -106,28 +104,26 @@ namespace Cantera { //@} - /// return a reference to the mixture. - thermo_t& contents() { - return *m_mix; - } + void resetState(); - const thermo_t& contents() const { - return *m_mix; - } + /// return a reference to the contents. + thermo_t& contents() { return *m_mix; } + + const thermo_t& contents() const { return *m_mix; } doublereal residenceTime(); - //------------------------------------------------------ - - - /** @name Solution components. */ + /** + * @name Solution components. + * The values returned are those after the last call to advance + * or step. + */ //@{ /// the current time (s). doublereal time() const { return m_time; } - // property values after the last call to advance. doublereal volume() const { return m_vol; } doublereal density() const { return m_state[1]; } doublereal temperature() const { return m_state[0]; } @@ -139,23 +135,16 @@ namespace Cantera { doublereal massFraction(int k) const { return m_state[k+2]; } //@} - //----------------------------------------------------- - - int error(string msg) const { - cout << "Error: " << msg << endl; + writelog("Error: "+msg); return 1; } - //----------------------------------------------------- - - protected: int m_nsp; thermo_t* m_mix; thermo_t* m_thermo; -// kinetics_t* m_kin; doublereal m_time; doublereal m_vol, m_vol0; bool m_init; @@ -173,8 +162,9 @@ namespace Cantera { private: - void tilt() const { throw error("ReactorBase method called!"); } - + void tilt(string method="") const { + throw CanteraError("ReactorBase::"+method, + "ReactorBase method called!"); } }; } diff --git a/Cantera/src/zeroD/Wall.cpp b/Cantera/src/zeroD/Wall.cpp index 69597ec41..ca83472dd 100644 --- a/Cantera/src/zeroD/Wall.cpp +++ b/Cantera/src/zeroD/Wall.cpp @@ -28,22 +28,40 @@ namespace Cantera { return true; } - void Wall::setKinetics(Kinetics* left, - Kinetics* right) { - m_chem[0] = left; - m_chem[1] = right; - if (left) { - m_surf[0] = (SurfPhase*)&left->thermo(left->surfacePhaseIndex()); + /** Specify the kinetics managers for the surface mechanisms on + * the left side and right side of the wall. Enter 0 if there is + * no reaction mechanism. + */ + void Wall::setKinetics(Kinetics* left, Kinetics* right) { + m_chem[0] = left; + m_chem[1] = right; + int ileft = 0, iright = 0; + if (left) { + ileft = left->surfacePhaseIndex(); + if (ileft >= 0) { + m_surf[0] = (SurfPhase*)&left->thermo(ileft); m_nsp[0] = m_surf[0]->nSpecies(); } - if (right) { - m_surf[1] = (SurfPhase*)&right->thermo(right->surfacePhaseIndex()); + } + if (right) { + iright = right->surfacePhaseIndex(); + if (iright >= 0) { + m_surf[1] = (SurfPhase*)&right->thermo(iright); m_nsp[1] = m_surf[1]->nSpecies(); } - } + if (ileft < 0 || iright < 0) { + throw CanteraError("Wall::setKinetics", + "specified surface kinetics manager does not " + "represent a surface reaction mechanism."); + } + } - + /** + * The volume rate of change is given by + * \f[ \dot V = K A (P_{left} - P_{right}) + F(t) \f] + * where \f$ F(t) \f$ is a specified function of time. + */ doublereal Wall::vdot(doublereal t) { double rate1 = m_k * m_area * (m_left->pressure() - m_right->pressure()); @@ -51,6 +69,12 @@ namespace Cantera { return rate1; } + /** + * The heat flux is given by + * \f[ Q = h A (T_{left} - T_{right}) + G(t) \f] + * where h is the heat transfer coefficient, and + * \f$ G(t) \f$ is a specified function of time. + */ doublereal Wall::Q(doublereal t) { double q1 = (m_area * m_rrth) * (m_left->temperature() - m_right->temperature()); diff --git a/Cantera/src/zeroD/Wall.h b/Cantera/src/zeroD/Wall.h index 822bd0c5e..43d3e9eea 100644 --- a/Cantera/src/zeroD/Wall.h +++ b/Cantera/src/zeroD/Wall.h @@ -40,8 +40,8 @@ namespace Cantera { virtual ~Wall() {} /** - * Rate of volume change (kg/s). Positive value increases volume - * Of reactor on left, and decreases volume on right. + * Rate of volume change (kg/s). Positive value increases + * volume of reactor on left, and decreases volume on right. */ virtual doublereal vdot(doublereal t); virtual doublereal Q(doublereal t); @@ -57,8 +57,12 @@ namespace Cantera { /// Set the overall heat transfer coefficient [W/m^2/K]. void setHeatTransferCoeff(doublereal U) { m_rrth = U; } + /** Set the rate of volume change to a specified function.*/ void setExpansionRate(Func1* f=0) {if (f) m_vf = f;} + /** + * Set the expansion rate coefficient. + */ void setExpansionRateCoeff(doublereal k) {m_k = k;} /**