msd_fft¶
- mdcraft.algorithm.correlation.msd_fft(r_i: ndarray[float], r_j: ndarray[float] = None, /, axis: int = None, *, average: bool = True) ndarray[float][source]¶
Evaluates the mean squared displacements (MSD) or the analogous cross displacements (CD) of positions \(\mathbf{r}_i(t)\) and \(\mathbf{r}_j(t)\) using fast Fourier transforms (FFT).
For a set of positions \(\mathbf{r}_i(t)\), the MSD is computed using the algorithm [1] [2]
\[\begin{split}\mathrm{MSD}_{i,\,m}&=\frac{1}{N_t-m}\sum_{k=0}^{N_t-m-1} [\textbf{r}_{i,\,k+m}-\textbf{r}_{i,\,k}]^2\\ &=\frac{1}{N_t-m}\sum_{k=0}^{N_t-m-1} \left[\textbf{r}_{i,\,k+m}^2+\textbf{r}_{i,\,k}^2\right] -\frac{2}{N_t-m}\sum_{k=0}^{N_t-m-1} \textbf{r}_{i,\,k}\cdot\textbf{r}_{i,\,k+m}\\ &=S_{ii,\,m}-2\mathrm{R}_{ii,\,m}\end{split}\]where \(i\) is the species index, \(m\) is the index corresponding to time lag \(\tau\), \(\mathrm{R}_{ii,\,m}\) is the autocorrelation of \(\mathbf{r}_i(t)\), and \(S_m\) is evaluated using the recursive relation
\[\begin{split}\begin{gather*} D_{ii,\,m}=\textbf{r}_{i,\,m}^2\\ Q_{ii,\,-1}=2\sum_{k=0}^{N_t-1}D_{ii,\,k}\\ Q_{ii,\,m}=Q_{ii,\,m-1}-D_{ii,\,m-1}-D_{ii,\,N_t-m}\\ S_{ii,\,m}=\frac{Q_{ii,\,m}}{N_t-m} \end{gather*}\end{split}\]Similarly, the CD for two sets of positions \(\mathbf{r}_i(t)\) and \(\mathbf{r}_j(t)\) is computed using
\[\mathrm{CD}_{ij,m}=S_{ij,\,m}-2\mathrm{R}_{ij,\,m}\]where \(\mathrm{R}_{ij,\,m}\) is the cross-correlation of \(\mathbf{r}_i(t)\) and \(\mathbf{r}_j(t)\), and \(S_{ij,\,m}\) is evaluated using the recursive relation
\[\begin{split}\begin{gather*} D_{ij,\,m}=\textbf{r}_{i,\,m}\cdot\textbf{r}_{j,\,m}\\ Q_{ij,\,-1}=2\sum_{k=0}^{N_t-1}D_{ij,\,k}\\ Q_{ij,\,m}=Q_{ij,\,m-1}-D_{ij,\,m-1}-D_{ij,\,N_t-m}\\ S_{ij,\,m}=\frac{Q_{ij,\,m}}{N_t-m} \end{gather*}\end{split}\]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}{d\tau}\left\langle \sum_{\alpha=1}^{N_i}[\mathbf{r}_{i,\,\alpha}(t_0+\tau) -\mathbf{r}_{i,\,\alpha}(t_0)]\cdot \sum_{\beta=1}^{N_j}[\mathbf{r}_{j,\,\beta}(t_0+\tau) -\mathbf{r}_{j,\,\beta(t_0)}]\right\rangle\]r_i and r_j should be summed over all entities before being passed to this function.
- Parameters:
- r_inumpy.ndarray, positional-only
Time evolution of individual or averaged positions for \(N\) entities over \(N_\mathrm{b}\) blocks of \(N_t\) times each.
Shape: \((N_t,\,3)\), \((N_t,\,N,\,3)\), \((N_\mathrm{b},\,N_t,\,3)\), or \((N_\mathrm{b},\,N_t,\,N,\,3)\).
Reference unit: \(\mathrm{Å}\).
- r_jnumpy.ndarray, positional-only, optional
Time evolution of individual or averaged positions for another \(N\) entities over \(N_\mathrm{b}\) blocks of \(N_t\) times each.
Shape: Same as r_i.
Reference unit: \(\mathrm{Å}\).
- axisint, optional
Axis along which time evolves. If not specified, the axis is determined automatically using the shape of r_i.
- averagebool, keyword-only, default:
True Determines whether the MSD/CD is averaged over all entities. Only available if r_i and r_j contain information for multiple entities.
- Returns:
- dispnumpy.ndarray
MSD or CD.
Shape: Same as the shape of r_i, except with the last axis removed. If
average=True, the axis indexing 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.