+/*! \brief Computes forces and potential for flat-bottom cylindrical restraints.
+ * Returns the flat-bottom potential. */
+static real do_fbposres_cylinder(int fbdim, rvec fm, rvec dx, real rfb, real kk, gmx_bool bInvert)
+{
+ int d;
+ real dr, dr2, invdr, v, rfb2;
+
+ dr2 = 0.0;
+ rfb2 = sqr(rfb);
+ v = 0.0;
+
+ for (d = 0; d < DIM; d++)
+ {
+ if (d != fbdim)
+ {
+ dr2 += sqr(dx[d]);
+ }
+ }
+
+ if (dr2 > 0.0 &&
+ ( (dr2 > rfb2 && bInvert == FALSE ) || (dr2 < rfb2 && bInvert == TRUE ) )
+ )
+ {
+ dr = sqrt(dr2);
+ invdr = 1./dr;
+ v = 0.5*kk*sqr(dr - rfb);
+ for (d = 0; d < DIM; d++)
+ {
+ if (d != fbdim)
+ {
+ fm[d] = -kk*(dr-rfb)*dx[d]*invdr; /* Force pointing to the center */
+ }
+ }
+ }
+
+ return v;
+}
+