SLACKHA / pyJac

Creates C and CUDA analytical Jacobians for chemical kinetics ODE systems
http://slackha.github.io/pyJac/
MIT License
52 stars 23 forks source link

Bug in SRI Falloff #16

Closed michael-a-hansen closed 7 years ago

michael-a-hansen commented 7 years ago

When I compare dydt from cantera and pyJac for a mechanism including an SRI falloff reaction, I get huge differences. This shows up immediately in a time integration problem.

The mechanism of interest is Zabetta et al. for methanol (see paper and mechanism below). It only has a single SRI reaction but that causes major problems.

Coda Zabetta, Hupa_2008.pdf methanol-zabetta.xml.zip

skyreflectedinmirrors commented 7 years ago

@michael-a-hansen I would guess that the issue here is that pyJac moves a user-specified species to the end of the model to use for explicit mass conservation.

If the user doesn't specify a last species explicitly it will in this case choose N2 (followed by He and Ar, IIRC).

We do some mapping of species dydt's in our functional tester to get around this problem, but there's an easier way, e.g.:

import cantera as ct 
gas = ct.Solution('methanol-zabetta.xml')
n2_ind = gas.species_index('N2')
specs = gas.species()[:]
gas2 = ct.Solution(thermo='IdealGas', kinetics='GasKinetics', species=specs[:n2_ind] + specs[n2_ind + 1:] + [specs[n2_ind]], reactions=gas.reactions())

I'll add it to the list of "things that need to be documented"

michael-a-hansen commented 7 years ago

I don't think that's it, because I specified the last species to match that in the input file. I saw some of the species mapping stuff and wanted to avoid any issues there, so I compiled pyJac with HE as the last species, matching the input file. I talked with @kyleniemeyer about SRI last Spring, I remember it being an issue or not implemented yet or something like that.

kyleniemeyer commented 7 years ago

We certainly support SRI, and in fact made sure to include a kinetic model with SRI falloff reactions in the validation of our paper.

We did fix a bug related to SRI recently (#12), so it's possibly you found another one. Are you used the most recent version, or did you download from PyPI? We haven't pushed the latest version there yet...

michael-a-hansen commented 7 years ago

I pulled from GitHub yesterday

kyleniemeyer commented 7 years ago

OK, sounds like you identified a new bug!

skyreflectedinmirrors commented 7 years ago

The XML file you provided actually ends with AR as the last species.

I'm in the process of trying to recreate this, I'll report back soon with an update!

michael-a-hansen commented 7 years ago

Whoops, you are correct, it's AR. Don't know how I got HE in there. I regenerated my pyJac/pyWrap module and now it works as expected. Sorry for the false alarm!

skyreflectedinmirrors commented 7 years ago

Hah, no worries!

Thanks for pointing out the hole in our documentation / examples. Definitely appreciated!