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

Parser error with <Space> + END in mechanism file #18

Closed kahilah closed 7 years ago

kahilah commented 7 years ago

Minor issue regarding the mechanism file reader: If there is a white space in front of "END"-marker of the "SPECIES" block in the chemkin mechanism file, pyjac reads END as a specie and prints out an error: "Error: missing thermo data for END"

Removing the white space removes the problem.

Not a pyjac bug as such but worth to consider adding a check for specie name not being "END".


As an example, consider the following mechanism (SK54.inp) from http://www.sciencedirect.com/science/article/pii/S001623611631184X

in more particular:

http://www.sciencedirect.com/science/MiamiMultiMediaURL/1-s2.0-S001623611631184X/1-s2.0-S001623611631184X-mmc1.zip/271496/html/S001623611631184X/623c3347955e91002d0a4fd53a1570fd/mmc1.zip

Best regards,

-Heikki

skyreflectedinmirrors commented 7 years ago

Hmm, I'm wary of diving into the "trying to fix badly formatted Chemkin files" game, since there are simply so many of them (and the Cantera converter does a much better job than we would).

@kyleniemeyer I think the best solution here would be to issue a warning for any species name that starts with whitespace?

kyleniemeyer commented 7 years ago

I think a simple fix would be to just strip leading & trailing whitespace from the lines before processing—actually I'm surprised we don't do this already...

This should be a "simple" fix, let me take a look.

kyleniemeyer commented 7 years ago

OK, so we do already strip leading & trailing whitespace, but right after the block of code where keywords are parsed.

I'm going to move that to happen immediately prior to parsing keywords, and that should fix the issue.

kyleniemeyer commented 7 years ago

Hi @kahilah, could you try with the newest version now? Either download the source, or install v1.0.5b0 via pip or conda.

kahilah commented 7 years ago

Hi,

Tested and works!

Cheers