[Matlab] Trivial changes to variable names and whitespace for consistency

This commit is contained in:
Bryan W. Weber 2014-07-18 14:33:09 +00:00
parent f4041d6fb2
commit ab251257e5
172 changed files with 576 additions and 464 deletions

View file

@ -8,31 +8,31 @@ if nargin == 1
elseif nargin == 2
% a stagnation flow
if a == 1
if isa(b,'Solution')
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')
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');
error('Wrong object type.');
end
elseif nargin == 3
if a == 1
if isa(b,'Solution')
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('unknown domain type');
error('Unknown domain type.');
end
end
if d.dom_id < 0

View file

@ -1,7 +1,8 @@
function n = componentIndex(d, name)
% COMPONENTINDEX -
%
if isa(name,'double')
if isa(name, 'double')
n = name;
else
n = domain_methods(d.dom_id, 18, name);

View file

@ -5,12 +5,13 @@ function y = massFraction(d, k)
% 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('Input domain must be an inlet');
end

View file

@ -32,21 +32,21 @@ while length(property_argin) >= 2,
property_argin = property_argin(3:end);
switch prop
case 'Temperature'
setTemperature(a,val);
setTemperature(a, val);
case 'T'
setTemperature(a,val);
setTemperature(a, val);
case 'MassFractions'
setMassFractions(a,val);
setMassFractions(a, val);
case 'Y'
setMassFractions(a,val);
setMassFractions(a, val);
case 'mdot'
setMdot(a,val);
setMdot(a, val);
case 'MassFlux'
setMdot(a,val);
setMdot(a, val);
case 'P'
setPressure(a,val);
setPressure(a, val);
case 'Pressure'
setPressure(a,val);
setPressure(a, val);
case 'tol'
sz = size(val);
if sz == nComponents(a)
@ -54,7 +54,7 @@ while length(property_argin) >= 2,
elseif length(val) == 2
setSteadyTolerances(a, 'default', val(1), val(2));
else
error('wrong array size for error tolerances');
error('Wrong array size for error tolerances.');
end
case 'tol-time'
sz = size(val);
@ -65,7 +65,7 @@ while length(property_argin) >= 2,
at = val(2);
setTransientTolerances(a, 'default', rt, at);
else
error('wrong array size for error tolerances');
error('Wrong array size for error tolerances.');
end
case 'grid'
setupGrid(a, val);

View file

@ -1,5 +1,5 @@
function d = setBounds(d, component, lower, upper)
% SETBOUNDS -
%
n = componentIndex(d,component);
n = componentIndex(d, component);
domain_methods(d.dom_id, 51, n, lower, upper);

View file

@ -1,4 +1,4 @@
function d = setCoverageEqs(d,onoff)
function d = setCoverageEqs(d, onoff)
% SETCOVERAGEEQS - Enable or disable solving the coverage equations.
%
if d.domain_type ~= 6
@ -7,14 +7,14 @@ 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))
error(strcat('unknown option: ', onoff))
end
elseif isa(onoff,'numeric')
elseif isa(onoff, 'numeric')
ion = onoff;
end
domain_methods(d.dom_id, 120, ion);

View file

@ -10,6 +10,6 @@ if sz(1) == 2
elseif sz(2) == 2
domain_methods(d.dom_id, 64, profile(:,1), profile(:,2));
else
error('wrong temperature profile array shape');
error('Wrong temperature profile array shape.');
end

View file

@ -2,7 +2,7 @@ function d = setProfile(d, n, p)
% 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);
setProfile(d.stack,domainIndex(d), n, p);

View file

@ -1,7 +1,8 @@
function d = setSteadyTolerances(d, component, rtol, atol)
% SETSTEADYTOLERANCES -
%
if strcmp(component,'default')
if strcmp(component, 'default')
nc = nComponents(d);
for ii = 1:nc
domain_methods(d.dom_id, 55, ii, rtol, atol);

View file

@ -1,7 +1,8 @@
function d = setSteadyTolerances(d, component, rtol, atol)
% SETSTEADYTOLERANCES -
%
if strcmp(component,'default')
if strcmp(component, 'default')
nc = nComponents(d);
for ii = 1:nc
domain_methods(d.dom_id, 56, ii, rtol, atol);

View file

@ -17,7 +17,7 @@ if nargin == 1
s.stack_id = stack_methods(0, 8, nd, ids);
else
help(Stack);
error('wrong number of parameters');
error('Wrong number of parameters.');
end
if s.stack_id < 0
error(geterr);

View file

@ -1,7 +1,8 @@
function n = domainIndex(d, name)
function n = domainIndex(s, name)
% DOMAININDEX - Index of the domain with a specified name.
if isa(name,'double')
if isa(name, 'double')
n = name;
else
n = stack_methods(d.stack_id, 109, name);
n = stack_methods(s.stack_id, 109, name);
end

View file

@ -1,6 +1,7 @@
function z = grid(s, d)
function z = grid(s, name)
% GRID - the grid in one domain.
%
n = domainIndex(s,d);
n = domainIndex(s, name);
d = s.domains(n);
z = gridPoints(d);

View file

@ -3,7 +3,8 @@ function plotSolution(s, domain, component)
%
% plotSolution(s, 'flow', 'T') plots component 'T' in domain 'flow'
%
n = domainIndex(s,domain);
n = domainIndex(s, domain);
d = s.domains(n);
z = gridPoints(d);
x = solution(s, domain, component);

View file

@ -1,4 +1,5 @@
function setFlatProfile(s, n, comp, v)
function setFlatProfile(s, domain, comp, v)
% SETFLATPROFILE -
%
stack_methods(s.stack_id, 102, n, comp, v);
stack_methods(s.stack_id, 102, domain, comp, v);

View file

@ -19,7 +19,8 @@ function setProfile(s, name, comp, p)
% v = [500 650 700 730 800 900];
% setProfile(1, 2, zr, v);
%
if isa(name,'double')
if isa(name, 'double')
n = name;
else
n = domainIndex(s, name);
@ -27,24 +28,24 @@ 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')
elseif isa(comp, 'char')
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});
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));
else
error('wrong profile shape');
error('Wrong profile shape.');
end

View file

@ -1,4 +1,4 @@
function d = setRefineCriteria(d, n, ratio, slope, curve, prune)
function s = setRefineCriteria(s, n, ratio, slope, curve, prune)
% SETREFINECRITERIA - Set the criteria used to refine the grid.
%
% n -- domain number beginning with domain 1 at the left
@ -13,6 +13,7 @@ function d = setRefineCriteria(d, n, ratio, slope, curve, prune)
% components, it will be deleted, unless either
% neighboring point is already marked for deletion.
%
if nargin < 3
ratio = 10.0;
end
@ -26,4 +27,4 @@ if nargin < 6
prune = -0.1;
end
stack_methods(d.stack_id, 106, n, ratio, slope, curve, prune);
stack_methods(s.stack_id, 106, n, ratio, slope, curve, prune);

View file

@ -1,5 +1,6 @@
function b = subsref(s,index)
function b = subsref(s, index)
% SUBSREF -
switch index.type
case '()'
b = s.domains(index.subs{:});

View file

@ -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);
setID(m, id);
end

View file

@ -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);
setID(m, id);
end

View file

@ -5,7 +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

View file

@ -3,7 +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

View file

@ -3,7 +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

View file

@ -4,11 +4,11 @@ function m = Surface(id, surface_mech)
if nargin < 2
m = Domain1D(3);
if nargin == 0
setID(m,'surface');
setID(m, 'surface');
elseif nargin == 1
setID(m,id);
setID(m, id);
end
else
m = Domain1D(6, surface_mech);
setID(m,id);
setID(m, id);
end

View file

@ -3,7 +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

View file

@ -19,7 +19,7 @@ function flame = npflame_init(gas, left, flow, right, fuel, oxidizer, nuox)
% Check input parameters
if nargin ~= 7
error('wrong number of input arguments.');
error('npflame_init expects seven input arguments.');
end
if ~isIdealGas(gas)
@ -44,12 +44,12 @@ rho0 = density(gas);
wt = molecularWeights(gas);
% find the fuel and oxidizer
ifuel = speciesIndex(gas,fuel);
ioxidizer = speciesIndex(gas,oxidizer);
ifuel = speciesIndex(gas, fuel);
ioxidizer = speciesIndex(gas, oxidizer);
s = nuox*wt(ioxidizer)/wt(ifuel);
y0f = massFraction(left,ifuel);
y0ox = massFraction(right,ioxidizer);
y0f = massFraction(left, ifuel);
y0ox = massFraction(right, ioxidizer);
phi = s*y0f/y0ox;
zst = 1.0/(1.0 + phi);
@ -62,13 +62,13 @@ 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);
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);
equilibrate(gas,'HP');
set(gas, 'T', temperature(left), 'P', pressure(gas), 'Y', ystoich);
equilibrate(gas, 'HP');
teq = temperature(gas);
yeq = massFractions(gas);
@ -84,11 +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);
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);
@ -116,7 +116,7 @@ setProfile(flame, 2, {'u', 'V'}, [zrel; u; v]);
setProfile(flame, 2, 'T', [zrel; t] );
for n = 1:nsp
nm = speciesName(gas,n);
nm = speciesName(gas, n);
setProfile(flame, 2, nm, [zrel; transpose(y(:,n))])
end

View file

@ -3,11 +3,11 @@ function x = FlowDevice(typ)
if nargin == 0
typ = 1;
end
x.index = flowdevicemethods(0,typ);
x.index = flowdevicemethods(0, typ);
if x.index < 0
error(geterr);
end
x.type = typ;
x.upstream = -1;
x.downstream = -1;
x = class(x,'FlowDevice');
x = class(x, 'FlowDevice');

View file

@ -1,4 +1,5 @@
function clear(f)
% CLEAR -
%
flowdevicemethods(1, f.index)
flowdevicemethods(1, f.index);

View file

@ -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

View file

@ -37,38 +37,38 @@ x.coeffs = 0;
itype = -1;
if strcmp(typ, 'polynomial')
itype = 2;
elseif strcmp(typ,'fourier')
elseif strcmp(typ, 'fourier')
itype = 1;
elseif strcmp(typ,'arrhenius')
elseif strcmp(typ, 'arrhenius')
itype = 3;
elseif strcmp(typ,'gaussian')
elseif strcmp(typ, 'gaussian')
itype = 4;
end
if itype > 0
x.coeffs = p;
x.index = funcmethods(0,itype,n,p);
elseif strcmp(typ,'periodic')
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);
x.index = funcmethods(0, itype, n.index, p);
else
if strcmp(typ,'sum')
if strcmp(typ, 'sum')
itype = 20;
elseif strcmp(typ,'diff')
elseif strcmp(typ, 'diff')
itype = 25;
elseif strcmp(typ,'prod')
elseif strcmp(typ, 'prod')
itype = 30;
elseif strcmp(typ,'ratio')
elseif strcmp(typ, 'ratio')
itype = 40;
elseif strcmp(typ,'composite')
elseif strcmp(typ, 'composite')
itype = 60;
end
x.f1 = n;
x.f2 = p;
x.index = funcmethods(0,itype,n.index,p.index);
x.index = funcmethods(0, itype, n.index, p.index);
end
x.typ = typ;
x = class(x,'Func');
x = class(x, 'Func');

View file

@ -44,17 +44,17 @@ else
end
d = d - 1;
end
elseif strcmp(p.typ,'gaussian')
elseif strcmp(p.typ, 'gaussian')
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;
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

View file

@ -3,4 +3,4 @@ function r = plus(a, b)
% PLUS - Return a functor representing the sum of two functors a
% and b.
%
r = Func('sum',a,b);
r = Func('sum', a, b);

View file

@ -1,4 +1,5 @@
function r = rdivide(a,b)
function r = rdivide(a, b)
% RDIVIDE -
%
r = Func('ratio',a,b);
r = Func('ratio', a, b);

View file

@ -1,11 +1,11 @@
function b = subsref(a,s)
function b = subsref(a, s)
% SUBSREF
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));
b(k) = funcmethods(2, a.index, ind(k));
end
otherwise
error('Specify value for x as p(x)')

View file

@ -1,4 +1,5 @@
function r = times(a,b)
function r = times(a, b)
% TIMES -
%
r = Func('prod',a,b);
r = Func('prod', a, b);

View file

@ -1,21 +1,21 @@
function s = Interface(src, id, p1, p2, p3, p4)
% Interface - class Interface constructor.
%
doc = XML_Node('doc',src);
node = findByID(doc,id);
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);
s = class(s,'Interface', t, k);

View file

@ -4,12 +4,12 @@ function c = concentrations(s)
c = surfmethods(thermo_hndl(s), 101);
if nargout == 0
figure
set(gcf,'Name','Concentrations')
set(gcf, 'Name', 'Concentrations')
bar(c);
colormap(summer);
nm = speciesNames(s);
legend(nm);
xlabel('Species Number');
set(gca,'XTickLabel', nm);
xlabel('Species Name');
ylabel('Concentration [kmol/m2]');
title('Surface Species Concentrations');
end

View file

@ -4,12 +4,12 @@ function c = coverages(s)
c = surfmethods(thermo_hndl(s), 101);
if nargout == 0
figure
set(gcf,'Name','Coverages')
set(gcf, 'Name', 'Coverages')
bar(c);
colormap(summer);
nm = speciesNames(s);
legend(nm);
xlabel('Species Number');
set(gca,'XTickLabel', nm);
xlabel('Species Name');
ylabel('Coverage');
title('Surface Species Coverages');
end

View file

@ -1,7 +1,7 @@
function setCoverages(s,cov)
function setCoverages(s, cov)
% SETCOVERAGES - set surface coverages
%
if isa(cov,'double')
if isa(cov, 'double')
sz = length(cov);
if sz == nSpecies(s)
surfmethods(thermo_hndl(s), 3, cov);

View file

@ -17,7 +17,7 @@ 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')
if isa(r, 'Kinetics')
k = r;
return
else
@ -25,9 +25,9 @@ if nargin == 1
end
end
% if more than one arguement, first one must be an XML_Node
% if more than one argument, first one must be an XML_Node
% instance representing the XML tree
if ~isa(r,'XML_Node')
if ~isa(r, 'XML_Node')
error('first argument must be an XML_Node object')
end
@ -49,11 +49,11 @@ if nargin > 2
end
end
end
k.id = kinetics_get(ixml,0,iphase,ineighbor1,ineighbor2,ineighbor3, ...
k.id = kinetics_get(ixml, 0, iphase, ineighbor1, ineighbor2, ineighbor3, ...
ineighbor4);
if k.id < 0
error(geterr);
end
k = class(k,'Kinetics');
k = class(k, 'Kinetics');

View file

@ -1,4 +1,5 @@
function clear(k)
% CLEAR - delete the Kinetics instance.
%
kinetics_set(k.id,3);
kinetics_set(k.id, 3, 0, 0);

View file

@ -9,10 +9,10 @@ function cdot = creationRates(a)
%
% See also: destructionRates, netProdRates.
%
cdot = kinetics_get(a.id,21,0);
cdot = kinetics_get(a.id, 21, 0);
if nargout == 0
figure
set(gcf,'Name','Creation Rates')
set(gcf, 'Name', 'Creation Rates')
bar(cdot)
xlabel('Species Number')
ylabel('Creation Rate (kmol/m^3-s)')

View file

@ -9,10 +9,10 @@ function ddot = destructionRates(a)
%
% See also: creationRates, netProdRates.
%
ddot = kinetics_get(a.id,22,0);
ddot = kinetics_get(a.id, 22, 0);
if nargout == 0
figure
set(gcf,'Name','Destruction Rates')
set(gcf, 'Name', 'Destruction Rates')
bar(ddot)
xlabel('Species Number')
ylabel('Destruction Rate (kmol/m^3/s)')

View file

@ -1,4 +1,4 @@
function q = destruction_rates(a)
function ddot = destruction_rates(a)
% destruction_rates Chemical destruction rates for all species.
%
% q = destruction_rates(a)
@ -7,11 +7,12 @@ function q = destruction_rates(a)
%
% See also: creation_rates, net_production_rates.
%
q = production(a.id,nSpecies(a.ph),1);
ddot = destructionRates(a);
if nargout == 0
figure
set(gcf,'Name','Destruction Rates')
bar(q)
set(gcf, 'Name', 'Destruction Rates')
bar(ddot)
xlabel('Species Number')
ylabel('Destruction Rate (kmol/m^3/s)')
title('Species Chemical Destruction Rates')

View file

@ -9,12 +9,13 @@ function kc = equil_Kc(a)
% occur only for the reversible reactions.
%
%
kc = kinetics_get(a.id,14,0);
kc = kinetics_get(a.id, 14, 0);
if nargout == 0
figure
set(gcf,'Name','Equilibrium Constants')
set(gcf, 'Name', 'Equilibrium Constants')
bar(log10(kc))
xlabel('Reaction Number')
ylabel('log_1_0 Kc [kmol, m, s]')
ylabel('log_{10} Kc [kmol, m, s]')
title('Equilibrium Constants Kc')
end

View file

@ -6,4 +6,4 @@ function kf = fwdRateConstants(a)
% Returns a column vector of the forward rate constants of
% all of the reactions.
%
kf = kinetics_get(a.id,15,0);
kf = kinetics_get(a.id, 15, 0);

View file

@ -11,4 +11,4 @@ function yn = isReversible(a, i)
% ISREVERSIBLE(K, IRXN) returns 1 if reaction number IRXN is
% reversible, and 0 if it is irreversible.
%
yn = kinetics_get(a.id,4,i);
yn = kinetics_get(a.id, 4, i);

View file

@ -1,4 +1,4 @@
function n = multiplier(a,irxn)
function n = multiplier(a, irxn)
% MULTIPLIER Multiplier for reaction rate of progress.
%
% The multiplier multiplies the reaction rate of progress. It may
@ -10,4 +10,4 @@ function n = multiplier(a,irxn)
%
% MULTIPLIER(K, IRXN) Multiplier for reaction number IRXN
%
n = kinetics_get(a.id,2,irxn);
n = kinetics_get(a.id, 2, irxn);

View file

@ -1,4 +1,4 @@
function n = nReactions(a)
% NREACTIONS - Number of reactions.
%
n = kinetics_get(a.id,1,0);
n = kinetics_get(a.id, 1, 0);

View file

@ -9,10 +9,10 @@ function wdot = netProdRates(a)
%
% See also: creationRates, destructionRates
%
wdot = kinetics_get(a.id,23,0);
wdot = kinetics_get(a.id, 23, 0);
if nargout == 0
figure
set(gcf,'Name','Production Rates')
set(gcf, 'Name', 'Production Rates')
bar(wdot)
xlabel('Species Number')
ylabel('Net Production Rate (kmol/m^3/s)')

View file

@ -14,12 +14,12 @@ elseif nargin == 2
end
if m == 1 && n == 1
e = kinetics_get(a.id, 31, irxn); % rxnstring(a.id, irxn);
e = kinetics_get(a.id, 31, irxn);
else
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));
e{i, j} = kinetics_get(a.id, 31, irxn(i,j));
end
end
end

View file

@ -6,4 +6,4 @@ function kr = revRateConstants(a)
% Returns a column vector of the reverse rate constants of
% all of the reactions.
%
kr = kinetics_get(a.id,16,0);
kr = kinetics_get(a.id, 16, 0);

View file

@ -1,4 +1,4 @@
function rop = rop(k)
function rop = rop(a)
% ROP - Forward and reverse rates of progress.
%
% ROP(K) returns an M x 2 array of reaction rates of
@ -6,12 +6,13 @@ 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);
f = rop_f(a);
r = rop_r(a);
rop = [f r];
if nargout == 0
figure
set(gcf,'Name','Rates of Progress');
set(gcf, 'Name', 'Rates of Progress');
bar(rop);
xlabel('Reaction Number');
ylabel('Rate of Progress [kmol/m^3-s]');

View file

@ -8,10 +8,10 @@ function q = rop_f(a)
%
% See also: rop_r, rop_net.
%
q = kinetics_get(a.id,11,0);
q = kinetics_get(a.id, 11, 0);
if nargout == 0
figure
set(gcf,'Name','Rates of Progress')
set(gcf, 'Name', 'Rates of Progress')
bar(q)
xlabel('Reaction Number')
ylabel('Forward Rate of Progress [kmol/m^3]')

View file

@ -8,10 +8,11 @@ function q = rop_net(a)
%
% See also: rop_r, rop_net.
%
q = kinetics_get(a.id,13,0);
q = kinetics_get(a.id, 13, 0);
if nargout == 0
figure
set(gcf,'Name','Rates of Progress')
set(gcf, 'Name', 'Net Rates of Progress')
bar(q)
xlabel('Reaction Number')
ylabel('Net Rate of Progress [kmol/m^3]')

View file

@ -9,4 +9,12 @@ function q = rop_r(a)
%
% See also: rop_r, rop_net.
%
q = kinetics_get(a.id,12,0);
q = kinetics_get(a.id, 12, 0);
if nargout == 0
figure
set(gcf, 'Name', 'Reverse Rates of Progress')
bar(q)
xlabel('Reaction Number')
ylabel('Reverse Rate of Progress [kmol/m^3]')
title('Reverse Rates of Progress')
end

View file

@ -1,4 +1,4 @@
function setMultiplier(a,irxn,v)
function setMultiplier(a, irxn, v)
% SETMULTIPLIER Set the rate of progress multiplier.
%
% SETMULTIPLIER(K, IRXN, V) sets the multipler for reaction IRXN
@ -11,12 +11,14 @@ if nargin == 2
m = nReactions(a);
irxn = (1:m)';
n = 1;
else
elseif nargin == 3
[m, n] = size(irxn);
else
error('setMultiplier requires 2 or 3 arguments.')
end
for jm = 1:m
for jn = 1:n
kinetics_set(a.id,1,irxn(jm,jn),v);
kinetics_set(a.id, 1, irxn(jm,jn), v);
end
end

View file

@ -1,4 +1,4 @@
function nu = stoich_net(a,species,rxns)
function nu = stoich_net(a, species, rxns)
% stoich_net Net stoichiometric coefficients.
%
% nu = stoich_net(a)
@ -23,8 +23,7 @@ function nu = stoich_net(a,species,rxns)
if nargin == 1
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(['stoich_net requires 1 or 3 arguments.'])
end

View file

@ -1,4 +1,4 @@
function nu_p = stoich_p(a,species,rxns)
function nu_p = stoich_p(a, species, rxns)
% stoich_p Product stoichiometric coefficients.
%
% nu = stoich_p(a)
@ -19,9 +19,8 @@ function nu_p = stoich_p(a,species,rxns)
% See also: stoich_r, stoich_net.
%
nsp = nTotalSpecies(a);
nr =nReactions(a);
b = sparse(nsp,nr);
f = @kinetics_get;
nr = nReactions(a);
b = sparse(nsp, nr);
if nargin == 1
kvals = 1:nsp;
ivals = 1:nr;
@ -29,14 +28,14 @@ elseif nargin == 3
kvals = species;
ivals = rxns;
else
error('Syntax error. type ''help stoich_r'' for more information.')
error('stoich_p requires 1 or 3 arguments.')
end
for k = kvals
for i = ivals
nu = feval(f,a.id,6,i,k);
nu = kinetics_get(a.id, 6, i, k);
if nu ~= 0.0
b(k,i) = nu;
b(k, i) = nu;
end
end
end

View file

@ -1,4 +1,4 @@
function nu_r = stoich_r(a,species,rxns)
function nu_r = stoich_r(a, species, rxns)
% stoich_r Reactant stoichiometric coefficients.
%
% nu = stoich_r(a)
@ -19,9 +19,8 @@ function nu_r = stoich_r(a,species,rxns)
% See also: stoich_p, stoich_net.
%
nsp = nTotalSpecies(a);
nr =nReactions(a);
b = sparse(nsp,nr);
f = @kinetics_get;
nr = nReactions(a);
b = sparse(nsp, nr);
if nargin == 1
kvals = 1:nsp;
ivals = 1:nr;
@ -29,14 +28,14 @@ elseif nargin == 3
kvals = species;
ivals = rxns;
else
error('Syntax error. type ''help stoich_r'' for more information.')
error('stoich_r requires 1 or 3 arguments.')
end
for k = kvals
for i = ivals
nu = feval(f,a.id,5,i,k);
nu = kinetics_get(a.id, 5, i, k);
if nu ~= 0.0
b(k,i) = nu;
b(k, i) = nu;
end
end
end

View file

@ -1,4 +1,4 @@
function v = ydot(a)
% YDOT - Evaluates wdot_k M_k / (density)
%
v = kinetics_get(a.id,24,0);
v = kinetics_get(a.id, 24, 0);

View file

@ -36,19 +36,19 @@ end
m.mixindex = mixturemethods(0, 0, 0);
m.phases = phases;
m = class(m,'Mixture');
m = class(m, 'Mixture');
% if phases are supplied, add them
if nargin == 1
if ~isa(phases,'cell')
error('enter phases as a cell array');
if ~isa(phases, 'cell')
error('Enter phases as a cell array.');
end
% first column contains the phase objects, and the second column
% the mole numbers of each phase
[np nc] = size(phases);
if nc ~= 2
error('wrong size for phases cell array');
error('Cell array of phases should have each phase on a new row');
end
for n = 1:np
addPhase(m, phases{n,1}, phases{n,2});

View file

@ -5,17 +5,17 @@ function addPhase(self, phase, moles)
% addPhase(mix, carbon, 1.0);
%
if ~isa(phase,'ThermoPhase')
error('phase object of wrong type.');
error('Phase object of wrong type.');
end
if ~isa(moles,'numeric')
error('number of moles must be numeric.');
error('Number of moles must be numeric.');
end
if moles < 0.0
error('negative moles!');
error('Negative moles!');
end
iphase = thermo_hndl(phase);
iok = mixturemethods(4, mix_hndl(self), iphase, moles);
if iok < 0
error('error adding phase');
error('Error adding phase');
end

View file

@ -2,7 +2,7 @@ function display(self)
[np nc] = size(self.phases);
for n = 1:np
s = [sprintf('\n******************* Phase %d', n) ...
sprintf(' ******************************\n\n Moles: %12.6g', phaseMoles(self,n))];
sprintf(' ******************************\n\n Moles: %12.6g', phaseMoles(self,n))];
disp(s);
display(self.phases{n,1});
display(self.phases{n, 1});
end

View file

@ -1,5 +1,4 @@
function r = equilibrate(self, XY, err, maxsteps, maxiter, ...
loglevel)
function r = equilibrate(self, XY, err, maxsteps, maxiter, loglevel)
%
% EQUILIBRATE - Set the mixture to a state of chemical equilibrium.
%

View file

@ -5,7 +5,7 @@ if nargin == 2
moles = mixturemethods(28, mix_hndl(self), n);
elseif nargin == 1
np = nPhases(self);
m = zeros(1,np);
m = zeros(1, np);
for n = 1:np
m(n) = mixturemethods(28, mix_hndl(self), n);
end

View file

@ -1,4 +1,5 @@
function n = pressure(self)
function p = pressure(self)
% PRESSURE - pressure (Pa)
%
n = mixturemethods(26, mix_hndl(self));
p = mixturemethods(26, mix_hndl(self));

View file

@ -1,4 +1,5 @@
function n = temperature(self)
function t = temperature(self)
% TEMPERATURE - temperature (K)
%
n = mixturemethods(25, mix_hndl(self));
t = mixturemethods(25, mix_hndl(self));

View file

@ -20,13 +20,13 @@ elseif nargin > 2
error('too many arguments');
end
x.index = reactormethods(0,typ);
x.index = reactormethods(0, typ);
if x.index < 0
error(geterr);
end
x.contents = contents;
x = class(x,'Reactor');
x = class(x, 'Reactor');
if isa(contents,'Solution')
if isa(contents, 'Solution')
insert(x, contents);
end

View file

@ -1,5 +1,11 @@
function y = massFraction(r, species)
% MASSFRACTION - Mass fraction of species with name 'species'.
%
k = speciesIndex(r.contents, species) - 1;
if ischar(species)
k = speciesIndex(r.contents, species) - 1;
else
k = species - 1;
end
y = reactormethods(30, reactor_hndl(r), k);

View file

@ -1,4 +1,4 @@
function setEnergy(f, flag)
function setEnergy(r, flag)
% SETENERGY - enable or disable solving the energy equation. If the
% energy equation is disabled, then the reactor temperature is
% constant. The parameter should be the string 'on' to enable the
@ -12,13 +12,13 @@ function setEnergy(f, flag)
% >>> setEnergy(r, 'off');
%
iflag = -1;
if strcmp(flag,{'on'})
if strcmp(flag, {'on'})
iflag = 1;
elseif strcmp(flag,{'off'})
elseif strcmp(flag, {'off'})
iflag = 0;
end
if iflag >= 0
reactormethods(9, f.index, iflag)
reactormethods(9, r.index, iflag)
else
error('input to setEnergy not understood');
error('Input to setEnergy not understood.');
end

View file

@ -1,4 +1,5 @@
function setInitialVolume(r, t0)
function setInitialVolume(r, v0)
% SETINITIALVOLUME -
%
reactormethods(4, reactor_hndl(r), t0);
reactormethods(4, reactor_hndl(r), v0);

View file

@ -4,9 +4,9 @@ function x = ReactorNet(reactors)
% A ReactorNet object is a container that holds one or more
% Reactor objects.
%
if nargin == 1
else
error('wrong number of arguments to ReactorNet constructor');
if nargin ~= 1
error('Wrong number of arguments to ReactorNet constructor.');
end
if isa(reactors, 'Reactor')
@ -14,14 +14,14 @@ if isa(reactors, 'Reactor')
reactors = {reactors};
end
x.index = reactornetmethods(0,0);
x.index = reactornetmethods(0, 0);
if x.index < 0
error(geterr);
end
x = class(x,'ReactorNet');
x = class(x, 'ReactorNet');
% add reactors
nr = length(reactors);
for i = 1:nr
addReactor(x,reactors{i});
addReactor(x, reactors{i});
end

View file

@ -2,14 +2,14 @@ function t = ThermoPhase(r)
%THERMOPHASE Cantera ThermoPhase class constructor
%
if nargin == 1
if isa(r,'ThermoPhase')
if isa(r, 'ThermoPhase')
% create a copy
t = r;
return
elseif isa(r,'XML_Node')
elseif isa(r, 'XML_Node')
t.owner = 1;
hr = hndl(r);
t.tp_id = thermo_get(hr,0);
t.tp_id = thermo_get(hr, 0);
if t.tp_id < 0
error(geterr);
end
@ -17,7 +17,7 @@ if nargin == 1
t.owner = 0;
t.tp_id = r;
end
t = class(t,'ThermoPhase');
t = class(t, 'ThermoPhase');
else
error('wrong number of arguments');
error('ThermoPhase expects 1 input argument.');
end

View file

@ -1,4 +1,5 @@
function x = atomicMasses(a)
function x = atomicMasses(tp)
% ATOMICMASSES - Array of element atomic masses [kg/kmol].
%
x = phase_get(a.tp_id,30);
x = phase_get(tp.tp_id, 30);

View file

@ -1,9 +1,10 @@
function mu = chemPotentials(p)
function mu = chemPotentials(tp)
% CHEMPOTENTIALS - Species chemical potentials.
%
% This method returns an array containing the species
% chemical potentials [J/kmol]. The expressions used to
% compute these depend on the model implemented by the
% underlying kernel thermo manager."""
mu = thermo_get(p.tp_id,34);
mu = thermo_get(tp.tp_id, 34);

View file

@ -1,5 +1,6 @@
function clear(t)
function clear(tp)
% CLEAR - Delete the kernel object.
%
thermo_set(t.tp_id,0,10);
thermo_set(tp.tp_id, 0, 10);

View file

@ -1,7 +1,8 @@
function v = cp_R(p)
function v = cp_R(tp)
% CP_R - Species non-dimensional heat capacities.
%
% This method returns an array containing the pure species
% standard-state heat capacities at constant pressure.
%
v = thermo_get(p.tp_id,38);
v = thermo_get(tp.tp_id, 38);

View file

@ -1,3 +1,4 @@
function v = cp_mass(a)
function v = cp_mass(tp)
% CP_MASS - Specific heat at constant pressure [J/kg-K].
v = thermo_get(a.tp_id,13);
v = thermo_get(tp.tp_id, 13);

View file

@ -1,3 +1,4 @@
function v = cp_mole(a)
function v = cp_mole(tp)
% CP_MOLE - Molar heat capacity at constant pressure [J/kmol-K].
v = thermo_get(a.tp_id,6);
v = thermo_get(tp.tp_id, 6);

View file

@ -1,4 +1,5 @@
function v = critDensity(a)
function v = critDensity(tp)
% CRITDENSITY - Critical density [kg/m3].
%
v = thermo_get(a.tp_id,21);
v = thermo_get(tp.tp_id, 21);

View file

@ -1,4 +1,5 @@
function v = critPressure(a)
function v = critPressure(tp)
% CRITPRESSURE - Critical pressure [Pa].
%
v = thermo_get(a.tp_id,20);
v = thermo_get(tp.tp_id, 20);

View file

@ -1,4 +1,5 @@
function v = critTemperature(a)
function v = critTemperature(tp)
% CRITTEMPERATURE - Critical temperature [K].
%
v = thermo_get(a.tp_id,19);
v = thermo_get(tp.tp_id, 19);

View file

@ -1,3 +1,4 @@
function v = cv_mass(a)
function v = cv_mass(tp)
% CV_MASS - Specific heat at constant volume [J/kg-K].
v = thermo_get(a.tp_id,14);
v = thermo_get(tp.tp_id, 14);

View file

@ -1,3 +1,4 @@
function v = cv_mole(a)
function v = cv_mole(tp)
% CV_MOLE - Molar heat capacity at constant volume [J/kmol-K].
v = thermo_get(a.tp_id,7);
v = thermo_get(tp.tp_id, 7);

View file

@ -1,4 +1,5 @@
function rho = density(p)
function rho = density(tp)
% DENSITY - Mass density [kg/m^3].
%
rho = phase_get(p.tp_id,2);
rho = phase_get(tp.tp_id, 2);

View file

@ -1,4 +1,5 @@
function v = electricPotential(a)
function v = electricPotential(tp)
% ELECTRICPOTENTIAL - the electric potential of the phase
%
v = thermo_get(a.tp_id,25);
v = thermo_get(tp.tp_id, 25);

View file

@ -1,4 +1,4 @@
function k = elementIndex(a,name)
function k = elementIndex(tp, name)
% ELEMENTINDEX - The element index of the element with name
% 'name'.
%
@ -21,12 +21,12 @@ function k = elementIndex(a,name)
if iscell(name)
[m, n] = size(name);
k = zeros(m,n);
k = zeros(m, n);
for i = 1:m
for j = 1:n
k(i,j) = phase_get(a.tp_id,13,name{i,j});
k(i,j) = phase_get(tp.tp_id, 13, name{i,j});
end
end
else
k = phase_get(a.tp_id,13,name);
k = phase_get(tp.tp_id, 13, name);
end

View file

@ -1,4 +1,4 @@
function nm = elementName(a, m)
function nm = elementName(tp, m)
% ELEMENTNAME - Name of element with index m.
%
% If m is a scalar integer, the return value will be a string
@ -6,10 +6,11 @@ function nm = elementName(a, m)
% integers, the output will be a cell array of
% the same shape containing the name strings.
%
[mm, nn] = size(m);
nm = cell(mm,nn);
for i = 1:mm
for j = 1:nn
nm{i,j} = phase_get(a.tp_id, 41, m(i,j));
nm{i,j} = phase_get(tp.tp_id, 41, m(i,j));
end
end

View file

@ -1,4 +1,4 @@
function v = enthalpies_RT(p)
function v = enthalpies_RT(tp)
% ENTHALPIES_RT - Pure species non-dimensional enthalpies.
%
% h_rt = enthalpies_RT(phase)
@ -9,4 +9,5 @@ function v = enthalpies_RT(p)
% values are ideal gas enthalpies.
%
%
v = thermo_get(p.tp_id,32);
v = thermo_get(tp.tp_id, 32);

View file

@ -1,4 +1,5 @@
function v = enthalpy_mass(a)
function v = enthalpy_mass(tp)
% ENTHALPY_MASS - Specific enthalpy [J/kg].
%
v = thermo_get(a.tp_id,9);
v = thermo_get(tp.tp_id, 9);

View file

@ -1,4 +1,5 @@
function v = enthalpy_mole(a)
% ENTHALPY_MOLE - Molar enthalpy [J/kmol].
%
v = thermo_get(a.tp_id,2);
v = thermo_get(a.tp_id, 2);

View file

@ -1,7 +1,8 @@
function v = entropies_R(p)
function s = entropies_R(tp)
% ENTROPIES_R - Species non-dimensional entropies.
%
% This method returns an array containing the pure species
% standard-state entropies.
%
v = thermo_get(p.tp_id,36);
s = thermo_get(tp.tp_id, 36);

View file

@ -1,2 +1,3 @@
function v = entropy_mass(a)
v = thermo_get(a.tp_id,11);
function v = entropy_mass(tp)
v = thermo_get(tp.tp_id, 11);

View file

@ -1,2 +1,3 @@
function v = entropy_mole(a)
v = thermo_get(a.tp_id,4);
function v = entropy_mole(tp)
v = thermo_get(tp.tp_id, 4);

View file

@ -1,7 +1,8 @@
function e = eosType(a)
function e = eosType(tp)
% EOSTYPE - Equation of state type.
%
% This method returns an integer flag identifying the type of
% equation of state.
%
e = thermo_get(a.tp_id, 18);
e = thermo_get(tp.tp_id, 18);

View file

@ -1,4 +1,4 @@
function a = equilibrate(a, xy, solver, rtol, maxsteps, maxiter, loglevel)
function tp = equilibrate(tp, xy, solver, rtol, maxsteps, maxiter, loglevel)
% EQUILIBRATE Set the phase to a state of chemical equilibrium.
%
% XY -- A two-letter string, which must be one of the set
@ -43,7 +43,7 @@ if nargin < 7
loglevel = 0;
end
iok = thermo_set(a.tp_id, 50, xy, solver, rtol, maxsteps, maxiter, loglevel);
iok = thermo_set(tp.tp_id, 50, xy, solver, rtol, maxsteps, maxiter, loglevel);
if iok < 0
e = geterr;
if e == 0

View file

@ -1,7 +1,8 @@
function g_RT = gibbs_RT(p)
function g_RT = gibbs_RT(tp)
% GIBBS_RT - Species non-dimensional Gibbs free energies.
%
% This method returns an array containing the pure species
% standard-state Gibbs free energies.
%
g_RT = enthalpies_RT(p) - entropies_R(p);
g_RT = enthalpies_RT(tp) - entropies_R(tp);

View file

@ -1,3 +1,4 @@
function v = gibbs_mass(a)
function v = gibbs_mass(tp)
% GIBBS_MASS - Specific Gibbs function [J/kg].
v = thermo_get(a.tp_id,12);
v = thermo_get(tp.tp_id, 12);

View file

@ -1,3 +1,4 @@
function v = gibbs_mole(a)
function v = gibbs_mole(tp)
% GIBBS_MOLE - Molar Gibbs function [J/kmol].
v = thermo_get(a.tp_id,5);
v = thermo_get(tp.tp_id, 5);

Some files were not shown because too many files have changed in this diff Show more