Fixed issues with Matlab toolbox identified by the code analyzer
This commit is contained in:
parent
790d40b00c
commit
e4f2acaf3d
40 changed files with 72 additions and 84 deletions
|
|
@ -2,6 +2,7 @@ function s = componentName(d, n)
|
|||
% COMPONENTNAME - Name of component n.
|
||||
%
|
||||
m = length(n);
|
||||
s = cell(m);
|
||||
for i = 1:m
|
||||
s{i} = domain_methods(d.dom_id, 40, n(i));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ function zz = gridPoints(d, n)
|
|||
% GRID -
|
||||
%
|
||||
if nargin == 1
|
||||
zz = zeros(1, nPoints(d));
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
else
|
||||
m = length(n);
|
||||
zz = zeros(1, m);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ end
|
|||
|
||||
ion = -1;
|
||||
if isa(onoff,'char')
|
||||
if strcmp(onoff,'on') | strcmp(onoff,'yes')
|
||||
if strcmp(onoff,'on') || strcmp(onoff,'yes')
|
||||
ion = 1;
|
||||
elseif strcmp(onoff,'off') | strcmp(onoff,'no')
|
||||
elseif strcmp(onoff,'off') || strcmp(onoff,'no')
|
||||
ion = 0;
|
||||
else
|
||||
error(strcat('unknown option: ',onoff))
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ function zz = z(d, n)
|
|||
% GRID -
|
||||
%
|
||||
if nargin == 1
|
||||
zz = zeros(1, nPoints(d));
|
||||
for i = 1:nPoints(d)
|
||||
zz(i) = domain_methods(d.dom_id, 19, i);
|
||||
end
|
||||
else
|
||||
m = length(n);
|
||||
zz = zeros(1, m);
|
||||
for i = 1:m
|
||||
zz(i) = domain_methods(d.dom_id, 19, n(i));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ s.stack_id = -1;
|
|||
s.domains = domains;
|
||||
if nargin == 1
|
||||
nd = length(domains);
|
||||
ids = zeros(1, nd);
|
||||
for n=1:nd
|
||||
ids(n) = domain_hndl(domains(n));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function saveSoln(s, fname, id, desc)
|
||||
function save(s, fname, id, desc)
|
||||
% SAVE -
|
||||
%
|
||||
if nargin == 2
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ end
|
|||
|
||||
d = s.domains(n);
|
||||
|
||||
if isa(comp,'double') | isa(comp,'cell')
|
||||
if isa(comp,'double') || isa(comp,'cell')
|
||||
c = comp;
|
||||
elseif isa(comp,'char')
|
||||
c = {comp};
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@ function x = solution(s, domain, component)
|
|||
%
|
||||
idom = domainIndex(s, domain);
|
||||
d = s.domains(idom);
|
||||
|
||||
np = nPoints(d);
|
||||
if nargin == 3
|
||||
icomp = componentIndex(d, component);
|
||||
for n = 1:nPoints(d)
|
||||
x = zeros(1, np);
|
||||
for n = 1:np
|
||||
x(n) = stack_methods(s.stack_id, 30, idom, icomp, n);
|
||||
end
|
||||
else
|
||||
nc = nComponents(d);
|
||||
np = nPoints(d);
|
||||
x = zeros(nc, np);
|
||||
for m = 1:nc
|
||||
for n = 1:np
|
||||
x(m,n) = stack_methods(s.stack_id, 30, idom, m, n);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ if nargin < 2
|
|||
setID(m,id);
|
||||
end
|
||||
else
|
||||
m = Domain1D(6, surface_mech)
|
||||
m = Domain1D(6, surface_mech);
|
||||
setID(m,id);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
function n = nComponents(d)
|
||||
n = domain_methods(d.dom_id, 11)
|
||||
n = domain_methods(d.dom_id, 11);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ wt = molecularWeights(gas);
|
|||
% find the fuel and oxidizer
|
||||
ifuel = speciesIndex(gas,fuel);
|
||||
ioxidizer = speciesIndex(gas,oxidizer);
|
||||
ih = speciesIndex(gas,'H');
|
||||
|
||||
s = nuox*wt(ioxidizer)/wt(ifuel);
|
||||
y0f = massFraction(left,ifuel);
|
||||
|
|
@ -59,6 +58,9 @@ nsp = nSpecies(gas);
|
|||
tf = temperature(left);
|
||||
tox = temperature(right);
|
||||
|
||||
yox = zeros(1, nsp);
|
||||
yf = zeros(1, nsp);
|
||||
ystoich = zeros(1, nsp);
|
||||
for n = 1:nsp
|
||||
yox(n) = massFraction(right,n);
|
||||
yf(n) = massFraction(left,n);
|
||||
|
|
@ -82,6 +84,11 @@ f = sqrt(a/(2.0*diff(ioxidizer)));
|
|||
x0 = massFlux(left)*dz/(massFlux(left) + massFlux(right));
|
||||
|
||||
nz = nPoints(flow);
|
||||
zm = zeros(1,nz);
|
||||
u = zeros(1,nz);
|
||||
v = zeros(1,nz);
|
||||
y = zeros(nz,nsp);
|
||||
t = zeros(1,nz);
|
||||
for j = 1:nz
|
||||
x = zz(j);
|
||||
zeta = f*(x - x0);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function install(f, upstream, downstream)
|
||||
|
||||
if nargin == 3
|
||||
if ~isa(upstream,'Reactor') | ~isa(downstream,'Reactor')
|
||||
if ~isa(upstream,'Reactor') || ~isa(downstream,'Reactor')
|
||||
error(['Flow devices can only be installed between reactors or' ...
|
||||
' reservoirs'])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ else
|
|||
a = -a;
|
||||
end
|
||||
end
|
||||
if a ~= 1 | d == 0
|
||||
if a ~= 1 || d == 0
|
||||
s = [s num2str(a)];
|
||||
if d > 0
|
||||
s = [s '*'];
|
||||
|
|
@ -45,7 +45,6 @@ else
|
|||
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)) ')'];
|
||||
|
|
@ -57,7 +56,7 @@ else
|
|||
B = c(2:end,2);
|
||||
N = size(c,1)-1;
|
||||
if Ao ~= 0
|
||||
s = [num2str(Ao/2)];
|
||||
s = num2str(Ao/2);
|
||||
else
|
||||
s = '';
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function d = display(a)
|
||||
function display(a)
|
||||
% DISPLAY -
|
||||
%
|
||||
disp(' ');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ function b = subsref(a,s)
|
|||
switch s.type
|
||||
case '()'
|
||||
ind = s.subs{:};
|
||||
b = zeros(1, length(ind));
|
||||
for k = 1:length(ind)
|
||||
b(k) = funcmethods(2,a.index,ind(k));
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ function e = reactionEqn(a, irxn)
|
|||
if nargin == 1
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]';
|
||||
irxn = (1:m)';
|
||||
elseif nargin == 2
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
|
|
@ -13,10 +13,10 @@ elseif nargin == 2
|
|||
end
|
||||
end
|
||||
|
||||
if m == 1 & n == 1
|
||||
if m == 1 && n == 1
|
||||
e = kinetics_get(a.id, 31, irxn); % rxnstring(a.id, irxn);
|
||||
else
|
||||
e = {};
|
||||
e = cell(m,n);
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ function rop = rop(k)
|
|||
% 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)
|
||||
r = rop_r(k)
|
||||
rop = [f r]
|
||||
f = rop_f(k);
|
||||
r = rop_r(k);
|
||||
rop = [f r];
|
||||
if nargout == 0
|
||||
figure
|
||||
set(gcf,'Name','Rates of Progress');
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ function e = rxnEqs(a, irxn)
|
|||
if nargin == 1
|
||||
m = nReactions(a);
|
||||
n = 1;
|
||||
irxn = [1:m]'
|
||||
irxn = (1:m)';
|
||||
elseif nargin == 2
|
||||
if isa(irxn,'double')
|
||||
[m, n] = size(irxn);
|
||||
|
|
@ -13,10 +13,10 @@ elseif nargin == 2
|
|||
end
|
||||
end
|
||||
|
||||
if m == 1 & n == 1
|
||||
if m == 1 && n == 1
|
||||
e = rxnstring(a.id, irxn);
|
||||
else
|
||||
e = {};
|
||||
e = cell(m,n);
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
e{i,j} = rxnstring(a.id, irxn(i,j));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function setMultiplier(a,irxn,v)
|
|||
if nargin == 2
|
||||
v = irxn;
|
||||
m = nReactions(a);
|
||||
irxn = [1:m]';
|
||||
irxn = (1:m)';
|
||||
n = 1;
|
||||
else
|
||||
[m, n] = size(irxn);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ 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);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ if nargin == 2
|
|||
moles = mixturemethods(28, mix_hndl(self), n);
|
||||
elseif nargin == 1
|
||||
np = nPhases(self);
|
||||
m = zeros(1,np);
|
||||
for n = 1:np
|
||||
m(n) = mixturemethods(28, mix_hndl(self), n);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ function y = massFractions(r)
|
|||
%
|
||||
nsp = nSpecies(r.contents);
|
||||
ir = reactor_hndl(r);
|
||||
y = zeros(1, nsp);
|
||||
for k = 1:nsp
|
||||
yy(k) = reactormethods(30, ir, k-1);
|
||||
y(k) = reactormethods(30, ir, k-1);
|
||||
end
|
||||
y = yy;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function setEnergy(f, flag)
|
|||
% >>> setEnergy(r, 'on');
|
||||
% >>> setEnergy(r, 'off');
|
||||
%
|
||||
iflag = -1
|
||||
iflag = -1;
|
||||
if strcmp(flag,{'on'})
|
||||
iflag = 1;
|
||||
elseif strcmp(flag,{'off'})
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
function i = reactor_hndl(r)
|
||||
function i = reactornet_hndl(r)
|
||||
i = r.index;
|
||||
|
|
|
|||
|
|
@ -148,23 +148,23 @@ elseif ntot == 2
|
|||
%
|
||||
% set property pairs
|
||||
%
|
||||
if nt == 1 & nv == 1
|
||||
if nt == 1 && nv == 1
|
||||
setTemperature(a,tval);
|
||||
setDensity(a,1.0/vval);
|
||||
elseif nt == 1 & np == 1
|
||||
elseif nt == 1 && np == 1
|
||||
setTemperature(a,tval);
|
||||
setPressure(a, pval);
|
||||
elseif nt == 1 & nq == 1
|
||||
elseif nt == 1 && nq == 1
|
||||
setState_Tsat(a, [tval,qval]);
|
||||
elseif np == 1 & nq == 1
|
||||
elseif np == 1 && nq == 1
|
||||
setState_Psat(a, [pval,qval]);
|
||||
elseif np == 1 & nh == 1
|
||||
elseif np == 1 && nh == 1
|
||||
setState_HP(a,[hval,pval]);
|
||||
elseif nu == 1 & nv == 1
|
||||
elseif nu == 1 && nv == 1
|
||||
setState_UV(a,[uval,vval]);
|
||||
elseif ns == 1 & np == 1
|
||||
elseif ns == 1 && np == 1
|
||||
setState_SP(a,[sval,pval]);
|
||||
elseif ns == 1 & nv == 1
|
||||
elseif ns == 1 && nv == 1
|
||||
setState_SV(a,[sval,vval]);
|
||||
else
|
||||
error('unimplemented property pair');
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function nm = elementName(a, m)
|
|||
% the same shape containing the name strings.
|
||||
%
|
||||
[mm, nn] = size(m);
|
||||
nm = {};
|
||||
nm = cell(mm,nn);
|
||||
for i = 1:mm
|
||||
for j = 1:nn
|
||||
nm{i,j} = phase_get(a.tp_id, 41, m(i,j));
|
||||
|
|
|
|||
|
|
@ -48,36 +48,7 @@ if nargin < 7
|
|||
loglevel = 0;
|
||||
end
|
||||
|
||||
iok = 0;
|
||||
iok = thermo_set(a.tp_id, 50, xy, solver, rtol, maxsteps, maxiter, loglevel);
|
||||
% $$$ switch xy
|
||||
% $$$ case 'TP'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 104, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'TV'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 100, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'HP'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 101, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'SP'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 102, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'SV'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 107, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'UV'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 105, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'PT'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 104, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'VT'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 100, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'PH'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 101, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'PS'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 102, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'VS'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 107, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ case 'VU'
|
||||
% $$$ iok = thermo_set(a.tp_id, 50, 105, solver, rtol, maxsteps, loglevel);
|
||||
% $$$ otherwise
|
||||
% $$$ error('unsupported option')
|
||||
% $$$ end
|
||||
if iok < 0
|
||||
e = geterr;
|
||||
if e == 0
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ function g_RT = gibbs_RT(p)
|
|||
% This method returns an array containing the pure species
|
||||
% standard-state Gibbs free energies.
|
||||
%
|
||||
g_RT = enthalpies_RT(g) - entropies_R(g);
|
||||
g_RT = enthalpies_RT(p) - entropies_R(p);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ if isa(species,'char')
|
|||
|
||||
elseif isa(species,'cell')
|
||||
n = length(species);
|
||||
y = zeros(1, n);
|
||||
for j = 1:n
|
||||
k = speciesIndex(s, species{j});
|
||||
if k > 0
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ if isa(species,'char')
|
|||
|
||||
elseif isa(species,'cell')
|
||||
n = length(species);
|
||||
x = zeros(1, n);
|
||||
for j = 1:n
|
||||
k = speciesIndex(s, species{j});
|
||||
if k > 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function a = setState(a,job,values)
|
||||
disp('deprecated')
|
||||
if nargin ~= 3 | ~isa(job,'char')
|
||||
if nargin ~= 3 || ~isa(job,'char')
|
||||
error('Syntax error. Type "help setState" for more information.')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ function nm = speciesName(a, k)
|
|||
% the same shape containing the name strings.
|
||||
%
|
||||
[m, n] = size(k);
|
||||
nm = {};
|
||||
nm = cell(m,n);
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
nm{i,j} = phase_get(a.tp_id, 40, k(i,j));
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function tr = Transport(xml_phase, th, model, loglevel)
|
|||
tr.id = 0;
|
||||
if nargin == 4
|
||||
tr.th = th;
|
||||
if model == 'default'
|
||||
if strcmp(model, 'default')
|
||||
try
|
||||
node = child(xml_phase,'transport');
|
||||
tr.model = attrib(node,'model');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function a = area(w)
|
||||
% AREA -
|
||||
%
|
||||
a = wallmethods(23, wall_hndl(w))
|
||||
a = wallmethods(23, wall_hndl(w));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function a = attrib(x, key)
|
||||
|
||||
if nargin ~= 2 | ~isa(key,'char')
|
||||
if nargin ~= 2 || ~isa(key,'char')
|
||||
error('Syntax error. Type "help attrib" for more information.')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
function x = build(x, file, pre)
|
||||
|
||||
if nargin < 2 | ~isa(file,'char')
|
||||
if nargin < 2 || ~isa(file,'char')
|
||||
error('Syntax error. Type "help build" for more information.')
|
||||
end
|
||||
|
||||
if nargin == 3 & pre > 0
|
||||
iok = ctmethods(10, 15, x.id, file)
|
||||
if nargin == 3 && pre > 0
|
||||
ctmethods(10, 15, x.id, file)
|
||||
else
|
||||
iok = ctmethods(10, 4, x.id, file)
|
||||
ctmethods(10, 4, x.id, file)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dydt = conhp(t,y,gas,mw)
|
||||
function dydt = conhp(t,y,gas,mw) %#ok<INUSL>
|
||||
% CONHP ODE system for a constant-pressure, adiabatic reactor.
|
||||
%
|
||||
% Function CONHP evaluates the system of ordinary differential
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dydt = conuv(t,y,gas,mw)
|
||||
function dydt = conuv(t,y,gas,mw) %#ok<INUSL>
|
||||
% CONUV ODE system for a constant-volume, adiabatic reactor.
|
||||
%
|
||||
% Function CONUV evaluates the system of ordinary differential
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function e = geterr
|
||||
try
|
||||
e = ctmethods(0,2); % getCanteraError;
|
||||
catch
|
||||
e = ' ';
|
||||
end
|
||||
catch ME
|
||||
e = getReport(ME);
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue