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

cti2yaml: fix issues with composition strings and kinetics model of "None" #1127

Merged
merged 4 commits into from
Nov 18, 2021

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Oct 22, 2021

Changes proposed in this pull request

  • Handle transport/kinetics models specified as None consistently
  • Allow for spaces in CTI composition definition (e.g. N2: 0.9 rather than N2:0.9)
  • Allow for specification of exact reaction id's

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

Closes #1009

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

see conversion of Mayur-ISSP.cti atttached to #1009. The result after applying this fix is Mayur-ISSP.yaml.txt

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

@ischoegl ischoegl added the Input Input parsing and conversion (for example, ck2yaml) label Oct 22, 2021
@ischoegl ischoegl requested review from a team and removed request for a team October 22, 2021 16:22
@ischoegl ischoegl marked this pull request as draft October 22, 2021 16:31
@ischoegl ischoegl marked this pull request as ready for review October 23, 2021 00:38
@ischoegl ischoegl requested a review from a team October 23, 2021 00:38
This change allows for composition specifications that include a whitespace after
a separating colon (example: "N2: 0.9, O2: 0.1" rather than "N2:0.9, O2:0.1")
@ischoegl
Copy link
Member Author

@speth / @bryanwweber ... I dropped the 'fix' for #1132 from here (per @speth's comment this will resolve itself).

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. The first two changes look fine to me.

I'm not sure about the change to "allow for specification of exact reaction id's", though. If I'm reading this correctly, it only supports the case where a single reaction id is given (which I don't think is frequently used), correct? As currently implemented, this has the side-effect of obscuring the warning that was in place to let users know that cti2yaml does not support the range notation that CTI used (which I think was also rarely used).

" files not supported ({}: {})".format(datasrc, rnum))
else:
_printerr("WARNING: Reaction specification"
" '{}' not supported".format(rnum))
Copy link
Member

Choose a reason for hiding this comment

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

Changing this set of allowed reaction specifications to be permissive means that certain cases that we know are not handled, like n005 to n008 are passed through without raising a warning, and the resulting error when importing the mechanism is not easy to diagnose as it no longer mentions the unsupported user input.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I'm reading this correctly, it only supports the case where a single reaction id is given

this is correct. I didn’t see a way around replacing the warnings as I had assumed that correct cti conversion was most important.

Could you be more specific about n005 to n008?

Copy link
Member Author

@ischoegl ischoegl Oct 29, 2021

Choose a reason for hiding this comment

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

Actually, there's always the option to still produce a warning while leaving the same in place. I added this as a separate commit, but can squash if necessary. As is, the conversion works, but produces a warning, i.e.

$ cti2yaml Mayur-ISSP.cti 
WARNING: Conversion of reaction specification 'rxn-SEI-comp' may not be supported

Edit: I ended up changing things, so this is obsolete

Copy link
Member

Choose a reason for hiding this comment

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

Take a look at some of the examples given here: https://cantera.org/tutorials/cti/phases.html#declaring-the-reactions

Admittedly, I've never seen this construct used in the wild, which is why I didn't worry about it for cti2yaml in the first place. But I've also the reaction selection used to pick just a single reaction, either.

Copy link
Member Author

@ischoegl ischoegl Oct 29, 2021

Choose a reason for hiding this comment

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

@speth ... thanks! I think it's possible to add the conversion of n005 to n008 if it ever comes up. As it stands, the single reaction already came up, so I'd suggest to update the warning message and leave the import in place.

Edit: I added a separate error for anything containing to, and tweaked the warning message.

PS: found a better way by catching exceptions at a later point

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #1127 (a37e3d0) into main (861377d) will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1127      +/-   ##
==========================================
+ Coverage   73.45%   73.49%   +0.04%     
==========================================
  Files         365      365              
  Lines       47912    48187     +275     
==========================================
+ Hits        35194    35417     +223     
- Misses      12718    12770      +52     
Impacted Files Coverage Δ
src/oneD/IonFlow.cpp 52.38% <0.00%> (-1.47%) ⬇️
src/oneD/Boundary1D.cpp 53.22% <0.00%> (-0.21%) ⬇️
include/cantera/base/AnyMap.h 100.00% <0.00%> (ø)
include/cantera/oneD/OneDim.h 52.45% <0.00%> (ø)
include/cantera/oneD/StFlow.h 99.04% <0.00%> (ø)
include/cantera/oneD/IonFlow.h 84.61% <0.00%> (ø)
include/cantera/oneD/Domain1D.h 85.57% <0.00%> (ø)
include/cantera/oneD/Boundary1D.h 50.00% <0.00%> (ø)
src/base/AnyMap.cpp 89.75% <0.00%> (+0.24%) ⬆️
src/oneD/StFlow.cpp 90.44% <0.00%> (+0.35%) ⬆️
... and 4 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 861377d...a37e3d0. Read the comment docs.

@ischoegl
Copy link
Member Author

ischoegl commented Oct 29, 2021

@speth ... thank you for the comment. I believe I found a good solution by raising exceptions when things get parsed at a later point. As an example, the unimplemented n005 to n008 input will produce the following warning:

$ cti2yaml test.cti 
WARNING: Unable to generate field 'test_not_implemented-reactions'
from reaction specification 'n005 to n008'

The specification of a single reaction works, and will not raise a confusing warning message (the test_not_implemented above points to the CTI phase definition that attempts to add those reactions).

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 looks good to me.

@speth speth merged commit 032de5e into Cantera:main Nov 18, 2021
@ischoegl ischoegl deleted the fix-1009 branch November 22, 2021 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Input parsing and conversion (for example, ck2yaml)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cti2yaml issues with composition strings and kinetics model of "None"
2 participants