mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Changed name of Stack
class to Sim1D
class
This commit is contained in:
parent
9c87e5d571
commit
0c6920a98b
@ -20,7 +20,7 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
|
||||
% :param oxidizer:
|
||||
% String representing the oxidizer species. Most commonly O2.
|
||||
% :return:
|
||||
% Instance of :mat:func:`Stack` object representing the left
|
||||
% Instance of :mat:func:`Sim1D` object representing the left
|
||||
% inlet, flow, and right inlet.
|
||||
%
|
||||
|
||||
@ -166,7 +166,7 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
|
||||
%% Create the flame stack.
|
||||
% Set the profile of the flame with the estimated axial velocities,
|
||||
% radial velocities, temperature, and mass fractions calculated above.
|
||||
flame = Stack([left flow right]);
|
||||
flame = Sim1D([left flow right]);
|
||||
flame.setProfile(2, {'velocity', 'spread_rate'}, [zrel; u; v]);
|
||||
flame.setProfile(2, 'T', [zrel; t] );
|
||||
for n = 1:nsp
|
||||
|
@ -561,30 +561,6 @@ classdef Domain1D < handle
|
||||
callct('bdry_setMoleFractions', d.domainID, x);
|
||||
end
|
||||
|
||||
function setProfileD(d, n, p)
|
||||
% Set the profile of a component.
|
||||
%
|
||||
% d.setProfileD(n, p)
|
||||
%
|
||||
% Convenience function to allow an instance of :mat:func:`Domain1D` to
|
||||
% have a profile of its components set when it is part of a :mat:func:`Stack`.
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param n:
|
||||
% Integer index of component, vector of component indices, string
|
||||
% of component name, or cell array of strings of component names.
|
||||
% :param p:
|
||||
% n x 2 array, whose columns are the relative (normalized) positions
|
||||
% and the component values at those points. The number of positions
|
||||
% ``n`` is arbitrary.
|
||||
%
|
||||
if d.stack == 0
|
||||
error('Install domain in stack before calling setProfile.');
|
||||
end
|
||||
d.stack.setProfile(d.domainIndex, n, p);
|
||||
end
|
||||
|
||||
function setSteadyTolerances(d, component, rtol, atol)
|
||||
% Set the steady-state tolerances.
|
||||
%
|
||||
|
@ -1,9 +1,9 @@
|
||||
classdef Stack < handle
|
||||
% Stack Class
|
||||
classdef Sim1D < handle
|
||||
% Sim1D Class
|
||||
%
|
||||
% s = Stack(domains)
|
||||
% s = Sim1D(domains)
|
||||
%
|
||||
% A stack object is a container for one-dimensional domains,
|
||||
% A Sim1D object is a container for one-dimensional domains,
|
||||
% which are instances of class Domain1D. The domains are of two
|
||||
% types - extended domains, and connector domains.
|
||||
%
|
||||
@ -12,24 +12,24 @@ classdef Stack < handle
|
||||
% :param domains:
|
||||
% Vector of domain instances
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% Instance of class :mat:func:`Sim1D`
|
||||
%
|
||||
|
||||
properties (SetAccess = immutable)
|
||||
|
||||
stID % ID of the stack.
|
||||
stID % ID of the Sim1D object.
|
||||
|
||||
domains % Domain instances contained within the Stack object.
|
||||
domains % Domain instances contained within the Sim1D object.
|
||||
end
|
||||
|
||||
properties (SetAccess = protected)
|
||||
|
||||
% The index of a domain in a stack given its name.
|
||||
% The index of a domain in a Sim1D given its name.
|
||||
%
|
||||
% n = s.stackIndex(name)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param name:
|
||||
% If double, the value is :returned. Otherwise, the name is
|
||||
% looked up and its index is :returned.
|
||||
@ -42,7 +42,7 @@ classdef Stack < handle
|
||||
% z = s.grid(name)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% Instance of class :mat:func:`Sim1D`
|
||||
% :param name:
|
||||
% Name of the domain for which the grid
|
||||
% should be retrieved.
|
||||
@ -55,7 +55,7 @@ classdef Stack < handle
|
||||
% r = s.resid(domain, rdt, count)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param domain:
|
||||
% Name of the domain.
|
||||
% :param rdt:
|
||||
@ -66,9 +66,9 @@ classdef Stack < handle
|
||||
end
|
||||
|
||||
methods
|
||||
%% Stack Class Constructor
|
||||
%% Sim1D Class Constructor
|
||||
|
||||
function s = Stack(domains)
|
||||
function s = Sim1D(domains)
|
||||
checklib;
|
||||
|
||||
s.stID = -1;
|
||||
@ -81,12 +81,12 @@ classdef Stack < handle
|
||||
end
|
||||
s.stID = callct('sim1D_new', nd, ids);
|
||||
else
|
||||
help(Stack);
|
||||
help(Sim1D);
|
||||
error('Wrong number of parameters.');
|
||||
end
|
||||
end
|
||||
|
||||
%% Stack Class Destructor
|
||||
%% Sim1D Class Destructor
|
||||
|
||||
function delete(s)
|
||||
% Delete the C++ Sim1D object.
|
||||
@ -94,7 +94,7 @@ classdef Stack < handle
|
||||
callct('sim1D_del', s.stID);
|
||||
end
|
||||
|
||||
%% Stack Utility Methods
|
||||
%% Sim1D Utility Methods
|
||||
|
||||
function display(s, fname)
|
||||
% Show all domains.
|
||||
@ -111,7 +111,7 @@ classdef Stack < handle
|
||||
% s.plotSolution(domain, component)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param domain:
|
||||
% Name of domain from which the component should be
|
||||
% retrieved.
|
||||
@ -138,7 +138,7 @@ classdef Stack < handle
|
||||
% See also: :mat:func:`save`
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% Instance of class :mat:func:`Sim1D`
|
||||
% :param fname:
|
||||
% File name of an XML file containing solution information
|
||||
% :param id:
|
||||
@ -156,7 +156,7 @@ classdef Stack < handle
|
||||
% can be used by :mat:func:`restore`
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% Instance of class :mat:func:`Sim1D`
|
||||
% :param fname:
|
||||
% File name where XML file should be written
|
||||
% :param id:
|
||||
@ -184,7 +184,7 @@ classdef Stack < handle
|
||||
% s.solution(domain, component)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param domain:
|
||||
% String name of the domain from which the solution is
|
||||
% desired.
|
||||
@ -225,7 +225,7 @@ classdef Stack < handle
|
||||
% s.solve(loglevel, refineGrid)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param loglevel:
|
||||
% Integer flag controlling the amount of diagnostic output.
|
||||
% Zero supresses all output, and 5 produces very verbose
|
||||
@ -247,13 +247,13 @@ classdef Stack < handle
|
||||
% each one.
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% Instance of class :mat:func:`Sim1D`
|
||||
%
|
||||
|
||||
callct('sim1D_writeStats', s.stID, 1);
|
||||
end
|
||||
|
||||
%% Stack Get Methods
|
||||
%% Sim1D Get Methods
|
||||
|
||||
function getInitialSoln(s)
|
||||
% Get the initial solution.
|
||||
@ -302,7 +302,7 @@ classdef Stack < handle
|
||||
end
|
||||
end
|
||||
|
||||
%% Stack Set Methods
|
||||
%% Sim1D Set Methods
|
||||
|
||||
function setFixedTemperature(s, T)
|
||||
% Set the temperature used to fix the spatial location of a
|
||||
@ -326,7 +326,7 @@ classdef Stack < handle
|
||||
% s.setFlatProfile(domain, comp, v)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param domain:
|
||||
% Integer ID of the domain.
|
||||
% :param comp:
|
||||
@ -360,7 +360,7 @@ classdef Stack < handle
|
||||
% s.setMaxJacAge(ss_age, ts_age)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param ss_age:
|
||||
% Maximum age of the Jacobian for steady state analysis.
|
||||
% :param ts_age:
|
||||
@ -388,13 +388,13 @@ classdef Stack < handle
|
||||
% called at any time, but is usually used to set the initial
|
||||
% guess for the solution.
|
||||
%
|
||||
% Example (assuming 's' is an instance of class 'Stack'):
|
||||
% Example (assuming 's' is an instance of class 'Sim1D'):
|
||||
% >> zr = [0.0, 0.1, 0.2, 0.4, 0.8, 1.0];
|
||||
% >> v = [500, 650, 700, 730, 800, 900];
|
||||
% >> s.setProfile(1, 2, [zr, v]);
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param name:
|
||||
% Domain name.
|
||||
% :param comp:
|
||||
@ -444,7 +444,7 @@ classdef Stack < handle
|
||||
% s.setRefineCriteria(n, ratio, slope, curve, prune)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param ratio:
|
||||
% Maximum size ratio between adjacent cells.
|
||||
% :param slope:
|
||||
@ -500,7 +500,7 @@ classdef Stack < handle
|
||||
%
|
||||
% s.setValue(n, comp, localPoints, v)
|
||||
%
|
||||
% Example (assuming 's' is an instance of class 'Stack'):
|
||||
% Example (assuming 's' is an instance of class 'Sim1D'):
|
||||
%
|
||||
% setValue(s, 3, 5, 1, 5.6);
|
||||
%
|
||||
@ -508,10 +508,10 @@ classdef Stack < handle
|
||||
% in domain 3 to the value 5.6. Note that the local index
|
||||
% always begins at 1 at the left of each domain, independent of
|
||||
% the global index of the point, wchih depends on the location
|
||||
% of this domain in the stack.
|
||||
% of this domain in the Sim1D object.
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% Instance of class 'Sim1D'.
|
||||
% :param n:
|
||||
% Domain number.
|
||||
% :param comp:
|
||||
|
@ -131,10 +131,10 @@ surf.T = tsurf;
|
||||
% Once the component parts have been created, they can be assembled
|
||||
% to create the 1D simulation.
|
||||
|
||||
sim1D = Stack([inlt, flow, surf]);
|
||||
stack = Sim1D([inlt, flow, surf]);
|
||||
|
||||
% set the initial profiles.
|
||||
sim1D.setProfile(2, {'velocity', 'spread_rate', 'T'}, [0.0, 1.0 % z/zmax
|
||||
stack.setProfile(2, {'velocity', 'spread_rate', 'T'}, [0.0, 1.0 % z/zmax
|
||||
0.06, 0.0 % u
|
||||
0.0, 0.0 % V
|
||||
tinlet, tsurf]); % T
|
||||
@ -142,10 +142,10 @@ names = gas.speciesNames;
|
||||
|
||||
for k = 1:gas.nSpecies
|
||||
y = inlt.massFraction(k);
|
||||
sim1D.setProfile(2, names{k}, [0, 1; y, y]);
|
||||
stack.setProfile(2, names{k}, [0, 1; y, y]);
|
||||
end
|
||||
|
||||
sim1D
|
||||
stack
|
||||
|
||||
%setTimeStep(fl, 1.0e-5, [1, 3, 6, 12]);
|
||||
%setMaxJacAge(fl, 4, 5);
|
||||
@ -163,7 +163,7 @@ surf_phase.setMultiplier(0.0);
|
||||
gas.setMultiplier(0.0);
|
||||
|
||||
% solve the problem, refining the grid if needed
|
||||
sim1D.solve(1, refine_grid);
|
||||
stack.solve(1, refine_grid);
|
||||
|
||||
% now turn on the surface coverage equations, and turn the
|
||||
% chemistry on slowly
|
||||
@ -174,7 +174,7 @@ for iter=1:6
|
||||
mult = 10.0^(iter - 6);
|
||||
surf_phase.setMultiplier(mult);
|
||||
gas.setMultiplier(mult);
|
||||
sim1D.solve(1, refine_grid);
|
||||
stack.solve(1, refine_grid);
|
||||
end
|
||||
|
||||
% At this point, we should have the solution for the hydrogen/air
|
||||
@ -182,20 +182,20 @@ end
|
||||
inlt.setMoleFractions(comp2);
|
||||
|
||||
% set more stringent grid refinement criteria
|
||||
sim1D.setRefineCriteria(2, 100.0, 0.15, 0.2);
|
||||
stack.setRefineCriteria(2, 100.0, 0.15, 0.2);
|
||||
|
||||
% solve the problem for the final time
|
||||
sim1D.solve(loglevel, refine_grid);
|
||||
stack.solve(loglevel, refine_grid);
|
||||
|
||||
% show the solution
|
||||
sim1D
|
||||
stack
|
||||
|
||||
% save the solution
|
||||
sim1D.saveSoln('catcomb.xml', 'energy', ['solution with energy equation']);
|
||||
stack.saveSoln('catcomb.xml', 'energy', ['solution with energy equation']);
|
||||
|
||||
%% Show statistics
|
||||
|
||||
sim1D.writeStats;
|
||||
stack.writeStats;
|
||||
elapsed = cputime - t0;
|
||||
e = sprintf('Elapsed CPU time: %10.4g',elapsed);
|
||||
disp(e);
|
||||
@ -205,37 +205,37 @@ disp(e);
|
||||
clf;
|
||||
|
||||
subplot(3, 3, 1);
|
||||
sim1D.plotSolution('flow', 'T');
|
||||
stack.plotSolution('flow', 'T');
|
||||
title('Temperature [K]');
|
||||
|
||||
subplot(3, 3, 2);
|
||||
sim1D.plotSolution('flow', 'velocity');
|
||||
stack.plotSolution('flow', 'velocity');
|
||||
title('Axial Velocity [m/s]');
|
||||
|
||||
subplot(3, 3, 3);
|
||||
sim1D.plotSolution('flow', 'spread_rate');
|
||||
stack.plotSolution('flow', 'spread_rate');
|
||||
title('Radial Velocity / Radius [1/s]');
|
||||
|
||||
subplot(3, 3, 4);
|
||||
sim1D.plotSolution('flow', 'CH4');
|
||||
stack.plotSolution('flow', 'CH4');
|
||||
title('CH4 Mass Fraction');
|
||||
|
||||
subplot(3, 3, 5);
|
||||
sim1D.plotSolution('flow', 'O2');
|
||||
stack.plotSolution('flow', 'O2');
|
||||
title('O2 Mass Fraction');
|
||||
|
||||
subplot(3, 3, 6);
|
||||
sim1D.plotSolution('flow', 'CO');
|
||||
stack.plotSolution('flow', 'CO');
|
||||
title('CO Mass Fraction');
|
||||
|
||||
subplot(3, 3, 7);
|
||||
sim1D.plotSolution('flow', 'CO2');
|
||||
stack.plotSolution('flow', 'CO2');
|
||||
title('CO2 Mass Fraction');
|
||||
|
||||
subplot(3, 3, 8);
|
||||
sim1D.plotSolution('flow', 'H2O');
|
||||
stack.plotSolution('flow', 'H2O');
|
||||
title('H2O Mass Fraction');
|
||||
|
||||
subplot(3, 3, 9);
|
||||
sim1D.plotSolution('flow', 'H2');
|
||||
stack.plotSolution('flow', 'H2');
|
||||
title('H2 Mass Fraction');
|
||||
|
@ -24,7 +24,7 @@ function f = flame(gas, left, flow, right)
|
||||
end
|
||||
|
||||
% create the container object
|
||||
f = Stack([left flow right]);
|
||||
f = Sim1D([left flow right]);
|
||||
|
||||
% set default initial profiles.
|
||||
rho0 = gas.D;
|
||||
|
Loading…
Reference in New Issue
Block a user