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

Make 1D flow domains agnostic of transport model #1514

Merged
merged 8 commits into from
Jun 27, 2023

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Jun 24, 2023

Changes proposed in this pull request

Switch between StFlow and IonFlow in C++ factory constructors. This allows for the following:

  • Absorb IonFlow behavior in conventional FreeFlow/UnstrainedFlow/AxisymmetricFlow
  • Absorb IonFreeFlame in FreeFlame
  • Absorb IonBurnerFlame in BurnerFlame
  • Deprecate all "ion" specializations in the user-facing API

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

Closes Cantera/enhancements#165

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

# Instantiate Solution with 'ionized-gas' transport model
gas = ct.Solution('gri30_ion.yaml')
gas.TPX = Tin, p, reactants

# Set up flame object - automatically sets up correct flow domain model
f = ct.FreeFlame(gas, width=width)

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 Jun 24, 2023

Codecov Report

Merging #1514 (fa2895f) into main (d717e8b) will decrease coverage by 0.05%.
The diff coverage is 44.70%.

❗ Current head fa2895f differs from pull request most recent head 2a9bb1e. Consider uploading reports for the commit 2a9bb1e to get more accurate results

@@            Coverage Diff             @@
##             main    #1514      +/-   ##
==========================================
- Coverage   70.46%   70.42%   -0.05%     
==========================================
  Files         375      375              
  Lines       58405    58437      +32     
  Branches    20899    20917      +18     
==========================================
- Hits        41158    41152       -6     
- Misses      14227    14262      +35     
- Partials     3020     3023       +3     
Impacted Files Coverage Δ
include/cantera/oneD/IonFlow.h 73.33% <0.00%> (-11.29%) ⬇️
include/cantera/oneD/StFlow.h 100.00% <ø> (ø)
src/oneD/IonFlow.cpp 46.89% <0.00%> (-2.26%) ⬇️
src/oneD/StFlow.cpp 82.18% <6.25%> (-1.98%) ⬇️
src/oneD/DomainFactory.cpp 81.63% <55.55%> (-9.07%) ⬇️
interfaces/cython/cantera/_onedim.pyx 81.18% <57.69%> (-0.77%) ⬇️
interfaces/cython/cantera/onedim.py 82.92% <60.71%> (-0.66%) ⬇️

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

@ischoegl ischoegl marked this pull request as ready for review June 24, 2023 19:12
@ischoegl ischoegl requested a review from a team June 24, 2023 19:12
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 makes sense and simplifies flame instantiation a bit. I had just a few suggested changes.

interfaces/cython/cantera/_onedim.pxd Outdated Show resolved Hide resolved
Comment on lines +49 to +53
if (solution->transport()->transportModel() == "ionized-gas") {
ret = new IonFlow(solution, id);
} else {
ret = new StFlow(solution, id);
}
Copy link
Member

Choose a reason for hiding this comment

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

This reliance on the specific model name is a little fragile/limiting, in that it doesn't provide a way for any other transport model to be used with IonFlow. I believe the only requirement the IonFlow class puts on the transport model is that it must implement the getMobilities method. Perhaps we can do something like adding a boolean providesGetMobilities() method to Transport that can be reimplemented by any relevant transport model.

Copy link
Member Author

Choose a reason for hiding this comment

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

Valid comment. However, MixTransport defines the function also, which complicates this a bit. As long as "ionized-gas" is the only model that implements this, I believe it's safe as long as it's tested. I added two specific tests for all flame types to test_oneD.cpp, which will fail if any of this is touched.

include/cantera/oneD/StFlow.h Outdated Show resolved Hide resolved
@ischoegl
Copy link
Member Author

ischoegl commented Jun 26, 2023

@speth ... thanks for catching the translate_exception - these are nasty crashes.

Regarding your point about the brittle implementation of the IonFlow factory constructor switch, I added a googletest that should be adequate until the point when someone adds a new transport model that is suitable for 1D simulations.

@ischoegl ischoegl requested a review from speth June 27, 2023 17:02
@speth speth merged commit 36faa94 into Cantera:main Jun 27, 2023
@ischoegl ischoegl deleted the agnostic-StFlow branch June 27, 2023 22:52
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.

Make 1D flow domains agnostic of thermo/transport model
2 participants