Forum Navigation
You need to log in to create posts and topics.

exclusion of 1-2, 1-3 or 1-4 interactions in the RDF computation

Hi Constanze, hi Alex,

I simulated a molecular system and was wondering if it is somehow possible to exclude the nearest bonded atoms from the RDF calculation.


I want to evaluate hydrogen bridges between amide groups of a polyamide, e.g. Rest-N(H)C(=O)-Rest. A partial RDF for H-O in the amide group could be helpful. But obviously I am interested in the RDF with other parts of the same molecule or other molecules and not the one inside the very same amide group. Therefore I would like to exclude all atoms that are contained in the dihedral (1-4) interactions. I hope my description is understandable. Is that somehow possible?

kind regards



Hi Wolfgang,

Thank your for providing us with example data and more detailed information. In hope that this will also help others, I will publish the possible solution to your inquiry here. Attached you'll find a python script modifier meant for the GUI, that generates 1) a histogram of the pair-wise distances between O and H atoms (types 'hc' and 'o_1' ) and (2) another histogram of the pair-wise distances of O and H atoms that are part of the same dihedral (1-4).

The results will be stored as an OVITO Data Table "O-H Pair Distribution" and will be displayed in the Data Inspector, see attached screenshot.
Please let us know what you think.


Uploaded files:
  • You need to login to have access to uploads.

Hi Constanze,

thanks for having a look into this. Basically I wanted to the exact opposite and exclude those 1-4 dihedrals. So basically I need to subtract one from the other. But your script showed me nicely how to scan through the dihedrals, that was my missing part. Thx.

I'll post my script as soon as I've finished it.



Exactly. Constanze forgot to mention it. The idea is to subtract the histogram containing only the 1-4 dihedrals from the complete histogram to obtain the filtered bond length distribution. Adding this subtraction step should be straightforward. Please tailor the script to your needs.

Hi Constanze, Hi Alex,

thank you very much for your support. I was already playing around during the weekend and rebuild the whole RDF and partial RDF in python as it was a good opportunity to learn some python 🙂

I came up with a little bit different solution which is probably much slower than Constance's solution. But on the other hand, I think it is a little bit more flexible. As already stated it mimics the Coordination and RDF functionality and is verified with Ovito's original implementation.

Before evaluating atoms i and j with respect to coordination or RDF a function "check" is called, where I check for the 1-4 interaction explained in the initial question. But this could also be easily exchanged for e.g. Molecule ID, Cluster ID or sth. else. So I thought I'd provide it here because maybe somebody else might have a similar task. I hope there is sufficient comments.

Things that have to be set/adjusted:

  • ~ lines 39 ff.:  "cutoff", number of bins  and "partial_rdf" (0/1) to state if the partial RDF should be evaluated or not
  • function check() (~ lines 8-35): to return True if the pair is to be evaluated, False otherwise.

Just a thought, maybe it would be an idea to have somewhere a corner in this forum where custom modifiers/scripts are collected? So that they don't get forgotten.



Uploaded files:
  • You need to login to have access to uploads.