Skip to content

Fix MATLAB interface samples #1911

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

ssun30
Copy link
Contributor

@ssun30 ssun30 commented Jun 18, 2025

There are numerous changes to class structures to the MATLAB interface that necessitate modifications to our current collection of MATLAB samples.

Changes proposed in this pull request

  • Fix crashes/solver errors in MATLAB samples.
  • Compare the results to their equivalent Python samples to make sure the solutions are correct.

If applicable, fill in the issue number this pull request is fixing

Closes #1722

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.28%. Comparing base (284a989) to head (4863f99).

Files with missing lines Patch % Lines
interfaces/matlab_experimental/Base/Interface.m 0.00% 1 Missing ⚠️
interfaces/matlab_experimental/Base/ThermoPhase.m 0.00% 1 Missing ⚠️
interfaces/matlab_experimental/OneDim/Sim1D.m 0.00% 1 Missing ⚠️
...faces/matlab_experimental/Reactor/ReactorSurface.m 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1911   +/-   ##
=======================================
  Coverage   74.28%   74.28%           
=======================================
  Files         448      448           
  Lines       55744    55743    -1     
  Branches     9190     9190           
=======================================
  Hits        41411    41411           
+ Misses      11232    11231    -1     
  Partials     3101     3101           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ssun30 ssun30 force-pushed the matlab_fix_samples branch from 9a6a562 to f8ebb67 Compare June 20, 2025 13:38
Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssun30 ... thanks for addressing!

Out of curiosity: for the Python API, all examples are tested as part of a CI job, see run-examples in .github/workflows/main.yml.

The relevant code is:

   - name: Run the examples
        # See https://unix.stackexchange.com/a/392973 for an explanation of the -exec part.
        run: |
          ln -s libcantera_shared.so build/lib/libcantera_shared.so.3
          export LD_LIBRARY_PATH=build/lib
          find samples/python -type f -iname "*.py" \
          -exec sh -c 'for n; do echo "$n" | tee -a results.txt && python3 "$n" >> results.txt || exit 1; done' sh {} +

I believe it's possible to do something similar here as it's possible to run MATLAB scripts from the command line:

matlab -r "try, run('rankine.m'), catch, exit(1), end, exit(0)"

where I had set matlab to

alias matlab="/Applications/MATLAB_R2023b.app/bin/matlab -nojvm -nodesktop"

on macOS (fwiw, I just ran a quick test so the options may not be the greatest selection)

@@ -58,14 +58,9 @@ function delete(s)

%% Sim1D Utility Methods

function display(s, fname)
function display(s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency with other APIs, the name of the method should be show, see https://cantera.org/stable/python/onedim.html#cantera.Sim1D.show.

@ssun30 ssun30 force-pushed the matlab_fix_samples branch 2 times, most recently from f6520e5 to 4863f99 Compare June 30, 2025 20:10
ssun30 and others added 6 commits June 30, 2025 16:10
Fixed a typo in Interface.concentrations
Changed refine criteria for Diff_flame
for axis for periodic_cstr.m sample
Modified several samples to include this change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken flame examples in experimental MATLAB toolbox
2 participants