Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab toolbox revamp #1182

Merged
merged 65 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
36c20bb
[Matlab] Initial version of 'experimental' Matlab toolbox
ssun30 Nov 1, 2021
9159f41
Added Reactor Class and Changed Class ID Variable Names
ssun30 Nov 5, 2021
9523778
Experimental Matlab toolbox now working
ssun30 Jan 11, 2022
3eef41d
Added examples to the new Matlab toolbox
ssun30 Jan 11, 2022
2c95a22
Some fixes to a few Classes
ssun30 Jan 21, 2022
dac5224
Added 1D/CounterFLowDiffusionFlame
ssun30 Jan 21, 2022
ecd8ef7
Added and fixed Examples for the new toolbox
ssun30 Jan 21, 2022
aaabae1
Fixed some Examples
ssun30 Feb 15, 2022
4c22b23
Added installation guide
rwest Oct 13, 2022
751ba81
[Matlab] Remove automatic figure generation for kinetic rate functions
ssun30 Mar 4, 2022
ade4fe7
[Matlab] Updates to examples
ssun30 Mar 7, 2022
079767a
Made changes based on Feedback.
ssun30 Mar 22, 2022
9e422f3
[Matlab] Add named constructors for functors
ssun30 Apr 22, 2022
d345afa
More fixes to new MatlabToolbox
ssun30 Apr 22, 2022
38cb407
[Matlab] Update 1D documentation
ssun30 May 16, 2022
a85a1d4
[Matlab] Documentation updates
ssun30 Jun 2, 2022
bd1f047
Tutorials/Sconscript/Docs
ssun30 Jul 1, 2022
9be8320
[Matlab] Fix docstrings for Sphinx compatibility
rwest Jul 1, 2022
c12b88e
[Matlab] Update to reflect removal of CTI/XML input formts
ssun30 Jul 15, 2022
6755272
Changed how strings are passed between Matlab and Clib
ssun30 Aug 12, 2022
514401a
Use thermo_report instead of thermo_print to print thermo properties.
ssun30 Aug 12, 2022
82d8350
Combined `calllib` and `error` handling into one `callct` command
ssun30 Aug 16, 2022
6bb24b1
Added callct2 utility function to handle all string outputs
ssun30 Aug 26, 2022
a1576f7
Changed some thermo_set methods to use geterr for error handling.
ssun30 Aug 26, 2022
dabf692
Addressed issues in Kinetics Class.
ssun30 Aug 29, 2022
617dd29
[Matlab] Fixed issue causing crash when getting diffusion coefficients
ssun30 Dec 10, 2022
e4f61dd
Added an option to remove all Cantera search paths from Matlab
ssun30 Aug 31, 2022
dffb80b
Changed a bunch of docstrings for examples, added error handling for …
ssun30 Aug 31, 2022
7ee85aa
Changed LoadCantera so it could load in Linux
ssun30 Sep 2, 2022
60825fe
Fixed typos in several classes and samples
ssun30 Sep 2, 2022
a342a14
Added Diamond CVD Example
ssun30 Sep 2, 2022
86abc9b
Fixed a few problems in Samples and Utility
ssun30 Sep 6, 2022
054326b
Deleted Preset Mixture Phases and Removed Unnecessary Code
ssun30 Sep 7, 2022
a633bc6
Added key words for Matlab Examples
ssun30 Sep 8, 2022
c908e88
Deleted unnecessay code and added Cantera version info in LoadCantera
ssun30 Sep 9, 2022
7c67755
Addressed several reviewer comments and changed readme to .md file
ssun30 Sep 9, 2022
bfaa45c
[Matlab] Converted all possible methods to properties
ssun30 Sep 16, 2022
029237b
Fixed all docstring issues.
ssun30 Sep 16, 2022
315a4dd
Changed name of `Stack` class to `Sim1D` class
ssun30 Sep 23, 2022
1e10b06
Fixed all issues caused by modifying class methods into properties.
ssun30 Oct 13, 2022
2023a28
Fixed condition checking for mole/mass fraction normalization
ssun30 Oct 19, 2022
f6f0641
Addressed changes proposed by reviewers - 120422
ssun30 Dec 8, 2022
b77d650
Reformatted all matlab interface and sample files to Cantera contribu…
ssun30 Dec 8, 2022
c9ec3bc
Changed Functor into its standalone class.
ssun30 Dec 15, 2022
895be16
Addressed reviewer comments including subclass definitions and docstr…
ssun30 Dec 21, 2022
071069c
Fixed docstrings and moving several unncessary methods into class
ssun30 Jan 5, 2023
acf0dc0
Changed name of constants to be consistent with C++ core.
ssun30 Jan 31, 2023
70e731c
Fixed Purefluid Phases that had incorrect output name.
ssun30 Jan 31, 2023
eedd19c
Changed names of functions handling loading and unloading Cantera.
ssun30 Jan 31, 2023
99a9833
Changed all callct2 to ctString
ssun30 Feb 1, 2023
fdc04ea
Changed all callct to ctFunc
ssun30 Feb 1, 2023
53416d0
Fixed names of two utility methods and changed how Transport handles
ssun30 Feb 9, 2023
33775f4
Reformatted ThermoPhase/changed property getter methods/add docstrings.
ssun30 Feb 15, 2023
a280657
Added 'Q' as a PureFluid property replacing 'vaporFraction'.
ssun30 Feb 15, 2023
17df30a
Added class destructor for Interface class.
ssun30 Feb 15, 2023
f0759c5
Changed property names in Kinetics to be consistent with Python.
ssun30 Feb 23, 2023
d78d0ad
Fixed a lot of docstrings and turned 0/1 outputs into boolean.
ssun30 Feb 25, 2023
7dd5060
Changed several naming conventions to match main branch.
ssun30 Mar 16, 2023
f090378
Redo Base class to use Smart Cabinets See PR#1448
ssun30 Apr 11, 2023
a260b87
Redo 1D class to use DomainFactory See PR #1445
ssun30 Apr 21, 2023
75948bd
Avoid class destructors from deleting already-deleted objects.
ssun30 Apr 21, 2023
95e70f8
Changed doctree and docstrings after OneDim change
ssun30 Apr 21, 2023
1dabfa5
Moved folders/fixed doctrees
ssun30 May 3, 2023
066609b
Restructure readme for experimental matlab toolbox
ssun30 May 8, 2023
66e1fb9
[Matlab] Fix various typos
speth May 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions interfaces/matlab_experimental/Base/CarbonDioxide.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function c = CarbonDioxide()
% Return an object representing carbon dioxide. ::
%
% >> c = CarbonDioxide
%
% The object returned by this method implements an accurate equation of
% state for carbon dioxide that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from
%
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
% computational equations for forty substances.* Stanford: Stanford
% University, 1979. Print.
%
% For more details, see classes Cantera::PureFluid and tpx::CarbonDioxide in the
% Cantera C++ source code documentation.
%
% :return:
% Instance of class :mat:class:`Solution`.

c = Solution('liquidvapor.yaml', 'carbon-dioxide');
end
24 changes: 24 additions & 0 deletions interfaces/matlab_experimental/Base/HFC134a.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function h = HFC134a()
% Return an object representing refrigerant HFC134a. ::
%
% >> h = HFC134a()
%
% The object returned by this method implements an accurate equation of
% state for refrigerant HFC134a (R134a) that can be used in the liquid,
% vapor, saturated liquid/vapor, and supercritical regions of the phase
% diagram. Implements the equation of state given in:
%
% R. Tillner-Roth and H. D. Baehr. "An International Standard Formulation for
% The Thermodynamic Properties of 1,1,1,2-Tetrafluoroethane (HFC-134a) for
% Temperatures From 170 K to 455 K and Pressures up to 70 MPa". J. Phys.
% Chem. Ref. Data, Vol. 23, No. 5, 1994. pp. 657--729.
% http://dx.doi.org/10.1063/1.555958
%
% For more details, see classes Cantera::PureFluid and tpx::HFC134a in the
% Cantera C++ source code documentation.
%
% :return:
% Instance of class :mat:class:`Solution`.

h = Solution('liquidvapor.yaml', 'HFC-134a');
end
22 changes: 22 additions & 0 deletions interfaces/matlab_experimental/Base/Heptane.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function h = Heptane
% Return an object representing n-heptane. ::
%
% >> h = Heptane()
%
% The object returned by this method implements an accurate equation of
% state for n-heptane that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from
%
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
% computational equations for forty substances.* Stanford: Stanford
% University, 1979. Print.
%
% For more details, see classes Cantera::PureFluid and tpx::Heptane in the
% Cantera C++ source code documentation.
%
% :return:
% Instance of class :mat:class:`Solution`.

h = Solution('liquidvapor.yaml', 'heptane');
end
22 changes: 22 additions & 0 deletions interfaces/matlab_experimental/Base/Hydrogen.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function h = Hydrogen()
% Return an object representing hydrogen. ::
%
% >> h = Hydrogen()
%
% The object returned by this method implements an accurate equation of
% state for hydrogen that can be used in the liquid, vapor, saturated
% liquid/vapor, and supercritical regions of the phase diagram. The
% equation of state is taken from
%
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
% computational equations for forty substances* Stanford: Stanford
% University, 1979. Print.
%
% For more details, see classes Cantera::PureFluid and tpx::hydrogen in the
% Cantera C++ source code documentation.
%
% :return:
% Instance of class :mat:class:`Solution`.

h = Solution('liquidvapor.yaml', 'hydrogen');
end
170 changes: 170 additions & 0 deletions interfaces/matlab_experimental/Base/Interface.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
classdef Interface < handle & ThermoPhase & Kinetics
% Interface Class ::
%
% >> s = Interface(src, id, p1, p2, p3, p4)
%
% See `ideal-surface <https://cantera.org/documentation/docs-2.6/sphinx/html/yaml/phases.html#sec-yaml-ideal-surface>`__
% and `Declaring adjacent phases <https://cantera.org/tutorials/yaml/phases.html#declaring-adjacent-phases>`__.
%
% :param varargin:
% Variable number of inputs consisting of the following:
% - src: YAML file containing the interface or edge phase.
% - id: Name of the interface or edge phase in the YAML file.
% Optional:
% - p1: 1st adjacent phase to the interface.
% - p2: 2nd adjacent phase to the interface.
% - p3: 3rd adjacent phase to the interface.
% - p4: 4th adjacent phase to the interface.
% :return:
% Instance of class :mat:class:`Interface`.

properties (SetAccess = immutable)
phaseID % ID of the interface.
interfaceName % Name of the interface.
end

properties (SetAccess = public)

% Surface coverages of the species on an interface.
% Unit: kmol/m^2 for surface phases, kmol/m for edge phases.
siteDensity

end

properties (SetAccess = protected)
concentrations % Concentrations of the species on an interface.
nAdjacent % Number of adjacent phases.
end

methods
%% Interface Class Constructor

function s = Interface(varargin)
% Create an :mat:class:`Interface` object.

ctIsLoaded;

src = varargin{1};
name = varargin{2};
na = nargin - 2;

% Get ID of adjacent phases
adj = [];
for i = 3:nargin
adj(i-2) = varargin{i}.phaseID;
end

ID = ctFunc('soln_newInterface', src, name, na, adj);

% Inherit methods and properties from ThermoPhase and Kinetics
s@ThermoPhase('clib', ID);
s@Kinetics('clib', ID);
s.phaseID = ID;
s.interfaceName = name;
s.nAdjacent = ctFunc('soln_nAdjacent', ID);
end

%% Interface Class Destructor

function delete(s)
% Delete :mat:class:`Interface` object.
disp('Interface class object has been deleted');
end

%% Interface Get Methods

function phase = adjacent(s, n)
% Get the nth adjacent phase of an interface.
phase = ctFunc('soln_adjacent', s, n);
end

function c = coverages(s)
% Surface coverages of the species on an interface.

surfID = s.tpID;
nsp = s.nSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
ctFunc('surf_getCoverages', surfID, pt);
c = pt.Value;
end

function d = get.siteDensity(s)
surfID = s.tpID;
d = ctFunc('surf_siteDensity', surfID);
end

function c = get.concentrations(s)
surfID = s.tr_id;
nsp = s.nSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
ctFunc('surf_getConcentrations', surfID, xx);
c = pt.Value;
end

function setCoverages(s, cov, norm)
% Set surface coverages of the species on an interface.
%
% s.setCoverages(cov, norm)
%
% :param s:
% Instance of class :mat:class:`Interface`
% :param cov:
% Coverage of the species. ``cov`` can be either a vector of
% length ``n_surf_species``, or a string in the format
% ``'Species:Coverage, Species:Coverage'``
% :param norm:
% Optional flag that denotes whether or not to normalize the species
% coverages. ``norm`` is either of the two strings ``'nonorm'``` or
% ``'norm'``. If left unset, the default is `norm`. This only works if
% ``s`` is a vector, not a string. Since unnormalized coverages can lead to
% unphysical results, ``'nonorm'`` should be used only in rare cases, such
% as computing partial derivatives with respect to a species coverage.

if nargin == 3 && strcmp(norm, 'nonorm')
norm_flag = 0;
else
norm_flag = 1;
end

surfID = s.tpID;
nsp = s.nSpecies;
[m, n] = size(cov);

if isa(cov, 'double')
sz = length(cov);

if sz ~= nsp
error('wrong size for coverage array');
end

if ((m == nsp && n == 1) || (m == 1 & n == nsp))
ctFunc('surf_setCoverages', surfID, cov, norm_flag);
else error('wrong size for coverage array');
end

elseif isa(cov, 'char')
ctFunc('surf_setCoveragesByName', surfID, cov);
end

end

function set.siteDensity(s, d)
% Set the site density of a phase on an interface.
%
% s.siteDensity = d
%
% :param s:
% Instance of class :mat:class:`Interface`
% :param d
% Double site density. Unit: kmol/m^2 for surface phases,
% kmol/m for edge phases.

surfID = s.tpID;
ctFunc('surf_setSiteDensity', surfID, d);
end

end

end
Loading