# custom colvars

I’m implementing a custom collective variable that is a function of atomic coordinates. I’d like to use the new fix-colvar from the USER/COLVARS package.

Is it possible to define a colvar that contains loops over atomic neighbors, trigonometric functions of atomic coordinates and summations over groups? Am I better off using the PLUMED plugin for more complex CVs?

Thanks for the help.

I'm implementing a custom collective variable that is a function of atomic
coordinates. I'd like to use the new fix-colvar from the USER/COLVARS
package.

Is it possible to define a colvar that contains loops over atomic neighbors,
trigonometric functions of atomic coordinates and summations over groups?
Am I better off using the PLUMED plugin for more complex CVs?

neither PLUMED nor the COLVARS based colllective
(groups, neighbor lists etc.).

it is not obvious from your rather vague description
what kind of information you need to transport through
the interface that connects the MD code to the CV code.

i cannot talk about PLUMED, but in the COLVARS library
you can define rather complex constructs already.

axel.

I’d like to take my CV as equation 20 on page 5 from this publication, which I’ve copied below.

CV = sqrt ( [sum cos( k dot r_ij)]^2 + [sum sin( k dot r_ij)]^2 )

k is an arbitrary unit vector, the summations are over all atomic neighbor pairs (ij).

I'd like to take my CV as equation 20 on page 5 from this publication, which
I've copied below.

CV = sqrt ( [sum cos( k dot r_ij)]^2 + [sum sin( k dot r_ij)]^2 )

k is an arbitrary unit vector, the summations are over all atomic neighbor
pairs (ij).

technically, it should be possible, but you'll likely have to communicate
all atom coordinates to the collective variable codes (since they are
serial) and thus it will be rather inefficient. regardless of which package
you want to use, even if you include your own neighbor list code and
what is required for it.

it'll probably be easier to implement the collective variable as such
as a fix. now, the interesting question is, if there is a benefit to
connect such a fix to one of the existing libraries, so you can
save some of the programming effort. let me contact the authors
of the COLVARS library, if they have a suggestion there.

axel.

I forgot to mention that I’m also interested in so called ‘well tempered’ metadynamics which adds in some time dependence to the magnitude of the bias energy contribution, which it looks like isn’t included in the fix-colvars package.

From what I’ve seen in the fix-colvars code, the bias energy is communicated from the colvars package to the LAMMPS simulation by the colvarproxy_lammps::compute() function. So my fix just needs to compute a bias energy and somehow get that result into the colvarproxy_lammps::compute(). Does that sound about right?

Thanks for the help Axel.

I forgot to mention that I'm also interested in so called 'well tempered'
metadynamics which adds in some time dependence to the magnitude of the bias
energy contribution, which it looks like isn't included in the fix-colvars
package.

please keep in mind, that the colvars fix is just a rather dumb
wrapper that feeds the colvars library a system description and
then monitors the atoms that the colvars library tells it to watch,
hands in the coordinates and receives and applies forces (if computed).

From what I've seen in the fix-colvars code, the bias energy is communicated
from the colvars package to the LAMMPS simulation by the
colvarproxy_lammps::compute() function. So my fix just needs to compute a
bias energy and somehow get that result into the
colvarproxy_lammps::compute(). Does that sound about right?

i don't think so. but i am not the expert on these things.
i have not had the time yet, to discuss this with my
(former) colleagues that are maintaining (and continually
improving) the colvars package. i also need to have a
closer look at the paper that you are referring to. i don't
want to rush this and give a wrong answer. my gut feeling
is, that this is not going to be trivial and easy to do, but
if done right, it will open a window for a whole new family
of collective variables that can be implemented in LAMMPS
more efficiently than in many other MD codes.

axel.

The paper I sent before is just where I’ve pulled the order parameter from and probably won’t be helpful. I plan on expanding on the metadynamics methods described here, their order parameter is vaguely similar to the one I described before.

I missed it before, but it looks like they did use PLUMED for their simulation, I’m not clear on how efficient it was, although their largest simulation had 6500 atoms for 10^7 time steps with 2 CVs.

If the fix-colvar maintainers are interested in expanding it to handle CVs of this nature, there certainly seems to be demand to justify it, and I would be happy to help.