msd_shift

mdcraft.algorithm.correlation.msd_shift(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 the Einstein relation.

For a set of positions \(\mathbf{r}_i(t)\), the MSD is defined as

\[\mathrm{MSD}_i(\tau)=\left\langle[\textbf{r}_i(t_0+\tau) -\textbf{r}_i(t_0)]^2\right\rangle =\dfrac{1}{N_\tau}\sum_{k=1}^{N_\tau}[\textbf{r}_i(t_k+\tau) -\textbf{r}_i(t_k)]^2\]

where \(\tau\) is the time lag, \(t_j\) is an arbitrary reference time, and \(N_\tau\) is the number of possible reference times.

Similarly, the CD for two sets of positions \(\mathbf{r}_i(t)\) and \(\mathbf{r}_j(t)\) is defined as

\[\begin{split}\mathrm{CD}_{ij}(\tau)&=\langle [\textbf{r}_i(t_0+\tau)-\textbf{r}_i(t_0)]\cdot [\textbf{r}_j(t_0+\tau)-\textbf{r}_j(t_0)]\rangle\\ &=\dfrac{1}{N_\tau}\sum_{k=1}^{N_\tau} [\textbf{r}_i(t_k+\tau)-\textbf{r}_i(t_k))\cdot (\textbf{r}_j(t_k+\tau)-\textbf{r}_j(t_k)]\end{split}\]

To minimize statistical noise, the MSD/CD is calculated for and averaged over all possible reference times \(t_0\).

Note

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

\[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 containing the \(N\) entities is also removed.

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

References

[1]

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.