Task #3353

Document gmx densmap output

Added by Christian Blau 12 months ago. Updated 12 months ago.

Target version:


The output format of the gmx densmap tool is only clear after looking at the code.

Ok, I believe I have found the nature of this 'quirk' looking at the source code (as Berk suggested me to do).
I was assuming a format, but GROMACS is producing another: the .dat file in the output contains the values PLUS the coordinates for each bin, that is the first row and the first colum are not denisty values, but coordinates; hence the output matrix is indeed (n1+1)x(n2+1), the actual values being in grid[1:n1-1,1:n2-1] (0-start index convention).
So apparently is not a bug in the code, but just a misunderstanding of me as user; I double checked the documentation (both for 2019.04 and for the new 2020 release) and I did not find any reference to the format of the output file: could it be a good idea to incude some indication in that regard?

I am struggling a little bit with gmx densmap. I am trying to obtain a matrix with density values from the .dat file generated by the program; however the number of data in the output file does not match what I am expecting.

I tried to prescribe both the number of bins in each direction (-n1 and -n2 options) and the grid size (-bin option), not at the same, of course:

gmx densmap -f traj.trr -s system.tpr -od densmap.dat -b 800.0 -e 1200.0 -aver y -n1 4772 -n2 3531
OR (equivalently):
gmx densmap -f traj.trr -s system.tpr -od densmap.dat -b 800.0 -e 1200.0 -aver y -bin 0.01

In both cases I get a dimension mismatch (I expect 16849932 values but I get 4359553).


#1 Updated by Berk Hess 12 months ago

IIRC densmap adds one grid point for each dimension. Maybe it's better to remove this and offset the grid points by half a spacing.

Also available in: Atom PDF