Page 1 of 1

adding distance constrain between the centers of two molecules

Posted: Tue Nov 29, 2022 9:11 am
by qingyiyang
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!

Re: adding distance constrain between the centers of two molecules

Posted: Tue Nov 29, 2022 10:11 am
by egallicc
See:

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

as an example. It uses CustomCentroidBondForce.

Re: adding distance constrain between the centers of two molecules

Posted: Tue Nov 29, 2022 11:15 am
by peastman
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.