From 6279debf1ef2c3318d9775d0ae365f62d34d4d97 Mon Sep 17 00:00:00 2001 From: ssun30 Date: Tue, 31 Jan 2023 18:27:52 -0500 Subject: [PATCH] Changed names of functions handling loading and unloading Cantera. --- interfaces/matlab_experimental/Func/fplus.m | 1 + .../matlab_experimental/Utility/LoadCantera.m | 26 ------------------ .../Utility/UnloadCantera.m | 7 ----- .../Utility/cantera_root.m | 3 --- .../matlab_experimental/Utility/cleanup.m | 12 --------- .../matlab_experimental/Utility/ctCleanUp.m | 21 +++++++++++++++ .../matlab_experimental/Utility/ctLoad.m | 27 +++++++++++++++++++ .../matlab_experimental/Utility/ctRoot.m | 3 +++ .../matlab_experimental/Utility/ctUnload.m | 10 +++++++ 9 files changed, 62 insertions(+), 48 deletions(-) delete mode 100644 interfaces/matlab_experimental/Utility/LoadCantera.m delete mode 100644 interfaces/matlab_experimental/Utility/UnloadCantera.m delete mode 100644 interfaces/matlab_experimental/Utility/cantera_root.m delete mode 100644 interfaces/matlab_experimental/Utility/cleanup.m create mode 100644 interfaces/matlab_experimental/Utility/ctCleanUp.m create mode 100644 interfaces/matlab_experimental/Utility/ctLoad.m create mode 100644 interfaces/matlab_experimental/Utility/ctRoot.m create mode 100644 interfaces/matlab_experimental/Utility/ctUnload.m diff --git a/interfaces/matlab_experimental/Func/fplus.m b/interfaces/matlab_experimental/Func/fplus.m index b974122b33..bf920ca328 100644 --- a/interfaces/matlab_experimental/Func/fplus.m +++ b/interfaces/matlab_experimental/Func/fplus.m @@ -10,6 +10,7 @@ % :return: % Instance of class :mat:class:`fplus` % + methods function f = fplus(a, b) diff --git a/interfaces/matlab_experimental/Utility/LoadCantera.m b/interfaces/matlab_experimental/Utility/LoadCantera.m deleted file mode 100644 index b954e59a89..0000000000 --- a/interfaces/matlab_experimental/Utility/LoadCantera.m +++ /dev/null @@ -1,26 +0,0 @@ -% Load the Cantera C Library into the Memory -% -if ispc - ctname = '/Lib/cantera_shared.dll'; -elseif ismac - ctname = '/Lib/libcantera_shared.dylib'; -elseif isunix - ctname = '/lib/libcantera_shared.so'; -else - error('Operating System Not Supported!'); - return; -end - -if ~libisloaded(ct) - [~, warnings] = loadlibrary([cantera_root, 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'); -end - -ct_ver = canteraVersion; -sprintf('%s is ready for use.', ct_ver); -clear all diff --git a/interfaces/matlab_experimental/Utility/UnloadCantera.m b/interfaces/matlab_experimental/Utility/UnloadCantera.m deleted file mode 100644 index 7154b7a1e7..0000000000 --- a/interfaces/matlab_experimental/Utility/UnloadCantera.m +++ /dev/null @@ -1,7 +0,0 @@ -% Unload the Cantear C Library from the Memory -% -if libisloaded(ct) - unloadlibrary(ct); -end - -disp('Cantera has been unloaded'); diff --git a/interfaces/matlab_experimental/Utility/cantera_root.m b/interfaces/matlab_experimental/Utility/cantera_root.m deleted file mode 100644 index ec2cec2add..0000000000 --- a/interfaces/matlab_experimental/Utility/cantera_root.m +++ /dev/null @@ -1,3 +0,0 @@ -function output = cantera_root() - output = ''; -end diff --git a/interfaces/matlab_experimental/Utility/cleanup.m b/interfaces/matlab_experimental/Utility/cleanup.m deleted file mode 100644 index 86d3861b95..0000000000 --- a/interfaces/matlab_experimental/Utility/cleanup.m +++ /dev/null @@ -1,12 +0,0 @@ -function cleanup() - % Delete all stored Cantera objects and reclaim memory. - % - checklib; - callct('ct_clearOneDim'); - callct('ct_clearMix'); - callct('ct_clearFunc'); - callct('ct_clearStorage'); - callct('ct_clearReactors'); - callct('ct_clearReactionPath'); - clear all -end diff --git a/interfaces/matlab_experimental/Utility/ctCleanUp.m b/interfaces/matlab_experimental/Utility/ctCleanUp.m new file mode 100644 index 0000000000..f4b8d4146c --- /dev/null +++ b/interfaces/matlab_experimental/Utility/ctCleanUp.m @@ -0,0 +1,21 @@ +function ctCleanUp() + % Delete all stored Cantera objects and reclaim memory. + % + ctIsLoaded; + + classList = {'Domain1D', 'Sim1D', 'Func', 'Kinetics', ... + 'Interface', 'Mixture', 'Solution', 'FlowDevice', 'Reactor', ... + 'Wall', 'ReactorNet', 'ReactorSurface', 'ThermoPhase', 'Transport'}; + + varList = evalin('base', 'whos'); + + for i = 1:length(varList) + for j = 1:length(classList) + if isa(evalin('base', ['eval("', varList(i).name, '")']), ... + classList{j}); + evalin('base', ['clear ', varList(i).name]); + break + end + end + end +end diff --git a/interfaces/matlab_experimental/Utility/ctLoad.m b/interfaces/matlab_experimental/Utility/ctLoad.m new file mode 100644 index 0000000000..c5a08a4009 --- /dev/null +++ b/interfaces/matlab_experimental/Utility/ctLoad.m @@ -0,0 +1,27 @@ +function ctLoad() + % Load the Cantera C Library into Memory + % + if ispc + ctName = '/Lib/cantera_shared.dll'; + elseif ismac + ctName = '/Lib/libcantera_shared.dylib'; + elseif isunix + ctName = '/lib/libcantera_shared.so'; + else + error('Operating System Not Supported!'); + return; + end + + if ~libisloaded(ctSharedLibrary) + [~, warnings] = loadlibrary([ctRoot, ctName], ... + [ctRoot, '/include/cantera/clib/ctmatlab.h'], ... + 'includepath', [ctRoot '/include'], ... + 'addheader', 'ct', 'addheader', 'ctfunc', ... + 'addheader', 'ctmultiphase', 'addheader', ... + 'ctonedim', 'addheader', 'ctreactor', ... + 'addheader', 'ctrpath', 'addheader', 'ctsurf'); + end + + disp(sprintf('Cantera %s is ready for use.', ctVersion)) + +end diff --git a/interfaces/matlab_experimental/Utility/ctRoot.m b/interfaces/matlab_experimental/Utility/ctRoot.m new file mode 100644 index 0000000000..463dd25773 --- /dev/null +++ b/interfaces/matlab_experimental/Utility/ctRoot.m @@ -0,0 +1,3 @@ +function output = ctRoot() + output = '/home/ssun30/anaconda3/envs/ct-matlab'; +end diff --git a/interfaces/matlab_experimental/Utility/ctUnload.m b/interfaces/matlab_experimental/Utility/ctUnload.m new file mode 100644 index 0000000000..fb69c1f849 --- /dev/null +++ b/interfaces/matlab_experimental/Utility/ctUnload.m @@ -0,0 +1,10 @@ +function ctUnload() + % Unload the Cantear C Library from the Memory + % + if libisloaded(ctSharedLibrary) + ctCleanUp; + unloadlibrary(ctSharedLibrary); + end + + disp('Cantera has been unloaded'); +end