Page 1 of 1

Determination of potential energies after simulation

Posted: Tue Dec 03, 2013 8:46 am
by mbeeg
Dear all,
How can I determine the potential energy of the different forces specified in the forcefield (torsion, harmonic bond...) for every frame in my trajectory after the simulation has finished?

Thanks in advanced for your help
All the best
Marten

Re: Determination of potential energies after simulation

Posted: Tue Dec 03, 2013 9:22 am
by proteneer
Hi,

You can use force groups to separate each force into a different group. When you call getState later on, you can query by the forceGroup. Take a look at the API in the docs, and if you have trouble understanding it let us know

Re: Determination of potential energies after simulation

Posted: Tue Dec 03, 2013 11:27 am
by peastman
More precisely, before you create your Context/Simulation, call setForceGroup() on each Force in the System. Something like this:

Code: Select all

for i in range(system.getNumForces()):
    system.getForce(i).setForceGroup(i)
Then to query the energy of group i, call

Code: Select all

context.getState(getEnergy=True, groups=1<<i).getPotentialEnergy()
Peter