adding distance constrain between the centers of two molecules

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Joy Yang
Posts: 1
Joined: Tue Nov 29, 2022 7:07 am

adding distance constrain between the centers of two molecules

Post by Joy Yang » Tue Nov 29, 2022 9:11 am

Hi, I'm new to OpenMM. Could someone help on adding distance constrain between the mass centers of two molecules? e.g.

f= k(r-ro)^a, r>r0
f=0,r<=r0

r is the distance between the centers of two molecules.

How should define the external force in openmm?

Thank you very much!

User avatar
Emilio Galllicchio
Posts: 13
Joined: Fri Feb 24, 2012 11:49 am

Re: adding distance constrain between the centers of two molecules

Post by Emilio Galllicchio » Tue Nov 29, 2022 10:11 am

See:

https://github.com/Gallicchio-Lab/openm ... ils.py#L78

as an example. It uses CustomCentroidBondForce.

User avatar
Peter Eastman
Posts: 2562
Joined: Thu Aug 09, 2007 1:25 pm

Re: adding distance constrain between the centers of two molecules

Post by Peter Eastman » Tue Nov 29, 2022 11:15 am

The API documentation on CustomCentroidBondForce may also be helpful. For your case an expression like this should work:

Code: Select all

force = CustomCentroidBondForce("k*max(0, r-r0)^a")
k, r0, and a can all be either global or per-bond parameters, whatever works for you. Or if they just have a single fixed value that never changes, you can just hardcode them in the expression:

Code: Select all

force = CustomCentroidBondForce("100*max(0, r-1.5)^2")
Remember that energies are in kJ/mol and distances are in nm.

POST REPLY