How to identify whether two atoms are in a same dihedral

Dear all,
I meet some problems when i am writing a code in compute style to characterize the number of H_bond in the system.For the system to be characterized has the fuctionanl group COOH, and it can form two H bond each , so it’s necessary to make out whether the formed two H bond are interacting with the same COOH group.
As i imagined,my code work like these,
For each COOH group stored with the dihedral_atom2,
get the local index of dihedral_atom1,2,3,4
search for the neighbor of dihedral_atom2 and using the H_bond forming criteria(needs coordinate of the H_bond forming atom) to judge whether H_bond forms
if forming two H_bonds ,then judge whether the formed two H_bond are interacting with the same COOH group.

It is able to get the local id of the atoms that form H_bond with this COOH group,but how to identify that they are in a same dihedral? Can someone help me to solve this ?
Sincerely thanks,
Xiaoneng Ran

Dear all,
I meet some problems when i am writing a code in compute style to characterize the number of H_bond in the system.For the system to be characterized has the fuctionanl group COOH, and it can form two H bond each , so it’s necessary to make out whether the formed two H bond are interacting with the same COOH group.
As i imagined,my code work like these,
For each COOH group stored with the dihedral_atom2,
get the local index of dihedral_atom1,2,3,4
search for the neighbor of dihedral_atom2 and using the H_bond forming criteria(needs coordinate of the H_bond forming atom) to judge whether H_bond forms
if forming two H_bonds ,then judge whether the formed two H_bond are interacting with the same COOH group.

It is able to get the local id of the atoms that form H_bond with this COOH group,but how to identify that they are in a same dihedral? Can someone help me to solve this ?

as a minimal requirement, you can check the molecule id. if it is different, those atoms belong to different molecules. this would only fail, if you have molecules that are long enough to have hydrogen bonds with itself. but then you could either change the molecule id assignment to make it apply to chemical groups, or use fix property/atom to assign a custom id for each structural element.

axel.