Hi,
I'm writing my C++ application with OpenMM C++ API. Given a system object, what's the easiest way to get the values of charge, sigma, and epsilon for all the particles?
The method I'm using is first getting the force from system, finding out which force is non bonded force and the non-bonded force object has a method called getParticelParameters(). The tricky thing of doing this is to figure out which force index is nonbonded force. Now I'm using force group num 6 and assuming the non bonded force's force group num is always 6. Is this true? I also try to find if there is an enumeration type defining force group numbers and couldn't find it.
Xinqiang Ding
Accese charge, sigma and epsilon from system C++ object
- Xinqiang Ding
- Posts: 33
- Joined: Tue May 05, 2015 2:27 pm
- Jason Swails
- Posts: 47
- Joined: Mon Jan 07, 2013 5:11 pm
Re: Accese charge, sigma and epsilon from system C++ object
You definitely can't rely on this. This happens to be true if you serialize a system from CharmmPsfFile in the OpenMM application layer, but this won't really be true for any other System in general. The reason it's not specified is because this is a user-definable variable. By default, all force groups are 0 unless you change them (the CharmmPsfFile class changes them explicitly).negelis wrote:Now I'm using force group num 6 and assuming the non bonded force's force group num is always 6. Is this true? I also try to find if there is an enumeration type defining force group numbers and couldn't find it.
The appropriate thing to do here is attempt a dynamic cast to NonbondedForce and check against NULL when searching through all of the forces. If it's not NULL, then that's the NonbondedForce. Here are some examples in the OpenMM source code where this type of pattern is used to determine a specific subclass that's being used: https://github.com/pandegroup/openmm/bl ... #L153-L171
- Xinqiang Ding
- Posts: 33
- Joined: Tue May 05, 2015 2:27 pm
Re: Accese charge, sigma and epsilon from system C++ object
Thanks, Jason! It works.
Xinqiang
Xinqiang