diff --git a/Cantera/matlab/cantera/@FlowDevice/setFunction.m b/Cantera/matlab/cantera/@FlowDevice/setFunction.m new file mode 100644 index 000000000..764077053 --- /dev/null +++ b/Cantera/matlab/cantera/@FlowDevice/setFunction.m @@ -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 + diff --git a/Cantera/matlab/cantera/@Func/char.m b/Cantera/matlab/cantera/@Func/char.m index a47410ae6..b4ff878c3 100644 --- a/Cantera/matlab/cantera/@Func/char.m +++ b/Cantera/matlab/cantera/@Func/char.m @@ -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 diff --git a/Cantera/matlab/cantera/@Func/func_hndl.m b/Cantera/matlab/cantera/@Func/func_hndl.m new file mode 100644 index 000000000..4a6af7096 --- /dev/null +++ b/Cantera/matlab/cantera/@Func/func_hndl.m @@ -0,0 +1,4 @@ +function i = func_hndl(f) +% FUNC_HNDL - +% +i = f.index; diff --git a/Cantera/matlab/cantera/@Func/subsref.m b/Cantera/matlab/cantera/@Func/subsref.m index 2000bf34d..c7ba4c736 100644 --- a/Cantera/matlab/cantera/@Func/subsref.m +++ b/Cantera/matlab/cantera/@Func/subsref.m @@ -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)') diff --git a/Cantera/matlab/cantera/@ThermoPhase/massFraction.m b/Cantera/matlab/cantera/@ThermoPhase/massFraction.m new file mode 100644 index 000000000..34b1dbb45 --- /dev/null +++ b/Cantera/matlab/cantera/@ThermoPhase/massFraction.m @@ -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 diff --git a/Cantera/matlab/cantera/@Wall/setHeatFlux.m b/Cantera/matlab/cantera/@Wall/setHeatFlux.m new file mode 100644 index 000000000..191d15004 --- /dev/null +++ b/Cantera/matlab/cantera/@Wall/setHeatFlux.m @@ -0,0 +1,4 @@ +function setHeatFlux(w, f) +% SET HEAT FLUX - +% +wallmethods(8, wall_hndl(w), func_hndl(f)); diff --git a/Cantera/matlab/cantera/@Wall/setVelocity.m b/Cantera/matlab/cantera/@Wall/setVelocity.m new file mode 100644 index 000000000..59b273b70 --- /dev/null +++ b/Cantera/matlab/cantera/@Wall/setVelocity.m @@ -0,0 +1,4 @@ +function setVelocity(w, f) +% SET VELOCITY - +% +wallmethods(10, wall_hndl(w), func_hndl(f));