Pierre de Buyl's homepage

Tidynamics, what use?

In 2018 I published small Python library, tidynamics. The scope was deliberately limited: compute the typical correlation functions for stochastic and molecular dynamics: the autocorrelation and the mean-square displacement. Two years later, I wonder about its usage. There are now over 3000 downloads on conda-forge but I have no idea of the amount of PyPI or GitHub downloads or whether the downloads on conda-forge are from a few automated systems or from many individual users. I don't know the research fields of the hypothetical users. Feedback on this is definitively welcome if you happen to use the library!

Why I wrote tidynamics

For my research, I analyze stochastic and molecular simulations and need, very frequently, to compute the autocorrelation function and the mean-square displacement. It is indeed possible to use "off the shelf" correlation routines from NumPy or SciPy. There are two problems however. 1. Until some time ago, there was no FFT-based correlation routine in NumPy. 2. Neither routine obeys the textbook definition of the correlation function in physics, which leads to wrong results without suitable correction.

When analyzing data or teaching courses on stochastic dynamics, I would rely on copy-pasted wrappers around the SciPy routines. This was annoying and error-prone. Of course, there was no convenient implementation of the mean-squared displacement computation for my use case.

I thus wrote the algorithm by following the publication Kneller1995 and decided to publish the library in JOSS, the Journal of Open Source Software, see deBuyl2018. Preparing the library to reach the expected quality of the journal was interesting and improved the software! Also, the review process was much nicer than the "typical" one.

Is it useful or used?

In my computational work, tidynamics has been of great help. I am one import away of verified routines for the autocorrelation or mean-square displacement of my stochastic or related models. The performance is good enough, so it has become my go-to solution. It is also an improvement for teaching: for simulations of the Langevin equations, I can simply point to the routines "acf" and "msd" and that's it.

The code only depends on NumPy for the FFT, and not on SciPy. This is by design, to make it as convenient as possible to install. It is available by pip install and through conda-forge.

To give an idea, I show how to compute the mean-square displacement of a random walk below:

import numpy as np
import tidynamics

random_walk = np.cumsum(-1+2*np.random.randint(2, size=(10000, 2)), axis=0)

msd = tidynamics.msd(random_walk)

The resulting time-series is what you would expect from textbook examples in my field.


tidynamics is one of the pieces of code that I use the most and the time spent into writing a clean and tested library has undoubtedly paid off! I suspect that it would benefit a lot to many other scientists (using Python) in statistical physics and related domains.

The "expected" benefit of publishing in JOSS, which was also to gather citations did not happen. I don't know whether it is because it is not actually used or because citing software is not commonplace enough in the statistical physics and/or the stochastic simulation research field.

I should point out that I was motivated to write this blog article because tidynamics is likely to be imported in the popular package for the analysis of molecular dynamics simulations MDAnalysis. This is a positive feedback for sure.

Some links:

  • tidynamics on GitHub https://github.com/pdebuyl-lab/tidynamics
  • tidynamics on PyPI https://pypi.org/project/tidynamics/
  • the documentation http://lab.pdebuyl.be/tidynamics/


  • Kneller1995 Gerald R. Kneller, Volker Keiner, Meinhard Kneller and Matthias Schiller. nMOLDYN: A program package for a neutron scattering oriented analysis of Molecular Dynamics simulations, Comp. Phys. Commun. 91, 191-214 (1995).

  • deBuyl2018 Pierre de Buyl, tidynamics: A tiny package to compute the dynamics of stochastic and molecular simulations, Journal of Open Source Software, 3(28), 877 (2018).

Comments !

Generated with Pelican. Theme based on MIT-licensed Skeleton.