rdf

A module containing the RDF class. The RDF class is used to calculate the radial distribution of a reference selection to a target selection. The radial distribution function (RDF) is a measure of the probability density of finding a particle at a distance r from another particle.

Summary

Classes:

RDF

A class for calculating the radial distribution of a reference selection to a target selection.

Reference

class RDF(
traj: Trajectory | TrajectoryReader,
reference_species: SelectionCompatible,
target_species: SelectionCompatible,
use_full_atom_info: bool = False,
no_intra_molecular: bool = False,
n_bins: PositiveInt | None = None,
delta_r: PositiveReal | None = None,
r_max: PositiveReal | None = None,
r_min: PositiveReal | None = 0.0,
)[source]

Bases: object

A class for calculating the radial distribution of a reference selection to a target selection. The radial distribution function (RDF) is a measure of the probability density of finding a particle at a distance r from another particle.

The RDF analysis is initialized with the provided parameters. The RDF analysis can be run by calling the run method. The run method returns the middle points of the bins of the RDF analysis, the normalized bins of the RDF analysis based on the spherical shell model, the integrated bins of the RDF analysis, the normalized bins of the RDF analysis based on the number of atoms in the system and the differential bins of the RDF analysis based on the spherical shell model.

The RDF class can be initialized with either a trajectory object or via a TrajectoryReader object. If a trajectory object is given, it is assumed to have a constant topology over all frames! The main difference between the two is that the TrajectoryReader object allows for lazy loading of the trajectory, meaning that the trajectory is only loaded frame by frame when needed. This can be useful for large trajectories that do not fit into memory.

Parameters:
  • traj (Trajectory | TrajectoryReader) – The trajectory to analyze. If a TrajectoryReader is provided, the trajectory frame by frame via a frame_generator

  • reference_species (SelectionCompatible) – The reference species of the RDF analysis.

  • target_species (SelectionCompatible) – The target species of the RDF analysis.

  • use_full_atom_info (bool, optional) – Whether to use the full atom information of the trajectory or not, by default None (False).

  • no_intra_molecular (bool, optional) – Whether to exclude intra-molecular distances or not, by default None (False).

  • n_bins (PositiveInt | None, optional) – number of bins, by default None

  • delta_r (PositiveReal | None, optional) – delta r between bins, by default None

  • r_max (PositiveReal | None, optional) – maximum radius from reference species of the RDF analysis, by default None

  • r_min (PositiveReal, optional) – minimum (starting) radius from reference species of the RDF analysis, by default 0.0 (equals to None)

Raises:
  • RDFError – If the trajectory is not fully periodic or fully in vacuum. Meaning that some frames are in vacuum and others are periodic.

  • RDFError – If the trajectory is empty.

  • RDFError – If n_bins and delta_r are both not specified.

  • RDFError – If n_bins, delta_r and r_max are all specified. This would lead to ambiguous results.

Notes

Furthermore, to initialize the RDF analysis object at least one of the parameters n_bins or delta_r must be specified. If n_bins and delta_r are both specified, r_max is calculated from these parameters. If n_bins and r_max are both specified, delta_r is calculated from these parameters. If delta_r and r_max are both specified, n_bins is calculated from these parameters.

It is not possible to specify all of n_bins, delta_r and r_max in the same RDF analysis as this would lead to ambiguous results.

It is also possible to initialize a non-vacuum trajectory by only using n_bins or delta_r. In this case, r_max is calculated from the provided parameters and the box vectors of the trajectory. If the trajectory is in vacuum, an RDFError is raised as the maximum radius cannot be inferred from the box vectors.

See also

Trajectory, Selection, TrajectoryReader, Trajectory

run() tuple[Np1DNumberArray, Np1DNumberArray, Np1DNumberArray, Np1DNumberArray, Np1DNumberArray][source]

Runs the RDF analysis.

This method runs the RDF analysis and returns the middle points of the bins of the RDF analysis, the normalized bins of the RDF analysis based on the spherical shell model, the integrated bins of the RDF analysis, the normalized bins of the RDF analysis based on the number of atoms in the system and the differential bins of the RDF analysis based on the spherical shell model.

This method will display a progress bar by default. This can be disabled by setting with_progress_bar to False.

Returns:

  • bin_middle_points (Np1DNumberArray) – The middle points of the bins of the RDF analysis.

  • normalized_bins (Np1DNumberArray) – The normalized bins of the RDF analysis based on the spherical shell model.

  • integrated_bins (Np1DNumberArray) – The integrated bins of the RDF analysis.

  • normalized_bins2 (Np1DNumberArray) – The normalized bins of the RDF analysis based on the number of atoms in the system.

  • differential_bins (Np1DNumberArray) – The differential bins of the RDF analysis based on the spherical shell model.

property average_volume: PositiveReal

The average volume of the trajectory.

Type:

PositiveReal

logger = <CustomLogger PQAnalysis.RDF (INFO)>
property n_atoms: int

The number of atoms of the RDF analysis.

Type:

int

property n_frames: int

The number of frames of the RDF analysis.

Type:

int