AtChem / AtChem2

Atmospheric chemistry box-model for the MCM
MIT License
59 stars 22 forks source link

Strange issue with mech_converter.py #476

Closed mixtli-c closed 1 year ago

mixtli-c commented 1 year ago

Hello

I was trying to build atchem2 with a (mcm_3-3-1.fac) mechanism extracted from http://mcm.york.ac.uk

I got an error when using the build script build_atchem2.sh

While tracing the error, I realized it comes from the converter, so I isolated it at home on my windows pc.

It originates from the tokenise_and_process function, as it starts referencing to the q vector, it comes to a point when it suddenly halts with a KeyError (see picture).

It happens with the extracted mechanism from the MCM website when marking everything on the list.

I tried with a downloaded MCM v3.2 and there is no error, so I went to fish for differences in the format of the two files, but nothing suspicious is readily apparent.

Not sure what I am doing wrong, any assistance would be appreciated, or just fyi.

mech_converter mcm_3-3-1.txt mcm_3-2.txt

mixtli-c commented 1 year ago

On further inspection I found that the extracted MCM 3.3.1 file has some complex reactions at the section end of the form (e.g. line 1007):

KNO = KRO2NO*NO ;

where NO is not previously defined, hence the KeyError

These rates are only defined in the complex reactions section and not used elsewhere so I guess it is a problem with my extraction.

Thanks,

spco commented 1 year ago

Hi @mixtli-c . It looks like you've identified the issue yourself, and this seems to be a duplicate of the previously closed https://github.com/AtChem/AtChem2/issues/451 and https://github.com/AtChem/AtChem2/issues/470 . Please see the discussion there for an explanation and suggestion of how to fix the file.

Unfortunately, we don't control the published MCM standard, and so I hope they are able to correct this mistake in a future edition. I don't have a simple way to automatically detect and correct this line in the file that I could implement in half an hour (and not then have to maintain for a long time too!), otherwise I would try to do so.

Sorry for the confusion!

@rs028 any indication of whether a bugfixed version (3.3.2) can be expected to be released?

mixtli-c commented 1 year ago

Ah yes, I ended up removing those reactions. It is reassuring to read that doing so was a suggestion.

Thanks and all the best!

rs028 commented 1 year ago

Don't know about the timeline of updates to the MCM website.

In the meantime, I should probably add a note to the readme.md file so people can find the answer quickly.