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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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