The pair correlation function, also known as the radial distribution function, is a way to characterize the distribution of particles on a two-dimensional plane or in a three-dimensional space. Please check out Eric Weeks’ web site for an introduction to pair correlation functions. He has written some routines in IDL to compute these functions. Using his foundation, I have written some simple routines in Python to compute 2D and 3D pair correlation functions.

Download

The pair correlation code is available in the Shocksolution_Examples repository on GitHub. If you are familiar with Git, you can clone the entire repository, or simply right-click and save the individual files that you need.

Two-Dimensional Pair Correlation (Radial Distribution) Function

Validation

The pair correlation function g(r) is a measure of the structure that is present in a collection of particles. To validate the code, and understand how it works, I generated some populations of particles and plotted the pair correlation functions. The populations were generated by random sequential adsorption (RSA) in which each particle was added to the population in a random position. If the position caused the particle to overlap an existing one, the position was rejected and a new one was generated. The first plot shows a representative low-density population of particles. The red particles were used to compute g(r) because a circle of radius rMax centered at those particles lies entirely within the domain. Because the populations were randomly generated, the plotted g(r) is averaged over fifty different populations (dotted lines are +/- one standard deviation). Note that g(r) is never actually negative!

2D Low Density Distribution
2D Low Density Particles
Pair correlation function for low density population
Pair correlation function for low density population

The pair correlation function is almost uniform for this distribution of particles. Because the particles are randomly located and not tightly packed, they have essentially no structure. g(r) is zero for r<1 because the particles have radius one and they are not allowed to overlap.

Now we will test the function on randomly distributed particles that are more densely packed.

2D High Density Particles
2D High Density Particles
Pair correlation function for high density population
Pair correlation function for high density population

The pair correlation function now shows some structure for distances close to the reference particle. Although the particles are still randomly distributed, the higher density forces them to take on some short-range structure as they try to fit in the square without overlapping.

Now we will examine the pair correlation function of a highly ordered array of particles. These particles are hexagonally packed, which is mathematically proven to be the highest-density arrangement for circles on a plane.

2D hexagonally packed particles
2D hexagonally packed particles
Pair correlation function for hexagonally packed circles
Pair correlation function for hexagonally packed circles

The pair correlation function now shows the large amount of order in the particles. If you draw a circle surrounded by hexagonally packed circles and do a little geometry, you can see that each “spike” corresponds to the center-center distance between the reference circle and another circle.

Three-Dimensional Pair Correlation (Radial Distribution) Function

Validation

The 3D pair correlation function was validated using a low-density and high-density distribution of particles within a cube. Because packing spheres in 3D space is much more involved than 2D circle packing, I did not test the routine on packed spheres. If you do, I’d like to hear about it.

Spheres in a cube, low density
Spheres in a cube, low density
3D pair correlation function for low-density spheres
3D pair correlation function for low-density spheres

Now we will look at spherical particles which are more densely packed.

Densely packed spheres in a 3D cube
Densely packed spheres in a 3D cube
Pair correlation function for densely packed spheres
Pair correlation function for densely packed spheres

Short-range order is evident in the pair correlation function.

3 thoughts on “Calculating the Pair Correlation Function in Python

  1. Hi sir! please guide me how i calculate the average number of neighboring particle of two different particles in phase separation and radius of gyration (distribution function) for each particles

    Like

  2. That’s a pretty complicated question, so I can’t answer it here. Please email me at the address shown above if you want to hire me to work on it.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s