PyGrunn: looking at molecules using python - Jonathan Barnoud

Tags: pygrunn, python

(One of my summaries of a talk at the 2017 PyGrunn conference).

He researches at fat molecules. He applies simulation to molecules. F = m * a (+ some much more elaborate formulas). With an elaborate simulation, he was able to explain some of the properties of fat (using a “jupyter” notebook).

His (python) workflow? First you need to prepare the simulation. He did have (of did build) a simulation engine. The preparation takes text files with the following info:

  • Topology.

  • Initial coordinates.

  • Simulation parameters.

Those text files are prepared and fed to the simulation engine. What comes out is a trajectory (a file with the position and direction and speed of every single molecure for all timesteps).

The next step is analysis. A problem here is that various simulation engines export different formats…. Similar problem with the input, btw…

Luckily we’ve got python. And for python there are a huge amount of libraries. Including “MDAnalysis” ( , a library that can use these trajectory files. The output: python numpy arrays. Nice! This way you can use the entire python scientific stack (numpy, scipy, etc) with all its power.

Numpy? Made for matrices. So you can work with your entire data set. Or you can filter, mask or slice your data.

Thanks to these tools, he can experiment with the data in a comfortable way. And make plots.

But… movies with the 3D simulation are better! So: . His molecules are moving around. He can even place a graph nearby and bind the timeline in the graph and the 3D visualization together. It is all python!

A problem he had was his directory structure. Lots of directories with simulation config files with different settings. A mess. So: , “persistent, pythonic trees for heterogeneous data”.


  • Python is awesome.

  • Jupyter is awesome too.

  • The python science stack is awesome as well.

  • Each field develops awesome tools based on the above.

Photo explanation: just a nice unrelated picture from the my work-in-progress german model railway

Dutch note: python+django programmeren in hartje Utrecht bij de oude gracht? Watersector, dus veel data en geo. Leuk! Nelen&Schuurmans is op zoek. Stuur mij maar een mailtje, want de vacaturetekst staat nog niet online :-) logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):