Page 1 of 1

Positional Restraints info

Posted: Wed May 17, 2017 1:13 pm
by nividic73
Hi there,

In my system, I’m using positional restraints by adding a Custom External Force like the following:

Code: Select all

openmm.CustomExternalForce('k_restr*( (x-x0)^2 + (y-y0)^2 + (z-z0)^2 )')
where the per particle parameters x0, y0 and z0 are taken from my starting structure positions. I’m performing a NVT simulation and my system crashes soon after started. I was able to track down the error which seems related to the fact that the whole system is translated during the NVT simulation while the x0, y0, and z0 per particle parameters are not. If I translate my original system to be centered at xc=box_x/2, yc=box_y/2, zc=box_z/2 (where box_x, box_y and box_z are my box size dimensions) prior to run the simulation, I do not have any crashes. I wonder if I’m making some mistakes or I must follow another procedure to apply positional restraints.

Thanks a lot

Re: Positional Restraints info

Posted: Wed May 17, 2017 1:57 pm
by peastman
Change your force to this:

Code: Select all

openmm.CustomExternalForce('k_restr*periodicdistance(x, y, z, x0, y0, z0)^2')
That way it will apply periodic boundary conditions when computing the distance.

Peter

Re: Positional Restraints info

Posted: Wed May 17, 2017 3:16 pm
by nividic73
Hi Peter,

This is a new OpenMM magic that I was not aware of!

Thank you so much for your help and support.

Gaetano

Re: Positional Restraints info

Posted: Wed Sep 27, 2017 8:34 am
by broomsday
Oh nice, I was having exactly the same problem and my current workout was to pre-translate all my starting structures. I'll test this out.

One thing to note, the internal translation that OpenMM applies only seems to occur DURING the simulation. If you ask for the particle positions after simulating, they are back to being like those of the input structure, whereas any output made using Reporters have the translation applied.

Anyway, thanks for posting this solution.