[Matlab] Remove automatic figure generation for kinetic rate functions

Miscellaneous formatting updates
This commit is contained in:
ssun30 2022-03-04 16:33:49 -05:00 committed by Ray Speth
parent 3dad11e9ff
commit c11b157add
11 changed files with 107 additions and 108 deletions

View File

@ -346,7 +346,7 @@ classdef Stack < handle
% step to be taken first time the steady-state solution % step to be taken first time the steady-state solution
% attempted. If this failed, two time steps would be taken. % attempted. If this failed, two time steps would be taken.
checklib; checklib;
calllib(ct, 'sim1D_', s.st_id, ... calllib(ct, 'sim1D_TimeStep', s.st_id, ...
stepsize, length(steps), steps); stepsize, length(steps), steps);
end end

View File

@ -53,17 +53,17 @@ classdef Interface < handle & ThermoPhase & Kinetics
calllib(ct, 'surf_getCoverages', surf_id, xx); calllib(ct, 'surf_getCoverages', surf_id, xx);
c = pt.Value; c = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Coverages') % set(gcf, 'Name', 'Coverages')
bar(c); % bar(c);
colormap(summer); % colormap(summer);
nm = s.speciesNames; % nm = s.speciesNames;
set(gca, 'XTickLabel', nm); % set(gca, 'XTickLabel', nm);
xlabel('Species Name'); % xlabel('Species Name');
ylabel('Coverage'); % ylabel('Coverage');
title('Surface Species Coverages'); % title('Surface Species Coverages');
end % end
end end
function c = concentrations(s) function c = concentrations(s)
@ -82,17 +82,17 @@ classdef Interface < handle & ThermoPhase & Kinetics
calllib(ct, 'surf_getConcentrations', surf_id, xx); calllib(ct, 'surf_getConcentrations', surf_id, xx);
c = pt.Value; c = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Concentrations') % set(gcf, 'Name', 'Concentrations')
bar(c); % bar(c);
colormap(summer); % colormap(summer);
nm = speciesNames(s); % nm = speciesNames(s);
set(gca, 'XTickLabel', nm); % set(gca, 'XTickLabel', nm);
xlabel('Species Name'); % xlabel('Species Name');
ylabel('Concentration [kmol/m^2]'); % ylabel('Concentration [kmol/m^2]');
title('Surface Species Concentrations'); % title('Surface Species Concentrations');
end % end
end end
function set.coverages(s, cov, norm) function set.coverages(s, cov, norm)

View File

@ -41,7 +41,7 @@ classdef Kinetics < handle
end end
end end
kin.kin_id = calllib(ct, 'kin_newFromFile', src, id, ... kin.kin_id = calllib(ct, 'kin_newFromFile', src, id, ...
iph, inb1, inb2, inb3, inb4); iph, inb1, inb2, inb3, inb4);
end end
%% Utility methods %% Utility methods
@ -187,7 +187,7 @@ classdef Kinetics < handle
kin.kin_id, k-1, i-1); kin.kin_id, k-1, i-1);
if t ~= 0.0 if t ~= 0.0
temp(k, i) = t; temp(k, i) = t;
end end
end end
end end
@ -240,14 +240,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getCreationRates', kin.kin_id, nsp, pt); calllib(ct, 'kin_getCreationRates', kin.kin_id, nsp, pt);
cdot = pt.Value; cdot = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Creation Rates') % set(gcf, 'Name', 'Creation Rates')
bar(q) % bar(q)
xlabel('Species Number') % xlabel('Species Number')
ylabel('Creation Rate [kmol/m^3-s]') % ylabel('Creation Rate [kmol/m^3-s]')
title('Species Chemical Reaction Rates') % title('Species Chemical Reaction Rates')
end % end
end end
function ddot = destructionRates(kin) function ddot = destructionRates(kin)
@ -264,14 +264,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getDestructionRates', kin.kin_id, nsp, pt); calllib(ct, 'kin_getDestructionRates', kin.kin_id, nsp, pt);
ddot = pt.Value; ddot = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Destruction Rates') % set(gcf, 'Name', 'Destruction Rates')
bar(q) % bar(q)
xlabel('Species Number') % xlabel('Species Number')
ylabel('Destruction Rate [kmol/m^3-s]') % ylabel('Destruction Rate [kmol/m^3-s]')
title('Species Chemical Reaction Rates') % title('Species Chemical Reaction Rates')
end % end
end end
function wdot = netProdRates(kin) function wdot = netProdRates(kin)
@ -288,14 +288,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getNetProductionRates', kin.kin_id, nsp, pt); calllib(ct, 'kin_getNetProductionRates', kin.kin_id, nsp, pt);
wdot = pt.Value; wdot = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Production Rates') % set(gcf, 'Name', 'Production Rates')
bar(q) % bar(q)
xlabel('Species Number') % xlabel('Species Number')
ylabel('Net Production Rate [kmol/m^3-s]') % ylabel('Net Production Rate [kmol/m^3-s]')
title('Species Net Chemical Reaction Rates') % title('Species Net Chemical Reaction Rates')
end % end
end end
function q = rop_f(kin) function q = rop_f(kin)
@ -312,14 +312,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getFwdRateOfProgress', kin.kin_id, nr, pt); calllib(ct, 'kin_getFwdRateOfProgress', kin.kin_id, nr, pt);
q = pt.Value; q = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Rates of Progress') % set(gcf, 'Name', 'Rates of Progress')
bar(q) % bar(q)
xlabel('Reaction Number') % xlabel('Reaction Number')
ylabel('Forward Rate of Progress [kmol/m^3]') % ylabel('Forward Rate of Progress [kmol/m^3]')
title('Forward Rates of Progress') % title('Forward Rates of Progress')
end % end
end end
function q = rop_r(kin) function q = rop_r(kin)
@ -336,14 +336,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getRevRateOfProgress', kin.kin_id, nr, pt); calllib(ct, 'kin_getRevRateOfProgress', kin.kin_id, nr, pt);
q = pt.Value; q = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Rates of Progress') % set(gcf, 'Name', 'Rates of Progress')
bar(q) % bar(q)
xlabel('Reaction Number') % xlabel('Reaction Number')
ylabel('Reverse Rate of Progress [kmol/m^3]') % ylabel('Reverse Rate of Progress [kmol/m^3]')
title('Reverse Rates of Progress') % title('Reverse Rates of Progress')
end % end
end end
function q = rop(kin) function q = rop(kin)
@ -360,15 +360,15 @@ classdef Kinetics < handle
f = rop_f(kin); f = rop_f(kin);
r = rop_r(kin); r = rop_r(kin);
q = [f, r]; q = [f, r];
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Rates of Progress') % set(gcf, 'Name', 'Rates of Progress')
bar(q) % bar(q)
xlabel('Reaction Number') % xlabel('Reaction Number')
ylabel('Rate of Progress [kmol/m^3]') % ylabel('Rate of Progress [kmol/m^3]')
title('Rates of Progress') % title('Rates of Progress')
legend('Forward', 'Reverse') % legend('Forward', 'Reverse')
end % end
end end
function q = rop_net(kin) function q = rop_net(kin)
@ -385,14 +385,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getNetRatesOfProgress', kin.kin_id, nr, pt); calllib(ct, 'kin_getNetRatesOfProgress', kin.kin_id, nr, pt);
q = pt.Value; q = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Rates of Progress') % set(gcf, 'Name', 'Rates of Progress')
bar(q) % bar(q)
xlabel('Reaction Number') % xlabel('Reaction Number')
ylabel('Net Rate of Progress [kmol/m^3]') % ylabel('Net Rate of Progress [kmol/m^3]')
title('Net Rates of Progress') % title('Net Rates of Progress')
end % end
end end
function rxn = reactionEqn(kin, irxn) function rxn = reactionEqn(kin, irxn)
@ -492,14 +492,14 @@ classdef Kinetics < handle
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);
calllib(ct, 'kin_getEquilibriumConstants', kin.kin_id, nr, pt); calllib(ct, 'kin_getEquilibriumConstants', kin.kin_id, nr, pt);
k = pt.Value; k = pt.Value;
if nargout == 0 % if nargout == 0
figure % figure
set(gcf, 'Name', 'Equilibrium Constants') % set(gcf, 'Name', 'Equilibrium Constants')
bar(k) % bar(k)
xlabel('Reaction Number') % xlabel('Reaction Number')
ylabel('log_{10} Kc [kmol,m, s]') % ylabel('log_{10} Kc [kmol,m, s]')
title('Equilibrium Constants') % title('Equilibrium Constants')
end % end
end end
function k = get.Kf(kin) function k = get.Kf(kin)

View File

@ -79,7 +79,7 @@ classdef Mixture < handle
for n = 1:np for n = 1:np
s = [sprintf('\n******************* Phase %d', n) ... s = [sprintf('\n******************* Phase %d', n) ...
sprintf(' ******************************\n\n Moles: %12.6g', ... sprintf(' ******************************\n\n Moles: %12.6g', ...
phaseMoles(m, n))]; phaseMoles(m, n))];
disp(s); disp(s);
display(m.phases{n, 1}); display(m.phases{n, 1});
end end

View File

@ -13,7 +13,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
s@Kinetics(tp, src, id); s@Kinetics(tp, src, id);
if nargin == 3 if nargin == 3
if ~(strcmp(trans, 'default') || strcmp(trans, 'None')... if ~(strcmp(trans, 'default') || strcmp(trans, 'None')...
|| strcmp(trans, 'Mix') || strcmp(trans, 'Multi')) || strcmp(trans, 'Mix') || strcmp(trans, 'Multi'))
error('Unknown transport modelling specified.'); error('Unknown transport modelling specified.');
end end
else else

View File

@ -174,7 +174,7 @@ classdef ThermoPhase < handle
tp.tp_id, name) + 1; tp.tp_id, name) + 1;
if k > 1e3 if k > 1e3
warning(['Element ', name, ... warning(['Element ', name, ...
' does not exist in the phase']); ' does not exist in the phase']);
k = -1; k = -1;
end end
else else
@ -365,7 +365,7 @@ classdef ThermoPhase < handle
if buflen > 0 if buflen > 0
aa = char(zeros(1, buflen)); aa = char(zeros(1, buflen));
[~, aa] = calllib(ct, 'thermo_getSpeciesName', ... [~, aa] = calllib(ct, 'thermo_getSpeciesName', ...
tp.tp_id, ksp, buflen, aa); tp.tp_id, ksp, buflen, aa);
nm{i, j} = aa; nm{i, j} = aa;
end end
end end

View File

@ -2,4 +2,3 @@ function w = Water()
% Return an object representing water. % Return an object representing water.
w = Solution('liquidvapor.yaml', 'water'); w = Solution('liquidvapor.yaml', 'water');
end end

View File

@ -15,13 +15,13 @@ function LoadCantera
if ~libisloaded(ct) if ~libisloaded(ct)
load('Utility/cantera_root.mat'); load('Utility/cantera_root.mat');
[~,warnings] = loadlibrary([cantera_root '/lib/' ctname], ... [~,warnings] = loadlibrary([cantera_root '/lib/' ctname], ...
[cantera_root '/include/cantera/clib/ctmatlab.h'], ... [cantera_root '/include/cantera/clib/ctmatlab.h'], ...
'includepath', [cantera_root '/include'], ... 'includepath', [cantera_root '/include'], ...
'addheader','ct','addheader','ctfunc', ... 'addheader','ct','addheader','ctfunc', ...
'addheader','ctmultiphase','addheader', ... 'addheader','ctmultiphase','addheader', ...
'ctonedim','addheader','ctreactor', ... 'ctonedim','addheader','ctreactor', ...
'addheader','ctrpath','addheader','ctsurf', ... 'addheader','ctrpath','addheader','ctsurf', ...
'addheader','ctxml'); 'addheader','ctxml');
end end
disp('Cantera is ready for use'); disp('Cantera is ready for use');
end end

View File

@ -115,7 +115,7 @@ for i = 2:length(x_calc)
%-------------------------------------------------------------------------- %--------------------------------------------------------------------------
%-------------------------------------------------------------------------- %--------------------------------------------------------------------------
% These values are passed onto the ode15s solver % These values are passed onto the ode15s solver
[~,y] = ode15s(@PFR_Solver, limits, inlet_soln, options,..., [~,y] = ode15s(@PFR_Solver, limits, inlet_soln, options, ...
gas_calc, mdot_calc, A_in, dAdx, k); gas_calc, mdot_calc, A_in, dAdx, k);
T_calc(i) = y(end, 2); T_calc(i) = y(end, 2);

View File

@ -40,11 +40,11 @@ function F = PFR_Solver(x, soln_vector, gas, mdot, A_in, dAdx, k)
%-------------------------reactor------------------------------------------ %-------------------------reactor------------------------------------------
%-------------------------------------------------------------------------- %--------------------------------------------------------------------------
F(1) = ((1-R/Cp)*((rho*vx)^2)*(1/A)*(dAdx)... F(1) = ((1-R/Cp)*((rho*vx)^2)*(1/A)*(dAdx)...
+ rho*R*sum(MW.*w.*(h-MW_mix*Cp*T./MW))/(vx*Cp) )... + rho*R*sum(MW.*w.*(h-MW_mix*Cp*T./MW))/(vx*Cp) )...
/ (P*(1+vx^2/(Cp*T)) - rho*vx^2); / (P*(1+vx^2/(Cp*T)) - rho*vx^2);
F(2) = (vx*vx/(rho*Cp))*F(1) + vx*vx*(1/A)*(dAdx)/Cp... F(2) = (vx*vx/(rho*Cp))*F(1) + vx*vx*(1/A)*(dAdx)/Cp...
- (1/(vx*rho*Cp))*sum(h.*w.*MW); - (1/(vx*rho*Cp))*sum(h.*w.*MW);
F(3:nsp+2) = w(1:nsp).*MW(1:nsp)./(rho*vx); F(3:nsp+2) = w(1:nsp).*MW(1:nsp)./(rho*vx);

View File

@ -47,7 +47,7 @@ gas = Solution(rxnmech, 'gri30', 'Mix');
gas.TPX = {tin, p, comp2}; gas.TPX = {tin, p, comp2};
%% Create the flow object %% Create the flow object
%
f = AxisymmetricFlow(gas,'flow'); f = AxisymmetricFlow(gas,'flow');
f.setPressure(p); f.setPressure(p);
f.setupGrid(initial_grid); f.setupGrid(initial_grid);
@ -65,7 +65,7 @@ inlet_o.setMdot(mdot_o);
inlet_o.setMoleFractions(comp1); inlet_o.setMoleFractions(comp1);
%% Create the fuel inlet %% Create the fuel inlet
%
inlet_f = Inlet('fuel_inlet'); inlet_f = Inlet('fuel_inlet');
inlet_f.T = tin; inlet_f.T = tin;
inlet_f.setMdot(mdot_f); inlet_f.setMdot(mdot_f);