Page 1 of 2

Restraints with reference position changing based on system dimension

Posted: Sat Feb 09, 2019 2:18 pm
by khaos
Dear OpenMM developers,

Is there a way to construct a positional restraint with the reference position changing based on the system dimensions (in NPT ensemble)?
For example, if I want to apply a restraint that maintains an atom at the center of a system, how should I construct the CustomExternalForce?

Thanks,
Jumin

Re: Restraints with reference position changing based on system dimension

Posted: Sat Feb 09, 2019 4:46 pm
by peastman
How about this. Put a dummy atom at the reference position. Set its mass to 0 and its charge and epsilon to 0. That way nothing should affect it except the barostat, which should scale its position with the box. Then you can add a bond between the real atom and the dummy atom.

Re: Restraints with reference position changing based on system dimension

Posted: Mon Feb 11, 2019 8:04 am
by khaos
Thank you for the suggestion.
So, are you suggesting to use CustomBondForce?
However, if I apply a bond restraint between dummy and real atom, the position of dummy can be affected by the restraint force?

Re: Restraints with reference position changing based on system dimension

Posted: Mon Feb 11, 2019 8:14 am
by khaos
Oh... The position of dummy atom may not be affected because mass is zero?

Re: Restraints with reference position changing based on system dimension

Posted: Mon Feb 11, 2019 9:41 am
by peastman
Right. You can use CustomBondForce, or just HarmonicBondForce if you want the restraints to be harmonic.

Re: Restraints with reference position changing based on system dimension

Posted: Thu Feb 14, 2019 2:28 pm
by simtkolos
Peter, it all sounds straightforward, but when I tried to define dummy atoms and adding the bonds I got lost. Could you show an example how to do what you are suggesting? I have about 100 CA atoms that I'd like to restrain, though, not just one.

Many thanks,

Istvan

Re: Restraints with reference position changing based on system dimension

Posted: Thu Feb 14, 2019 3:51 pm
by peastman
Where are you getting lost? You add the bond just like any other bond. For example,

Code: Select all

force.addBond(atomIndex, dummyAtomIndex, 0, k)
where force is a HarmonicBondForce. If the dummy atoms have their masses set to 0, the bond force won't cause them to move.

Re: Restraints with reference position changing based on system dimension

Posted: Fri Feb 15, 2019 8:31 am
by simtkolos
Sorry, I am embarrassed to say but I don't know how to add a dummy atom.

Re: Restraints with reference position changing based on system dimension

Posted: Fri Feb 15, 2019 10:03 am
by peastman
Just call

Code: Select all

system.addParticle(0)
And then on the NonbondedForce, call

Code: Select all

nb.addParticle(0, 1, 0)

Re: Restraints with reference position changing based on system dimension

Posted: Fri Feb 15, 2019 10:39 am
by simtkolos
Thanks, Peter! I really appreciate your time, these small things are so difficult to figure out for mortals. :)