AtChem / AtChem2

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

DILUTE Error with Latest Stoichiometry Update #515

Closed AlfredMayhew closed 10 months ago

AlfredMayhew commented 10 months ago

I have noticed that all AtChem2 models now fail if DILUTE is not set to NOTUSED, following the changes in #514 . This is because the added dilution reactions in the mechanism.reac file don't have defined stoichiometric coefficients. I have fixed this by adding a coefficient of 1.

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (27ede44) 52.05% compared to head (0840c46) 52.05%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #515 +/- ## ======================================= Coverage 52.05% 52.05% ======================================= Files 17 17 Lines 2096 2096 Branches 166 166 ======================================= Hits 1091 1091 Misses 933 933 Partials 72 72 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rs028 commented 10 months ago

One question, does the stoichiometric coeff need to be a real number or does this work even if the user set it to an integer?

PS: you should be able to merge this, after you accept the invite to be member (I think!)

AlfredMayhew commented 10 months ago

The accepted formats in the mechanism file should be either a integer or decimal number, with or without a space. i.e. all of the following should be accepted:

This is then read by python and converted to a float in the separate_stoichiometry function. This means it's always written out to mechanism.reac and mechanism.prod as a decimal (real?). I haven't actually tried manually editing these files to change the 1.0 to an integer of 1. I suspect that would cause a FORTRAN error because it would be the wrong type, but I'm not sure.

One thing that has come to mind that I will test is I'm not sure how the .kpp conversion script will handle this change either, so I'll try and test that at some point!

I can't seem to merge the request, so feel free to do that.

AlfredMayhew commented 10 months ago

Ok, looking at the kpp conversion script it seems like it treats the reaction lines as a 'rate section' and a 'reaction section' and just swaps them, without digging into what the individual species are. This means it should carry any stoichiometry through. I think the kpp test would have failed too if there was an issue, but I will double check when I have some time.