Computational cost of reaction rates

43 views
Skip to first unread message

Dave Holland

unread,
Jul 5, 2024, 9:58:52 AMJul 5
to Cantera Users' Group
Hi all,

My company currently use cantera within our CFD tool to perform finite rate chemistry calculations. I have recently been performing some profiling of the code to try and make it more efficient. From this I have found that the call to exp() in the reaction rates calculation dwarfs the cost of everything else (>10x the next most expensive function). As far as I see it there are two ways to try and improve this:

1. Reduce the number of calls to calculate the reaction rates. Currently, the jacobian is calculated numerically via the ODE solver. From what I can tell some pull requests have been merged which allow analytical jacobians to be calculated (https://github.com/Cantera/enhancements/issues/19) are there any examples showing how to use these? I have also looked at the new Adaptive Preconditioner but so far this has not improved the efficiency of my code, is there any advice on how to choose the tolerances for this to try and improve its performance? Are there any other ways to reduce the number of calls to the reaction rates calculations?

2. Make the exp() calculation more efficient. In A. Walker's paper on preconditioning he references a paper on approximations to exponential  and logarithm functions. Has there been any considerations to implementing these? https://www.sciencedirect.com/science/article/abs/pii/S0010218018301652

Thanks,
Dave

Ray Speth

unread,
Jul 7, 2024, 5:25:33 PMJul 7
to Cantera Users' Group
Hi Dave,

What size is your reaction mechanism? I would guess if you're already seeing that the rate calculations are taking up most of the time and the preconditioned solver isn't improving things much, then this is a fairy small mechanism.

There is currently no way to use the analytical Jacobian with CVODES, outside the preconditioned solver. That's probably something that would be worth looking into after the these Jacobians are complete -- they are currently missing some terms related to interactions between reactors, which is the subject of PR #1634.

I think implementing approximations for the reaction rate functions would be a useful performance enhancement. A while back, I had implemented a version using linear interpolation in Ember and gotten pretty substantial speedups. And improving these calculations only becomes more effective as we reduce the linear algebra overhead by using the preconditioned solver. Other aspects to this are making sure that these calculations are vectorized where possible and eliminating redundant/unnecessary rate calculations. I had started experimenting with some of these ideas in PR #1217, but that's now somewhat out of date.

Regards,
Ray

Dave Holland

unread,
Jul 8, 2024, 10:40:01 AMJul 8
to Cantera Users' Group
Hi Ray,

I am currently testing an a reduced mechanism for ethanol with 33 species and 60 reactions, so yes, quite small. I guess it would be interesting to see the speedup from using the full reaction mechanism.

Thanks, I will look out for PR #1634 being merged and test with that.

That is very interesting that you were able to achieve substantial speedups. Do you plan on incorporating these into cantera then? Do you plan on completing PR #1217?

Thanks,
Dave

Ray Speth

unread,
Jul 8, 2024, 11:35:18 AMJul 8
to Cantera Users' Group
Hi Dave,

My current focus is on finalizing changes for the release of Cantera 3.1, which should be coming later this summer. PR #1217 isn't on my radar for this release. If there's someone in the Cantera user community interested in pursuing some of these optimizations, I'd be more than happy to advise and collaborate on the implementation. Beyond that, I haven't entirely decided on my priorities for the following Cantera release.

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages