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

FlowReactor with heterogeneous chemistry #1490

Merged
merged 47 commits into from
Jun 14, 2023
Merged

Conversation

speth
Copy link
Member

@speth speth commented May 12, 2023

This is a new attempt to integrate the work originally done in #575 and updated in #1319, which enables solving the DAE system that arises when modeling a plug flow reactor with surface chemistry.

Changes proposed in this pull request

  • Substantial rewrite of the DAE_Solver class (now IdasIntegrator)
  • Implementation of heterogeneous PFR equations in the FlowReactor class
  • New Python example based on the Jupyter notebook 1D_pfr_surfchem
  • Update surf_pfr.py to use the FlowReactor class instead of a chain of IdealGasReactors integrated to steady-state (the previous version is still available as surf_pfr_chain.py

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

See the two new examples referenced above.

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

@speth speth force-pushed the flowreactor_surf branch from eaf4d44 to ad27f6e Compare May 12, 2023 23:55
@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #1490 (a23efe5) into main (e2cdb1c) will increase coverage by 0.51%.
The diff coverage is 70.52%.

@@            Coverage Diff             @@
##             main    #1490      +/-   ##
==========================================
+ Coverage   69.77%   70.29%   +0.51%     
==========================================
  Files         377      376       -1     
  Lines       58011    58242     +231     
  Branches    20695    20797     +102     
==========================================
+ Hits        40479    40943     +464     
+ Misses      14577    14315     -262     
- Partials     2955     2984      +29     
Impacted Files Coverage Δ
include/cantera/kinetics/ImplicitSurfChem.h 100.00% <ø> (ø)
include/cantera/kinetics/InterfaceKinetics.h 87.50% <ø> (ø)
include/cantera/numerics/FuncEval.h 42.85% <0.00%> (-17.15%) ⬇️
include/cantera/numerics/IdasIntegrator.h 0.00% <0.00%> (ø)
include/cantera/numerics/Integrator.h 11.36% <0.00%> (-2.15%) ⬇️
include/cantera/zeroD/ReactorBase.h 54.76% <ø> (ø)
src/numerics/FuncEval.cpp 26.31% <30.43%> (+0.28%) ⬆️
src/numerics/Integrators.cpp 57.14% <33.33%> (ø)
include/cantera/zeroD/Reactor.h 61.76% <40.00%> (-9.07%) ⬇️
include/cantera/zeroD/ReactorNet.h 75.00% <50.00%> (-1.67%) ⬇️
... 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

@speth speth force-pushed the flowreactor_surf branch 3 times, most recently from 8fb5fe4 to c287969 Compare May 15, 2023 00:32
@speth speth force-pushed the flowreactor_surf branch 3 times, most recently from 6321064 to 76a05a4 Compare May 22, 2023 18:19
@speth speth force-pushed the flowreactor_surf branch 5 times, most recently from 5af9499 to 25db091 Compare May 30, 2023 13:52
@speth speth force-pushed the flowreactor_surf branch 5 times, most recently from d7b2a31 to b4aadc0 Compare June 10, 2023 12:51
@speth speth force-pushed the flowreactor_surf branch from b4aadc0 to 0c6f6b4 Compare June 11, 2023 21:47
@speth speth marked this pull request as ready for review June 11, 2023 23:07
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.

@speth ... thank you for tackling this PR, which concludes a major effort started some time ago. I mainly have a couple of minor comments, plus the concern that removing distance may be confusing for some.

0, *r.thermo['CH4', 'H2', 'CO'].X))

while sim.time < length:
dist = sim.time * 1e3
Copy link
Member

Choose a reason for hiding this comment

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

I know that distance is proportional to time, but it's still a little confusing to write it like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made some changes so that ReactorNet now has both time and distance properties, where the one that is not applicable (depending on the reactor types involved) raises an exception. I updated some of the documentation as well to reflect the fact that the integrator's independent variable could be either time or distance, but stopped short of creating alternative names for set_initial_time() and the max_time_step property.

}
double distance() const {
Copy link
Member

Choose a reason for hiding this comment

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

Would you reconsider the removal of distance? In some contexts (examples!), using time as a placeholder for distance is somewhat confusing, and also not universally applicable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I brought this back, but in a deprecated form -- I think the value of the independent variable should be accessed via the ReactorNet object, the same as for other Reactor types.

Comment on lines -458 to -459
property distance:
""" The distance of the fluid element from the inlet of the reactor."""
Copy link
Member

Choose a reason for hiding this comment

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

See other comment.

speth added 24 commits June 13, 2023 19:30
Some implementation issues are fixed here, but the sensitivities
currently do not match finite difference comparisons.
The kinetic data is only valid for a single temperature, so the example
should be at constant temperature to avoid being misleading.

Update plots to show deposition rates
The SurfPhase object needs to be reset to match the reactor surface's
input state before calculating the consistent initial conditions, in
case the SurfPhase state was altered between creating the ReactorSurface
and initializing the ReactorNet.
Rename DAE-specific 'getState' to 'getStateDae' to avoid ambiguity
when overriding.
Also implement getters for all new properties
@speth speth force-pushed the flowreactor_surf branch from 0c6f6b4 to a23efe5 Compare June 14, 2023 13:33
@speth speth requested a review from ischoegl June 14, 2023 16:40
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, @speth!

@ischoegl ischoegl merged commit cd8756e into Cantera:main Jun 14, 2023
@speth speth deleted the flowreactor_surf branch June 14, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

5 participants