In [1]:
# Imports of required packages
from rdftool import InterRDF
import MDAnalysis as mda
%matplotlib inline
import matplotlib.pyplot as plt
Firstly, let's load up a Universe and inspect what we have in our system. The test system here is a single frame of octanol.
In [2]:
u = mda.Universe('conf.gro')
print u
print len(u.trajectory)
print set(u.atoms.names())
print set(u.atoms.types())
In [3]:
oxygen = u.selectAtoms('name HO')
hydrogen = u.selectAtoms('name HO')
print len(oxygen)
print len(hydrogen)
Next we create an RDF making object, and pass it our two AtomGroup selections
In [4]:
rdf = InterRDF(oxygen, hydrogen, bins=50, range=(0.0, 12.0))
In [5]:
rdf.run()
In [6]:
plt.plot(rdf.bins, rdf.rdf)
Out[6]:
Oops, that didn't work. We've got a single huge peak at an incredibly small distance which obscures everything. This is caused by the OH and HO bonded pairs which are being included.
These can be excluded using the "exclusion_block" keyword.
In [7]:
rdf = InterRDF(oxygen, hydrogen, bins=50, range=(0.0, 12.0), exclusion_block=(1,1))
rdf.run()
In [8]:
plt.plot(rdf.bins, rdf.rdf)
Out[8]:
In [ ]:
In [ ]: