Normalized whitespace and indentation in the matlab toolbox
This commit is contained in:
parent
b159a8f20b
commit
790d40b00c
278 changed files with 1399 additions and 1584 deletions
|
|
@ -1,42 +1,42 @@
|
|||
function d = Domain1D(a, b, c, d, e)
|
||||
% DOMAIN1D - Create a new one-dimensional domain.
|
||||
% DOMAIN1D - Create a new one-dimensional domain.
|
||||
%
|
||||
d.dom_id = -1;
|
||||
|
||||
if nargin == 1
|
||||
d.dom_id = domain_methods(0, a);
|
||||
d.dom_id = domain_methods(0, a);
|
||||
elseif nargin == 2
|
||||
% a stagnation flow
|
||||
if a == 1
|
||||
if isa(b,'Solution')
|
||||
d.dom_id = domain_methods(0, 1, thermo_hndl(b), kinetics_hndl(b), ...
|
||||
trans_hndl(b), 1);
|
||||
% a stagnation flow
|
||||
if a == 1
|
||||
if isa(b,'Solution')
|
||||
d.dom_id = domain_methods(0, 1, thermo_hndl(b), kinetics_hndl(b), ...
|
||||
trans_hndl(b), 1);
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
end
|
||||
elseif a == 6
|
||||
if isa(b,'Interface')
|
||||
d.dom_id = domain_methods(0, 6, kinetics_hndl(b));
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Interface.');
|
||||
end
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
error('wrong object type');
|
||||
end
|
||||
elseif a == 6
|
||||
if isa(b,'Interface')
|
||||
d.dom_id = domain_methods(0, 6, kinetics_hndl(b));
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Interface.');
|
||||
end
|
||||
else
|
||||
error('wrong object type');
|
||||
end
|
||||
elseif nargin == 3
|
||||
if a == 1
|
||||
if isa(b,'Solution')
|
||||
d.dom_id = domain_methods(0, 1, thermo_hndl(b), kinetics_hndl(b), ...
|
||||
trans_hndl(b), c);
|
||||
if a == 1
|
||||
if isa(b,'Solution')
|
||||
d.dom_id = domain_methods(0, 1, thermo_hndl(b), kinetics_hndl(b), ...
|
||||
trans_hndl(b), c);
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
end
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
error('unknown domain type');
|
||||
end
|
||||
else
|
||||
error('unknown domain type');
|
||||
end
|
||||
end
|
||||
if d.dom_id < 0
|
||||
error(geterr);
|
||||
error(geterr);
|
||||
end
|
||||
d.domain_type = a;
|
||||
d = class(d, 'Domain1D');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
function n = componentIndex(d, name)
|
||||
% COMPONENTINDEX -
|
||||
%
|
||||
% COMPONENTINDEX -
|
||||
%
|
||||
if isa(name,'double')
|
||||
n = name;
|
||||
n = name;
|
||||
else
|
||||
n = domain_methods(d.dom_id, 18, name);
|
||||
n = domain_methods(d.dom_id, 18, name);
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function s = componentName(d, n)
|
||||
% COMPONENTNAME - Name of component n.
|
||||
%
|
||||
%
|
||||
m = length(n);
|
||||
for i = 1:m
|
||||
s{i} = domain_methods(d.dom_id, 40, n(i));
|
||||
s{i} = domain_methods(d.dom_id, 40, n(i));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = disableEnergy(d)
|
||||
% ENABLEENERGY - enable the energy equation
|
||||
%
|
||||
%
|
||||
domain_methods(d.dom_id, 66, 0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function i = domainIndex(d)
|
||||
% DOMAININDEX - domain index.
|
||||
%
|
||||
%
|
||||
% This function returns an integer flag denoting the location
|
||||
% of the domain, beginning with 1 at the left.
|
||||
%
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function i = domainType(d)
|
||||
% DOMAINTYPE - Type of domain.
|
||||
%
|
||||
%
|
||||
% This function returns an integer flag denoting the domain
|
||||
% type.
|
||||
i = domain_methods(d.dom_id, 12);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function n = domain_hndl(d)
|
||||
% DOMAIN_HNDL - Integer used to access kernel object.
|
||||
%
|
||||
%
|
||||
n = d.dom_id;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
function zz = gridPoints(d, n)
|
||||
% GRID -
|
||||
%
|
||||
% GRID -
|
||||
%
|
||||
if nargin == 1
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
else
|
||||
m = length(n);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
m = length(n);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
function a = isFlow(d)
|
||||
% ISFLOW - Returns 1 if the domain is a flow domain, and 0 otherwise.
|
||||
%
|
||||
%
|
||||
t = domainType(d);
|
||||
if t == 50
|
||||
a = 1;
|
||||
a = 1;
|
||||
else
|
||||
a = 0;
|
||||
a = 0;
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@ if t == 104
|
|||
else
|
||||
a = 0;
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
function a = isSurface(d)
|
||||
% ISSURFACE - Returns 1 if the domain is a surface, and 0 otherwise.
|
||||
%
|
||||
%
|
||||
t = domainType(d);
|
||||
if t == 102
|
||||
a = 1;
|
||||
a = 1;
|
||||
else
|
||||
a = 0;
|
||||
a = 0;
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function mdot = massFlux(d)
|
||||
% MASSFLUX -
|
||||
%
|
||||
% MASSFLUX -
|
||||
%
|
||||
mdot = domain_methods(d.dom_id, 17);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
function y = massFraction(d, k)
|
||||
% MASSFRACTION - Mass fraction of species k.
|
||||
%
|
||||
%
|
||||
% This method returns the mass fraction of species k, where
|
||||
% k is the integer index of the species in the flow domain
|
||||
% to which the boundary domain is attached.
|
||||
%
|
||||
if domainIndex(d) == 0
|
||||
error('no flow domain attached!')
|
||||
error('no flow domain attached!')
|
||||
end
|
||||
|
||||
if isInlet(d)
|
||||
y = domain_methods(d.dom_id,16,k-1);
|
||||
y = domain_methods(d.dom_id,16,k-1);
|
||||
else
|
||||
error('not yet...');
|
||||
error('not yet...');
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function n = nComponents(d)
|
||||
% NCOMPONENTS - number of components
|
||||
%
|
||||
%
|
||||
n = domain_methods(d.dom_id, 11);
|
||||
|
|
|
|||
|
|
@ -2,4 +2,3 @@ function npts = nPoints(d)
|
|||
% NPOINTS - Number of grid points.
|
||||
%
|
||||
npts = domain_methods(d.dom_id, 14);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
function v = domain_methods(n, job, a, b, c, d)
|
||||
%
|
||||
if nargin == 2
|
||||
v = ctmethods(90, n, job);
|
||||
v = ctmethods(90, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(90, n, job, a);
|
||||
v = ctmethods(90, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(90, n, job, a, b);
|
||||
v = ctmethods(90, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(90, n, job, a, b, c);
|
||||
v = ctmethods(90, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(90, n, job, a, b, c, d);
|
||||
v = ctmethods(90, n, job, a, b, c, d);
|
||||
elseif nargin == 7
|
||||
v = ctmethods(90, n, job, a, b, c, d, e);
|
||||
v = ctmethods(90, n, job, a, b, c, d, e);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
function a = set(a,varargin)
|
||||
% SET - Set properties.
|
||||
%
|
||||
% The properties that may be set are
|
||||
%
|
||||
% The properties that may be set are
|
||||
%
|
||||
% Either the full property name or the symbol may be
|
||||
% specified. For the extensive properties (V,H,U,S), the values
|
||||
% must be given per unit mass. H, U, and S must be set in
|
||||
|
|
@ -25,62 +25,62 @@ function a = set(a,varargin)
|
|||
%
|
||||
|
||||
property_argin = varargin;
|
||||
|
||||
|
||||
while length(property_argin) >= 2,
|
||||
prop = property_argin{1};
|
||||
val = property_argin{2};
|
||||
property_argin = property_argin(3:end);
|
||||
switch prop
|
||||
case 'Temperature'
|
||||
setTemperature(a,val);
|
||||
case 'T'
|
||||
setTemperature(a,val);
|
||||
case 'MassFractions'
|
||||
setMassFractions(a,val);
|
||||
case 'Y'
|
||||
setMassFractions(a,val);
|
||||
case 'mdot'
|
||||
setMdot(a,val);
|
||||
case 'MassFlux'
|
||||
setMdot(a,val);
|
||||
case 'P'
|
||||
setPressure(a,val);
|
||||
case 'Pressure'
|
||||
setPressure(a,val);
|
||||
case 'tol'
|
||||
sz = size(val);
|
||||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
setTolerances(a, 'default', val(1), val(2));
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
end
|
||||
case 'tol-time'
|
||||
sz = size(val);
|
||||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
rt = val(1);
|
||||
at = val(2);
|
||||
setTolerances(a, 'default', rt, at, 'ts');
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
end
|
||||
case 'grid'
|
||||
setupGrid(a, val);
|
||||
case 'bounds'
|
||||
setBounds(a, val(1,:), val(2,:));
|
||||
case 'X'
|
||||
setMoleFractions(a, val);
|
||||
case 'MoleFractions'
|
||||
setMoleFractions(a, val);
|
||||
case 'T_fixed'
|
||||
setFixedTempProfile(a, val);
|
||||
case 'ID'
|
||||
setID(a, val);
|
||||
otherwise
|
||||
error(['unknown property ' char(prop)]);
|
||||
end
|
||||
prop = property_argin{1};
|
||||
val = property_argin{2};
|
||||
property_argin = property_argin(3:end);
|
||||
switch prop
|
||||
case 'Temperature'
|
||||
setTemperature(a,val);
|
||||
case 'T'
|
||||
setTemperature(a,val);
|
||||
case 'MassFractions'
|
||||
setMassFractions(a,val);
|
||||
case 'Y'
|
||||
setMassFractions(a,val);
|
||||
case 'mdot'
|
||||
setMdot(a,val);
|
||||
case 'MassFlux'
|
||||
setMdot(a,val);
|
||||
case 'P'
|
||||
setPressure(a,val);
|
||||
case 'Pressure'
|
||||
setPressure(a,val);
|
||||
case 'tol'
|
||||
sz = size(val);
|
||||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
setTolerances(a, 'default', val(1), val(2));
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
end
|
||||
case 'tol-time'
|
||||
sz = size(val);
|
||||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
rt = val(1);
|
||||
at = val(2);
|
||||
setTolerances(a, 'default', rt, at, 'ts');
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
end
|
||||
case 'grid'
|
||||
setupGrid(a, val);
|
||||
case 'bounds'
|
||||
setBounds(a, val(1,:), val(2,:));
|
||||
case 'X'
|
||||
setMoleFractions(a, val);
|
||||
case 'MoleFractions'
|
||||
setMoleFractions(a, val);
|
||||
case 'T_fixed'
|
||||
setFixedTempProfile(a, val);
|
||||
case 'ID'
|
||||
setID(a, val);
|
||||
otherwise
|
||||
error(['unknown property ' char(prop)]);
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function d = setBounds(d, component, lower, upper)
|
||||
% SETBOUNDS -
|
||||
%
|
||||
% SETBOUNDS -
|
||||
%
|
||||
n = componentIndex(d,component);
|
||||
domain_methods(d.dom_id, 51, n, lower, upper);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
function d = setCoverageEqs(d,onoff)
|
||||
% SETCOVERAGEEQS - Enable or disable solving the coverage equations.
|
||||
%
|
||||
%
|
||||
if d.domain_type ~= 6
|
||||
error('Wrong domain type. Expected a reacting surface domain.')
|
||||
error('Wrong domain type. Expected a reacting surface domain.')
|
||||
end
|
||||
|
||||
ion = -1;
|
||||
if isa(onoff,'char')
|
||||
if strcmp(onoff,'on') | strcmp(onoff,'yes')
|
||||
ion = 1;
|
||||
elseif strcmp(onoff,'off') | strcmp(onoff,'no')
|
||||
ion = 0;
|
||||
else
|
||||
error(strcat('unknown option: ',onoff))
|
||||
end
|
||||
if strcmp(onoff,'on') | strcmp(onoff,'yes')
|
||||
ion = 1;
|
||||
elseif strcmp(onoff,'off') | strcmp(onoff,'no')
|
||||
ion = 0;
|
||||
else
|
||||
error(strcat('unknown option: ',onoff))
|
||||
end
|
||||
elseif isa(onoff,'numeric')
|
||||
ion = onoff;
|
||||
ion = onoff;
|
||||
end
|
||||
domain_methods(d.dom_id, 120, ion);
|
||||
domain_methods(d.dom_id, 120, ion);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = setID(d, id)
|
||||
% SETID - Set the ID tag for the domain.
|
||||
%
|
||||
%
|
||||
domain_methods(d.dom_id, 54, id);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = setMdot(d, mdot)
|
||||
% SETMDOT -
|
||||
%
|
||||
% SETMDOT -
|
||||
%
|
||||
domain_methods(d.dom_id, 60, mdot);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = setMoleFractions(d, x)
|
||||
% SETMOLEFRACTIONS -
|
||||
%
|
||||
% SETMOLEFRACTIONS -
|
||||
%
|
||||
domain_methods(d.dom_id, 62, x);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function d = setPressure(d, p)
|
||||
% SETPRESSURE -
|
||||
%
|
||||
% SETPRESSURE -
|
||||
%
|
||||
domain_methods(d.dom_id, 63, p);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
function d = setProfile(d, n, p)
|
||||
% SETPROFILE -
|
||||
%
|
||||
% SETPROFILE -
|
||||
%
|
||||
if d.stack == 0
|
||||
error('install domain in stack before calling setProfile.');
|
||||
error('install domain in stack before calling setProfile.');
|
||||
end
|
||||
|
||||
setProfile(d.stack,domainIndex(d),n,p);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = setTemperature(d, t)
|
||||
% SETTEMPERATURE - Set the temperature [K].
|
||||
%
|
||||
%
|
||||
domain_methods(d.dom_id, 61, t);
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
function d = setTolerances(d, component, rtol, atol, typ)
|
||||
% SETTOLERANCES -
|
||||
%
|
||||
% SETTOLERANCES -
|
||||
%
|
||||
ityp = 0;
|
||||
if nargin == 5
|
||||
switch typ
|
||||
case 'ts'
|
||||
ityp = -1;
|
||||
case 'time'
|
||||
ityp = -1;
|
||||
case 'ss'
|
||||
ityp = 1;
|
||||
case 'steady'
|
||||
ityp = 1;
|
||||
end
|
||||
switch typ
|
||||
case 'ts'
|
||||
ityp = -1;
|
||||
case 'time'
|
||||
ityp = -1;
|
||||
case 'ss'
|
||||
ityp = 1;
|
||||
case 'steady'
|
||||
ityp = 1;
|
||||
end
|
||||
end
|
||||
|
||||
if strcmp(component,'default')
|
||||
nc = nComponents(d);
|
||||
for ii = 1:nc
|
||||
domain_methods(d.dom_id, 52, ii, rtol, atol, ityp);
|
||||
end
|
||||
return
|
||||
nc = nComponents(d);
|
||||
for ii = 1:nc
|
||||
domain_methods(d.dom_id, 52, ii, rtol, atol, ityp);
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if iscell(component)
|
||||
nc = length(component);
|
||||
for ii = 1:nc
|
||||
n = componentIndex(d, component{ii});
|
||||
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
|
||||
end
|
||||
nc = length(component);
|
||||
for ii = 1:nc
|
||||
n = componentIndex(d, component{ii});
|
||||
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
|
||||
end
|
||||
else
|
||||
n = componentIndex(d, component);
|
||||
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
|
||||
n = componentIndex(d, component);
|
||||
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function d = setupGrid(d, grid)
|
||||
% SETUPGRID -
|
||||
%
|
||||
% SETUPGRID -
|
||||
%
|
||||
domain_methods(d.dom_id, 53, grid);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function t = temperature(d)
|
||||
% TEMPERATURE - Temperature [K].
|
||||
%
|
||||
%
|
||||
t = domain_methods(d.dom_id, 15);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
function zz = z(d, n)
|
||||
% GRID -
|
||||
%
|
||||
% GRID -
|
||||
%
|
||||
if nargin == 1
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
else
|
||||
m = length(n);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
m = length(n);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
function s = Stack(domains)
|
||||
%
|
||||
% STACK - A one-dimensional 'stack' of domains.
|
||||
%
|
||||
% STACK - A one-dimensional 'stack' of domains.
|
||||
%
|
||||
% A stack 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.
|
||||
% types - extended domains, and connector domains.
|
||||
%
|
||||
s.stack_id = -1;
|
||||
s.domains = domains;
|
||||
if nargin == 1
|
||||
nd = length(domains);
|
||||
for n=1:nd
|
||||
ids(n) = domain_hndl(domains(n));
|
||||
end
|
||||
s.stack_id = stack_methods(0, 8, nd, ids);
|
||||
nd = length(domains);
|
||||
for n=1:nd
|
||||
ids(n) = domain_hndl(domains(n));
|
||||
end
|
||||
s.stack_id = stack_methods(0, 8, nd, ids);
|
||||
else
|
||||
help(Stack);
|
||||
error('wrong number of parameters');
|
||||
help(Stack);
|
||||
error('wrong number of parameters');
|
||||
end
|
||||
if s.stack_id < 0
|
||||
error(geterr);
|
||||
error(geterr);
|
||||
end
|
||||
s = class(s, 'Stack');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
function display(s, fname)
|
||||
% DISPLAY - show all domains.
|
||||
% DISPLAY - show all domains.
|
||||
%
|
||||
% fname - file to write summary to. If omitted, output is to the screen.
|
||||
%
|
||||
if nargin == 1
|
||||
fname = '-';
|
||||
fname = '-';
|
||||
end
|
||||
stack_methods(s.stack_id, 103, fname);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function n = domainIndex(d, name)
|
||||
% DOMAININDEX - Index of the domain with a specified name.
|
||||
if isa(name,'double')
|
||||
n = name
|
||||
n = name
|
||||
else
|
||||
n = stack_methods(d.stack_id, 109, name);
|
||||
n = stack_methods(d.stack_id, 109, name);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function z = grid(s, d)
|
||||
% GRID - the grid in one domain.
|
||||
%
|
||||
%
|
||||
n = domainIndex(s,d);
|
||||
d = s.domains(n);
|
||||
z = gridPoints(d);
|
||||
|
|
|
|||
|
|
@ -10,4 +10,3 @@ x = solution(s, domain, component);
|
|||
plot(z, x);
|
||||
xlabel('z (m)');
|
||||
ylabel(component);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,20 +6,19 @@ function v = stack_methods(n, job, a, b, c, d, e, f)
|
|||
% and simply calls ctmethods with a flag associated with this class
|
||||
% as the first parameter, followed by the input arguments.
|
||||
if nargin == 2
|
||||
v = ctmethods(90, n, job);
|
||||
v = ctmethods(90, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(90, n, job, a);
|
||||
v = ctmethods(90, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(90, n, job, a, b);
|
||||
v = ctmethods(90, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(90, n, job, a, b, c);
|
||||
v = ctmethods(90, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(90, n, job, a, b, c, d);
|
||||
v = ctmethods(90, n, job, a, b, c, d);
|
||||
elseif nargin == 7
|
||||
v = ctmethods(90, n, job, a, b, c, d, e);
|
||||
v = ctmethods(90, n, job, a, b, c, d, e);
|
||||
elseif nargin == 8
|
||||
v = ctmethods(90, n, job, a, b, c, d, e, f);
|
||||
v = ctmethods(90, n, job, a, b, c, d, e, f);
|
||||
else
|
||||
error('too many arguments');
|
||||
error('too many arguments');
|
||||
end
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
function r = resid(s, domain, rdt, count)
|
||||
if nargin == 2
|
||||
rdt = 0.0;
|
||||
count = 0;
|
||||
rdt = 0.0;
|
||||
count = 0;
|
||||
end
|
||||
|
||||
idom = domainIndex(s, domain);
|
||||
|
|
@ -10,7 +10,7 @@ d = s.domains(idom);
|
|||
r = zeros(nComponents(d), nPoints(d));
|
||||
stack_methods(s.stack_id, 113, rdt, count);
|
||||
for m = 1:nComponents(d)
|
||||
for n = 1:nPoints(d)
|
||||
r(m,n) = stack_methods(s.stack_id, 31, idom, m, n);
|
||||
end
|
||||
for n = 1:nPoints(d)
|
||||
r(m,n) = stack_methods(s.stack_id, 31, idom, m, n);
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function restore(s, fname, id)
|
||||
% RESTORE - Restore a previously-saved solution.
|
||||
%
|
||||
%
|
||||
% This method can be used to provide an initial guess for the
|
||||
% solution.
|
||||
% solution.
|
||||
stack_methods(s.stack_id, 111, fname, id);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
function saveSoln(s, fname, id, desc)
|
||||
% SAVE -
|
||||
%
|
||||
% SAVE -
|
||||
%
|
||||
if nargin == 2
|
||||
id = 'solution';
|
||||
desc = '-';
|
||||
id = 'solution';
|
||||
desc = '-';
|
||||
elseif nargin == 3
|
||||
desc = '-';
|
||||
desc = '-';
|
||||
end
|
||||
stack_methods(s.stack_id, 107, fname, id, desc);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
function saveSoln(s, fname, id, desc)
|
||||
% SAVE - Save solution.
|
||||
%
|
||||
%
|
||||
if nargin == 1
|
||||
fname = 'soln.xml';
|
||||
id = 'solution';
|
||||
desc = '--';
|
||||
fname = 'soln.xml';
|
||||
id = 'solution';
|
||||
desc = '--';
|
||||
elseif nargin == 2
|
||||
id = 'solution';
|
||||
desc = '--';
|
||||
id = 'solution';
|
||||
desc = '--';
|
||||
elseif nargin == 3
|
||||
desc = '--';
|
||||
desc = '--';
|
||||
end
|
||||
stack_methods(s.stack_id, 107, fname, id, desc);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function setFlatProfile(s, n, comp, v)
|
||||
% SETFLATPROFILE -
|
||||
%
|
||||
% SETFLATPROFILE -
|
||||
%
|
||||
stack_methods(s.stack_id, 102, n, comp, v);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
function setMaxJacAge(s, ss_age, ts_age)
|
||||
% SETMAXJACAGE - Set the number of times the Jacobian will be used
|
||||
% SETMAXJACAGE - Set the number of times the Jacobian will be used
|
||||
% before it is recomputed.
|
||||
%
|
||||
%
|
||||
if nargin == 2
|
||||
ts_age = ss_age;
|
||||
ts_age = ss_age;
|
||||
end
|
||||
stack_methods(s.stack_id, 114, ss_age, ts_age);
|
||||
|
|
|
|||
|
|
@ -7,46 +7,44 @@ function setProfile(s, name, comp, p)
|
|||
% v -- array of values
|
||||
%
|
||||
% The solution vector values for this component will be linearly
|
||||
% interpolated from the discrete function defined by v vs. zr.
|
||||
% interpolated from the discrete function defined by v vs. zr.
|
||||
% Note that zr = 0.0 corresponds to the leftmost grid point in
|
||||
% the specified domain, and zr = 1.0 corresponds to the rightmost
|
||||
% grid point. This method can be called at any time, but is
|
||||
% usually used to set the initial guess for the solution.
|
||||
%
|
||||
% Example:
|
||||
%
|
||||
%
|
||||
% zr = [0 0.1 0.2 0.4 0.8 1];
|
||||
% v = [500 650 700 730 800 900];
|
||||
% setProfile(1, 2, zr, v);
|
||||
%
|
||||
if isa(name,'double')
|
||||
n = name;
|
||||
n = name;
|
||||
else
|
||||
n = domainIndex(s, name);
|
||||
n = domainIndex(s, name);
|
||||
end
|
||||
|
||||
d = s.domains(n);
|
||||
|
||||
if isa(comp,'double') | isa(comp,'cell')
|
||||
c = comp;
|
||||
c = comp;
|
||||
elseif isa(comp,'char')
|
||||
c = {comp};
|
||||
c = {comp};
|
||||
else
|
||||
error('wrong type');
|
||||
error('wrong type');
|
||||
end
|
||||
|
||||
np = length(c);
|
||||
sz = size(p);
|
||||
if sz(1) == np + 1;
|
||||
for j = 1:np
|
||||
ic = componentIndex(d,c{j});
|
||||
stack_methods(s.stack_id, 101, n, ic, p(1,:), p(j+1,:));
|
||||
end
|
||||
for j = 1:np
|
||||
ic = componentIndex(d,c{j});
|
||||
stack_methods(s.stack_id, 101, n, ic, p(1,:), p(j+1,:));
|
||||
end
|
||||
elseif sz(2) == np + 1;
|
||||
ic = componentIndex(d,c{j});
|
||||
stack_methods(s.stack_id, 101, n, ic, p(:,1), p(:,j+1));
|
||||
ic = componentIndex(d,c{j});
|
||||
stack_methods(s.stack_id, 101, n, ic, p(:,1), p(:,j+1));
|
||||
else
|
||||
error('wrong profile shape');
|
||||
error('wrong profile shape');
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,20 +11,19 @@ function d = setRefineCriteria(d, n, ratio, slope, curve, prune)
|
|||
% will be retained in the grid. If the computed
|
||||
% slope or curve value is below prune for all
|
||||
% components, it will be deleted, unless either
|
||||
% neighboring point is already marked for deletion.
|
||||
%
|
||||
% neighboring point is already marked for deletion.
|
||||
%
|
||||
if nargin < 3
|
||||
ratio = 10.0;
|
||||
ratio = 10.0;
|
||||
end
|
||||
if nargin < 4
|
||||
slope = 0.8;
|
||||
slope = 0.8;
|
||||
end
|
||||
if nargin < 5
|
||||
curve = 0.8;
|
||||
curve = 0.8;
|
||||
end
|
||||
if nargin < 6
|
||||
prune = -0.1;
|
||||
prune = -0.1;
|
||||
end
|
||||
|
||||
stack_methods(d.stack_id, 106, n, ratio, slope, curve, prune);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function setValue(s, n, comp, localPoint, v)
|
||||
% SETVALUE - Set the value of a single entry in the solution vector.
|
||||
%
|
||||
%
|
||||
% n -- domain number
|
||||
% comp -- component number
|
||||
% localPoint -- local index of the grid point in the domain
|
||||
|
|
@ -17,4 +17,3 @@ function setValue(s, n, comp, localPoint, v)
|
|||
% stack.
|
||||
%
|
||||
stack_methods(s.stack_id, 100, n, comp, localPoint, v);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,21 +3,21 @@ function x = solution(s, domain, component)
|
|||
%
|
||||
% x = solution(s, 'flow', 'T') returns in vector x the values of
|
||||
% solution component 'T' in domain 'flow'.
|
||||
%
|
||||
%
|
||||
idom = domainIndex(s, domain);
|
||||
d = s.domains(idom);
|
||||
|
||||
if nargin == 3
|
||||
icomp = componentIndex(d, component);
|
||||
for n = 1:nPoints(d)
|
||||
x(n) = stack_methods(s.stack_id, 30, idom, icomp, n);
|
||||
end
|
||||
icomp = componentIndex(d, component);
|
||||
for n = 1:nPoints(d)
|
||||
x(n) = stack_methods(s.stack_id, 30, idom, icomp, n);
|
||||
end
|
||||
else
|
||||
nc = nComponents(d);
|
||||
np = nPoints(d);
|
||||
for m = 1:nc
|
||||
for n = 1:np
|
||||
x(m,n) = stack_methods(s.stack_id, 30, idom, m, n);
|
||||
end
|
||||
end
|
||||
nc = nComponents(d);
|
||||
np = nPoints(d);
|
||||
for m = 1:nc
|
||||
for n = 1:np
|
||||
x(m,n) = stack_methods(s.stack_id, 30, idom, m, n);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function solve(s, loglevel, refine_grid)
|
||||
% SOLVE -
|
||||
%
|
||||
% SOLVE -
|
||||
%
|
||||
stack_methods(s.stack_id, 104, loglevel, refine_grid);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
function b = subsref(s,index)
|
||||
% SUBSREF -
|
||||
% SUBSREF -
|
||||
switch index.type
|
||||
case '()'
|
||||
b = s.domains(index.subs{:});
|
||||
case '.'
|
||||
n = domainIndex(s, index.subs);
|
||||
b = s.domains(n);
|
||||
otherwise
|
||||
error('syntax error');
|
||||
case '()'
|
||||
b = s.domains(index.subs{:});
|
||||
case '.'
|
||||
n = domainIndex(s, index.subs);
|
||||
b = s.domains(n);
|
||||
otherwise
|
||||
error('syntax error');
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
function writeStats(s)
|
||||
% WRITESTATS - Print statistics for the current solution.
|
||||
%
|
||||
%
|
||||
% writeStats(s) prints a summary of the number of function and
|
||||
% Jacobian evaluations for each grid, and the CPU time spent on
|
||||
% each one.
|
||||
%
|
||||
stack_methods(s.stack_id, 108);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ function m = AxiStagnFlow(gas)
|
|||
% AXISTAGNFLOW - Axisymmetric stagnation flow.
|
||||
%
|
||||
% Return a Domain1D instance representing an axisymmetric
|
||||
% stagnation flow.
|
||||
% stagnation flow.
|
||||
m = Domain1D(1, gas);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ function m = AxisymmetricFlow(gas, id)
|
|||
%
|
||||
m = Domain1D(1, gas);
|
||||
if nargin == 1
|
||||
setID(m,'flow');
|
||||
setID(m,'flow');
|
||||
else
|
||||
setID(m,id);
|
||||
end
|
||||
setID(m,id);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ function m = FreeFlame(gas, id)
|
|||
%
|
||||
m = Domain1D(1, gas, 2);
|
||||
if nargin == 1
|
||||
setID(m,'flame');
|
||||
setID(m,'flame');
|
||||
else
|
||||
setID(m,id);
|
||||
end
|
||||
setID(m,id);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ function m = Inlet(id)
|
|||
% either the leftmost or rightmost domain in a stack.
|
||||
m = Domain1D(2);
|
||||
if nargin == 0
|
||||
setID(m,'inlet');
|
||||
setID(m,'inlet');
|
||||
else
|
||||
setID(m,id);
|
||||
setID(m,id);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ function m = Outlet(id)
|
|||
%
|
||||
m = Domain1D(5);
|
||||
if nargin == 0
|
||||
setID(m,'outlet');
|
||||
setID(m,'outlet');
|
||||
else
|
||||
setID(m,id);
|
||||
setID(m,id);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ function m = OutletRes(id)
|
|||
%
|
||||
m = Domain1D(-2);
|
||||
if nargin == 0
|
||||
setID(m,'outletres');
|
||||
setID(m,'outletres');
|
||||
else
|
||||
setID(m,id);
|
||||
setID(m,id);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ function m = Surface(id, surface_mech)
|
|||
% SURFACE - Return a Domain1D instance representing a non-reacting
|
||||
% or reacting surface.
|
||||
if nargin < 2
|
||||
m = Domain1D(3);
|
||||
if nargin == 0
|
||||
setID(m,'surface');
|
||||
elseif nargin == 1
|
||||
setID(m,id);
|
||||
end
|
||||
m = Domain1D(3);
|
||||
if nargin == 0
|
||||
setID(m,'surface');
|
||||
elseif nargin == 1
|
||||
setID(m,id);
|
||||
end
|
||||
else
|
||||
m = Domain1D(6, surface_mech)
|
||||
setID(m,id);
|
||||
m = Domain1D(6, surface_mech)
|
||||
setID(m,id);
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ function m = SymmPlane(id)
|
|||
%
|
||||
m = Domain1D(4);
|
||||
if nargin == 0
|
||||
setID(m,'symmetry_plane');
|
||||
setID(m,'symmetry_plane');
|
||||
else
|
||||
setID(m,id);
|
||||
setID(m,id);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,20 +19,20 @@ function flame = npflame_init(gas, left, flow, right, fuel, oxidizer, nuox)
|
|||
|
||||
% Check input parameters
|
||||
if nargin ~= 7
|
||||
error('wrong number of input arguments.');
|
||||
error('wrong number of input arguments.');
|
||||
end
|
||||
|
||||
if ~isIdealGas(gas)
|
||||
error('gas object must represent an ideal gas mixture.');
|
||||
error('gas object must represent an ideal gas mixture.');
|
||||
end
|
||||
if ~isInlet(left)
|
||||
error('left inlet object of wrong type.');
|
||||
error('left inlet object of wrong type.');
|
||||
end
|
||||
if ~isFlow(flow)
|
||||
error('flow object of wrong type.');
|
||||
error('flow object of wrong type.');
|
||||
end
|
||||
if ~isInlet(right)
|
||||
error('right inlet object of wrong type.');
|
||||
error('right inlet object of wrong type.');
|
||||
end
|
||||
|
||||
% create the container object
|
||||
|
|
@ -60,9 +60,9 @@ tf = temperature(left);
|
|||
tox = temperature(right);
|
||||
|
||||
for n = 1:nsp
|
||||
yox(n) = massFraction(right,n);
|
||||
yf(n) = massFraction(left,n);
|
||||
ystoich(n) = zst*yf(n) + (1.0 - zst)*yox(n);
|
||||
yox(n) = massFraction(right,n);
|
||||
yf(n) = massFraction(left,n);
|
||||
ystoich(n) = zst*yf(n) + (1.0 - zst)*yox(n);
|
||||
end
|
||||
|
||||
set(gas,'T',temperature(left),'P',pressure(gas),'Y',ystoich);
|
||||
|
|
@ -83,23 +83,23 @@ x0 = massFlux(left)*dz/(massFlux(left) + massFlux(right));
|
|||
|
||||
nz = nPoints(flow);
|
||||
for j = 1:nz
|
||||
x = zz(j);
|
||||
zeta = f*(x - x0);
|
||||
zmix = 0.5*(1.0 - erf(zeta));
|
||||
zm(j) = zmix;
|
||||
u(j) = a*(x0 - zz(j));
|
||||
v(j) = a;
|
||||
if zmix > zst
|
||||
for n = 1:nsp
|
||||
y(j,n) = yeq(n) + (zmix - zst)*(yf(n) - yeq(n))/(1.0 - zst);
|
||||
x = zz(j);
|
||||
zeta = f*(x - x0);
|
||||
zmix = 0.5*(1.0 - erf(zeta));
|
||||
zm(j) = zmix;
|
||||
u(j) = a*(x0 - zz(j));
|
||||
v(j) = a;
|
||||
if zmix > zst
|
||||
for n = 1:nsp
|
||||
y(j,n) = yeq(n) + (zmix - zst)*(yf(n) - yeq(n))/(1.0 - zst);
|
||||
end
|
||||
t(j) = teq + (tf - teq)*(zmix - zst)/(1.0 - zst);
|
||||
else
|
||||
for n = 1:nsp
|
||||
y(j,n) = yox(n) + zmix*(yeq(n) - yox(n))/zst;
|
||||
end
|
||||
t(j) = tox + zmix*(teq - tox)/zst;
|
||||
end
|
||||
t(j) = teq + (tf - teq)*(zmix - zst)/(1.0 - zst);
|
||||
else
|
||||
for n = 1:nsp
|
||||
y(j,n) = yox(n) + zmix*(yeq(n) - yox(n))/zst;
|
||||
end
|
||||
t(j) = tox + zmix*(teq - tox)/zst;
|
||||
end
|
||||
end
|
||||
|
||||
zrel = zz/dz;
|
||||
|
|
@ -109,9 +109,9 @@ setProfile(flame, 2, {'u', 'V'}, [zrel; u; v]);
|
|||
setProfile(flame, 2, 'T', [zrel; t] );
|
||||
|
||||
for n = 1:nsp
|
||||
nm = speciesName(gas,n);
|
||||
setProfile(flame, 2, nm, [zrel; transpose(y(:,n))])
|
||||
nm = speciesName(gas,n);
|
||||
setProfile(flame, 2, nm, [zrel; transpose(y(:,n))])
|
||||
end
|
||||
|
||||
% set minimal grid refinement criteria
|
||||
setRefineCriteria(flame, 2, 10.0, 0.99, 0.99);
|
||||
% set minimal grid refinement criteria
|
||||
setRefineCriteria(flame, 2, 10.0, 0.99, 0.99);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
function x = FlowDevice(typ)
|
||||
%
|
||||
if nargin == 0
|
||||
typ = 1;
|
||||
typ = 1;
|
||||
end
|
||||
x.index = flowdevicemethods(0,typ);
|
||||
if x.index < 0
|
||||
error(geterr);
|
||||
error(geterr);
|
||||
end
|
||||
x.type = typ;
|
||||
x.upstream = -1;
|
||||
x.downstream = -1;
|
||||
x = class(x,'FlowDevice');
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function clear(f)
|
||||
% CLEAR -
|
||||
%
|
||||
% CLEAR -
|
||||
%
|
||||
flowdevicemethods(1, f.index)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
function install(f, upstream, downstream)
|
||||
|
||||
if nargin == 3
|
||||
if ~isa(upstream,'Reactor') | ~isa(downstream,'Reactor')
|
||||
error(['Flow devices can only be installed between reactors or' ...
|
||||
' reservoirs'])
|
||||
end
|
||||
i = hndl(upstream);
|
||||
j = hndl(downstream);
|
||||
ok = flowdevicemethods(2, f.index, i, j);
|
||||
if ok < 0
|
||||
error(geterr)
|
||||
end
|
||||
if ~isa(upstream,'Reactor') | ~isa(downstream,'Reactor')
|
||||
error(['Flow devices can only be installed between reactors or' ...
|
||||
' reservoirs'])
|
||||
end
|
||||
i = hndl(upstream);
|
||||
j = hndl(downstream);
|
||||
ok = flowdevicemethods(2, f.index, i, j);
|
||||
if ok < 0
|
||||
error(geterr)
|
||||
end
|
||||
else
|
||||
error('install requires 3 arguments')
|
||||
end
|
||||
error('install requires 3 arguments')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function mdot = massFlowRate(f, time)
|
||||
% MASSFLOWRATE - mass flow rate in kg/s
|
||||
%
|
||||
%
|
||||
mdot = flowdevicemethods(21, f.index, time);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
function v = flowdevicemethods(n, job, a, b, c, d)
|
||||
%
|
||||
%
|
||||
if nargin == 2
|
||||
v = ctmethods(80, n, job);
|
||||
v = ctmethods(80, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(80, n, job, a);
|
||||
v = ctmethods(80, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(80, n, job, a, b);
|
||||
v = ctmethods(80, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(80, n, job, a, b, c);
|
||||
v = ctmethods(80, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(80, n, job, a, b, c, d);
|
||||
end
|
||||
v = ctmethods(80, n, job, a, b, c, d);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ function setFunction(f, mf)
|
|||
% SETMASSFLOWRATE -
|
||||
%
|
||||
if f.type == 1
|
||||
k = flowdevicemethods(5, f.index, func_hndl(mf));
|
||||
if k < 0
|
||||
error(geterr);
|
||||
end
|
||||
k = flowdevicemethods(5, f.index, func_hndl(mf));
|
||||
if k < 0
|
||||
error(geterr);
|
||||
end
|
||||
else
|
||||
error('Mass flow rate can only be set for mass flow controllers')
|
||||
error('Mass flow rate can only be set for mass flow controllers')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
function setMassFlowRate(f, mdot)
|
||||
% SETMASSFLOWRATE -
|
||||
%
|
||||
% SETMASSFLOWRATE -
|
||||
%
|
||||
if f.type == 1
|
||||
k = flowdevicemethods(3, f.index, mdot);
|
||||
if k < 0
|
||||
error(geterr);
|
||||
end
|
||||
k = flowdevicemethods(3, f.index, mdot);
|
||||
if k < 0
|
||||
error(geterr);
|
||||
end
|
||||
else
|
||||
error('Mass flow rate can only be set for mass flow controllers')
|
||||
error('Mass flow rate can only be set for mass flow controllers')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
function setValveCoeff(f, k)
|
||||
% SETVALVECOEFF - set valve coefficient
|
||||
%
|
||||
%
|
||||
if f.type ~= 3
|
||||
error('Valve coefficient can only be set for valves')
|
||||
error('Valve coefficient can only be set for valves')
|
||||
end
|
||||
ok = flowdevicemethods(4, f.index, k);
|
||||
if ok < 0
|
||||
error(geterr);
|
||||
end
|
||||
error(geterr);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
function x = Func(typ, n, p)
|
||||
%
|
||||
% Func - a class for functors.
|
||||
%
|
||||
%
|
||||
% A functor is an object that behaves like a function. Cantera
|
||||
% defines a set of functors to use to create arbitrary functions to
|
||||
% specify things like heat fluxes, piston speeds, etc., in reactor
|
||||
% network simulations. Of course, they can be used for other things
|
||||
% too.
|
||||
% too.
|
||||
%
|
||||
% The main feature of a functor class is that it overloads the '()'
|
||||
% operator to evaluate the function. For example, suppose object
|
||||
|
|
@ -27,7 +27,7 @@ function x = Func(typ, n, p)
|
|||
% "Func1". See the Cantera C++ documentation for more details.
|
||||
%
|
||||
if ~isa(typ, 'char')
|
||||
error('Function type must be a string')
|
||||
error('Function type must be a string')
|
||||
end
|
||||
|
||||
x.f1 = 0;
|
||||
|
|
@ -36,41 +36,39 @@ x.coeffs = 0;
|
|||
|
||||
itype = -1;
|
||||
if strcmp(typ, 'polynomial')
|
||||
itype = 2;
|
||||
itype = 2;
|
||||
elseif strcmp(typ,'fourier')
|
||||
itype = 1;
|
||||
itype = 1;
|
||||
elseif strcmp(typ,'arrhenius')
|
||||
itype = 3;
|
||||
itype = 3;
|
||||
elseif strcmp(typ,'gaussian')
|
||||
itype = 4;
|
||||
itype = 4;
|
||||
end
|
||||
|
||||
if itype > 0
|
||||
x.coeffs = p;
|
||||
x.index = funcmethods(0,itype,n,p);
|
||||
x.coeffs = p;
|
||||
x.index = funcmethods(0,itype,n,p);
|
||||
elseif strcmp(typ,'periodic')
|
||||
itype = 50;
|
||||
x.f1 = n;
|
||||
x.coeffs = p;
|
||||
x.index = funcmethods(0,itype,n.index,p);
|
||||
itype = 50;
|
||||
x.f1 = n;
|
||||
x.coeffs = p;
|
||||
x.index = funcmethods(0,itype,n.index,p);
|
||||
else
|
||||
if strcmp(typ,'sum')
|
||||
itype = 20;
|
||||
elseif strcmp(typ,'diff')
|
||||
itype = 25;
|
||||
elseif strcmp(typ,'prod')
|
||||
itype = 30;
|
||||
elseif strcmp(typ,'ratio')
|
||||
itype = 40;
|
||||
elseif strcmp(typ,'composite')
|
||||
itype = 60;
|
||||
end
|
||||
x.f1 = n;
|
||||
x.f2 = p;
|
||||
x.index = funcmethods(0,itype,n.index,p.index);
|
||||
if strcmp(typ,'sum')
|
||||
itype = 20;
|
||||
elseif strcmp(typ,'diff')
|
||||
itype = 25;
|
||||
elseif strcmp(typ,'prod')
|
||||
itype = 30;
|
||||
elseif strcmp(typ,'ratio')
|
||||
itype = 40;
|
||||
elseif strcmp(typ,'composite')
|
||||
itype = 60;
|
||||
end
|
||||
x.f1 = n;
|
||||
x.f2 = p;
|
||||
x.index = funcmethods(0,itype,n.index,p.index);
|
||||
end
|
||||
|
||||
x.typ = typ;
|
||||
x = class(x,'Func');
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,92 +1,92 @@
|
|||
function s = char(p)
|
||||
% CHAR -
|
||||
%
|
||||
% CHAR -
|
||||
%
|
||||
if strcmp(p.typ,'sum')
|
||||
s = ['(' char(p.f1) ') + (' char(p.f2) ')'];
|
||||
s = ['(' char(p.f1) ') + (' char(p.f2) ')'];
|
||||
elseif strcmp(p.typ,'diff')
|
||||
s = ['(' char(p.f1) ') - (' char(p.f2) ')'];
|
||||
s = ['(' char(p.f1) ') - (' char(p.f2) ')'];
|
||||
elseif strcmp(p.typ,'prod')
|
||||
s = ['(' char(p.f1) ') * (' char(p.f2) ')'];
|
||||
s = ['(' char(p.f1) ') * (' char(p.f2) ')'];
|
||||
elseif strcmp(p.typ,'ratio')
|
||||
s = ['(' char(p.f1) ') / (' char(p.f2) ')'];
|
||||
s = ['(' char(p.f1) ') / (' char(p.f2) ')'];
|
||||
elseif all(p.coeffs == 0)
|
||||
s = '0';
|
||||
s = '0';
|
||||
else
|
||||
if strcmp(p.typ,'polynomial')
|
||||
d = length(p.coeffs) - 1;
|
||||
s = [];
|
||||
nn = 0;
|
||||
for b = p.coeffs;
|
||||
cc(d+1-nn) = b;
|
||||
nn = nn + 1;
|
||||
if strcmp(p.typ,'polynomial')
|
||||
d = length(p.coeffs) - 1;
|
||||
s = [];
|
||||
nn = 0;
|
||||
for b = p.coeffs;
|
||||
cc(d+1-nn) = b;
|
||||
nn = nn + 1;
|
||||
end
|
||||
for a = cc;
|
||||
if a ~= 0;
|
||||
if ~isempty(s)
|
||||
if a > 0
|
||||
s = [s ' + '];
|
||||
else
|
||||
s = [s ' - '];
|
||||
a = -a;
|
||||
end
|
||||
end
|
||||
if a ~= 1 | d == 0
|
||||
s = [s num2str(a)];
|
||||
if d > 0
|
||||
s = [s '*'];
|
||||
end
|
||||
end
|
||||
if d >= 2
|
||||
s = [s 'x^' int2str(d)];
|
||||
elseif d == 1
|
||||
s = [s 'x'];
|
||||
end
|
||||
end
|
||||
d = d - 1;
|
||||
end
|
||||
elseif strcmp(p.typ,'gaussian')
|
||||
s = num2str(p.coeffs(1));
|
||||
s = ['Gaussian(' num2str(p.coeffs(1)) ',' ...
|
||||
num2str(p.coeffs(2)) ',' ...
|
||||
num2str(p.coeffs(3)) ')'];
|
||||
elseif strcmp(p.typ,'fourier')
|
||||
c = reshape(p.coeffs, [],2);
|
||||
Ao = c(1,1);
|
||||
w = c(1,2);
|
||||
A = c(2:end,1);
|
||||
B = c(2:end,2);
|
||||
N = size(c,1)-1;
|
||||
if Ao ~= 0
|
||||
s = [num2str(Ao/2)];
|
||||
else
|
||||
s = '';
|
||||
end
|
||||
for n=1:N
|
||||
if A(n) ~= 0
|
||||
if A(n) < 0
|
||||
prefix = ' - ';
|
||||
elseif s
|
||||
prefix = ' + ';
|
||||
else
|
||||
prefix = '';
|
||||
end
|
||||
|
||||
s = [s prefix num2str(abs(A(n))) '*cos(' num2str(n*w) '*x)'];
|
||||
end
|
||||
|
||||
if B(n) ~= 0
|
||||
if B(n) < 0
|
||||
prefix = ' - ';
|
||||
elseif s
|
||||
prefix = ' + ';
|
||||
else
|
||||
prefix = '';
|
||||
end
|
||||
|
||||
s = [s prefix num2str(abs(B(n))) '*sin(' num2str(n*w) '*x)'];
|
||||
end
|
||||
end
|
||||
else
|
||||
s = ['*** char not yet implemented for' p.typ ' ***'];
|
||||
end
|
||||
for a = cc;
|
||||
if a ~= 0;
|
||||
if ~isempty(s)
|
||||
if a > 0
|
||||
s = [s ' + '];
|
||||
else
|
||||
s = [s ' - '];
|
||||
a = -a;
|
||||
end
|
||||
end
|
||||
if a ~= 1 | d == 0
|
||||
s = [s num2str(a)];
|
||||
if d > 0
|
||||
s = [s '*'];
|
||||
end
|
||||
end
|
||||
if d >= 2
|
||||
s = [s 'x^' int2str(d)];
|
||||
elseif d == 1
|
||||
s = [s 'x'];
|
||||
end
|
||||
end
|
||||
d = d - 1;
|
||||
end
|
||||
elseif strcmp(p.typ,'gaussian')
|
||||
s = num2str(p.coeffs(1));
|
||||
s = ['Gaussian(' num2str(p.coeffs(1)) ',' ...
|
||||
num2str(p.coeffs(2)) ',' ...
|
||||
num2str(p.coeffs(3)) ')'];
|
||||
elseif strcmp(p.typ,'fourier')
|
||||
c = reshape(p.coeffs, [],2);
|
||||
Ao = c(1,1);
|
||||
w = c(1,2);
|
||||
A = c(2:end,1);
|
||||
B = c(2:end,2);
|
||||
N = size(c,1)-1;
|
||||
if Ao ~= 0
|
||||
s = [num2str(Ao/2)];
|
||||
else
|
||||
s = '';
|
||||
end
|
||||
for n=1:N
|
||||
if A(n) ~= 0
|
||||
if A(n) < 0
|
||||
prefix = ' - ';
|
||||
elseif s
|
||||
prefix = ' + ';
|
||||
else
|
||||
prefix = '';
|
||||
end
|
||||
|
||||
s = [s prefix num2str(abs(A(n))) '*cos(' num2str(n*w) '*x)'];
|
||||
end
|
||||
|
||||
if B(n) ~= 0
|
||||
if B(n) < 0
|
||||
prefix = ' - ';
|
||||
elseif s
|
||||
prefix = ' + ';
|
||||
else
|
||||
prefix = '';
|
||||
end
|
||||
|
||||
s = [s prefix num2str(abs(B(n))) '*sin(' num2str(n*w) '*x)'];
|
||||
end
|
||||
end
|
||||
else
|
||||
s = ['*** char not yet implemented for' p.typ ' ***'];
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
function d = display(a)
|
||||
% DISPLAY -
|
||||
% DISPLAY -
|
||||
%
|
||||
disp(' ');
|
||||
disp([inputname(1),' = '])
|
||||
disp(' ');
|
||||
disp([' ' char(a)])
|
||||
disp(' ');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,5 @@ function r = plus(a, b)
|
|||
%
|
||||
% PLUS - Return a functor representing the sum of two functors a
|
||||
% and b.
|
||||
%
|
||||
%
|
||||
r = Func('sum',a,b);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
function v = funcmethods(n, job, a, b, c, d)
|
||||
%
|
||||
%
|
||||
if nargin == 2
|
||||
v = ctmethods(110, n, job);
|
||||
v = ctmethods(110, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(110, n, job, a);
|
||||
v = ctmethods(110, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(110, n, job, a, b);
|
||||
v = ctmethods(110, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(110, n, job, a, b, c);
|
||||
v = ctmethods(110, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(110, n, job, a, b, c, d);
|
||||
end
|
||||
v = ctmethods(110, n, job, a, b, c, d);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function r = rdivide(a,b)
|
||||
% RDIVIDE -
|
||||
%
|
||||
% RDIVIDE -
|
||||
%
|
||||
r = Func('ratio',a,b);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
function b = subsref(a,s)
|
||||
% SUBSREF
|
||||
% SUBSREF
|
||||
switch s.type
|
||||
case '()'
|
||||
ind = s.subs{:};
|
||||
for k = 1:length(ind)
|
||||
b(k) = funcmethods(2,a.index,ind(k));
|
||||
end
|
||||
otherwise
|
||||
error('Specify value for x as p(x)')
|
||||
case '()'
|
||||
ind = s.subs{:};
|
||||
for k = 1:length(ind)
|
||||
b(k) = funcmethods(2,a.index,ind(k));
|
||||
end
|
||||
otherwise
|
||||
error('Specify value for x as p(x)')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function r = times(a,b)
|
||||
% TIMES -
|
||||
%
|
||||
% TIMES -
|
||||
%
|
||||
r = Func('prod',a,b);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,17 @@ doc = XML_Node('doc',src);
|
|||
node = findByID(doc,id);
|
||||
t = ThermoPhase(node);
|
||||
if nargin == 2
|
||||
k = Kinetics(node,t);
|
||||
k = Kinetics(node,t);
|
||||
elseif nargin == 3
|
||||
k = Kinetics(node,t,p1);
|
||||
k = Kinetics(node,t,p1);
|
||||
elseif nargin == 4
|
||||
k = Kinetics(node,t,p1,p2);
|
||||
k = Kinetics(node,t,p1,p2);
|
||||
elseif nargin == 5
|
||||
k = Kinetics(node,t,p1,p2,p3);
|
||||
k = Kinetics(node,t,p1,p2,p3);
|
||||
elseif nargin == 6
|
||||
k = Kinetics(node,t,p1,p2,p3,p4);
|
||||
k = Kinetics(node,t,p1,p2,p3,p4);
|
||||
end
|
||||
|
||||
s.kin = k;
|
||||
s.th = t;
|
||||
s = class(s,'Interface',t,k);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
function c = concentrations(s)
|
||||
% CONCENTRATIONS - Surface concentrations
|
||||
%
|
||||
%
|
||||
c = surfmethods(thermo_hndl(s), 101);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Concentrations')
|
||||
bar(c);
|
||||
colormap(summer);
|
||||
nm = speciesNames(s);
|
||||
legend(nm);
|
||||
xlabel('Species Number');
|
||||
ylabel('Concentration [kmol/m2]');
|
||||
title('Surface Species Concentrations');
|
||||
figure
|
||||
set(gcf,'Name','Concentrations')
|
||||
bar(c);
|
||||
colormap(summer);
|
||||
nm = speciesNames(s);
|
||||
legend(nm);
|
||||
xlabel('Species Number');
|
||||
ylabel('Concentration [kmol/m2]');
|
||||
title('Surface Species Concentrations');
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
function c = coverages(s)
|
||||
% COVERAGES - Surface coverages
|
||||
%
|
||||
%
|
||||
c = surfmethods(thermo_hndl(s), 101);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Coverages')
|
||||
bar(c);
|
||||
colormap(summer);
|
||||
nm = speciesNames(s);
|
||||
legend(nm);
|
||||
xlabel('Species Number');
|
||||
ylabel('Coverage');
|
||||
title('Surface Species Coverages');
|
||||
figure
|
||||
set(gcf,'Name','Coverages')
|
||||
bar(c);
|
||||
colormap(summer);
|
||||
nm = speciesNames(s);
|
||||
legend(nm);
|
||||
xlabel('Species Number');
|
||||
ylabel('Coverage');
|
||||
title('Surface Species Coverages');
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,20 +6,19 @@ function v = surfmethods(n, job, a, b, c, d, e, f)
|
|||
% and simply calls ctmethods with a flag associated with this class
|
||||
% as the first parameter, followed by the input arguments.
|
||||
if nargin == 2
|
||||
v = ctmethods(100, n, job);
|
||||
v = ctmethods(100, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(100, n, job, a);
|
||||
v = ctmethods(100, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(100, n, job, a, b);
|
||||
v = ctmethods(100, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(100, n, job, a, b, c);
|
||||
v = ctmethods(100, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(100, n, job, a, b, c, d);
|
||||
v = ctmethods(100, n, job, a, b, c, d);
|
||||
elseif nargin == 7
|
||||
v = ctmethods(100, n, job, a, b, c, d, e);
|
||||
v = ctmethods(100, n, job, a, b, c, d, e);
|
||||
elseif nargin == 8
|
||||
v = ctmethods(100, n, job, a, b, c, d, e, f);
|
||||
v = ctmethods(100, n, job, a, b, c, d, e, f);
|
||||
else
|
||||
error('too many arguments');
|
||||
error('too many arguments');
|
||||
end
|
||||
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
function setCoverages(s,cov)
|
||||
% SETCOVERAGES - set surface coverages
|
||||
%
|
||||
%
|
||||
if isa(cov,'double')
|
||||
sz = length(cov);
|
||||
if sz == nSpecies(s)
|
||||
surfmethods(thermo_hndl(s), 3, cov);
|
||||
else
|
||||
error('wrong size for coverage array');
|
||||
end
|
||||
sz = length(cov);
|
||||
if sz == nSpecies(s)
|
||||
surfmethods(thermo_hndl(s), 3, cov);
|
||||
else
|
||||
error('wrong size for coverage array');
|
||||
end
|
||||
elseif isa(cov,'char')
|
||||
surfmethods(thermo_hndl(s), 5, cov);
|
||||
surfmethods(thermo_hndl(s), 5, cov);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
function k = Kinetics(r, ph, neighbor1, neighbor2, neighbor3, neighbor4)
|
||||
%
|
||||
% KINETICS - Kinetics class constructor.
|
||||
% KINETICS - Kinetics class constructor.
|
||||
%
|
||||
% Class Kinetics represents kinetics managers, which are classes
|
||||
% that manage reaction mechanisms. The reaction mechanism
|
||||
% attributes are specified in a CTML file.
|
||||
% attributes are specified in a CTML file.
|
||||
%
|
||||
|
||||
% indices for bulk phases in a heterogeneous mechanism.
|
||||
|
|
@ -17,42 +17,42 @@ ineighbor4 = -1;
|
|||
% if only one argument is supplied, and it is an instance of
|
||||
% 'Kinetics', return a copy of this instance
|
||||
if nargin == 1
|
||||
if isa(r,'Kinetics')
|
||||
k = r;
|
||||
return
|
||||
else
|
||||
error('wrong number of arguments')
|
||||
end
|
||||
if isa(r,'Kinetics')
|
||||
k = r;
|
||||
return
|
||||
else
|
||||
error('wrong number of arguments')
|
||||
end
|
||||
end
|
||||
|
||||
% if more than one arguement, first one must be an XML_Node
|
||||
% instance representing the XML tree
|
||||
if ~isa(r,'XML_Node')
|
||||
error('first argument must be an XML_Node object')
|
||||
error('first argument must be an XML_Node object')
|
||||
end
|
||||
|
||||
k.owner = 1;
|
||||
ixml = hndl(r);
|
||||
|
||||
% get the integer indices used to find the stored objects
|
||||
% representing the phases participating in the mechanism.
|
||||
% representing the phases participating in the mechanism.
|
||||
iphase = thermo_hndl(ph);
|
||||
if nargin > 2
|
||||
ineighbor1 = thermo_hndl(neighbor1);
|
||||
if nargin > 3
|
||||
ineighbor2 = thermo_hndl(neighbor2);
|
||||
if nargin > 4
|
||||
ineighbor3 = thermo_hndl(neighbor3);
|
||||
if nargin > 5
|
||||
ineighbor4 = thermo_hndl(neighbor4);
|
||||
end
|
||||
ineighbor1 = thermo_hndl(neighbor1);
|
||||
if nargin > 3
|
||||
ineighbor2 = thermo_hndl(neighbor2);
|
||||
if nargin > 4
|
||||
ineighbor3 = thermo_hndl(neighbor3);
|
||||
if nargin > 5
|
||||
ineighbor4 = thermo_hndl(neighbor4);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
k.id = kinetics_get(ixml,0,iphase,ineighbor1,ineighbor2,ineighbor3, ...
|
||||
ineighbor4);
|
||||
ineighbor4);
|
||||
if k.id < 0
|
||||
error(geterr);
|
||||
error(geterr);
|
||||
end
|
||||
|
||||
k = class(k,'Kinetics');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function advanceCoverages(k, dt)
|
||||
% ADVANCECOVERAGES - advance the surface coverages forward in time holding the bulk phase concentrations fixed.
|
||||
%
|
||||
%
|
||||
kinetics_set(k.id, 5, 0, dt);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
function clear(k)
|
||||
% CLEAR - delete the Kinetics instance.
|
||||
%
|
||||
%
|
||||
kinetics_set(k.id,3);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,16 @@ function cdot = creationRates(a)
|
|||
%
|
||||
% Returns a column vector of the creation rates of all
|
||||
% species. If the output is not assigned to a variable, a
|
||||
% bar graph is produced.
|
||||
% bar graph is produced.
|
||||
%
|
||||
% See also: destructionRates, netProdRates.
|
||||
%
|
||||
cdot = kinetics_get(a.id,21,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Creation Rates')
|
||||
bar(cdot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Creation Rate (kmol/m^3-s)')
|
||||
title('Species Chemical Creation Rates')
|
||||
figure
|
||||
set(gcf,'Name','Creation Rates')
|
||||
bar(cdot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Creation Rate (kmol/m^3-s)')
|
||||
title('Species Chemical Creation Rates')
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,16 @@ function ddot = destructionRates(a)
|
|||
%
|
||||
% Returns a column vector of the destruction rates of all
|
||||
% species. If the output is not assigned to a variable, a
|
||||
% bar graph is produced.
|
||||
% bar graph is produced.
|
||||
%
|
||||
% See also: creationRates, netProdRates.
|
||||
%
|
||||
ddot = kinetics_get(a.id,22,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Destruction Rates')
|
||||
bar(ddot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Destruction Rate (kmol/m^3/s)')
|
||||
title('Species Chemical Destruction Rates')
|
||||
figure
|
||||
set(gcf,'Name','Destruction Rates')
|
||||
bar(ddot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Destruction Rate (kmol/m^3/s)')
|
||||
title('Species Chemical Destruction Rates')
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,18 +3,16 @@ function q = destruction_rates(a)
|
|||
%
|
||||
% q = destruction_rates(a)
|
||||
%
|
||||
% Returns a column vector of the destruction rates of all species.
|
||||
% Returns a column vector of the destruction rates of all species.
|
||||
%
|
||||
% See also: creation_rates, net_production_rates.
|
||||
%
|
||||
q = production(a.id,nSpecies(a.ph),1);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Destruction Rates')
|
||||
bar(q)
|
||||
xlabel('Species Number')
|
||||
ylabel('Destruction Rate (kmol/m^3/s)')
|
||||
title('Species Chemical Destruction Rates')
|
||||
figure
|
||||
set(gcf,'Name','Destruction Rates')
|
||||
bar(q)
|
||||
xlabel('Species Number')
|
||||
ylabel('Destruction Rate (kmol/m^3/s)')
|
||||
title('Species Chemical Destruction Rates')
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ function kc = equil_Kc(a)
|
|||
%
|
||||
kc = kinetics_get(a.id,14,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Equilibrium Constants')
|
||||
bar(log10(kc))
|
||||
xlabel('Reaction Number')
|
||||
ylabel('log_1_0 Kc [kmol, m, s]')
|
||||
title('Equilibrium Constants Kc')
|
||||
figure
|
||||
set(gcf,'Name','Equilibrium Constants')
|
||||
bar(log10(kc))
|
||||
xlabel('Reaction Number')
|
||||
ylabel('log_1_0 Kc [kmol, m, s]')
|
||||
title('Equilibrium Constants Kc')
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
function i = kinetics_hndl(k)
|
||||
% KINETICS_HNDL - integer used to access kernel object
|
||||
%
|
||||
%
|
||||
i = k.id;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@ function n = multiplier(a,irxn)
|
|||
% disable reactions. For reversible reactions, it multiplies both
|
||||
% the forward and reverse rates. By default, the multiplier value
|
||||
% is 1.0, but it may be set to any other value by calling method
|
||||
% setMultiplier.
|
||||
% setMultiplier.
|
||||
%
|
||||
% MULTIPLIER(K, IRXN) Multiplier for reaction number IRXN
|
||||
%
|
||||
n = kinetics_get(a.id,2,irxn);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,3 @@ function n = nReactions(a)
|
|||
% NREACTIONS - Number of reactions.
|
||||
%
|
||||
n = kinetics_get(a.id,1,0);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function nsp = nTotalSpecies(a)
|
||||
% NTOTALSPECIES - The total number of species, summed over all
|
||||
% participating phases.
|
||||
%
|
||||
% participating phases.
|
||||
%
|
||||
nsp = kinetics_get(a.id, 3, 0);
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ function wdot = netProdRates(a)
|
|||
%
|
||||
wdot = kinetics_get(a.id,23,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Production Rates')
|
||||
bar(wdot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Net Production Rate (kmol/m^3/s)')
|
||||
title('Species Net Chemical Production Rates')
|
||||
figure
|
||||
set(gcf,'Name','Production Rates')
|
||||
bar(wdot)
|
||||
xlabel('Species Number')
|
||||
ylabel('Net Production Rate (kmol/m^3/s)')
|
||||
title('Species Net Chemical Production Rates')
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
function v = kinetics_get(n, job, a, b, c, d, e, f)
|
||||
% KINETICS_GET - get kinetics attributes
|
||||
%
|
||||
% KINETICS_GET - get kinetics attributes
|
||||
%
|
||||
if nargin == 2
|
||||
v = ctmethods(40, n, job);
|
||||
v = ctmethods(40, n, job);
|
||||
elseif nargin == 3
|
||||
v = ctmethods(40, n, job, a);
|
||||
v = ctmethods(40, n, job, a);
|
||||
elseif nargin == 4
|
||||
v = ctmethods(40, n, job, a, b);
|
||||
v = ctmethods(40, n, job, a, b);
|
||||
elseif nargin == 5
|
||||
v = ctmethods(40, n, job, a, b, c);
|
||||
v = ctmethods(40, n, job, a, b, c);
|
||||
elseif nargin == 6
|
||||
v = ctmethods(40, n, job, a, b, c, d);
|
||||
v = ctmethods(40, n, job, a, b, c, d);
|
||||
elseif nargin == 7
|
||||
v = ctmethods(40, n, job, a, b, c, d, e);
|
||||
v = ctmethods(40, n, job, a, b, c, d, e);
|
||||
elseif nargin == 8
|
||||
v = ctmethods(40, n, job, a, b, c, d, e, f);
|
||||
end
|
||||
v = ctmethods(40, n, job, a, b, c, d, e, f);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
function kinetics_set(n, job, a, b)
|
||||
% KINETICS_SET - get kinetics attributes
|
||||
%
|
||||
% KINETICS_SET - get kinetics attributes
|
||||
%
|
||||
ctmethods(40, n, -job, a, b)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,28 +2,24 @@ function e = reactionEqn(a, irxn)
|
|||
% reactionEqn Reaction equation of reaction irxn.
|
||||
%
|
||||
if nargin == 1
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]';
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]';
|
||||
elseif nargin == 2
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
else
|
||||
error('reaction number(s) must be numeric');
|
||||
end
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
else
|
||||
error('reaction number(s) must be numeric');
|
||||
end
|
||||
end
|
||||
|
||||
if m == 1 & n == 1
|
||||
e = kinetics_get(a.id, 31, irxn); % rxnstring(a.id, irxn);
|
||||
e = kinetics_get(a.id, 31, irxn); % rxnstring(a.id, irxn);
|
||||
else
|
||||
e = {};
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
e{i,j} = kinetics_get(a.id, 31, irxn(i,j)); % rxnstring(a.id, irxn(i,j));
|
||||
end
|
||||
end
|
||||
e = {};
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
e{i,j} = kinetics_get(a.id, 31, irxn(i,j)); % rxnstring(a.id, irxn(i,j));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ function rop = rop(k)
|
|||
% progress. The first column contains the forward rates of progress,
|
||||
% and the second column the reverse rates. If this function
|
||||
% is called with no output argument, a bar graph is produced.
|
||||
%
|
||||
f = rop_f(k)
|
||||
%
|
||||
f = rop_f(k)
|
||||
r = rop_r(k)
|
||||
rop = [f r]
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress');
|
||||
bar(rop);
|
||||
xlabel('Reaction Number');
|
||||
ylabel('Rate of Progress [kmol/m^3-s]');
|
||||
title('Rates of Progress');
|
||||
legend('Forward', 'Reverse');
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress');
|
||||
bar(rop);
|
||||
xlabel('Reaction Number');
|
||||
ylabel('Rate of Progress [kmol/m^3-s]');
|
||||
title('Rates of Progress');
|
||||
legend('Forward', 'Reverse');
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@ function q = rop_f(a)
|
|||
%
|
||||
q = kinetics_get(a.id,11,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress')
|
||||
bar(q)
|
||||
xlabel('Reaction Number')
|
||||
ylabel('Forward Rate of Progress [kmol/m^3]')
|
||||
title('Forward Rates of Progress')
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress')
|
||||
bar(q)
|
||||
xlabel('Reaction Number')
|
||||
ylabel('Forward Rate of Progress [kmol/m^3]')
|
||||
title('Forward Rates of Progress')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@ function q = rop_net(a)
|
|||
%
|
||||
q = kinetics_get(a.id,13,0);
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress')
|
||||
bar(q)
|
||||
xlabel('Reaction Number')
|
||||
ylabel('Net Rate of Progress [kmol/m^3]')
|
||||
title('Net Rates of Progress')
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress')
|
||||
bar(q)
|
||||
xlabel('Reaction Number')
|
||||
ylabel('Net Rate of Progress [kmol/m^3]')
|
||||
title('Net Rates of Progress')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ function q = rop_r(a)
|
|||
%
|
||||
% Returns a column vector of the reverse rates of progress
|
||||
% for all reactions. The value is zero for irreversible
|
||||
% reactions.
|
||||
% reactions.
|
||||
%
|
||||
% See also: rop_r, rop_net.
|
||||
%
|
||||
q = kinetics_get(a.id,12,0);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +1,25 @@
|
|||
function e = rxnEqs(a, irxn)
|
||||
% rxnEqs
|
||||
% rxnEqs
|
||||
%
|
||||
if nargin == 1
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]'
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]'
|
||||
elseif nargin == 2
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
else
|
||||
error('reaction number(s) must be numeric');
|
||||
end
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
else
|
||||
error('reaction number(s) must be numeric');
|
||||
end
|
||||
end
|
||||
|
||||
if m == 1 & n == 1
|
||||
e = rxnstring(a.id, irxn);
|
||||
e = rxnstring(a.id, irxn);
|
||||
else
|
||||
e = {};
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
e{i,j} = rxnstring(a.id, irxn(i,j));
|
||||
end
|
||||
end
|
||||
e = {};
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
e{i,j} = rxnstring(a.id, irxn(i,j));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,18 +7,16 @@ function setMultiplier(a,irxn,v)
|
|||
% see also: MULTIPLIER
|
||||
%
|
||||
if nargin == 2
|
||||
v = irxn;
|
||||
m = nReactions(a);
|
||||
irxn = [1:m]';
|
||||
n = 1;
|
||||
v = irxn;
|
||||
m = nReactions(a);
|
||||
irxn = [1:m]';
|
||||
n = 1;
|
||||
else
|
||||
[m, n] = size(irxn);
|
||||
[m, n] = size(irxn);
|
||||
end
|
||||
|
||||
for jm = 1:m
|
||||
for jn = 1:n
|
||||
kinetics_set(a.id,1,irxn(jm,jn),v);
|
||||
end
|
||||
for jn = 1:n
|
||||
kinetics_set(a.id,1,irxn(jm,jn),v);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ function nu = stoich_net(a,species,rxns)
|
|||
% See also: stoich_r, stoich_p.
|
||||
%
|
||||
if nargin == 1
|
||||
nu = stoich_p(a) - stoich_r(a)
|
||||
nu = stoich_p(a) - stoich_r(a)
|
||||
elseif nargin == 3
|
||||
nu = stoich_p(a,species,rxns) - stoich_r(a,species,rxns);
|
||||
nu = stoich_p(a,species,rxns) - stoich_r(a,species,rxns);
|
||||
else
|
||||
error(['syntax error. Type ''help stoich_net'' for more' ...
|
||||
' information.'])
|
||||
error(['syntax error. Type ''help stoich_net'' for more' ...
|
||||
' information.'])
|
||||
end
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue