Hi there,
I wonder if CustomNonBonded forces still need to be applied on the same particles and on the same Exclusion/Exception list in OpenMM 5.0. If I decided to learn how to write a new plugin in OpenMM what can I gain in terms of implementation of different non bonded forces applied to different groups of atoms ? What can I do in a plugin that I cannot do with the standard API. What level of control do I have?
Cheers,
Gaetano
Custom Non Bonded interactions in OpenMM5
- Gaetano Calabro'
- Posts: 24
- Joined: Fri Feb 24, 2012 11:48 am
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Custom Non Bonded interactions in OpenMM5
CustomNonbondedForce is always applied to all particles. It's fine if the force happens to be zero for some particles, but there's no performance benefit from doing that. If you want to apply a force to only a very small number of particles, it might be better to use a CustomBondedForce and explicitly add every particle pair as a "bond". But that will only be faster if you're applying it to a very small fraction of the particles.
Can you describe what you're interested in doing? By writing a plugin you can do "almost anything", but the amount of work required will vary enormously depending on what you want to do.
Peter
Can you describe what you're interested in doing? By writing a plugin you can do "almost anything", but the amount of work required will vary enormously depending on what you want to do.
Peter
- Gaetano Calabro'
- Posts: 24
- Joined: Fri Feb 24, 2012 11:48 am
Re: Custom Non Bonded interactions in OpenMM5
Dear Peter,
Thanks for your prompt reply. I'm trying to implement the single topology method (alchemical transformations) for the calculation of free energy changes. To do so I have defined hard, to dummy and from dummy solute atoms. These groups of atoms interact differently with the solvent molecules. Until now I have set per particle parameters that I can switch on/off to select which force field to apply (I have done this because of the restriction on CustomNonBonded interactions: they must be applied on the same particles with the same exclusion/exception list). I have ended up with a very complicated custom non bonded energy expressions. So I wonder if writing a plugin would produce cleaner and more efficient code (but I have to learn how to do it!!). Some time ago I implemented a non bonded interaction using a CustomBonded force but I had some problems with periodic conditions. Can you handle pbc conditions using CustomBonded in OpenMM? I have a final question. Is it possible to define a custom non bonded force which depends on other custom forces? Do the forces must be independent each other? If so, in an OpenMM plugin would be possible to break this rule? Would it be very complicated to do?
I'm sorry for my long post and for all my questions.
Thanks again
Gaetano.
Thanks for your prompt reply. I'm trying to implement the single topology method (alchemical transformations) for the calculation of free energy changes. To do so I have defined hard, to dummy and from dummy solute atoms. These groups of atoms interact differently with the solvent molecules. Until now I have set per particle parameters that I can switch on/off to select which force field to apply (I have done this because of the restriction on CustomNonBonded interactions: they must be applied on the same particles with the same exclusion/exception list). I have ended up with a very complicated custom non bonded energy expressions. So I wonder if writing a plugin would produce cleaner and more efficient code (but I have to learn how to do it!!). Some time ago I implemented a non bonded interaction using a CustomBonded force but I had some problems with periodic conditions. Can you handle pbc conditions using CustomBonded in OpenMM? I have a final question. Is it possible to define a custom non bonded force which depends on other custom forces? Do the forces must be independent each other? If so, in an OpenMM plugin would be possible to break this rule? Would it be very complicated to do?
I'm sorry for my long post and for all my questions.
Thanks again
Gaetano.
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Custom Non Bonded interactions in OpenMM5
Sorry for the delay in replying.
CustomBondForce does not support applying periodic boundary conditions, so that isn't going to work for you.
Assuming you want to write a plugin, there are a few approaches you can take. First, you could write a bonded force that works very similarly to what you would do with CustomBondForce, only applying periodic boundary conditions. That wouldn't be too hard to do: CudaBondedUtilities or OpenCLBondedUtilities makes it pretty easy to create new bonded forces. This will be fast as long as the number of "bonds" is reasonably small.
Second, you could create a nonbonded force similar to what you would do with CustomNonbondedForce: all particles interact with all other particles. This is also pretty easy to do with CudaNonbondedUtilities or OpenCLNonbondedUtilities. You might be able to make the resulting GPU code a bit simpler and more efficient, so it could end up being a little faster than your CustomNonbondedForce. But it's still going to have the same algorithmic complexity.
Another option is to create a "nonbonded force" that only applies to a subset of the particles. This gets a lot more complicated, because you can't use the infrastructure (building a neighbor list, efficiently computing interactions in groups, etc.) provided by the existing utilities. You certainly can do it, and this would probably end up being the fastest solution, but it's by far the most work.
So the question is, how much work are you willing to put in, and how important is it to you to get the best possible performance?
CustomNonbondedForce cannot depend on other forces. But if you write a plugin, you can definitely implement a force that depends on other forces.
Peter
CustomBondForce does not support applying periodic boundary conditions, so that isn't going to work for you.
Assuming you want to write a plugin, there are a few approaches you can take. First, you could write a bonded force that works very similarly to what you would do with CustomBondForce, only applying periodic boundary conditions. That wouldn't be too hard to do: CudaBondedUtilities or OpenCLBondedUtilities makes it pretty easy to create new bonded forces. This will be fast as long as the number of "bonds" is reasonably small.
Second, you could create a nonbonded force similar to what you would do with CustomNonbondedForce: all particles interact with all other particles. This is also pretty easy to do with CudaNonbondedUtilities or OpenCLNonbondedUtilities. You might be able to make the resulting GPU code a bit simpler and more efficient, so it could end up being a little faster than your CustomNonbondedForce. But it's still going to have the same algorithmic complexity.
Another option is to create a "nonbonded force" that only applies to a subset of the particles. This gets a lot more complicated, because you can't use the infrastructure (building a neighbor list, efficiently computing interactions in groups, etc.) provided by the existing utilities. You certainly can do it, and this would probably end up being the fastest solution, but it's by far the most work.
So the question is, how much work are you willing to put in, and how important is it to you to get the best possible performance?
CustomNonbondedForce cannot depend on other forces. But if you write a plugin, you can definitely implement a force that depends on other forces.
Peter
- Gaetano Calabro'
- Posts: 24
- Joined: Fri Feb 24, 2012 11:48 am
Re: Custom Non Bonded interactions in OpenMM5
Hi Peter,
Thanks a lot for your help and support. I'll try to write a plug in.
Cheers,
Gaetano
Thanks a lot for your help and support. I'll try to write a plug in.
Cheers,
Gaetano