11# -*- coding: utf-8 -*-
2- '''
2+ # Copyright (c) 2015-2016, Exa Analytics Development Team
3+ # Distributed under the terms of the Apache License 2.0
4+ """
35Pair Correlation Functions
46############################
5- '''
7+ """
68import numpy as np
79import pandas as pd
810from exatomic import Length
911
1012
1113def radial_pair_correlation (universe , a , b , dr = 0.05 , start = 1.0 , stop = 13.0 ,
12- length = 'A' , window = 1 ):
13- '''
14+ length = "A" , window = 1 ):
15+ """
1416 Compute the angularly independent pair correlation function.
1517
1618 This function is sometimes called the pair radial distribution function. The
@@ -24,8 +26,8 @@ def radial_pair_correlation(universe, a, b, dr=0.05, start=1.0, stop=13.0,
2426
2527 .. code-block:: Python
2628
27- pcf = radial_pair_correlation(universe, 'O', 'O' )
28- pcf.plot(secondary_y=' Pair Count' )
29+ pcf = radial_pair_correlation(universe, "O", "O" )
30+ pcf.plot(secondary_y=" Pair Count" )
2931
3032 .. math::
3133
@@ -57,30 +59,30 @@ def radial_pair_correlation(universe, a, b, dr=0.05, start=1.0, stop=13.0,
5759 the volume sampled during computation of two body properties divided by
5860 the number of properties used in the histogram (the triple summation
5961 above, divided by the normalization for the radial distance outward).
60- '''
62+ """
6163 bins = np .arange (start , stop , dr ) # Discrete values of r for histogram
62- symbol = universe .atom [' symbol' ].astype (str ) # To select distances, map to symbols
63- symbol0 = universe .atom_two [' atom0' ].map (symbol )
64- symbol1 = universe .atom_two [' atom1' ].map (symbol )
64+ symbol = universe .atom [" symbol" ].astype (str ) # To select distances, map to symbols
65+ symbol0 = universe .atom_two [" atom0" ].map (symbol )
66+ symbol1 = universe .atom_two [" atom1" ].map (symbol )
6567 symbols = symbol0 + symbol1
6668 indexes = symbols [symbols .isin ([a + b , b + a ])].index # Distances of interest or those that
67- distances = universe .atom_two .ix [indexes , ' distance' ] # match symbol pairs
69+ distances = universe .atom_two .ix [indexes , " distance" ] # match symbol pairs
6870 hist , bins = np .histogram (distances , bins ) # Compute histogram
6971 nn = hist .sum () # Number of observations
7072 bmax = bins .max () # Note that bins is unchanged by np.hist..
71- rx , ry , rz = universe .frame [['rx' , 'ry' , 'rz' ]].mean ().values
73+ rx , ry , rz = universe .frame [["rx" , "ry" , "rz" ]].mean ().values
7274 ratio = (((bmax / rx + bmax / ry + bmax / rz )/ 3 )** 3 ).mean () # Variable actual vol and bin vol
7375 v_shell = bins [1 :]** 3 - bins [:- 1 ]** 3 # Volume of each bin shell
74- v_cell = universe .frame [' cell_volume' ].mean () # Actual volume
76+ v_cell = universe .frame [" cell_volume" ].mean () # Actual volume
7577 g = hist * v_cell * ratio / (v_shell * nn ) # Compute pair correlation
76- na = universe .atom [universe .atom [' symbol' ] == a ].groupby (' frame' ).size ().mean ()
77- nb = universe .atom [universe .atom [' symbol' ] == b ].groupby (' frame' ).size ().mean ()
78+ na = universe .atom [universe .atom [" symbol" ] == a ].groupby (" frame" ).size ().mean ()
79+ nb = universe .atom [universe .atom [" symbol" ] == b ].groupby (" frame" ).size ().mean ()
7880 if a == b :
7981 nb -= 1
8082 n = hist .cumsum ()/ nn * na * nb # Compute pair count
81- r = (bins [1 :] + bins [:- 1 ])/ 2 * Length ['au' , length ]
82- unit = 'au'
83- if length in ['A' , ' angstrom' , ' ang' ]:
83+ r = (bins [1 :] + bins [:- 1 ])/ 2 * Length ["au" , length ]
84+ unit = "au"
85+ if length in ["A" , " angstrom" , " ang" ]:
8486 unit = r"\AA"
8587 rlabel = r"$r\ \mathrm{(" + unit + ")}$"
8688 glabel = r"$g_\mathrm{" + a + b + r"}(r)$"
0 commit comments