File: subset_modes.py

package info (click to toggle)
mmtk 2.7.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,788 kB
  • ctags: 6,600
  • sloc: python: 18,050; ansic: 12,400; makefile: 129; csh: 3
file content (47 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# A normal mode calculation in the subspace of a part of the total system.
#

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ForceFields import Amber94ForceField
from MMTK.NormalModes import VibrationalModes
from MMTK.Subspace import Subspace
from MMTK.Minimization import ConjugateGradientMinimizer
from MMTK.Trajectory import StandardLogOutput

from Scientific import N

# Construct system
universe = InfiniteUniverse(Amber94ForceField())
universe.protein1 = Protein('bala1')
universe.protein2 = Protein('bala1')
universe.protein2.translateBy(Vector(1., 0., 0.))

# Define normal mode subspace
class SubsetSubspace(Subspace):

    def __init__(self, universe, objects):
        vectors = []
        for a in objects.atomList():
            for d in [Vector(1.,0.,0.), Vector(0.,1.,0.), Vector(0.,0.,1.)]:
                v = ParticleProperties.ParticleVector(universe)
                v[a] = d
                vectors.append(v)
        Subspace.__init__(self, universe, vectors)

subspace = SubsetSubspace(universe, universe.protein1)

# Minimize
minimizer = ConjugateGradientMinimizer(universe,
                                       actions=[StandardLogOutput(50)])
minimizer(convergence = 1.e-3, steps = 10000)

# Calculate normal modes
modes = VibrationalModes(universe, subspace=subspace)

# Print frequencies
for mode in modes:
    print mode

# Show animation of the first mode 
modes[0].view()