Some fixes to a few Classes

and Fixed Set Mdot and Set Max Jacobian Age
This commit is contained in:
Su Sun 2022-01-21 16:55:08 -05:00 committed by Ray Speth
parent 1e59450ca4
commit 7eb7d37aae
7 changed files with 50 additions and 47 deletions

View File

@ -31,19 +31,19 @@ classdef Domain1D < handle
% specified, defaults to 1. Ignored if a!= 1. % specified, defaults to 1. Ignored if a!= 1.
checklib; checklib;
d.dom_id = 1; d.dom_id = -1;
if nargin == 1 if nargin == 1
if a == 2 if a == 2
calllib(ct, 'inlet_new'); d.dom_id = calllib(ct, 'inlet_new');
elseif a == 3 elseif a == 3
calllib(ct, 'surf_new'); d.dom_id = calllib(ct, 'surf_new');
elseif a == 4 elseif a == 4
calllib(ct, 'symm_new'); d.dom_id = calllib(ct, 'symm_new');
elseif a == 5 elseif a == 5
calllib(ct, 'outlet_new'); d.dom_id = calllib(ct, 'outlet_new');
elseif a == -2 elseif a == -2
calllib(ct, 'outletres_new'); d.dom_id = calllib(ct, 'outletres_new');
else else
error('Not enough arguments for that job number'); error('Not enough arguments for that job number');
end end
@ -191,7 +191,7 @@ classdef Domain1D < handle
checklib; checklib;
disp(' '); disp(' ');
disp('Enabling the energy equation...'); disp('Enabling the energy equation...');
calllib(ctm 'stflow_solveEnergyEqn', d.dom_id, 1); calllib(ct, 'stflow_solveEnergyEqn', d.dom_id, 1);
end end
function zz = gridPoints(d, n) function zz = gridPoints(d, n)
@ -206,15 +206,15 @@ classdef Domain1D < handle
checklib; checklib;
if nargin == 1 if nargin == 1
np = d.nPoints; np = d.nPoints;
zz = zeros(1, d.np); zz = zeros(1, np);
for i = 1:np for i = 1:np
zz(i) = calllib(ct, 'domain_grid', dom_id, i-1); zz(i) = calllib(ct, 'domain_grid', d.dom_id, i-1);
end end
else else
m = length(n); m = length(n);
zz = zeros(1, m); zz = zeros(1, m);
for i = 1:m for i = 1:m
zz(i) = calllib(ct, 'domain_grid', dom_id, n(i)-1); zz(i) = calllib(ct, 'domain_grid', d.dom_id, n(i)-1);
end end
end end
end end
@ -372,11 +372,13 @@ classdef Domain1D < handle
checklib; checklib;
sz = size(profile); sz = size(profile);
if sz(1) == 2 if sz(1) == 2
l = length(1, :); l = length(profile(1, :));
calllib(ct, '', d.dom_id, l, profile(1, :), l, profile(2, :)); calllib(ct, 'stflow_setFixedTempProfile', d.dom_id, ...
l, profile(1, :), l, profile(2, :));
elseif sz(2) == 2 elseif sz(2) == 2
l = length(:, 1); l = length(profile(:, 1));
calllib(ct, '', d.dom_id, l, profile(:, 1); l, profile(:, 2)); calllib(ct, 'stflow_setFixedTempProfile', d.dom_id, ...
l, profile(:, 1), l, profile(:, 2));
else error('Wrong temperature profile array shape.'); else error('Wrong temperature profile array shape.');
end end
end end
@ -394,7 +396,7 @@ classdef Domain1D < handle
% parameter mdot: % parameter mdot:
% Mass flow rate. % Mass flow rate.
checklib; checklib;
calllib(ct, 'bdry_setTemperature', d.dom_id, mdot); calllib(ct, 'bdry_setMdot', d.dom_id, mdot);
end end
function setMoleFractions(d, x) function setMoleFractions(d, x)
@ -411,7 +413,7 @@ classdef Domain1D < handle
% parameter p: % parameter p:
% Pressure to be set. Unit: Pa. % Pressure to be set. Unit: Pa.
checklib; checklib;
calllib(ct, 'bdry_setPressure', d.dom_id, p); calllib(ct, 'stflow_setPressure', d.dom_id, p);
end end
function setProfileD(d, n, p) function setProfileD(d, n, p)
@ -515,7 +517,7 @@ classdef Domain1D < handle
function set.T(d, t) function set.T(d, t)
% Set the temperature (K). % Set the temperature (K).
checklib; checklib;
if temperature <= 0 if t <= 0
error('The temperature must be positive'); error('The temperature must be positive');
end end
calllib(ct, 'bdry_setTemperature', d.dom_id, t); calllib(ct, 'bdry_setTemperature', d.dom_id, t);

View File

@ -20,7 +20,7 @@ classdef Stack < handle
checklib; checklib;
s.st_id = 1; s.st_id = -1;
s.domains = domains; s.domains = domains;
if nargin == 1 if nargin == 1
nd = length(domains); nd = length(domains);
@ -378,7 +378,7 @@ classdef Stack < handle
n - 1, comp - 1, localPoints - 1, v); n - 1, comp - 1, localPoints - 1, v);
end end
function solution(s, domain, component) function x = solution(s, domain, component)
% Get a solution component in one domain. % Get a solution component in one domain.
% %
% parameter s: % parameter s:
@ -402,7 +402,7 @@ classdef Stack < handle
icomp = d.componentIndex(component); icomp = d.componentIndex(component);
x = zeros(1, np); x = zeros(1, np);
for n = 1:np for n = 1:np
x(n) = calllib(ct, 'sim1D_Value', s.st_id, ... x(n) = calllib(ct, 'sim1D_value', s.st_id, ...
idom - 1, icomp - 1, n - 1); idom - 1, icomp - 1, n - 1);
end end
else else
@ -410,7 +410,7 @@ classdef Stack < handle
x = zeros(nc, np); x = zeros(nc, np);
for m = 1:nc for m = 1:nc
for n = 1:np for n = 1:np
x(m, n) = calllib(ct, 'sim1D_Value', s.st_id, ... x(m, n) = calllib(ct, 'sim1D_value', s.st_id, ...
idom - 1, m - 1, n - 1); idom - 1, m - 1, n - 1);
end end
end end
@ -432,18 +432,18 @@ classdef Stack < handle
calllib(ct, 'sim1D_solve', s.st_id, loglevel, refine_grid); calllib(ct, 'sim1D_solve', s.st_id, loglevel, refine_grid);
end end
function b = subsref(s, index) % function b = subsref(s, index)
% Redefine subscripted references. % % Redefine subscripted references.
switch index.type % switch index.type
case '()' % case '()'
b = s.domains(index.subs{:}); % b = s.domains(index.subs{:});
case '.' % case '.'
n = s.domainIndex(index.subs); % n = s.domainIndex(index.subs);
b = s.domains(n); % b = s.domains(n);
otherwise % otherwise
error('syntax error'); % error('syntax error');
end % end
end % end
function writeStats(s) function writeStats(s)
% Print statistics for the current solution. % Print statistics for the current solution.
@ -451,7 +451,7 @@ classdef Stack < handle
% evaluations for each grid, and the CPU time spent on each % evaluations for each grid, and the CPU time spent on each
% one. % one.
checklib; checklib;
calllib(ct, 'sim1D_writeStats', s.st_id); calllib(ct, 'sim1D_writeStats', s.st_id, 1);
end end
end end

View File

@ -32,6 +32,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
args = {p1, p2, p3, p4}; args = {p1, p2, p3, p4};
end end
s@Kinetics(t, src, id, args{:}); s@Kinetics(t, src, id, args{:});
s.tp_id = t.tp_id;
end end
%% Interface methods %% Interface methods
@ -45,7 +46,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
% will be returned. % will be returned.
checklib; checklib;
surf_id = s.tr_id; surf_id = s.tp_id;
nsp = s.nSpecies; nsp = s.nSpecies;
xx = zeros(1, nsp); xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx); pt = libpointer('doublePtr', xx);

View File

@ -577,7 +577,7 @@ classdef Kinetics < handle
end end
end end
function advanceCoeverages(kin, dt) function advanceCoverages(kin, dt)
% Advance the surface coveages forward in time % Advance the surface coveages forward in time
% %
% parameter dt: % parameter dt:

View File

@ -1081,7 +1081,7 @@ classdef ThermoPhase < handle
calllib(ct, 'thermo_setMassFractions', tp.tp_id, ... calllib(ct, 'thermo_setMassFractions', tp.tp_id, ...
nsp, yy, norm); nsp, yy, norm);
elseif isa(yy, 'char') elseif isa(yy, 'char')
calllib(ct, 'thermo_setMassFracitonsByName', tp.tp_id, yy); calllib(ct, 'thermo_setMassFractionsByName', tp.tp_id, yy);
end end
end end

View File

@ -66,7 +66,7 @@ classdef FlowDevice < handle
end end
i = upstream.id; i = upstream.id;
j = downstream.id; j = downstream.id;
ok = calllib(ct, 'flowdev_install', f.id, i, j); calllib(ct, 'flowdev_install', f.id, i, j);
% if ok < 0 % if ok < 0
% error(geterr) % error(geterr)
% end % end

View File

@ -1,7 +1,7 @@
classdef ReactorSurface < handle classdef ReactorSurface < handle
properties properties
id surf_id
area area
reactor reactor
end end
@ -36,7 +36,7 @@ classdef ReactorSurface < handle
checklib; checklib;
s.id = calllib(ct, 'reactorsurface_new', 0); s.surf_id = calllib(ct, 'reactorsurface_new', 0);
s.reactor = -1; s.reactor = -1;
% if r.id < 0 % if r.id < 0
% error(geterr); % error(geterr);
@ -69,14 +69,14 @@ classdef ReactorSurface < handle
function clear(s) function clear(s)
% Clear the ReactorSurface object from the memory. % Clear the ReactorSurface object from the memory.
checklib; checklib;
calllib(ct, 'reactorsurface_del', s.id); calllib(ct, 'reactorsurface_del', s.surf_id);
end end
function install(s, r) function install(s, r)
% Install a ReactorSurface in a Reactor. % Install a ReactorSurface in a Reactor.
checklib; checklib;
s.reactor = r; s.reactor = r;
calllib(ct, 'reactorsurface_install', s.id, r.id); calllib(ct, 'reactorsurface_install', s.surf_id, r.id);
end end
%% ReactorSurface get methods %% ReactorSurface get methods
@ -84,15 +84,15 @@ classdef ReactorSurface < handle
function a = get.area(s) function a = get.area(s)
% Get the areaof the reactor surface in m^2. % Get the areaof the reactor surface in m^2.
checklib; checklib;
a = calllib(ct, 'reactorsurface_area', s.id); a = calllib(ct, 'reactorsurface_area', s.surf_id);
end end
%% ReactorSurface set methods %% ReactorSurface set methods
function s = set.area(s, a) function set.area(s, a)
% Set the area of a reactor surface % Set the area of a reactor surface
checklib; checklib;
calllib(ct, 'reactorsurface_setArea', s.id, a); calllib(ct, 'reactorsurface_setArea', s.surf_id, a);
end end
function setKinetics(s, kin) function setKinetics(s, kin)
@ -106,10 +106,10 @@ classdef ReactorSurface < handle
ikin = 0; ikin = 0;
if isa(kin, 'Kinetics') if isa(kin, 'Kinetics')
ikin = kin.id; ikin = kin.kin_id;
end end
calllib(ct, 'reactorsurface_setkinetics', s.id, ikin); calllib(ct, 'reactorsurface_setkinetics', s.surf_id, ikin);
end end
end end