Skip to content

Commit

Permalink
Redo Base class to use Smart Cabinets See PR#1448
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and speth committed May 11, 2023
1 parent df17f4e commit 4f78c0f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
22 changes: 12 additions & 10 deletions interfaces/matlab_experimental/Base/Kinetics.m
Expand Up @@ -116,12 +116,22 @@

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
Expand All @@ -134,14 +144,6 @@
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)
Expand Down
24 changes: 14 additions & 10 deletions interfaces/matlab_experimental/Base/Solution.m
Expand Up @@ -21,6 +21,7 @@
% 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
Expand All @@ -47,8 +48,9 @@
% :return:
% Instance of class :mat:class:`Solution`.

properties (Access = private)
tp
properties (SetAccess = immutable)
solnID
solnName
end

methods
Expand All @@ -63,9 +65,7 @@
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'))
Expand All @@ -74,17 +74,21 @@
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

Expand Down
14 changes: 6 additions & 8 deletions interfaces/matlab_experimental/Base/ThermoPhase.m
Expand Up @@ -420,6 +420,12 @@
% 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
Expand All @@ -428,14 +434,6 @@
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)
Expand Down
24 changes: 13 additions & 11 deletions interfaces/matlab_experimental/Base/Transport.m
@@ -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

Expand Down Expand Up @@ -29,10 +29,10 @@
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
Expand All @@ -57,6 +57,16 @@
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
Expand All @@ -80,14 +90,6 @@

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)
Expand Down

0 comments on commit 4f78c0f

Please sign in to comment.