Colvars' distancePairs to get minimum distance between molecules

GROMACS version: 2025.3
GROMACS modification: No

I am attempting to run a metadynamics simulation between two molecules with the following config file:


indexFile cpx.ndx
colvarsTrajFrequency 500

colvar {
name r
outputTotalForce yes
lowerBoundary 0.0 # smallest it can physically be
upperBoundary 4.0 # largest that it can physically be
width 0.05 # may need to alter this
extendedLagrangian yes
extendedFluctuation 0.01

# Replaced "distance" with "distancePairs"
distancePairs {
    group1 { indexGroup Ligand }
    group2 { indexGroup BindingSite }
    # "min" tracks the closest approach between any two atoms
    # Use forceVector if you need the direction, but min is standard for PMF
    mode min # suggested by Google Gemini, I can find no reference to this whatsoever on the internet
   }
}

harmonicWalls {
name wall_r
colvars r
outputEnergy yes
forceConstant 10.0
lowerWalls 0.2
upperWalls 2.8
}

metadynamics {
name metad_r
colvars r
outputEnergy yes
writeFreeEnergyFile yes
writeTIPMF yes
writeTISamples yes
hillWeight 1.0 # Suggestion: increase hillWeight for faster separation
gaussianSigmas 0.1
newHillFrequency 50
}

which is a modification of what “worked” for colvars’distanceparameter. I wrote mode min while wishing to select the minimum distance between the two molecules.

However, the output doesn’t make sense:


step         r                     r_r                   ft_r                   E_wall_r               E_metad_r
       0    1.26825742960010e-04  1.26825742960010e-04  0.00000000000000e+00   0.00000000000000e+00   0.00000000000000e+00
     500    1.33747887346636e-04  4.40791848016283e-03 -1.04243672273210e+02   0.00000000000000e+00   9.70221158476317e-01

the distances are unreasonably small. distancePairs makes a matrix from what I understand, and I want the minimum within this matrix. I don’t know what r is, but that’s clearly not the minimum interatomic distance between the molecules.

The reference manual / documentation is very sparse on distancePairs

How can I use metadynamics to drive these two molecules apart from one another, so that I can set the minimum distance between the two molecules, analogous to the parameter that’s output from gmx pairdist?

Hi, did you try running that config file? distancePairs is most likely not useful as is (it gives you a vector of values) and mode min does not exist: Google Gemini made it up. The doc is here:

I suggest using distanceInv to have a “minimum distance” kind of variable. (Note that a true min() function would be discontinuous, and unsuitable as a collective variable).

From that input, remove the “writeTI” and “extended*” keywords: you won’t need them.

Lastly, I strongly suggest adding units gromacs at the top and loading this input in the Colvars Dashboard VMD plugin (included in VMD 1.9.4 or later) to test it.

Giacomo