Skip to content

Commit

Permalink
[Matlab] Updates to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and speth committed May 11, 2023
1 parent c11b157 commit 0294939
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion interfaces/matlab_experimental/LoadCantera.m
@@ -1,6 +1,6 @@
function LoadCantera
addpath('Class', 'Utility', 'PresetMixtures', 'PresetReactors', ...
'PresetObjects', '1D', 'Examples');
'PresetObjects', '1D');
if ispc
ctname = 'cantera_shared.dll';
elseif ismac
Expand All @@ -22,6 +22,8 @@
'ctonedim','addheader','ctreactor', ...
'addheader','ctrpath','addheader','ctsurf', ...
'addheader','ctxml');
example_dir = [cantera_root, '/samples/matlab_new'];
addpath(example_dir);
end
disp('Cantera is ready for use');
end
3 changes: 2 additions & 1 deletion interfaces/matlab_experimental/readme.txt
Expand Up @@ -8,7 +8,8 @@ https://cantera.org/install/compiling-install.html
3) Here is a list of cantera.conf options I used for development:
python_package = 'full'
matlab_toolbox = 'y'
4) After building and installing Cantera from source. Move [path/to/cantera/source/code/interfaces/Matlab_Toolbox_Revamp] to [/path/to/cantera/installation/matlab]
4) After building and installing Cantera from source. Move [path/to/cantera/source/code/interfaces/Matlab_Toolbox_Revamp] to [/path/to/cantera/installation/matlab] *Temporary
4.1) Copy [path/to/cantera/source/code/samples/matlab_new] to [/path/to/cantera/installation/samples] *Temporary
5) Launch Matlab, then navigate to [/path/to/cantera/installation/matlab/Matlab_Toolbox_Revamp] using "Browse for Folder".
6) In the Matlab command window, type SetCanteraPath('path/to/cantera/installation'). This should generate a cantera_root.mat file under the Matlab_Toolbox_Revamp/Utility folder, which stores the path as a Matlab variable.
7) In the command window, type LoadCantera to start using Cantera.
Expand Down
6 changes: 4 additions & 2 deletions samples/matlab_experimental/conhp.m
Expand Up @@ -13,15 +13,17 @@

% energy equation
wdot = gas.netProdRates;
H = gas.enthalpies_RT';
gas.basis = 'mass';
tdot = - gas.T * gasconstant * gas.enthalpies_RT .* wdot / (gas.D * gas.cp);
tdot = - gas.T * gasconstant /(gas.D * gas.cp).* wdot * H;

% set up column vector for dydt
dydt = [tdot'
dydt = [tdot
zeros(nsp, 1)];

% species equations
rrho = 1.0/gas.D;
for i = 1:nsp
dydt(i+1) = rrho * mw(i) * wdot(i);
end
end
6 changes: 3 additions & 3 deletions samples/matlab_experimental/conuv.m
Expand Up @@ -14,12 +14,12 @@

% energy equation
wdot = gas.netProdRates;
H = (gas.enthalpies_RT - ones(1, nsp))';
gas.basis = 'mass';
tdot = - gas.T * gasconstant * (gas.enthalpies_RT - ones(1, nsp)) ...
.* wdot / (gas.D * gas.cv);
tdot = - gas.T * gasconstant / (gas.D * gas.cv).* wdot * H;

% set up column vector for dydt
dydt = [tdot'
dydt = [tdot
zeros(nsp, 1)];

% species equations
Expand Down

0 comments on commit 0294939

Please sign in to comment.