[MMTK] Writing universe out to a file
Jaroslaw Kalinowski
jak at biogeo.uw.edu.pl
Wed Dec 7 12:49:12 CET 2005
Have you checked that universe.writeToFile is in fact executed?
As you increment iter counter at the end of the function confition
if iter >= maxIter:
will never be true.
On Wed, 7 Dec 2005 vanitha at cs.wisc.edu wrote:
> I have a piece of code that minimizes the configuration of a protein. At
> the end of the minimization phase I invoke
> universe.writeToFile('somename.pdb') to write my minimized configuration
> to a PDB. I see no errors but I don't see my file in the current directory
> either. Is it possible that this is saved in a different folder?
>
> Here is my minimization function:
>
> 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()
> print "Energy = ", energy
> print "Gradient Norm = ", gradient.norm()
>
> iter = 0
>
> while iter < maxIter:
> # Choose the value of alfa using a Backtracking Line Search
> initialAlfa = 1
> alfa = initialAlfa
> direction = -gradient
> universeCopy = copy(universe)
> alfa = backtrackingLineSearch( universeCopy, initialAlfa,
> maxIter)
>
> #print "alfa = ", alfa
>
> # Update the configuration
> universe.addToConfiguration(alfa*direction)
>
> # Get the energy and gradients of the current configuration
> energy, gradient = universe.energyAndGradients()
> print "Energy = ", energy
> print "Gradient Norm = ", gradient.norm()
> print "Iteration = ", iter
>
> # Termination Criteria
> if gradient.norm() <= tolerance:
> universe.writeToFile('1bp2_min_s.pdb')
> break
> if iter >= maxIter:
> universe.writeToFile('1bp2_min_s.pdb')
> break
>
> # Update the iteration counter
> iter = iter + 1
>
> Here is the code that invokes it:
>
> from MMTK import *
> from MMTK.Proteins import Protein
> from MMTK.ParticleProperties import ParticleVector
> import SteepestDescent
> from MMTK.ForceFields import Amber94ForceField
>
> universe = InfiniteUniverse(Amber94ForceField())
> universe.Protein = Protein('1bp2.pdb')
> SteepestDescent.Minimize(universe, 1000, 0.0001)
>
>
> Thanks,
>
> - Vanitha
>
>
>
>
>
>
> _______________________________________________
> mmtk maillist - mmtk at starship.python.net
> http://starship.python.net/mailman/listinfo/mmtk
>
More information about the mmtk
mailing list