try pytraj online:

http://mybinder.org/badge.svg

Radial distribution function of watersΒΆ

../_images/rdf_tz2_ortho.png
In [1]:
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
# load pytraj
import pytraj as pt
In [2]:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'  # high resolution
import matplotlib
from matplotlib import pyplot as plt
In [3]:
# load trajectory
traj = pt.load_sample_data('tz2')
traj
Out[3]:
pytraj.TrajectoryIterator, 10 frames: 
Size: 0.001183 (GB)
<Topology: 5293 atoms, 1704 residues, 1692 mols, PBC with box type = ortho>
           
In [4]:
# perform RDF calculation for water

rdf_data = pt.rdf(traj, solvent_mask=':WAT@O', solute_mask=':WAT@O', bin_spacing=0.2, maximum=12.)
In [5]:
rdf_data
Out[5]:
(array([  0.1,   0.3,   0.5, ...,  11.5,  11.7,  11.9]),
 array([ 0.        ,  0.        ,  0.        , ...,  0.95114901,
         0.94740952,  0.95099495]))
In [6]:
plt.plot(rdf_data[0], rdf_data[1])
plt.xlabel(r"r ( $\AA$ )")
plt.ylabel('g(r)')
#plt.savefig('rdf_tz2_ortho.png')
Out[6]:
<matplotlib.text.Text at 0x10ac7c2b0>

(radial_distribution_function_of_water.ipynb; radial_distribution_function_of_water_evaluated.ipynb; radial_distribution_function_of_water.py)