dynsight.analysis.compute_rdf¶
- dynsight.analysis.compute_rdf(universe, distances_range, s1='all', s2='all', exclusion_block=None, nbins=200, norm='rdf', start=None, stop=None, step=1)[source]¶
Radial Distribution Function between two types of particles.
The RDF between two types of particles a and b is defined as:
\[g_{ab}(r) = (N_a N_b)^{-1} \sum_{i=1}^{N_a}\sum_{j=1}^{N_b} \langle \sigma(|\mathbf{r_i}\mathbf{r_j}| - r)\rangle\]The radial distribution function is calculated by histogramming distances between two groups of atoms s1 and s2. Periodic boundary conditions are taken into account via the minimum-image convention. More information concerning this function can be found here.
- Parameters:
universe (MDAnalysis.Universe) – Simulation MDAnalysis universe.
s1 (str) – First atom group.
s2 (str) – Second atom group.
distances_range (list[float]) – Initial and final distances within which to compute the RDF.
exclusion_block (list[int] | None) – A tuple specifying the size of blocks (e.g., molecules) to exclude distances between atoms within the same block. If s1 and s2 are equal, it prevents self-interactions by default with (1, 1).
nbins (int) – The number of bins used to divide the distance range for histogramming the RDF.
norm (Literal['rdf', 'density', 'none']) –
Type of normalization to apply:
’rdf’: Standard RDF normalization (default).
’density’: Normalize with respect to system density.
’none’: No normalization applied.
start (int | None) – Initial molecular dynamics step.
stop (int | None) – Final molecular dynamics step.
step (int) – Frequency at which the dynamics is sampled.
- Returns:
Two arrays where the pair separation distances and the RDF values are stored, respectively.
- Return type:
tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]
Example
import numpy as np import MDAnalysis from dynsight.analysis import compute_rdf univ = MDAnalysis.Universe(path / "trajectory.xyz", dt=1.0) univ.dimensions = np.array([10.0, 10.0, 10.0, 90.0, 90.0, 90.0]) r_dist, rdf = compute_rdf( universe=univ, distances_range=[0.0, 10.0], nbins=100, )
All supported input file formats by MDAnalysis can be used to set up the Universe.