per-bond energies
- Justin MacCallum
- Posts: 16
- Joined: Tue Dec 09, 2008 2:47 pm
per-bond energies
Is there any way to get per-bond energies out of the kernels and into the State objects? For example, I might add a HarmonicBondForce to the system and then add many bonds. For our particular application, it is necessary to get the energies of the individual bonds. Is that possible using the existing classes? I suspect it is not, but in that case, can you see a way to allow a custom kernel to return a vector of energies?
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: per-bond energies
Hi Justin,
No, it doesn't break out the energy into individual bond terms. You could, of course, update the bond parameters so that only one bond has a nonzero k, evaluate the energy, and then repeat. But that's going to be really slow, since it takes N energy evaluations for N bonds.
If you only need this for harmonic bonds, you're probably better off just getting the positions and calculating the energies yourself, since the calculation to evaluate a single bond is trivial. If you need this for something more complicated, that might be less acceptable.
Peter
No, it doesn't break out the energy into individual bond terms. You could, of course, update the bond parameters so that only one bond has a nonzero k, evaluate the energy, and then repeat. But that's going to be really slow, since it takes N energy evaluations for N bonds.
If you only need this for harmonic bonds, you're probably better off just getting the positions and calculating the energies yourself, since the calculation to evaluate a single bond is trivial. If you need this for something more complicated, that might be less acceptable.
Peter
- Justin MacCallum
- Posts: 16
- Joined: Tue Dec 09, 2008 2:47 pm
Re: per-bond energies
Hi Peter,
I assmed the existing kernels wouldn't break this up per bond. Is there anyway to squeeze that functionality into a new kernel that still sits in the rest of the openmm framework? We currently calculate all of these per bond energies on the CPU, but it's very slow because we have large numbers of them.
I assmed the existing kernels wouldn't break this up per bond. Is there anyway to squeeze that functionality into a new kernel that still sits in the rest of the openmm framework? We currently calculate all of these per bond energies on the CPU, but it's very slow because we have large numbers of them.
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: per-bond energies
Sure, you could write a plugin to do this. It would take the place of the HarmonicBondForce, and compute the same interaction, but write out each energy to an array in global memory. You could start by copying the code from HarmonicBondForce and just making a few minor changes.
Peter
Peter