# softmatter:Radial Distribution Function

The **radial distribution function**, also known as **RDF**, **g(r)**, or the **pair correlation function**, is a measure to determine the correlation between particles within a system. Specifically, it is a measure of, on average, the probability of finding a particle at a distance of *r* away from a given reference particle, relative to that for an ideal gas. The general algorithm involves determining how many particles are within a distance of r and r+dr away from a particle. This general theme is depicted to the right, where the red particle is our reference particle, and blue particles are those which are within the circular shell, dotted in red.

The RDF is usually determined by calculating the distance between all particle pairs and binning them into a histogram. The histogram is then normalized with respect to an ideal gas, where particle histograms are completely uncorrelated. For three dimensions, this normalization is the number density of the system multiplied by the volume of the spherical shell, which mathematically can be expressed as *N*_{i.g.}(*r*) = 4π*r*^{2}ρ*d**r*, where ρ is the number density.

## Contents |

## Calculation of Thermodynamic Properties

The radial distribution function is an important measure because several key thermodynamic properties, such as potential energy and pressure can be calculated from it.

For a 3-D system where particles interact via pairwise potentials, the potential energy of the system can be calculated as follows [1]:

Where N is the number of particles in the system, ρ is the number density, u(r) is the pair potential.

The pressure of the system can also be calculated by relating the 2nd virial coefficient to g(r). The pressure can be calculated as follows [1]:

Where T is the temperature and k_{B} is Boltzmann's constant. Note that the results of potential and pressure will not be as accurate as directly calculating these properties because of the averaging involved with the calculation of g(r).

## Examples

### Gas

An example plot of g(r) for a 500 particle Lennard-Jones gas simulated with Molecular dynamics at a number density = 0.01, T=1.0.

### Liquid

An example plot of g(r) for a 500 particle Lennard-Jones fluid simulated with Molecular dynamics at a number density = 0.5 and Temperature = 1.0.

### Solid

An example plot of g(r) for a 2000 particle Lennard-Jones crystal simulated with Molecular dynamics at a number density = 1.0 and Temperature = 0.5.