-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export mechanisms to KPP format #210
Conversation
The KPP export looks syntatically comparable to the old version, but it needs testing in a model. One thing that looks different is the old version appears to be combining 'identical' reactions (i.e. the same reactants and products) by summing rates. I can't see where in the codebase this is done and how valid it is, so I need to investigate.
A KPP export is implemented that syntatically looks valid compared with the previous website's version, although I have been unable to test it in a model yet. Users have also reported that additional modifications needed to be made the KPP to make it fully parseable. I'll need to identify what these modifications are and implement them in the web-app. |
The check for identical reactions now handles reactions ordered differently. |
Previously I was firstly traversing the sub-mechanism and extracting the species, and then finding the reactions these species were involved in. Now the traversal directly pulls out the reactions in 1 step.
Co-authored-by: UoY Faculty Dev NPA <csrv1059@york.ac.uk>
Co-authored-by: UoY Faculty Dev NPA <csrv1059@york.ac.uk>
Co-authored-by: UoY Faculty Dev NPA <csrv1059@york.ac.uk>
Co-authored-by: UoY Faculty Dev NPA <csrv1059@york.ac.uk>
Co-authored-by: UoY Faculty Dev NPA <csrv1059@york.ac.uk>
Hi @RolfSander and @yantosca, this PR adds a KPP export to the new MCM website.
a: Examples below, are there any other reactions like this?
b: Bob asked "should these be added to the #DEFVAR section (esp. O2 and H2O), because KPP won't parse it otherwise?"
c: Done d: Done e: f: How should g: I can remove this, although I can see that KPP 3 only came out a year ago so I imagine there are still users of KPP 2 who would welcome having backwards compatibility here. Are there are any other differences from KPP 2 to 3 that would affect these mechanism files? |
Hello @stulacy, it's great to see that you are working on the KPP output I have embedded my comments in the text below. Could you provide an example of a KPP file exported from the new MCM
When the products of a reaction are not known or not important, the https://kpp.readthedocs.io/en/stable/using_kpp/04_input_for_kpp.html#equations Equations 2 and 19 will then look like this:
Currently, I don't see any other reactions without products.
Yes, this should probably be added.
Yes, these can probably be removed.
Great, thanks.
Yes, this applies to all rate constants which depend on the
You can add "hv" as a pseudo-reactant, for example:
Good point, backwards compatibility is important. I need to discuss this
We provide upgrading information on our web page here: https://kpp.readthedocs.io/en/stable/getting_started/00_revision_history.html#kpp-3-0-0 AFAICS, the other items listed there do not affect the MCM-generated |
Hello, I have 3 more ideas on my wish list. Nothing essential, but h) MCM provides equation numbers as pure comments, e.g.,
For details, see: https://kpp.readthedocs.io/en/stable/using_kpp/05_output_from_kpp.html#root-monitor https://kpp.readthedocs.io/en/stable/using_kpp/04_input_for_kpp.html#eqntags i) To indicate double precision, Fortran numbers can be expressed with
j) I'm not a 100% sure about this but I think that you can lose |
Great, I've gone with PROD for simplicity's sake.
I've made this change. The regex is a bit hairy but from inspection of the output mechanism I think I've caught all the edge cases, let me know if there's something I've missed.
Ah yes I'll look into adding this.
The primary software that we target with the facsimile files is AtChem2, which comes with the MCM photolysis rates hardcoded. Thanks for all your comments, here's the current isoprene KPP |
Hi @stulacy and @RolfSander. I am traveling so I may be slow to look over the PR. One note, using E exponents will force REAL4 precision. Better to use e.g. 250.0_dp, where dp is the KPP double precision kind parameter. |
Thanks! Unfortunately, in contrast to what I've written before, we probably
Yes, it's not that easy to find a regexp for this. Reverting unwanted I've checked your latest isoprene file and everything looks good. Thanks!
It should be sufficient if
It is then the responsibility of the end user to fill the I've used the hardcoded number Although there are still a couple of open qustions, I think that the KPP I think the big challenge is that the code works for everyone. Bob and I |
I've added the H2O declaration. Is there anything else outstanding apart from the photolysis rates before it can be released do you think? |
Thanks!
Yes, one more thing. While we are still looking for the ultimate
This static list of variables is hopefully okay for now. In the long |
I've added the complex rate and photolysis declarations, and I've also added the photolysis rates so users will just need to input a zenith angle. |
Thanks for implementing the complex and photolysis rate constants!
|
Hi Rolf, I've made those changes. Latest isoprene mechanism here Rather than having unused indices in the photolysis array, I've mapped the J rates onto their index but left a comment with a reference to its original J value in the MCM. I.e. for J=56, this now maps onto the 31st index: And when it's referenced in a reaction it's correctly pointing to the remapped J. Does this look good to you? I've also reverted the Let me know if you're happy for me to release this on Monday. |
Hello Stuart, Great, thanks! The current version looks fine, I think it's ready to be
Thanks, the mapping is a good idea, it will avoid wasting memory in The comments with the references to the original MCM indices are also A question about future versions of the MCM: Do you think the developers
Thanks!
Good point! Yes, that's also something where we have to find a more |
I imagine that new photolyses will be added to the end, rather than risk breaking backwards compatibility by overwriting old rates (I'm not sure of the reason why there are gaps). |
I'm about to make the KPP export functionality live, we'll continue discussion of the outstanding issues in #177 |
This is a much requested feature that is currently under development (#177 )
Initially it will aim to reproduce the functionality as it was on the old site, before improving it based on user feedback.