[MATLAB] Migrate to generated Clib#1997
Conversation
|
Hi @ischoegl , I've started migrating the MATLAB interface to the generated Clib. It won't work with the generated Clib as-is due to the following two points:
On my local machine, I got around this issue by adding
MATLAB’s clibgen treats % as a comment character in MATLAB syntax. During parsing, the line is truncated at %, producing an unterminated string in the generated definectMatlab.m file and causing:
Affected functions: On my local machine, I got around this issue by removing the |
|
@ssun30 ... I pushed some fixes. I can compile things without needing to edit on my machine, and the toolbox loads, but the unit tests fail. Please ensure that you reset your local branch to this one to preserve my edits. |
2952e2c to
c4ea8aa
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1997 +/- ##
==========================================
+ Coverage 75.52% 76.47% +0.95%
==========================================
Files 455 464 +9
Lines 56938 54936 -2002
Branches 9363 9305 -58
==========================================
- Hits 43001 42012 -989
+ Misses 10764 9798 -966
+ Partials 3173 3126 -47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c4ea8aa to
0802ddd
Compare
Hi @ischoegl , I've fixed most of the issues with the unit tests. But five tests remain and I'll list each of them: sample I didn't find the new equivalent function to |
|
The next sample is The function signature for |
|
sample I didn't find the equivalent methods for |
|
The final errors are under In the legacy clib, the Now the corresponding methods in the generated clib lack those checks, and thus no error message was returned. |
0802ddd to
63b6408
Compare
|
@ssun30 ... thank you - I'll look into the issue you pointed out shortly. We just merged #1995, which changes some of the 1D access routes (good news: things should become somewhat easier). Could you rebase? I'll try to push some fixes to the issues you pointed out thereafter. PS: I outlined some of my thoughts on the 'onedim' portion in Cantera/enhancements#239. Only a small fraction is applicable to this PR. |
6719908 to
edb50bd
Compare
This was hard-coded in the legacy CLib, and won't be replicated as such in the generated CLib. You have two options:
|
Point-wise access should be replaced by |
The underlying C++ methods return The quick fix is to follow the Python approach, although an argument could be made to move this to C++ (which is significantly more difficult, as this changes long-standing behavior with potentially breaking changes). The best approach to implementing a change in C++ would be to create an enhancement request, as it exceeds the scope of the MATLAB toolbox. Edit: see #2004. PS: #2010 |
Yes - while there was a setter/getter, it was shadowed by |
|
@ssun30 ... I will have a look at the 1D components as there have been significant changes. I will try to make this as close to Cantera/enhancements#239 and the corresponding Python framework as possible so this is futureproof. |
2f38384 to
cc50e2c
Compare
|
@ssun30 ... I added a new The Overall, there were some issues with MATLAB functions calling incorrect CLib signatures. I created convenience access points as necessary. There are two observations:
|
cc50e2c to
cf6cf9e
Compare
27373f8 to
0569bdf
Compare
|
@ssun30 and @speth ... I ended up simplifying The main difference is that this requires a
|
0569bdf to
c066670
Compare
I think being able to test (both the test suite and interactively) without running |
258728c to
f8c0e3a
Compare
Fair point. Thankfully, the dependency on ctToolboxDir = '/path/to/cantera/source/interfaces/matlab_experimental';
ctIncludeDir = '/path/to/cantera/include';
ctLibDir = '/path/to/cantera/library';
ctBuildInterface(ctToolboxDir, ctIncludeDir, ctLibDir);I'll leave this for a final review now. There are many rough edges, but the migration to the generated CLib is accomplished (thank you @ssun30!). Additional improvements can be made in follow-up PRs. |
973c192 to
f680a53
Compare
Ensure enableEnergy / enableChemistry / massFlowRate are consistent with C++ API.
f680a53 to
5912be6
Compare
Changes proposed in this pull request
This PR updates the experimental MATLAB interface to use the auto-generated Cantera Clib (produced via
sourcegen), replacing the previously manually written Clib.Specifically, this PR:
ctEditLibraryDefinitionsthat was only required for the manually written Clib.Closes #1722
Checklist
scons build&scons test) and unit tests address code coverage