-
Notifications
You must be signed in to change notification settings - Fork 5
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
Re-implement the Matlab interface #32
Comments
As a friendly amendment, I am providing more detail to “import/call the Python interface” (copied verbatim from #7)
|
Thanks for the links Ingmar and for copying them here! |
I would strongly recommend the approach laid out in #39, which would help keep all of the language interfaces feature-complete. |
While the initial advocacy for using Calling the Python package is an interesting idea, but I am concerned about the difficulty for users of configuring this all the parts correctly. You can see how often this occurs by searching the Users' Group for |
As a very brief summary of how MATLAB could use Cantera's Python interface, I am attaching the following code snippet: % MATLAB is started from within a conda environment
% with Cantera installed
% load Cantera's Python module
ct = py.importlib.import_module("cantera");
% create solution object
gas = ct.Solution('gri30.cti');
% obtain number of species - returns Python int
gas.n_species
% number of species in default MATLAB numeric format
double(gas.n_species)
% mole fractions - returns Python ndarray
gas.X
% mole fractions in native MATLAB (one of several ways)
double(py.array.array('d', py.numpy.nditer(gas.X))) I.e. the only difference are number formats, which should be relatively straight-forward to handle. MATLAB can create class methods dynamically, so there may be a way to automatically generate all required wrappers (maybe based on Python PEP 484 |
@rwest … I believe this is now becoming work-in-progress? |
Yes, thanks for bringing this issue and discussion to my attention! Tagging @ssun30 who is undertaking this work. |
I've been experimenting with MATLAB's direct C++ integration recently. It should be a lot easier to maintain and faster to run than the current approach using a MEX interface. |
The current implementation has quite a few limitations; I believe that auto-generation as well as a modern class structure would be ideal. If you want to engage the community in your work, I’d recommend opening a discussion. |
Just linking this enhancement issue to discussion #102 (because I came here looking for what is in fact over there) |
Here's the first proof-of-concept toolbox for testing: |
Idea
We currently have a MATLAB interface to the C++ core library, based on the
mex
extension interface, but it is difficult to maintain. We would like to look at ways of replacing this interface. Options under consideration include using theloadlibrary
interface to more directly call Cantera's C wrapper functions, by using MATLAB to import/call the Python interface, or by using the direct C++ support in MATLAB (added in R2019a, https://www.mathworks.com/help/releases/R2019a/matlab/call-cpp-library-functions.html).In all of these cases, we would like to support some level of autogeneration of the interface to help maintainability.
Other tasks:
Difficulty
Hard
Required Knowledge
C/C++/Matlab or Matlab/Python, depending on which option is pursued
Mentors
@decaluwe
References
Related issues link at Cantera/cantera. Supersedes #7.
The text was updated successfully, but these errors were encountered: