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

Gas transport polynomial fits in Python #1077

Merged
merged 8 commits into from
Oct 1, 2021
Merged

Gas transport polynomial fits in Python #1077

merged 8 commits into from
Oct 1, 2021

Conversation

lavdwall
Copy link
Contributor

Some modifications that allow accessing and modifying the gas transport properties polynomial fits, also from the python interface.

This is an addition to the earlier pull request #817 and more specifically, a reply to the suggestion of @ischoegl to make the access functions to the transport polynomials also available in the python interface (see #817 (comment)).

Next to access to the polynomial fits, I also added the possibility to modify the polynomial coefficients. This in C++ as well as Python. Reason: there is literature that reports the polynomial fits to the transport properties explicitly (as function of log(T) or log(Tr)), rather than in terms of the classic L-J parameters. If this is important, the user now has the option to change the polynomial fits for some species or species pairs, after calculating them from the L-J parameters when first reading the *.cti or *.yaml input file. If the option to modify the polynomial fits is not OK for the public repo, I can remove those modification functions, and limit this pull request only to the access functions in the Python interface.

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

…operties polynomial fits. Also made those functions accessible from the python interface.
@codecov
Copy link

codecov bot commented Jul 25, 2021

Codecov Report

Merging #1077 (382f693) into main (1420a4c) will increase coverage by 0.38%.
The diff coverage is 84.77%.

❗ Current head 382f693 differs from pull request most recent head a9d8ba8. Consider uploading reports for the commit a9d8ba8 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1077      +/-   ##
==========================================
+ Coverage   73.07%   73.45%   +0.38%     
==========================================
  Files         358      364       +6     
  Lines       46956    47882     +926     
==========================================
+ Hits        34311    35170     +859     
- Misses      12645    12712      +67     
Impacted Files Coverage Δ
include/cantera/base/Units.h 100.00% <ø> (ø)
include/cantera/base/YamlWriter.h 100.00% <ø> (ø)
include/cantera/base/ctexceptions.h 73.68% <ø> (ø)
include/cantera/base/global.h 93.33% <ø> (ø)
include/cantera/kinetics/GasKinetics.h 100.00% <ø> (ø)
include/cantera/kinetics/InterfaceKinetics.h 100.00% <ø> (ø)
include/cantera/kinetics/KineticsFactory.h 100.00% <ø> (ø)
include/cantera/kinetics/Reaction.h 100.00% <ø> (ø)
include/cantera/thermo/MixtureFugacityTP.h 0.00% <ø> (ø)
include/cantera/thermo/RedlichKwongMFTP.h 100.00% <ø> (ø)
... and 64 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1420a4c...a9d8ba8. Read the comment docs.

@ischoegl
Copy link
Member

ischoegl commented Jul 26, 2021

@lavdwall ... thanks for posting! Personally, I believe that the ability to access & modify transport polynomials from Python is very useful.

Before I get into the details, would you mind adding some unit tests?

@lavdwall
Copy link
Contributor Author

lavdwall commented Aug 7, 2021

Hi @ischoegl ,

Sorry for the late reply (holidays...).

Thanks for your positive response. I will have a look at adding some unit tests in the coming week.
Until now, I just checked the implementation by a series of 'get' and 'set' commands, making sure the calculated transport properties remain the same after 'setting' the coefficients acquired from a previous 'get' command. Is that OK for a testing approach? If so, I will try to implement it like that in the cython test folder.

What I implemented in the current pull request is really just a get and set of the polynomial coefficients of viscosity, thermal conductivity, binary diffusion coefficients and collision integrals, just as they are available in the C++ core of the code. This is regardless of the transport model implementation that is used, so the user has to be aware of possible differences between CK_Mode = True or CK_Mode = False. And the user needs to be aware of possible discrepancies between the coefficients stored in memory and how those are documented in the doxygen documentation. The documentation is in agreement with textbooks (Kee, and others) but internally in the code the definitions are a bit different it seems.

Anyway, I will add test functions to show that set/get works. But maybe on the longer term, the code documentation should be adjusted a bit as well so that everyone can correctly use the access/modify functions without knowledge of the underlying code.

@ischoegl
Copy link
Member

ischoegl commented Aug 8, 2021

@lavdwall … yes, just checking whether coefficients are written correctly would be adequate. I’m not sure about the documentation; it may be worthwhile to raise an issue first so people with more intricate knowledge can chime in.

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.

Hi @lavdwall ... thank you for the PR! While I have quite a few suggestions, this looks mostly good to me. Most of my comments affect details of the implementation.

One caveat here is that I'm not as familiar with some of the changes that affect theory (it's somewhat out of my wheelhouse), but I'm sure that others can fill in those gaps.

include/cantera/cython/wrappers.h Outdated Show resolved Hide resolved
include/cantera/cython/wrappers.h Outdated Show resolved Hide resolved
include/cantera/cython/wrappers.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/_cantera.pxd Outdated Show resolved Hide resolved
interfaces/cython/cantera/_cantera.pxd Outdated Show resolved Hide resolved
include/cantera/cython/wrappers.h Outdated Show resolved Hide resolved
src/transport/GasTransport.cpp Outdated Show resolved Hide resolved
src/transport/MultiTransport.cpp Outdated Show resolved Hide resolved
interfaces/cython/cantera/transport.pyx Outdated Show resolved Hide resolved
include/cantera/transport/GasTransport.h Outdated Show resolved Hide resolved
@ischoegl
Copy link
Member

ischoegl commented Sep 3, 2021

Linking a recent request for this feature from the User Group.

@ischoegl
Copy link
Member

Hi @lavdwall ... just wanted to briefly check whether you had a chance to look over the review comments? Apart from the change to Transport, everything appears to be fairly close.

@lavdwall
Copy link
Contributor Author

Hi @ischoegl
Apologies for the delay. I believe most of your comments are addressed in the two commits I just pushed.

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.

Thanks for updating the PR, @lavdwall - things remaining from my side are mostly about formatting and should be easy to take care of.

include/cantera/transport/GasTransport.h Show resolved Hide resolved
include/cantera/transport/GasTransport.h Outdated Show resolved Hide resolved
include/cantera/transport/TransportBase.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/transport.pyx Outdated Show resolved Hide resolved
src/transport/GasTransport.cpp Outdated Show resolved Hide resolved
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.

@lavdwall ... thanks for taking care of the requests. Sorry for asking for one final edit: I hadn't noticed earlier that some of the lines exceed the 88 character limit we try to enforce (see CONTRIBUTING.md style guide). Beyond what I point out below, there's nothing else from my side.

include/cantera/transport/TransportBase.h Show resolved Hide resolved
include/cantera/transport/GasTransport.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/transport.pyx Outdated Show resolved Hide resolved
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.

@lavdwall ... thank you again for this PR and for taking care of the formatting right away. From my side, this looks ready to be merged. I will leave it open until later today, in case anyone else should have any requests.

@ischoegl ischoegl merged commit 77d50c6 into Cantera:main Oct 1, 2021
@Naikless
Copy link
Contributor

Naikless commented Dec 4, 2022

Just a quick follow up on this: is there any documentation on the theory behind the current polynomial implementation of the viscosity?

@ischoegl
Copy link
Member

ischoegl commented Dec 4, 2022

This PR (as well as the associated PR #817) are mostly just dealing with providing a better user interface. The code itself is documented in the C++ include files, which can be accessed by Cantera's doxygen documentation. Here is a link for GasTransport ... while it doesn't provide every detail in terms of theory, things should correspond to standard practice, see reference.

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.

3 participants