msd_shift¶
- mdhelper.algorithm.correlation.msd_shift(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 the Einstein relation.
The MSD is defined as
\[\mathrm{MSD}(\tau)=\langle\left[ \textbf{r}(t_0+\tau)-\textbf{r}(t_0)\right]^2\rangle =\dfrac{1}{N}\sum_{\alpha=1}^N\left[ \textbf{r}_\alpha(t_0+\tau)-\textbf{r}_\alpha(t_0)\right]^2\]while the CD between species \(i\) and \(j\) is given by
\[\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}\sum_{\alpha=1}^N (\textbf{r}_{i,\alpha}(t_0+\tau)-\textbf{r}_{i,\alpha}(t_0))\cdot (\textbf{r}_{j,\alpha}(t_0+\tau)-\textbf{r}_{j,\alpha}(t_0))\end{split}\]where \(\tau\) is the time lag, \(t_0\) is an arbitrary reference time, and \(N\) is the number of entities. To reduce 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}{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_t\) frames.
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]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.