CoordinationNumber

class CoordinationNumber(md_trajectory, cutoff_radius=None, start_time=None, end_time=None, pair_selection=None, calculate_distribution=True, time_resolution=None, info_panel=None)

Class for calculating the coordination number for an MD simulation.

Parameters:
  • md_trajectory (MDTrajectory | AtomicConfiguration) – The MDTrajectory or configuration to calculate the coordination number for.
  • cutoff_radius (PhysicalQuantity of type length) – Cut off distance for nearest neighbors (must be positive).
    Default: 2.5 * Angstrom
  • start_time (PhysicalQuantity of type time) – The start time.
    Default: 0.0 * fs
  • end_time (PhysicalQuantity of type time) – The end time.
    Default: The last time frame.
  • pair_selection (sequence) – Only include contributions between this selection of atoms. A sequence has to contain two of the following types: Element, tag name, list of indices, or None. If None is given instead of a list then all atom pairs will be considered.
    Default: None
  • calculate_distribution (bool) – A flag to determine whether the distribution of coordination numbers or the time-dependent evolution of coordination numbers along the trajectory should be calculated.
    Default: True
  • time_resolution (PhysicalQuantity of type time) – The time interval between snapshots in the MD trajectory that are included in the analysis. If time_resoultion is None then it will be the same as the MD time step.
    Default: None
  • info_panel (InfoPanel (Plot2D)) – Info panel to show the calculation progress.
    Default: No info panel
coordinationNumbers()

Return the coordination numbers associated with the histogram.

data()
Returns:The coordination number distribution if calculate_distribution has been selected, otherwise an array with the time-dependent evolution of the average coordination number.
Return type:numpy array
times()
Returns:The MD-times in case the time-evolution has been calculated, None otherwise.
Return type:PhysicalQuantity of type time | None

Usage Examples

Load an MDTrajectory and calculate the coordination number distribution of the first atom with all surrounding hydrogen atoms:

md_trajectory = nlread('ethane_md.nc')[-1]

coordination_number = CoordinationNumber(md_trajectory,
                                         cutoff_radius=1.2*Angstrom,
                                         start_time=10000.0*fs,
                                         end_time=50000.0*fs,
                                         pair_selection=[[0], Hydrogen])

# Get the histogram and the associated the coordination numbers.
bin_edges = coordination_number.coordinationNumbers() - 0.4
histogram = coordination_number.data()

# Plot the data using pylab.
import pylab

pylab.bar(bin_edges, histogram, label='Coordination of the first atom', width=0.8)
pylab.xlabel('Coordination number')
pylab.ylabel('Histogram')
pylab.legend()

pylab.show()

coordination_number.py

Notes

Set the cutoff_radius parameter to the maximum bond length that should be considered. A good choice is typically the end of the first peak in the RadialDistribution function of the respective elements.

Use the pair_selection parameter to select the atom interactions that are included in the calculation of the coordination number distribution. The first entry specifies the group of central atoms, while the second entry specifies which of the surrounding atoms are considered. You can use elements, lists of indices, tags, or None (selecting all atoms) for each entry.

This analysis has two modes, distribution and time evolution, which can be switched via the calculate distribution argument. In the distribution analysis the histogram of the coordination numbers is plotted. In the time evolution analysis, the change of the number of atoms associated with each coordination number is analyzed as a function the simulation time. This analysis is performed each coordination number detected in the snapshots of the simulation, as shown in the second example, this yields \(CN_{max}+1\) data sets, where \(CN_{max}\) is the largest coordination number found in the simulation.