Redo Base class to use Smart Cabinets See PR#1448

This commit is contained in:
ssun30 2023-04-11 14:05:37 -04:00 committed by Ray Speth
parent df17f4ead3
commit 4f78c0f186
4 changed files with 45 additions and 39 deletions

View File

@ -116,12 +116,22 @@ classdef Kinetics < handle
ctIsLoaded;
ph = varargin{1}.tpID;
tmp = varargin{1};
src = varargin{2};
id = varargin{3};
if ischar(tmp) & isnumeric(src)
if strcmp(tmp, 'CreateFromSolution')
kin.kinID = ctFunc('soln_kinetics', src);
return
end
end
ph = tmp.tpID;
if nargin == 2
id = '-';
elseif nargin > 2
id = varargin{3};
end
% indices for bulk phases in a heterogeneous mechanism
@ -134,14 +144,6 @@ classdef Kinetics < handle
kin.kinID = ctFunc('kin_newFromFile', src, id, ph, neighbours{:});
end
%% Kinetics Class Destructor
function delete(kin)
% Delete the :mat:class:`Kinetics` object.
ctFunc('kin_del', kin.kinID);
end
%% Get scalar attributes
function n = kineticsSpeciesIndex(kin, name, phase)

View File

@ -21,6 +21,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
% transport modeling as set in the input file. To specify the transport modeling,
% set the input argument ``trans`` to one of ``'default'``, ``'none'``,
% ``'mixture-averaged'``, or ``'multicomponent'``.
%
% In this case, the phase name must be specified as well. Alternatively,
% change the ``transport`` node in the YAML file, or ``transport``
% property in the CTI file before loading the phase. The transport
@ -47,8 +48,9 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
% :return:
% Instance of class :mat:class:`Solution`.
properties (Access = private)
tp
properties (SetAccess = immutable)
solnID
solnName
end
methods
@ -63,9 +65,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
if nargin < 2 || nargin > 3
error('Solution class constructor expects 2 or 3 input arguments.');
end
tp = ThermoPhase(src, id);
s@ThermoPhase(src, id);
s@Kinetics(tp, src, id);
if nargin == 3
if ~(strcmp(trans, 'default') || strcmp(trans, 'none')...
|| strcmp(trans, 'mixture-averaged') || strcmp(trans, 'multicomponent'))
@ -74,17 +74,21 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
else
trans = 'default';
end
s@Transport(tp, trans, 0);
s.tpClear;
s.tpID = tp.tpID;
ID = ctFunc('soln_newSolution', src, id, trans);
s@ThermoPhase('CreateFromSolution', ID);
s@Kinetics('CreateFromSolution', ID);
s@Transport('CreateFromSolution', ID);
s.solnID = ID;
s.solnName = ctString('soln_name', s.solnID);
s.th = s.tpID;
end
%% Solution Class Destructor
function delete(s)
% Delete :mat:class:`Solution` object.
s.tpClear;
ctFunc('soln_del', s.solnID);
disp('Solution class object has been deleted');
end

View File

@ -420,6 +420,12 @@ classdef ThermoPhase < handle
% Create a :mat:class:`ThermoPhase` object.
ctIsLoaded;
if strcmp(src, 'CreateFromSolution') & isnumeric(id)
tp.tpID = ctFunc('soln_thermo', id);
tp.basis = 'molar';
return
end
if nargin < 2
id = '';
end
@ -428,14 +434,6 @@ classdef ThermoPhase < handle
tp.basis = 'molar';
end
%% ThermoPhase Class Destructor
function tpClear(tp)
% Delete the :mat:class:`ThermoPhase` object.
ctFunc('thermo_del', tp.tpID);
end
%% ThermoPhase Utility Methods
function display(tp)

View File

@ -1,6 +1,6 @@
classdef Transport < handle
properties (Access = private)
properties (Access = protected)
th % ID of the ThermoPhase object used to create the Transport object.
end
@ -29,10 +29,10 @@ classdef Transport < handle
methods
%% Transport Class Constructor
function tr = Transport(tp, model, loglevel)
function tr = Transport(varargin)
% Transport Class ::
%
% >> tr = Transport(r, th, model, loglevel)
% >> tr = Transport(th, model, loglevel)
%
% Create a new instance of class :mat:class:`Transport`. One to three
% arguments may be supplied. The first must be an instance of class
@ -57,6 +57,16 @@ classdef Transport < handle
ctIsLoaded;
tr.trID = 0;
tp = varargin{1};
model = varargin{2};
if ischar(tp) & isnumeric(model)
if strcmp(tp, 'CreateFromSolution')
tr.trID = ctFunc('soln_transport', model);
return
end
end
if nargin == 2
model = 'default'
end
@ -80,14 +90,6 @@ classdef Transport < handle
end
%% Transport Class Destructor
function delete(tr)
% Delete the :mat:class:`Transport` object.
ctFunc('trans_del', tr.trID);
end
%% Transport Get Methods
function v = get.viscosity(tr)