[MMTK] Potential Energy and Energy Gradients

khinsen at cea.fr khinsen at cea.fr
Fri Nov 18 09:10:14 CET 2005

On 17.11.2005, at 21:11, vanitha at cs.wisc.edu wrote:

> Do any of you have sample code in Python that gets the potential  
> energy
> and the energy gradient for a given configuration (co-ordinates) of a
> protein?

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ForceFields import Amber94ForceField

universe = InfiniteUniverse(Amber94ForceField())
universe.protein = Protein('193l.pdb')

energy, gradients = universe.energyAndGradients()

print energy
print gradients.norm()

This prints:

You can also get all the individual energy terms with:

print universe.energyTerms()

{'electrostatic/pair sum': -17300.441764971772, 'cosine dihedral  
angle': 2163.4180900338383, 'harmonic bond': 382.00159302574025,  
'electrostatic': -17300.441764971772, 'harmonic bond angle':  
884.09017317857695, 'Lennard-Jones': -1063.4983249429888}

> I'm having a really hard time wading through the Python/C API calls  
> within
> MMTK_minimization.c to figure this out!

In C modules, an energy evaluation call looks like this (line 188 for  

     (*evaluator->eval_func)(evaluator, &p_energy, configuration, i >  

p_energy points to a structure that stores all the enery terms, and  
also a pointer to the gradient array. All this is defined in Include/ 

Konrad Hinsen
Laboratoire Leon Brillouin (CEA-CNRS), CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: khinsen at cea.fr

More information about the mmtk mailing list