From d90c9efe6b3b9cdfddfae4c02f108d19146677d2 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Mon, 28 Nov 2005 00:28:56 +0000 Subject: [PATCH] *** empty log message *** --- .../matlab/cantera/1D/@Domain1D/setTolerances.m | 2 +- Cantera/matlab/cantera/1D/npflame_init.m | 2 +- Cantera/matlab/cantera/@Reactor/Reactor.m | 4 ++-- Cantera/matlab/cantera/Reservoir.m | 4 ++-- Cantera/matlab/cantera/examples/flame.m | 6 +++--- Cantera/matlab/cantera/examples/rankine.m | 11 +++++++++-- Cantera/matlab/cantera/examples/surfreactor.m | 7 +++++-- Cantera/python/Cantera/Reactor.py | 14 +++++++------- Cantera/python/examples/reactors/reactor2.py | 2 +- Cantera/src/zeroD/ReactorNet.cpp | 3 +++ Cantera/src/zeroD/ReactorNet.h | 9 +++++++++ configure | 2 +- 12 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Cantera/matlab/cantera/1D/@Domain1D/setTolerances.m b/Cantera/matlab/cantera/1D/@Domain1D/setTolerances.m index ec2a5b23c..28cd490ed 100644 --- a/Cantera/matlab/cantera/1D/@Domain1D/setTolerances.m +++ b/Cantera/matlab/cantera/1D/@Domain1D/setTolerances.m @@ -16,7 +16,7 @@ if nargin == 5 end if strcmp(component,'default') - nc = nComponents(d) + nc = nComponents(d); for ii = 1:nc domain_methods(d.dom_id, 52, ii, rtol, atol, ityp); end diff --git a/Cantera/matlab/cantera/1D/npflame_init.m b/Cantera/matlab/cantera/1D/npflame_init.m index e0c0a0699..ce6467348 100644 --- a/Cantera/matlab/cantera/1D/npflame_init.m +++ b/Cantera/matlab/cantera/1D/npflame_init.m @@ -81,7 +81,7 @@ f = sqrt(a/(2.0*diff(ioxidizer))); x0 = massFlux(left)*dz/(massFlux(left) + massFlux(right)); -nz = nPoints(flow) +nz = nPoints(flow); for j = 1:nz x = zz(j); zeta = f*(x - x0); diff --git a/Cantera/matlab/cantera/@Reactor/Reactor.m b/Cantera/matlab/cantera/@Reactor/Reactor.m index 4909e1cab..c672e8aad 100644 --- a/Cantera/matlab/cantera/@Reactor/Reactor.m +++ b/Cantera/matlab/cantera/@Reactor/Reactor.m @@ -13,9 +13,9 @@ function x = Reactor(contents, typ) % if nargin == 0 contents = 0; - typ = 1; + typ = 2; elseif nargin == 1 - typ = 1; + typ = 2; elseif nargin > 2 error('too many arguments'); end diff --git a/Cantera/matlab/cantera/Reservoir.m b/Cantera/matlab/cantera/Reservoir.m index 8a71022ce..cfe648231 100644 --- a/Cantera/matlab/cantera/Reservoir.m +++ b/Cantera/matlab/cantera/Reservoir.m @@ -16,6 +16,6 @@ function r = Reservoir(contents) % See also: Reactor % if nargin == 0 - contents = 0 + contents = 0; end -r = Reactor(contents, 2); +r = Reactor(contents, 1); diff --git a/Cantera/matlab/cantera/examples/flame.m b/Cantera/matlab/cantera/examples/flame.m index 7d06d366a..772c6f7df 100644 --- a/Cantera/matlab/cantera/examples/flame.m +++ b/Cantera/matlab/cantera/examples/flame.m @@ -31,11 +31,11 @@ if ~isFlow(flow) error('flow object of wrong type.'); end -flametype = 0 +flametype = 0; if isSurface(right) - flametype = 1 + flametype = 1; elseif isInlet(right) - flametype = 3 + flametype = 3; end diff --git a/Cantera/matlab/cantera/examples/rankine.m b/Cantera/matlab/cantera/examples/rankine.m index 6c03b5aa0..b68951790 100644 --- a/Cantera/matlab/cantera/examples/rankine.m +++ b/Cantera/matlab/cantera/examples/rankine.m @@ -1,5 +1,12 @@ function [work, efficiency] = rankine(t1, p2, eta_pump, ... eta_turbine) +% +% RANKINE +% +% This example computes the efficiency of a simple vapor power +% cycle. +% +help rankine % create an object representing water w = Water; @@ -23,12 +30,12 @@ s3 = entropy_mass(w); heat_added = h3 - h2; % expand adiabatically back to the initial pressure -work = expand(w, p1, eta_turbine); +work = expand(w, p1, eta_turbine) h4 = enthalpy_mass(w); x4 = vaporFraction(w); % compute the efficiency -efficiency = (work - pump_work)/heat_added; +efficiency = (work - pump_work)/heat_added diff --git a/Cantera/matlab/cantera/examples/surfreactor.m b/Cantera/matlab/cantera/examples/surfreactor.m index 663667331..0b4f29ec3 100644 --- a/Cantera/matlab/cantera/examples/surfreactor.m +++ b/Cantera/matlab/cantera/examples/surfreactor.m @@ -48,10 +48,12 @@ setHeatTransferCoeff(w,1.0e1); % W/m2/K setExpansionRateCoeff(w, 1.0e2); network = ReactorNet({r}); +% setTolerances(network, 1.0e-8, 1.0e-12); t = 0; dt = 0.1; t0 = cputime; +p0 = pressure(r); names = {'CH4','CO','CO2','H2O'}; x = zeros([100 4]); for n = 1:100 @@ -59,7 +61,7 @@ for n = 1:100 advance(network, t); tim(n) = t; temp(n) = temperature(r); - pres(n) = pressure(r); + pres(n) = pressure(r) - p0; cov(n,:) = coverages(surf)'; x(n,:) = moleFraction(gas,names); end @@ -72,8 +74,9 @@ xlabel('Time (s)'); ylabel('Temperature (K)'); subplot(2,2,2); plot(tim,pres); +axis([0 5 -0.1 0.1]); xlabel('Time (s)'); -ylabel('Pressure (Pa)'); +ylabel('Delta Pressure (Pa)'); subplot(2,2,3); semilogy(tim,cov); xlabel('Time (s)'); diff --git a/Cantera/python/Cantera/Reactor.py b/Cantera/python/Cantera/Reactor.py index 52ccc5e0f..e45917a5a 100644 --- a/Cantera/python/Cantera/Reactor.py +++ b/Cantera/python/Cantera/Reactor.py @@ -29,8 +29,8 @@ class ReactorBase: type = -1, verbose = 0): """ See class 'Reactor' for a description of the constructor parameters. - The 'type' parameter specifies whether a Reactor (type = 1) or - Reservoir (type = 2) will be created. + The 'type' parameter specifies whether a Reactor (type = 2) or + Reservoir (type = 1) will be created. """ self.__reactor_id = _cantera.reactor_new(type) self._type = type @@ -245,21 +245,21 @@ class ReactorBase: """For internal use. Store a reference to 'inlet' so that it will not be deleted before this object.""" self._inlets.append(inlet) - if self._type == 1 and other._type == 2: + if self._type == 2 and other._type == 1: self._reservoirs.append(other) def _addOutlet(self, outlet, other): """For internal use. Store a reference to 'outlet' so that it will not be deleted before this object.""" self._outlets.append(outlet) - if self._type == 1 and other._type == 2: + if self._type == 2 and other._type == 1: self._reservoirs.append(other) def _addWall(self, wall, other): """For internal use. Store a reference to 'wall' so that it will not be deleted before this object.""" self._walls.append(wall) - if self._type == 1 and other._type == 2: + if self._type == 2 and other._type == 1: self._reservoirs.append(other) def syncContents(self): @@ -374,7 +374,7 @@ class Reactor(ReactorBase): _reactorcount += 1 ReactorBase.__init__(self, contents = contents, name = name, volume = volume, energy = energy, - verbose = verbose, type = 1) + verbose = verbose, type = 2) @@ -454,7 +454,7 @@ class Reservoir(ReactorBase): name = 'Reservoir_'+`_reservoircount` _reservoircount += 1 ReactorBase.__init__(self, contents = contents, - name = name, verbose = verbose, type = 2) + name = name, verbose = verbose, type = 1) def advance(self, time): """Deprecated. Do nothing.""" diff --git a/Cantera/python/examples/reactors/reactor2.py b/Cantera/python/examples/reactors/reactor2.py index 9968d8627..8ea267ef1 100644 --- a/Cantera/python/examples/reactors/reactor2.py +++ b/Cantera/python/examples/reactors/reactor2.py @@ -99,7 +99,7 @@ print 'Directory: '+os.getcwd() args = sys.argv if len(args) > 1 and args[1] == '-plot': try: - from matplotlib.matlab import * + from matplotlib.pylab import * clf subplot(2,2,1) plot(tm, temp[:,0],'g-',tm, temp[:,1],'b-') diff --git a/Cantera/src/zeroD/ReactorNet.cpp b/Cantera/src/zeroD/ReactorNet.cpp index 0d2a2b890..97794d5d7 100644 --- a/Cantera/src/zeroD/ReactorNet.cpp +++ b/Cantera/src/zeroD/ReactorNet.cpp @@ -32,6 +32,9 @@ namespace CanteraZeroD { if (m_verbose) { writelog("Initializing reactor network.\n"); } + if (m_nr == 0) + throw CanteraError("ReactorNet::initialize", + "no reactors in network!"); for (n = 0; n < m_nr; n++) { if (m_r[n]->type() >= ReactorType) { m_r[n]->initialize(t0); diff --git a/Cantera/src/zeroD/ReactorNet.h b/Cantera/src/zeroD/ReactorNet.h index 9e3583006..e3fcdc857 100644 --- a/Cantera/src/zeroD/ReactorNet.h +++ b/Cantera/src/zeroD/ReactorNet.h @@ -91,6 +91,15 @@ namespace CanteraZeroD { if (r->type() >= ReactorType) { m_r.push_back(r); m_nr++; + if (m_verbose) { + writelog("Adding reactor "+r->name()+"\n"); + } + } + else { + if (m_verbose) { + writelog("Not adding reactor "+r->name()+ + ", since type = "+int2str(r->type())); + } } } diff --git a/configure b/configure index 831569602..eba37d395 100755 --- a/configure +++ b/configure @@ -282,7 +282,7 @@ CXX=${CXX:=g++} CC=${CC:=gcc} # C++ compiler flags -CXXFLAGS=${CXXFLAGS:="-O0 -g -Wall"} +CXXFLAGS=${CXXFLAGS:="-O3 -Wall"} # the C++ flags required for linking. Uncomment if additional flags # need to be passed to the linker.