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

Remove vestigial onedim Python functions and methods #1464

Merged
merged 20 commits into from
Apr 9, 2023

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Mar 25, 2023

Changes proposed in this pull request

After moving SolutionArray support to C++ in #1426 and updating HDF support in #1385, remaining Python versions are replaced, vestigial functions are deprecated, and code is removed where appropriate. Some minor glitches are fixed.

  • Make Sim1D data vector accessible to Domain1D
  • Implement SolutionArray::normalize to normalize mass/mole fractions
  • Implement ThermoPhase::nativeMode to produce acronym describing storage mode
  • Fix minor bugs in new C++ SolutionArray interface
  • Rename some Python / C++ methods for consistency across interfaces
  • Use C++ SolutionArray methods for the interface between Python Sim1D and SolutionArray
  • Retain ability to restore legacy HDF using h5py for Cantera 3.0, but deprecate all associated methods
  • Remove OrderedDict, which is no longer necessary
  • Convert Python FutureWarnings to DeprecationWarnings
  • Replace some hardcoded indices
  • Deprecate h5py support

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

Resolves Cantera/enhancements#166

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

@codecov
Copy link

codecov bot commented Mar 25, 2023

Codecov Report

Merging #1464 (572ea0e) into main (8b5a0e9) will increase coverage by 0.02%.
The diff coverage is 73.36%.

❗ Current head 572ea0e differs from pull request most recent head a412b61. Consider uploading reports for the commit a412b61 to get more accurate results

@@            Coverage Diff             @@
##             main    #1464      +/-   ##
==========================================
+ Coverage   69.86%   69.89%   +0.02%     
==========================================
  Files         377      377              
  Lines       57298    57350      +52     
  Branches    19164    19203      +39     
==========================================
+ Hits        40033    40085      +52     
- Misses      14712    14715       +3     
+ Partials     2553     2550       -3     
Impacted Files Coverage Δ
include/cantera/base/SolutionArray.h 94.44% <ø> (ø)
include/cantera/oneD/OneDim.h 53.62% <ø> (ø)
include/cantera/oneD/StFlow.h 100.00% <ø> (ø)
include/cantera/thermo/Phase.h 78.57% <ø> (ø)
interfaces/cython/cantera/solutionbase.pyx 89.63% <0.00%> (ø)
interfaces/cython/cantera/thermo.pyx 92.23% <0.00%> (-0.13%) ⬇️
src/oneD/Boundary1D.cpp 55.39% <40.00%> (ø)
include/cantera/oneD/Sim1D.h 66.66% <50.00%> (ø)
src/base/SolutionArray.cpp 76.16% <55.55%> (-0.60%) ⬇️
include/cantera/oneD/Domain1D.h 79.69% <60.00%> (+0.46%) ⬆️
... and 10 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Prevent automatic alphabetic ordering of states in
SolutionArray::componentNames
@ischoegl ischoegl force-pushed the use-shared-onedim-data branch 2 times, most recently from f651e49 to 1a931a6 Compare March 25, 2023 23:25
@ischoegl ischoegl marked this pull request as ready for review March 25, 2023 23:40
@ischoegl ischoegl requested a review from a team March 25, 2023 23:53
@ischoegl
Copy link
Member Author

@speth ... while #1462 is mostly about cosmetics, this PR addresses some hanging chads left after #1385 and #1426. Changes are ready for a review.

@ischoegl ischoegl force-pushed the use-shared-onedim-data branch 3 times, most recently from 1d040f4 to 572ea0e Compare March 26, 2023 13:31
@ischoegl
Copy link
Member Author

ischoegl commented Mar 26, 2023

I added commits that replace hardcoded indices in StFlow. With these changes, tests show that changing the storage order now works for axisymmetric cases, but not for free flames. As locating the remaining hard-coded bits (presumably someplace around the fixed point) is beyond the scope of this PR, I am stopping here.

While the h5py deprecation warning needs improvement (there is a replacement!), I don’t want to add another force-push 😜 .

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, I think this is generally fine. I just had some minor suggestions/comments.

Comment on lines 575 to 576
shared_ptr<vector<double>> m_data; //!< data pointer shared from OneDim

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to find a more descriptive name for this array than just "data" (and likewise the setData method). Perhaps m_state, given that it's replacing m_x at the Sim1D level?

Also, we normally use the vector_fp typedef instead of writing vector<double>. This shows up several times in this PR. Unless you're suggesting preferring this name more broadly?

Copy link
Member Author

@ischoegl ischoegl Apr 8, 2023

Choose a reason for hiding this comment

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

I renamed m_data to m_state as suggested.

Regarding vector_fp vs vector<double>, I do indeed have a preference for the latter, as it is self-documenting while the former is somewhat hidden in ct_defs.h. I believe the extra 5 characters are worthwhile, especially now that we no longer require std::.

include/cantera/thermo/Phase.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/_onedim.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/_onedim.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/_onedim.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/onedim.py Outdated Show resolved Hide resolved
src/oneD/Domain1D.cpp Outdated Show resolved Hide resolved
test/general/test_composite.cpp Outdated Show resolved Hide resolved
test/python/test_composite.py Outdated Show resolved Hide resolved
@ischoegl
Copy link
Member Author

ischoegl commented Apr 8, 2023

@speth ... thanks for the review! I believe I addressed most of the comments, with a remaining comment about vector_fp.

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.

Looks good to me!

@speth speth merged commit f493f5b into Cantera:main Apr 9, 2023
@ischoegl ischoegl deleted the use-shared-onedim-data branch April 9, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Link FlameBase.to_solution_array to C++ SolutionArray
2 participants