Added several missing functions to the Matlab toolbox
This commit is contained in:
parent
54315d4472
commit
107ba5d381
7 changed files with 81 additions and 1 deletions
12
Cantera/matlab/cantera/@FlowDevice/setFunction.m
Normal file
12
Cantera/matlab/cantera/@FlowDevice/setFunction.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function setFunction(f, mf)
|
||||
% SETMASSFLOWRATE -
|
||||
%
|
||||
if f.type == 1
|
||||
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')
|
||||
end
|
||||
|
||||
|
|
@ -49,6 +49,43 @@ else
|
|||
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
|
||||
|
|
|
|||
4
Cantera/matlab/cantera/@Func/func_hndl.m
Normal file
4
Cantera/matlab/cantera/@Func/func_hndl.m
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function i = func_hndl(f)
|
||||
% FUNC_HNDL -
|
||||
%
|
||||
i = f.index;
|
||||
|
|
@ -4,7 +4,7 @@ switch s.type
|
|||
case '()'
|
||||
ind = s.subs{:};
|
||||
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)')
|
||||
|
|
|
|||
19
Cantera/matlab/cantera/@ThermoPhase/massFraction.m
Normal file
19
Cantera/matlab/cantera/@ThermoPhase/massFraction.m
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function y = massFraction(s, species)
|
||||
|
||||
y = 0.0;
|
||||
yarray = massFractions(s);
|
||||
if isa(species,'char')
|
||||
k = speciesIndex(s, species);
|
||||
if k > 0
|
||||
y = yarray(k);
|
||||
end
|
||||
|
||||
elseif isa(species,'cell')
|
||||
n = length(species);
|
||||
for j = 1:n
|
||||
k = speciesIndex(s, species{j});
|
||||
if k > 0
|
||||
y(j) = yarray(k);
|
||||
end
|
||||
end
|
||||
end
|
||||
4
Cantera/matlab/cantera/@Wall/setHeatFlux.m
Normal file
4
Cantera/matlab/cantera/@Wall/setHeatFlux.m
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function setHeatFlux(w, f)
|
||||
% SET HEAT FLUX -
|
||||
%
|
||||
wallmethods(8, wall_hndl(w), func_hndl(f));
|
||||
4
Cantera/matlab/cantera/@Wall/setVelocity.m
Normal file
4
Cantera/matlab/cantera/@Wall/setVelocity.m
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function setVelocity(w, f)
|
||||
% SET VELOCITY -
|
||||
%
|
||||
wallmethods(10, wall_hndl(w), func_hndl(f));
|
||||
Loading…
Add table
Reference in a new issue