[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
% attempted. If this failed, two time steps would be taken.
checklib;
calllib(ct, 'sim1D_', s.st_id, ...
calllib(ct, 'sim1D_TimeStep', s.st_id, ...
stepsize, length(steps), steps);
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -115,7 +115,7 @@ for i = 2:length(x_calc)
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% 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);
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------------------------------------------
%--------------------------------------------------------------------------
F(1) = ((1-R/Cp)*((rho*vx)^2)*(1/A)*(dAdx)...
+ rho*R*sum(MW.*w.*(h-MW_mix*Cp*T./MW))/(vx*Cp) )...
/ (P*(1+vx^2/(Cp*T)) - rho*vx^2);
+ rho*R*sum(MW.*w.*(h-MW_mix*Cp*T./MW))/(vx*Cp) )...
/ (P*(1+vx^2/(Cp*T)) - rho*vx^2);
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);

View File

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