1

**Frequently Asked Questions (FAQ) / How can the partial radial distribution functions be calculated with Ovito?**

« **on:**May 03, 2017, 04:37:26 PM »

OVITO's Coordination Analysis modifier can calculate the radial distribution function (RDF) of a system of particles. The RDF

However, the Coordination Analysis modifier only calculates the

Note that the partial RDF calculated by this script is normalized such that all partial RDFs, when computed for all possible pairs of atom types, sum up to the global RDF.

*g*(*r*) measures the probability of finding an atom at distance*r*given that there is an atom at position 0; it is essentially a normalized histogram of interatomic distances -and is calculated as such.However, the Coordination Analysis modifier only calculates the

*global*RDF ignoring the types of particles. For systems with more than one species, the so-called*partial*radial distribution functions*g*_{αβ}(*r*) may be of interest. To obtain them, a different route is currently needed (until the Coordination Analysis modifier will be extended in a future program version):- Insert the Create Bonds modifier. Let it create bonds only between those types of particles for which the partial RDF should be calculated. The cutoff parameter defines the range over which the RDF will be computed.
- Insert the Compute bond lengths modifier.
- Insert a Python script modifier and copy/paste the following script function, which computes the RDF from the bond lengths:

Code: [Select]

`import numpy as np`

num_bins = 100

def modify(frame, input, output):

hist, bin_edges = np.histogram(input.bond_properties.length.array, bins=num_bins)

rho = input.number_of_particles / input.cell.volume

factor = 4./3. * np.pi * rho * input.number_of_particles

radii = bin_edges[:-1]

radii_right = bin_edges[1:]

rdf = hist / (factor * (radii_right**3 - radii**3))

print(np.column_stack((radii,rdf)))

Note that the partial RDF calculated by this script is normalized such that all partial RDFs, when computed for all possible pairs of atom types, sum up to the global RDF.