Page 1 of 1

COM restraints using CustomCentroidBondForce

Posted: Mon Jan 28, 2019 1:00 pm
by khaos
Dear OpenMM developers,

Is it possible to apply multiple COM restraints using a single CustomCentroidBondForce?
For example, if I want to put two (or more) positional COM restraints at x=1 for group1 and x=10 for group2, do I need to construct two (or more) CustomCentroidBondForce for each?

Thanks,
Jumin

Re: COM restraints using CustomCentroidBondForce

Posted: Mon Jan 28, 2019 1:09 pm
by peastman
Define a per-bond parameter that gives the position you want to restrain it to. Then add a separate bond for each group.

Re: COM restraints using CustomCentroidBondForce

Posted: Tue Jan 29, 2019 8:15 am
by khaos
Thank you!
So, something like this?

Code: Select all

force = CustomCentroidBondForce(2, "k(x1-x0)^2")
force.addPerBondParameter("k")
force.addPerBondParameter("x0")
force.addGroup(particles1)
force.addGroup(particles2)
force.addBond([0], [k, x0])
force.addBond([1], [k, x0])

Re: COM restraints using CustomCentroidBondForce

Posted: Tue Jan 29, 2019 4:10 pm
by peastman
Right. Except pass 1 as the first argument to the constructor, since each bond only depends on one group.

Re: COM restraints using CustomCentroidBondForce

Posted: Wed Jan 30, 2019 7:19 am
by khaos
Thanks a lot!!