Auto-Mech / mechanalyzer

Tools construction, manipulation, visualization of chemical mechanisms
MIT License
3 stars 13 forks source link

new rxn name ordering => more robust pes/subpes/channel assignment #295

Open lpratalimaffei opened 3 weeks ago

lpratalimaffei commented 3 weeks ago

Every time we read a mechanism, we assign (from mechdriver by default, or when sorting for e.g., generating prompt reactions) a pes.subpes.chnl sorting. if the comments are written in the form "# pes.subpes.channel", then no resorting is made. In any case, the pes are ordered by formula https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L140 while the reactions within a pes and a subpes (i.e., the ubpes and channels) are only reordered by "reaction name" https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L198 this means that the value of the subpes and channels will depend on how the reaction is written (A+B=C, B+A=C will be ordered differently).

So what I would like to do is to try and make the subpes/channel sorting independent on how the reaction is written in the mechanism and order reactants and products according to this function, already used in the sorter for other purposes: https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L258 https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L16 where names of bimol reactions are arranged according to the formulas, and only then according to e.g., alphabetical order. so I would rewrite reaction strings and keys according to this classification. And I should also edit the criterion used within this function to make it consistent with the count_atoms used for the pes instead of the total atom counting that is currently done (https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L34)

Hopefully this would reduce the number of entries in the dataframe of the sorter, make it a bit simpler, and increase consistency/robustness. However, this would imply that the reaction lines might be re-written differently from what the user has in the input of mechanism.dat, which is instead debatable. One could probably use the "# pes.subpes.channel" also to avoid the resorting of reaction names. Or alternatively, I could implement consistent re-ordering for subpes/channel assignment but without changes to the reaction names so that they are consistent with the input by the user.

what do you think about this?

sjklipp commented 3 weeks ago

Luna,

      I am not immediately bothered by that idea. And as you say, we could add some flag to avoid the resorting.

      What I would not like to have happen is to have the forward/reverse direction of the reaction changed. For example, for good reason it is often preferable to write a reaction in the exothermic direction. Arbitrarily changing that would mess that up. But I don't think you are planning to do that anyways.

      Stephen


From: Luna Pratali Maffei @.> Sent: Tuesday, August 20, 2024 5:53 PM To: Auto-Mech/mechanalyzer @.> Cc: Klippenstein, Stephen J. @.>; Assign @.> Subject: [Auto-Mech/mechanalyzer] new rxn name ordering => more robust pes/subpes/channel assignment (Issue #295)

Every time we read a mechanism, we assign (from mechdriver by default, or when sorting for e. g. , generating prompt reactions) a pes. subpes. chnl sorting. if the comments are written in the form "# pes. subpes. channel", then no resorting is made.  ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd

Every time we read a mechanism, we assign (from mechdriver by default, or when sorting for e.g., generating prompt reactions) a pes.subpes.chnl sorting. if the comments are written in the form "# pes.subpes.channel", then no resorting is made. In any case, the pes are ordered by formula https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L140https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L140__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNnZ47OT0$ while the reactions within a pes and a subpes (i.e., the ubpes and channels) are only reordered by "reaction name" https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L198https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py*L198__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNo08smtn$ this means that the value of the subpes and channels will depend on how the reaction is written (A+B=C, B+A=C will be ordered differently).

So what I would like to do is to try and make the subpes/channel sorting independent on how the reaction is written in the mechanism and order reactants and products according to this function, already used in the sorter for other purposes: https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L258https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py*L258__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNkVey7eo$ https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L16https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L16__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNlAIn0Qh$ where names of bimol reactions are arranged according to the formulas, and only then according to e.g., alphabetical order. so I would rewrite reaction strings and keys according to this classification. And I should also edit the criterion used within this function to make it consistent with the count_atoms used for the pes instead of the total atom counting that is currently done (https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L34https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L34__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNnDi95Bi$)

Hopefully this would reduce the number of entries in the dataframe of the sorter, make it a bit simpler, and increase consistency/robustness. However, this would imply that the reaction lines might be re-written differently from what the user has in the input of mechanism.dat, which is instead debatable. One could probably use the "# pes.subpes.channel" also to avoid the resorting of reaction names. Or alternatively, I could implement consistent re-ordering for subpes/channel assignment but without changes to the reaction names so that they are consistent with the input by the user.

what do you think about this?

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/issues/295__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNgFNmgL4$, or unsubscribehttps://urldefense.us/v3/__https://github.com/notifications/unsubscribe-auth/AIJEZPUPPCDZ3STMYTVB6WTZSPCF5AVCNFSM6AAAAABM22OBGCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TMNRWHA3DOMY__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNuCUnKZn$. You are receiving this because you were assigned.Message ID: @.***>

lpratalimaffei commented 3 weeks ago

No I am not planning to reverse the direction of the reaction. Just so you know, I did introduce a change in the writing of the reaction since it was bothering me, which is to write A => B when I also find B => A in the mechanism. Our previous writer would write A = B and B = A so that chemkin or any other simulator would throw an error. The => is also used when a reaction has more than two products (excluding third bodies of course).

Luna

Da: sjklipp @.> Inviato: mercoledì 21 agosto 2024 01:56 A: Auto-Mech/mechanalyzer @.> Cc: Luna Pratali Maffei @.>; Author @.> Oggetto: Re: [Auto-Mech/mechanalyzer] new rxn name ordering => more robust pes/subpes/channel assignment (Issue #295)

Luna,

      I am not immediately bothered by that idea. And as you say, we could add some flag to avoid the resorting.

      What I would not like to have happen is to have the forward/reverse direction of the reaction changed. For example, for good reason it is often preferable to write a reaction in the exothermic direction. Arbitrarily changing that would mess that up. But I don't think you are planning to do that anyways.

      Stephen


From: Luna Pratali Maffei @.<mailto:@.>> Sent: Tuesday, August 20, 2024 5:53 PM To: Auto-Mech/mechanalyzer @.<mailto:@.>> Cc: Klippenstein, Stephen J. @.<mailto:@.>>; Assign @.<mailto:@.>> Subject: [Auto-Mech/mechanalyzer] new rxn name ordering => more robust pes/subpes/channel assignment (Issue #295)

Every time we read a mechanism, we assign (from mechdriver by default, or when sorting for e. g. , generating prompt reactions) a pes. subpes. chnl sorting. if the comments are written in the form "# pes. subpes. channel", then no resorting is made.  ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd

Every time we read a mechanism, we assign (from mechdriver by default, or when sorting for e.g., generating prompt reactions) a pes.subpes.chnl sorting. if the comments are written in the form "# pes.subpes.channel", then no resorting is made. In any case, the pes are ordered by formula https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L140https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L140__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNnZ47OT0$ while the reactions within a pes and a subpes (i.e., the ubpes and channels) are only reordered by "reaction name" https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L198https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py*L198__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNo08smtn$ this means that the value of the subpes and channels will depend on how the reaction is written (A+B=C, B+A=C will be ordered differently).

So what I would like to do is to try and make the subpes/channel sorting independent on how the reaction is written in the mechanism and order reactants and products according to this function, already used in the sorter for other purposes: https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py#L258https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/builder/sort_fct.py*L258__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNkVey7eo$ https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L16https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L16__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNlAIn0Qh$ where names of bimol reactions are arranged according to the formulas, and only then according to e.g., alphabetical order. so I would rewrite reaction strings and keys according to this classification. And I should also edit the criterion used within this function to make it consistent with the count_atoms used for the pes instead of the total atom counting that is currently done (https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py#L34https://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/blob/777991b8330d0e85bd544b9cec55b75949f6d192/mechanalyzer/parser/_util.py*L34__;Iw!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNnDi95Bi$)

Hopefully this would reduce the number of entries in the dataframe of the sorter, make it a bit simpler, and increase consistency/robustness. However, this would imply that the reaction lines might be re-written differently from what the user has in the input of mechanism.dat, which is instead debatable. One could probably use the "# pes.subpes.channel" also to avoid the resorting of reaction names. Or alternatively, I could implement consistent re-ordering for subpes/channel assignment but without changes to the reaction names so that they are consistent with the input by the user.

what do you think about this?

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https://github.com/Auto-Mech/mechanalyzer/issues/295__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNgFNmgL4$<https://urldefense.us/v3/__https:/github.com/Auto-Mech/mechanalyzer/issues/295__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNgFNmgL4$>, or unsubscribehttps://urldefense.us/v3/__https://github.com/notifications/unsubscribe-auth/AIJEZPUPPCDZ3STMYTVB6WTZSPCF5AVCNFSM6AAAAABM22OBGCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TMNRWHA3DOMY__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNuCUnKZn$<https://urldefense.us/v3/__https:/github.com/notifications/unsubscribe-auth/AIJEZPUPPCDZ3STMYTVB6WTZSPCF5AVCNFSM6AAAAABM22OBGCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TMNRWHA3DOMY__;!!G_uCfscf7eWS!ZD8Ivst6MrdI51jU089Oeqm36C-_5bPScy1bs1rYwR9be1EuEgjdIVIPs16c9XD4Q1nnSP-Cy5nYNuCUnKZn$>. You are receiving this because you were assigned.Message ID: @.<mailto:@.>>

— Reply to this email directly, view it on GitHubhttps://github.com/Auto-Mech/mechanalyzer/issues/295#issuecomment-2299951715, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOPNZNJVO2H3WHL3C4YT56LZSPJRDAVCNFSM6AAAAABM22OBGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJZHE2TCNZRGU. You are receiving this because you authored the thread.Message ID: @.**@.>>

avcopan commented 3 weeks ago

This sounds fine to me, @lpratalimaffei! And thank you for using the issues to make note of these things!