# Adding custom bias potential

**URL:** <https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906>\
**Category:** User discussions\
**Created:** [December 23, 2023, 6:03am UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906 "2023-12-23T06:03:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhall4](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jhall4](https://gromacs.bioexcel.eu/u/jhall4)\
**Post date:** [December 23, 2023, 6:03am UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906/1 "2023-12-23T06:03:54Z")

</div>

GROMACS version: Any  
GROMACS modification: Yes/No

I am trying to add a bias potential to a protein. I am aware of PLUMED, but after tinkering with it for awhile it seems to be somewhat difficult to define functions of many degrees of freedom (ie; lack of matrix operations and arrays make it difficult to define, say, a multivariate gaussian bias as a function of all bonds and angles, with a vector of means and precision matrix). I could very well be wrong, but it’s not clear to me from PLUMED’s documentation.

Does anyone know if gromacs has any builtin tools to add such a bias, or if not what the best addon to do this might be?

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [January 9, 2024, 3:54pm UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906/2 "2024-01-09T15:54:43Z")

</div>

A function of all bonds and angles sounds complicated. Now GROMACS also supports colvars, maybe that can do something for you.

---

<div class="post-metadata">

**Author:** ![giacomo.fiorin](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/giacomo.fiorin/32/2862_2.png) [@giacomo.fiorin](https://gromacs.bioexcel.eu/u/giacomo.fiorin)\
**Post date:** [January 10, 2024, 7:43pm UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906/3 "2024-01-10T19:43:54Z")

</div>

This [webpage](https://colvars.github.io/gromacs-2024/colvars-refman-gromacs.html) contains the documentation for all Colvars features currently supported as builtin features for GROMACS 2024.

One that may be relevant is the ability to combine multiple variables into one as a [linear combination](https://colvars.github.io/gromacs-2024/colvars-refman-gromacs.html#sec:cvc_superp) or as a [path variable](https://colvars.github.io/gromacs-2024/colvars-refman-gromacs.html#sec:cvc_gspathCV) in collective variable space.

@jhall4 hope that helps, and if not can you please provide more detail?

Giacomo

CC: @Hub @jhenin

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [January 11, 2024, 9:57am UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906/4 "2024-01-11T09:57:03Z")

</div>

I can also add that the GROMACS pull code now supports mathematical transformations from user strings on arbitrary combinations of pull coordinates. So theoretically the pull code can do everything. In practice this can become very tedious and slow when matrix operations are involved. Someone in my unit has modified the transformation pull coordinate code to handle large matrices, including GPU acceleration. I don’t know if that could help you.

---

<div class="post-metadata">

**Author:** ![jhall4](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jhall4](https://gromacs.bioexcel.eu/u/jhall4)\
**Post date:** [January 13, 2024, 10:49pm UTC](https://gromacs.bioexcel.eu/t/adding-custom-bias-potential/7906/5 "2024-01-13T22:49:46Z")

</div>

Thank you both for the advice. I’ll be taking a close look at the pull code and colvars support. I’ve also gotten some pointers elsewhere on how I might modify the PLUMED source code to suit my needs. I’m not sure what the easiest path forward is, but I’ll be experimenting with a few approaches.

In the meantime I am using PLUMED’s metadynamics with a very large PACE parameter (to prevent addition of more gaussians) and “restarting” from a prebuilt HILLS file to create a constant bias as a sum of gaussians, but I am limited to diagonal covariances in this way. This isn’t quite ideal but it is good enough for me for now.
