msd_fft

mdhelper.algorithm.correlation.msd_fft(pos1: ndarray[float], pos2: ndarray[float] = None, axis: int = None, *, average: bool = True) ndarray[float][source]

Evaluates the mean squared displacement (MSD) or the analogous cross displacement (CD) using fast Fourier transforms (FFT).

The algorithm [1] [2] is

\[\begin{split}\mathrm{MSD}_m&=\frac{1}{N_t-m}\sum_{k=0}^{N_t-m-1} \left[\textbf{r}_{k+m}-\textbf{r}_k\right]^2\\ &=\frac{1}{N_t-m}\sum_{k=0}^{N_t-m-1} \left[\textbf{r}_{k+m}^2+\textbf{r}_k^2\right] -\frac{2}{N_t-m}\sum_{k=0}^{N_t-m-1} \textbf{r}_k\cdot\textbf{r}_{k+m}\\ &=S_m-2A_m\end{split}\]

where \(m\) is the index corresponding to time lag \(\tau\), \(A_m\) is the autocorrelation of the positions, which is evaluated by calculating the power spectral density (PSD), inverting it, and then dividing by \(N_t-m\), and \(S_m\) can be evaluated using the recursive relation

\[\begin{split}\begin{gather*} D_k=\textbf{r}_k^2\\ Q_{-1}=2\sum_{k=0}^{N_t-1}D_k\\ Q_m=Q_{m-1}-D_{m-1}-D_{N_t-m}\\ S_m=\dfrac{Q_m}{N_t-m} \end{gather*}\end{split}\]

Similarly, when two distinct sets of positions are provided, the CD is computed using

\[\mathrm{CD}_{ij,m}=S_m-2C_{ij,m}\]

where \(C_{ij,m}\) is the cross-correlation of the two sets of positions and \(D_k\) in \(S_m\) is replaced with the analogous \(D_{ij,k} = \textbf{r}_{i,k}\cdot\textbf{r}_{j,k}\).

Note

To evaluate the sum in the expression used to calculate the Onsager transport coefficients [3]

\[L_{ij}=\frac{1}{6k_\mathrm{B}T}\lim_{t\rightarrow\infty} \frac{d}{dt}\left\langle\sum_{\alpha=1}^{N_i} [\mathrm{r}_\alpha(t_0+t)-\mathrm{r}_\alpha(t_0)]\cdot \sum_{\beta=1}^{N_j}[\mathrm{r}_\beta(t_0+t) -\mathrm{r}_\beta(t_0)]\right\rangle\]

pos1 and pos2 should be summed over all atoms before being passed to this function.

Parameters:
pos1numpy.ndarray

Individual or averaged position(s) of the \(N\) particles in the first particle group over \(N_\mathrm{b}\) blocks of \(N_t\) frames each.

Shape: \((N_t,\,3)\), \((N_t,\,N,\,3)\), or \((N_\mathrm{b},\,N_t,\,N,\,3)\).

Reference unit: \(\mathrm{Å}\).

pos2numpy.ndarray, optional

Individual or averaged position(s) of the \(N\) particles in the second particle group over \(N_t\) frames.

Shape: Same as pos1.

Reference unit: \(\mathrm{Å}\).

axisint, optional

Axis along which to evaluate the MSD/CD. If pos1 and/or pos2 contain a full, unsplit trajectory, the MSD/CD should be evaluated along the first axis (axis=0). If pos1 and/or pos2 contain a trajectory split into multiple blocks, the MSD should be evaluated along the second axis (axis=1). If not provided, the axis is selected automatically using the shape of pos1.

averagebool, keyword-only, default: True

Determines whether the MSD is averaged over all particles if the position arrays contain information for multiple particles.

Returns:
dispnumpy.ndarray

Mean-squared or cross displacement.

Shape: The shape of pos, except with the last dimension removed. If average=True, the axis containing the \(N\) entities is also removed.

Reference unit: \(\text{Å}^2\).

References

[1]

Kneller, G. R.; Keiner, V.; Kneller, M.; Schiller, M. NMOLDYN: A Program Package for a Neutron Scattering Oriented Analysis of Molecular Dynamics Simulations. Computer Physics Communications 1995, 91 (1–3), 191–214. https://doi.org/10.1016/0010-4655(95)00048-K.

[2]

Calandrini, V.; Pellegrini, E.; Calligari, P.; Hinsen, K.; Kneller, G. R. NMoldyn - Interfacing Spectroscopic Experiments, Molecular Dynamics Simulations and Models for Time Correlation Functions. JDN 2011, 12, 201–232. https://doi.org/10.1051/sfn/201112010.

[3]

Fong, K. D.; Self, J.; McCloskey, B. D.; Persson, K. A. Onsager Transport Coefficients and Transference Numbers in Polyelectrolyte Solutions and Polymerized Ionic Liquids. Macromolecules 2020, 53 (21), 9503–9512. https://doi.org/10.1021/acs.macromol.0c02001.