plumed2 icon indicating copy to clipboard operation
plumed2 copied to clipboard

COMBINE and PERIODIC

Open GiovanniBussi opened this issue 10 years ago • 1 comments

I just added a short example of COMBINE with PERIODIC in the manual (on Pratyush request).

Better thinking about it, I think we could automatize this choice for COMBINE. I write here how I think we could do it.

If none of the arguments is periodic, then use PERIODIC=NO

Else, if there are at least two arguments contributing (i.e. with POWERS!=0 and COEFFICIENTS!=0), then PERIODIC cannot be computed. Give an error and ask the user to provide periodicity.

Now we assume there is a single periodic argument. Consider its range (min,max), its coefficient (c), and its power (n). Notice that n might need to be normalized.

If n is odd OR (n is even AND min and max have the same sign) then one can set PERIODIC=A,B where A and B are same as c_min__n and c_max**n but sorted. Otherwise, give an error and ask user to provide periodicity.

Giovanni

GiovanniBussi avatar Jul 30 '15 13:07 GiovanniBussi

I better thought about this and actually it would probably make more sense to enforce sin/cos combinations when using periodic variables. I propose the following definition:

  1. If some of the arguments is not periodic or the result is not periodic, do the usual calculation.
  2. If all the arguments are periodic and the result is periodic, do the sin/cos combination described below.

In order to make the sin/cos combination, do the following:

  1. Subtract from each ARG the corresponding PARAMETER (as now). Differences should be done with PBC (notice that this is not currently done, I think it is a sort of bug that should be fixed).
  2. Scale the results by a factor 2*pi/(max-min) in order to convert it to an angle in radians. If applied to normal torsions, it would scale by a factor 1.
  3. Combine sin and cos of that angle using COEFFICIENTS as weights.
  4. Compute the atan2 of the resulting combinations.
  5. Scale the result by (max-min)/(2*pi) to make it consistent with the domain specified in the PERIODIC option.

Notice that the result will be invariant by a scaling of all the COEFFICIENTS, implying their normalization. This is because atan2(y,x) only depends on y/x and on the sign of y.

In this manner it would be possible to take the average value of many angles easily:

av: COMBINE ARG=(torsion.*) PERIODIC=-pi,pi

Also notice that POWERS could be used to scale the angles, in order to be consistent with taking the powers of an imaginary exponential. To this aim they should be >=0 and integers. Although I am not sure how useful this would be.

GiovanniBussi avatar Jun 19 '18 14:06 GiovanniBussi