Page 1 of 1

Periodic boundary condition for CustomNonbondedForce in CustomCVForce

Posted: Thu Jul 20, 2017 12:31 pm
by negelis
I'm trying to use the CustomCVForce, which uses two CustomNonbonedForce as collective variables. Each CustomNonbonedForce uses CutoffPeriodic. The cutoff distance is 1.4 nanometer and the box size of the system is 2.89 nanometer.When I try to create the context, it raises the Exception:
CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size.
When I add these two CustomNonbonedForces to the system directly, there is no exception.
Any idea about why it happens?

Here are my thoughts:
In order to add a CustomCVForce, OpenMM will create a new subsystem and a new subcontext. I'm wondering if the new subsystem or new context will use the box size of the original system to which the CustomCVForce is added.

Thanks,
Xinqiang

Re: Periodic boundary condition for CustomNonbondedForce in CustomCVForce

Posted: Fri Jul 21, 2017 10:02 am
by peastman
You're exactly right. When it created the internal System for evaluating CVs, it didn't copy over the default periodic box vectors. It did copy over the current box vectors every time it evaluated CVs, so it still produced correct results (as long as you didn't hit that exception). But in your case, it was getting stopped by the initial check on the default vectors when the inner context was first created.

I just posted a pull request with the fix: https://github.com/pandegroup/openmm/pull/1861. Could you test it and make sure it fixes the problem for you?

Peter

Re: Periodic boundary condition for CustomNonbondedForce in CustomCVForce

Posted: Fri Jul 21, 2017 12:15 pm
by negelis
Thanks for the quick fix. I have tested it and it does fix the problem.

Xinqiang

Re: Periodic boundary condition for CustomNonbondedForce in CustomCVForce

Posted: Fri Jul 21, 2017 1:00 pm
by peastman
Thanks! I just merged the fix.