Print dipol vectors
- Michael Schauperl
- Posts: 22
- Joined: Wed Sep 04, 2013 6:10 am
Print dipol vectors
Hi,
I just started using OpenMM and would need some help by setting up easy things.
Can you tell me how i can set up a reporter who is writing my the induced dipol moments(Amoeba) of an atom every x steps?
Thanks,
Michael
I just started using OpenMM and would need some help by setting up easy things.
Can you tell me how i can set up a reporter who is writing my the induced dipol moments(Amoeba) of an atom every x steps?
Thanks,
Michael
- Peter Eastman
- Posts: 2548
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Print dipol vectors
Hi Michael,
Unfortunately, there's no API to query the induced dipole moments of individual atoms. It would be a reasonable thing to add, though. Enter it into the feature request tracker (under "Advanced" at the left side of this page) and I'll see if we can get it into the next version.
In the mean time, it's still possible if you don't mind hacking the source code. I can provide details if you're interested in trying that.
Peter
Unfortunately, there's no API to query the induced dipole moments of individual atoms. It would be a reasonable thing to add, though. Enter it into the feature request tracker (under "Advanced" at the left side of this page) and I'll see if we can get it into the next version.
In the mean time, it's still possible if you don't mind hacking the source code. I can provide details if you're interested in trying that.
Peter
- Michael Schauperl
- Posts: 22
- Joined: Wed Sep 04, 2013 6:10 am
Re: Print dipol vectors
Hi Peter,
If you can provide some details on that for me, it would be great and i give it a go.
Thanks
If you can provide some details on that for me, it would be great and i give it a go.
Thanks
- Peter Eastman
- Posts: 2548
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Print dipol vectors
Hi Michael,
To start with, if you haven't already done so, take a look at the developer guide. It gives information about the overall architecture and about how plugins (such as AMOEBA) are implemented.
As your starting point, take a look at AmoebaMultipoleForce::getSystemMultipoleMoments(). That computes the overall multipole moments of the whole system, which involves querying the individual induced dipoles, so you can see how that works. AmoebaMultipoleForce::getSystemMultipoleMoments() invokes getSystemMultipoleMoments() on its AmoebaMultipoleForceImpl, which in turn invokes getSystemMultipoleMoments() on its CalcAmoebaMultipoleForceKernel. So take a look in AmoebaCudaKernels.cpp and find CudaCalcAmoebaMultipoleForceKernel::getSystemMultipoleMoments().
The critical lines in that are line 1789, which ensures that the multipole moments have been calculated:
and then line 1723, which downloads them from the GPU:
inducedDipoleVec now contains all the atom dipole moments. The first three elements are the x, y, and z components for the first atom, the next three are the second atom, etc.
Does that make sense?
Peter
To start with, if you haven't already done so, take a look at the developer guide. It gives information about the overall architecture and about how plugins (such as AMOEBA) are implemented.
As your starting point, take a look at AmoebaMultipoleForce::getSystemMultipoleMoments(). That computes the overall multipole moments of the whole system, which involves querying the individual induced dipoles, so you can see how that works. AmoebaMultipoleForce::getSystemMultipoleMoments() invokes getSystemMultipoleMoments() on its AmoebaMultipoleForceImpl, which in turn invokes getSystemMultipoleMoments() on its CalcAmoebaMultipoleForceKernel. So take a look in AmoebaCudaKernels.cpp and find CudaCalcAmoebaMultipoleForceKernel::getSystemMultipoleMoments().
The critical lines in that are line 1789, which ensures that the multipole moments have been calculated:
Code: Select all
ensureMultipolesValid(context);
Code: Select all
inducedDipole->download(inducedDipoleVec);
Does that make sense?
Peter
- Peter Eastman
- Posts: 2548
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Print dipol vectors
Ok, I went ahead and implemented this myself. If you check out the latest code from github, you'll find that AmoebaMultipoleForce now has a method called getInducedDipoles(). Try it out and see if it works for you.
Peter
Peter
- Michael Schauperl
- Posts: 22
- Joined: Wed Sep 04, 2013 6:10 am
Re: Print dipol vectors
Hi Peter,
Thanks for including that feature. Unfortunately i was quite busy this week, so i wasn't able to try.
I will try it as soon as possible.
But a second question occured this week. Is it possible to add a charge plasma or a background charge grid to a OpenMM simulation?
Michael
Thanks for including that feature. Unfortunately i was quite busy this week, so i wasn't able to try.
I will try it as soon as possible.
But a second question occured this week. Is it possible to add a charge plasma or a background charge grid to a OpenMM simulation?
Michael
- Peter Eastman
- Posts: 2548
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Print dipol vectors
Could you describe what you mean? If you're using PME, it already ignores the 0 frequency component, which is equivalent to filling all of space with a uniform charge density to neutralize the system. Is that what you're talking about, or something else?
Peter
Peter
- Michael Schauperl
- Posts: 22
- Joined: Wed Sep 04, 2013 6:10 am
Re: Print dipol vectors
That was exactly what i meant. Thanks for the quick response.
I just tried to do what you suggested to print out the dipol vectors, but i am not sure if i am doing everything in a sensible way.
Can you explain how i create a AmoebaMultipoleForce object in a sensible way. so what arguments i have to pass and so on. because if i create an AMF object and then call for example getNumMultipoles i get always 0)
I just tried to do what you suggested to print out the dipol vectors, but i am not sure if i am doing everything in a sensible way.
Can you explain how i create a AmoebaMultipoleForce object in a sensible way. so what arguments i have to pass and so on. because if i create an AMF object and then call for example getNumMultipoles i get always 0)
- Peter Eastman
- Posts: 2548
- Joined: Thu Aug 09, 2007 1:25 pm
Re: Print dipol vectors
I assume you're creating your system with ForceField.createSystem(), specifying the AMOEBA XML file? If so, then your system already contains an AmoebaMultipoleForce. You can get it like this:
Peter
Code: Select all
multipole = [f for f in system.getForces() if isinstance(f, AmoebaMultipoleForce)][0]
- Michael Schauperl
- Posts: 22
- Joined: Wed Sep 04, 2013 6:10 am
Re: Print dipol vectors
Thanks for your help so far. I am not sure what that third argument
std::vector<(Vec3,std::allocator<(Vec3)>)> dipoles
should be and how i define it.
Thanks for your help again.
Michael
std::vector<(Vec3,std::allocator<(Vec3)>)> dipoles
should be and how i define it.
Thanks for your help again.
Michael