[MMTK] Adding displacements to Protein Configuration

vanitha at cs.wisc.edu vanitha at cs.wisc.edu
Tue Nov 29 22:45:23 CET 2005


> 2) Can I use the universe.addToConfiguration(some particle vector)
> method
> to add a displacement to the current configuration?

Yes. Note that the displacements must be given as a ParticleVector
object - an array will not work.


I couldn't get this to work! I have copied and pasted the code from
test.py and SteepestDescent.py here:

Code in test.py:

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

universe = InfiniteUniverse(Amber94ForceField())
universe.Protein = Protein('1bp2.pdb')
SteepestDescent.Minimize(universe, 100, 0.0001)

Code in SteepestDescent.py:

from MMTK import *
from MMTK.ForceFields import Amber94ForceField
from MMTK.ParticleProperties import ParticleVector

def Minimize( universe, maxIter, tolerance):
 	# The current configuration of the universe is the initial guess

 	energy, gradient = universe.energyAndGradients()

	iter = 1

 	while 1:
 		direction = ParticleVector( universe, -gradient.array);

		# Choose the value of alfa using a Backtracking Line Search
		initialAlfa = 1
		alfa = initialAlfa
		#alfa = backtrackingLineSearch( universe, initialAlfa, maxIter)

		# Update the configuration
		universe.addToConfiguration( universe, direction)

		# Get the energy and gradients of the current configuration
		energy, gradient = universe.energyAndGradients()
		print gradient.norm()
		print iter

		# Termination Criteria
		if gradient.norm() <= tolerance: break
		if iter >= maxIter: break

		# Update the iteration counter
		iter = iter + 1


My code fails when it hits the universe.addToConfiguration(..) line. I
have attached the error along with this email. (file Error).

Note that direction is a particle vector... wonder why this is causing a
problem. Also, a few other questions:

1) Once I find the minimum energy configuration using my code, how do I
update the PDB to reflect the new atomic positions? Some sample code will
be greatly appreciated.

2) Is there any way to just get the gradients without having to get the
energy as well. I'm assuming that function evaluations are not cheap and
I'd like to avoid them if possible.


Thanks,

- Vanitha







-------------- next part --------------
A non-text attachment was scrubbed...
Name: Error
Type: application/octet-stream
Size: 965 bytes
Desc: not available
Url : http://starship.python.net/pipermail/mmtk/attachments/20051129/ef6b839a/Error.obj


More information about the mmtk mailing list