# Discontinuity in bias energy function for periodic collective variables

**URL:** <https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670>\
**Category:** Developers discussions\
**Tags:** forcefield\
**Created:** [August 19, 2026, 6:07am UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670 "2026-08-19T06:07:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunak](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shaunak](https://gromacs.bioexcel.eu/u/shaunak)\
**Post date:** [August 19, 2026, 6:07am UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670/1 "2026-08-19T06:07:35Z")

</div>

Hi devs,

I’m trying to understand how the biased simulations for techniques like umbrella sampling work in principle. When we add a bias to the potential function for, say a dihedral collective variable, `U_b(\mathbf{x}) = 0.5 k (\phi(\mathbf{x}) - \phi_0)^2`, I was confused about the nature of the bias function especially since the function is periodic. Say, \phi\_0 is 178, and then you have a certain configuration for which \phi is 180, so your bias would be `U_b = 0.5 K * 4`. If the dihedral goes further in the next step of the simulation, say to 181, it wraps around to -179. Then the bias value gets a huge spike, `U_b = 0.5 K (358)^2`. This is a discontinuity in the bias function, introduced by a periodic collective variable. How does gromacs deal with this?

I did try to read up a bit on the gromacs documentation [here](https://manual.gromacs.org/current/reference-manual/functions/restraints.html), but the mod of the delta is taken over 2 \* pi, which is 360. So even in the above case, since the delta is 358, mod of that w.r.t. 360 is still 358. This left me a bit confused. If anyone could provide clarity on how gromacs handles this bias for periodic CVs, it would be much appreciated. Thanks!

---

<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:** [August 19, 2026, 7:13am UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670/2 "2026-08-19T07:13:21Z")

</div>

The deviation of the angle is defined such that it is always between -180 and 180 degrees. So there is a jump when the deviation is 180 degrees. But in practice umbrella potentials are so tight that you never get such large deviations.

---

<div class="post-metadata">

**Author:** ![shaunak](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shaunak](https://gromacs.bioexcel.eu/u/shaunak)\
**Post date:** [August 19, 2026, 2:33pm UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670/3 "2026-08-19T14:33:58Z")

</div>

> The deviation of the angle is defined such that it is always between -180 and 180 degrees.

Is this done by adding 360 whenever it goes beyond -180, and subtracting 180 whenever it goes beyond 180?

> But in practice umbrella potentials are so tight that you never get such large deviations.

Is the umbrella potential the same as the one shown [here](https://manual.gromacs.org/current/reference-manual/functions/restraints.html)? I tried looking up some documentation but it has left me unsure of the exact functional form used in practice in gromacs. Could you please tell me the function used, and where I can read more about it? In theory, I would imagine that a small enough spring constant would result in the bias not being too tight.

---

<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:** [August 19, 2026, 3:04pm UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670/4 "2026-08-19T15:04:51Z")

</div>

Adding 360 when the deviation is below -180 and subtracting 360 when above 180.

The umbrella a plain harmonic potential: 0.5 _k dev^2_

---

<div class="post-metadata">

**Author:** ![shaunak](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@shaunak](https://gromacs.bioexcel.eu/u/shaunak)\
**Post date:** [August 20, 2026, 4:23am UTC](https://gromacs.bioexcel.eu/t/discontinuity-in-bias-energy-function-for-periodic-collective-variables/13670/5 "2026-08-20T04:23:23Z")

</div>

Got it. This makes things a lot clearer. Thank you.
