mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Addressed several reviewer comments and changed readme to .md file
This commit is contained in:
parent
4ac5bdf707
commit
f07ad939c3
@ -1,12 +0,0 @@
|
||||
function m = AxiStagnFlow(gas)
|
||||
% Get an axisymmetric stagnation flow domain.
|
||||
% m = AxiStagnFlow(gas)
|
||||
%
|
||||
% :param gas:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
% :return:
|
||||
% Domain1D instance representing an axisymmetric
|
||||
% stagnation flow.
|
||||
%
|
||||
m = Domain1D('StagnationFlow', gas);
|
||||
end
|
@ -10,14 +10,15 @@ classdef Domain1D < handle
|
||||
methods
|
||||
%% Domain1D class constructor.
|
||||
|
||||
function d = Domain1D(a, b, c)
|
||||
function d = Domain1D(a, b)
|
||||
% Domain1D class constructor.
|
||||
%
|
||||
% d = Domain1D(a, b, c)
|
||||
% d = Domain1D(a, b)
|
||||
%
|
||||
% :param a:
|
||||
% String type of domain. Possible values are:
|
||||
% `StagnationFlow`
|
||||
% `AxisymmetricFlow`
|
||||
% `Inlet1D`
|
||||
% `Surf1D`
|
||||
% `Symm1D`
|
||||
@ -29,13 +30,8 @@ classdef Domain1D < handle
|
||||
% Instance of class :mat:func:`Solution` (for ``a == 1``)
|
||||
% or :mat:func:`Interface` (for ``a == 6``). Not used for
|
||||
% all other valid values of ``a``.
|
||||
% :param c:
|
||||
% Integer, either 1 or 2, indicating whether an axisymmetric
|
||||
% stagnation flow or a free flame should be created. If not
|
||||
% specified, defaults to 1. Ignored if ``a != 1``.
|
||||
%
|
||||
checklib;
|
||||
d.domainID = -1;
|
||||
|
||||
if nargin == 1
|
||||
if strcmp(a, 'Inlet1D')
|
||||
@ -60,6 +56,13 @@ classdef Domain1D < handle
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
end
|
||||
elseif strcmp(a, 'AxisymmetricFlow')
|
||||
if isa(b, 'Solution')
|
||||
d.domainID = callct('stflow_new', ...
|
||||
b.tpID, b.kinID, b.trID, 2);
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
end
|
||||
elseif strcmp(a, 'ReactingSurface')
|
||||
if isa(b, 'Interface')
|
||||
d.domainID = callct('reactingsurf_new');
|
||||
@ -71,21 +74,6 @@ classdef Domain1D < handle
|
||||
else
|
||||
error('Wrong object type.');
|
||||
end
|
||||
elseif nargin == 3
|
||||
if strcmp(a, 'StagnationFlow')
|
||||
if isa(b, 'Solution')
|
||||
if strcmp(c, 'AxisymmetricFlow')
|
||||
flowtype = 1;
|
||||
else flowtype = 2;
|
||||
end
|
||||
d.domainID = callct('stflow_new', ...
|
||||
b.tpID, b.kinID, b.trID, flowtype);
|
||||
else
|
||||
error('Wrong argument type. Expecting instance of class Solution.');
|
||||
end
|
||||
else
|
||||
error('Unknown domain type.');
|
||||
end
|
||||
end
|
||||
d.type = a;
|
||||
end
|
||||
|
@ -2,15 +2,12 @@ classdef Kinetics < handle
|
||||
|
||||
properties
|
||||
kinID
|
||||
Kc % equilibrium constant
|
||||
Kf % forward reaction rate
|
||||
Kr % reverse reaction rate
|
||||
dH % enthalpy of reaction
|
||||
dHss % standard state enthalpy of reaction
|
||||
dH_standard % standard state enthalpy of reaction
|
||||
dS % entropy of reaction
|
||||
dSss % standard state entropy of reaction
|
||||
dS_standard % standard state entropy of reaction
|
||||
dG % gibbs free energy of reaction
|
||||
dGss % standard state gibbs free energy of reaction
|
||||
dG_standard % standard state gibbs free energy of reaction
|
||||
end
|
||||
|
||||
methods
|
||||
@ -345,30 +342,24 @@ classdef Kinetics < handle
|
||||
% Get the reaction equation of a reaction
|
||||
%
|
||||
% :parameter irxn:
|
||||
% Optional. Integer or vector of reaction numbers.
|
||||
% Integer index of the reaction.
|
||||
% :return:
|
||||
% String or cell arrray of strings of the reaction
|
||||
% equations.
|
||||
% String reaction equation.
|
||||
|
||||
if nargin == 1
|
||||
m = kin.nReactions;
|
||||
n = 1;
|
||||
irxn = (n:m);
|
||||
elseif nargin == 2
|
||||
if isa(irxn, 'double')
|
||||
[n, m] = size(irxn);
|
||||
else
|
||||
error('reaction numbers must be numeric');
|
||||
end
|
||||
end
|
||||
output = callct2('kin_getReactionString', kin.kinID, irxn-1);
|
||||
end
|
||||
|
||||
rxn = cell(m, n);
|
||||
for i = 1:n
|
||||
for j = 1:m
|
||||
output = callct2('kin_getReactionString', kin.kinID, ...
|
||||
irxn(i, j) - 1);
|
||||
rxn{j, i} = output;
|
||||
end
|
||||
function rxn = reactionEqns(kin)
|
||||
% Get all reaction equations within the Kinetics class
|
||||
%
|
||||
% :return:
|
||||
% Cell arrray of strings of the reaction equations.
|
||||
|
||||
m = kin.nReactions;
|
||||
irxn = (1:m);
|
||||
rxns = cell(1, m);
|
||||
for i = 1:m
|
||||
rxns{i} = kin.reactionEqn(irxn(i)-1);
|
||||
end
|
||||
end
|
||||
|
||||
@ -386,7 +377,7 @@ classdef Kinetics < handle
|
||||
enthalpy = pt.Value;
|
||||
end
|
||||
|
||||
function enthalpy = get.dHss(kin)
|
||||
function enthalpy = get.dH_standard(kin)
|
||||
% Get the standard state enthalpy of reaction for each reaction.
|
||||
%
|
||||
% :return:
|
||||
@ -414,7 +405,7 @@ classdef Kinetics < handle
|
||||
entropy = pt.Value;
|
||||
end
|
||||
|
||||
function entropy = get.dSss(kin)
|
||||
function entropy = get.dS_standard(kin)
|
||||
% Get the standard state entropy of reaction for each reaction.
|
||||
%
|
||||
% :return:
|
||||
@ -442,7 +433,7 @@ classdef Kinetics < handle
|
||||
gibbs = pt.Value;
|
||||
end
|
||||
|
||||
function gibbs = get.dGss(kin)
|
||||
function gibbs = get.dG_standard(kin)
|
||||
% Get the standard state Gibbs free energy of reaction for each reaction.
|
||||
%
|
||||
% :return:
|
||||
@ -456,7 +447,7 @@ classdef Kinetics < handle
|
||||
gibbs = pt.Value;
|
||||
end
|
||||
|
||||
function k = get.Kc(kin)
|
||||
function k = equilibriumConstants(kin)
|
||||
% Get the equilibrium constants for all reactions.
|
||||
%
|
||||
% :return:
|
||||
@ -472,7 +463,7 @@ classdef Kinetics < handle
|
||||
k = pt.Value;
|
||||
end
|
||||
|
||||
function k = get.Kf(kin)
|
||||
function k = forwardRateConstants(kin)
|
||||
% Get the forward reaction rate constants for all reactions.
|
||||
%
|
||||
% :return:
|
||||
@ -486,7 +477,7 @@ classdef Kinetics < handle
|
||||
k = pt.Value;
|
||||
end
|
||||
|
||||
function k = get.Kr(kin)
|
||||
function k = reverseRateConstants(kin)
|
||||
% Get the reverse reaction rate constants for all reactions.
|
||||
%
|
||||
% :return:
|
||||
@ -519,28 +510,24 @@ classdef Kinetics < handle
|
||||
% Set the multiplier for the reaction rate of progress.
|
||||
%
|
||||
% :parameter irxn:
|
||||
% Integer of vector reaction numbers for which the
|
||||
% multiplier should be set. Optional.
|
||||
% Integer vector reaction numbers for which the multiplier
|
||||
% should be set. Optional.
|
||||
% :parameter v:
|
||||
% Value by which the reaction rate of progress should be
|
||||
% multiplied.
|
||||
|
||||
if nargin == 2
|
||||
v = irxn;
|
||||
nr = kin.nReactions;
|
||||
irxn = (1:nr)';
|
||||
n = 1;
|
||||
n = kin.nReactions;
|
||||
irxn = (1:n);
|
||||
elseif nargin == 3
|
||||
[nr, n] = size(irxn);
|
||||
n = length(irxn);
|
||||
else
|
||||
error('setMultiplier requires 2 or 3 arguments.')
|
||||
end
|
||||
|
||||
for i = 1:nr
|
||||
for j = 1:n
|
||||
callct('kin_setMultiplier', kin.kinID, ...
|
||||
irxn(i, j)-1, v);
|
||||
end
|
||||
for i = 1:n
|
||||
calct('kin_setMultiplier', kin.kinID, irxn(i)-1, v);
|
||||
end
|
||||
end
|
||||
|
||||
|
22
interfaces/matlab_experimental/readme.md
Normal file
22
interfaces/matlab_experimental/readme.md
Normal file
@ -0,0 +1,22 @@
|
||||
This experimental Matlab Toolbox for Cantera changes the Matlab interface to the modern Matlab structure and syntaxes for OOP. It replaces the MEX interface with direct function calling from Canter Clib.
|
||||
|
||||
Installation guide:
|
||||
|
||||
1) Install Matlab (any release newer than R2008a).
|
||||
2) Compile Cantera from Source and install in your Conda environment, as directed in this link.
|
||||
https://cantera.org/install/compiling-install.html.
|
||||
2.5) The experimental Matlab Toolbox does not require a SCons option to install at this moment since it's stand-alone. It also does not require the current Matlab Toolbox to be installed.
|
||||
3) For first time users, launch Matlab, then navigate to [/path/to/cantera/source/code] using "Browse for Folder".
|
||||
4) In the Maltab command window, run `addpath(genpath([pwd, '/interfaces/matlab_experimental']))` to add search path for the experimental toolbox.
|
||||
5) In the Maltab command window, run `addpath(genpath([pwd, '/samples/matlab_experimental']))` to add search path for the sample files.
|
||||
6) In the Matlab command window, run `cd([pwd, '/interfaces/matlab_experimental/Utility']) to navigate to the Utility folder.
|
||||
7) Open the file named 'cantera_root.m', in the second line, edit `output=` to `output=[/path/to/conda/environment]`, then save the file. This sets the search path for the `LoadCantera` command to find the shared library file for Cantera.
|
||||
8) After steps 3 to 7 are complete, make sure search paths to the current Matlab Toolbox and samples files are removed (if it's already installed). Having both the current and experimental version of the toolbox in the search path will lead to conflicts.
|
||||
9) In the Matlab command window, run `savepath` to save all search paths.
|
||||
10) To start using the experimental toolbox, run `LoadCantera` command.
|
||||
11) To stop using the new Cantera interface, run the following commands:
|
||||
`clear all`
|
||||
`cleanup`
|
||||
`UnloadCantera`
|
||||
11) To switch back to the current matlab toolbox, undo steps 3, 4, 5, 8, and 9. The command to remove search path in Matlab is `rmpath`.
|
||||
12) A future updates will add automated installation.
|
@ -1,21 +0,0 @@
|
||||
This new Matlab Toolbox for Cantera changed the Matlab interface to the modern Matlab structure and syntaxes for OOP. It replaced the MEX interface with direct function calling from Canter Clib.
|
||||
|
||||
How to install the new Toolbox (for now):
|
||||
|
||||
1) Install Matlab (any version newer than R2008a). The toolbox have been tested for R2020a, R2020b, R2021a, and R2021b.
|
||||
2) Compile Cantera from Source, as directed in this link.
|
||||
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] *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.
|
||||
8) The Example folder contains test examples.
|
||||
9) To stop using Cantera, type the following commands:
|
||||
>> clear all
|
||||
>> close all
|
||||
>> cleanup
|
||||
>> UnloadCantera
|
Loading…
Reference in New Issue
Block a user