Skip to content

Experimental CLib zeroD API #1878

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

Merged
merged 13 commits into from
May 18, 2025
Merged

Experimental CLib zeroD API #1878

merged 13 commits into from
May 18, 2025

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Apr 25, 2025

Changes proposed in this pull request

With this PR, clib_experimental reaches parity with the traditional clib.

  • Add zeroD objects to experimental CLib
  • Further streamline C++ zeroD API:
    • Create ReactorNet with list of ReactorBase; deprecate incremental path via addReactor
    • Introduce several convenience methods for C++ API (newReservoir) and clarify future use of newReactor.
    • Avoid raw pointers in user-facing API methods.
  • Replace deprecated functions and methods in samples ... previously overlooked due to C++ samples not checked for use of deprecated methods #1603
  • Propagate all changes to Python interface

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

Addresses Cantera/enhancements#220

If applicable, provide an example illustrating new features this pull request is introducing

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 Apr 27, 2025

Codecov Report

Attention: Patch coverage is 67.92453% with 34 lines in your changes missing coverage. Please review.

Project coverage is 74.08%. Comparing base (0eb7f94) to head (93a0da1).
Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
src/zeroD/ReactorFactory.cpp 57.14% 4 Missing and 2 partials ⚠️
src/zeroD/ReactorBase.cpp 0.00% 5 Missing ⚠️
src/zeroD/ReactorNet.cpp 81.48% 2 Missing and 3 partials ⚠️
include/cantera/zeroD/FlowDevice.h 66.66% 4 Missing ⚠️
interfaces/cython/cantera/reactor.pyx 75.00% 4 Missing ⚠️
include/cantera/zeroD/Wall.h 57.14% 2 Missing and 1 partial ⚠️
src/clib/ct.cpp 71.42% 2 Missing ⚠️
src/zeroD/FlowDevice.cpp 0.00% 2 Missing ⚠️
src/zeroD/flowControllers.cpp 60.00% 1 Missing and 1 partial ⚠️
include/cantera/zeroD/flowControllers.h 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1878      +/-   ##
==========================================
- Coverage   74.33%   74.08%   -0.25%     
==========================================
  Files         443      443              
  Lines       55403    55488      +85     
  Branches     9108     9118      +10     
==========================================
- Hits        41183    41108      -75     
- Misses      11122    11285     +163     
+ Partials     3098     3095       -3     

☔ 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.

@ischoegl ischoegl marked this pull request as ready for review April 27, 2025 13:01
@ischoegl ischoegl requested a review from a team April 27, 2025 13:01
@ischoegl
Copy link
Member Author

@speth ... this is the last portion missing before the experimental CLib reaches parity with the traditional CLib API. Let me know if this needs further work.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Thanks, @ischoegl. This largely looks good to me. Just a handful of suggestions.

Comment on lines +1309 to +1319
def device_coefficient(self):
"""
Device coefficient (defined by derived class).

Example:

>>> v = Valve(res1, reactor1)
>>> v.device_coefficient = 1e-4 # Set the 'valve coefficient'

.. versionadded:: 3.2
"""
Copy link
Member

Choose a reason for hiding this comment

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

I understand the rationale for creating a generic interface for setting this coefficient in the CLib case, but I'm concerned that in the Python case, this is just creating a redundant interface that parallels the existing PressureController.pressure_coeff and MassFlowContoller.mass_flow_coeff properties.

Copy link
Member Author

@ischoegl ischoegl May 18, 2025

Choose a reason for hiding this comment

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

I implemented this as I was hoping to have mostly parallel implementations on all APIs. At the same time, I wasn't sure that I wanted to deprecate (in both C++ and Python). If you want me to make a decision, I'd be in favor of device_coefficient as it is a more efficient implementation.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with having both options in place for now, with the idea that we might eventually deprecate the device-specific implementation in favor of the generic approach.

@ischoegl ischoegl requested a review from speth May 18, 2025 04:34
@ischoegl
Copy link
Member Author

ischoegl commented May 18, 2025

@speth ... thanks for the review! I addressed all suggestions, with the exception of the last one, where I am conflicted on whether to deprecate the earlier coefficient getters/setters.

@speth speth merged commit 2ff5662 into Cantera:main May 18, 2025
49 of 51 checks passed
@ischoegl ischoegl deleted the sourcegen-zeroD branch May 18, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants