Skip to content

Commit

Permalink
check equivalent reactions considering resonance structures
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoruiDong committed May 31, 2024
1 parent a8990e3 commit 99bef5b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rdmc/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,23 +575,31 @@ def is_same_products(
def is_equivalent(
self,
reaction: "Reaction",
resonance: bool = False,
both_directions: bool = False,
) -> bool:
"""
Check if the reaction is equivalent to the given reaction.
Args:
reaction (Reaction): The reaction to compare.
resonance (bool, optional): Whether to consider resonance structures. Defaults to ``False``.
both_directions (bool, optional): Whether to check both directions. Defaults to ``False``.
Returns:
bool: Whether the reaction is equivalent to the given reaction.
"""
equiv = is_equivalent_reaction(self, reaction)
if resonance:
cur_rxn = self.apply_resonance_correction(inplace=False)
qry_rxn = reaction.apply_resonance_correction(inplace=False)
else:
cur_rxn = self
qry_rxn = reaction
equiv = is_equivalent_reaction(cur_rxn, qry_rxn)

if both_directions and not equiv:
tmp_reaction = self.get_reverse_reaction()
equiv = is_equivalent_reaction(tmp_reaction, reaction)
rev_rxn = cur_rxn.get_reverse_reaction()
equiv = is_equivalent_reaction(rev_rxn, qry_rxn)

return equiv

Expand Down

0 comments on commit 99bef5b

Please sign in to comment.