File: example.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 (52 lines) | stat: -rw-r--r-- 2,101 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
48
49
50
51
52
# An example for LangevinDynamics
#

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ForceFields import Amber94ForceField
from MMTK.Dynamics import TranslationRemover, RotationRemover, VelocityScaler
from MMTK.Trajectory import Trajectory, TrajectoryOutput, StandardLogOutput
from LangevinDynamics import LangevinIntegrator

# Define system
universe = InfiniteUniverse(Amber94ForceField())
universe.protein = Protein('bala1')
temperature = 300.*Units.K

# Initialize velocities
universe.initializeVelocitiesToTemperature(temperature)

# Set friction coefficients
friction = universe.masses()*0.01/Units.ps

# Create integrator
integrator = LangevinIntegrator(universe, delta_t=1.*Units.fs,
                                friction=friction, temperature=temperature)

# Equilibration
integrator(steps=10000,
	   actions=[# Scale velocities every 50 steps.
                    VelocityScaler(temperature, 0.1*temperature,
                                   0, None, 50),
                    # Remove global translation every 50 steps.
		    TranslationRemover(0, None, 50),
                    # Remove global rotation every 50 steps.
		    RotationRemover(0, None, 50),
                    # Log output to screen every 500 steps.
                    StandardLogOutput(500)])

# "Production" run
trajectory = Trajectory(universe, "langevin.nc", "w", "Langevin test")
integrator(steps=10000,
           actions = [# Remove global translation every 50 steps.
                      TranslationRemover(0, None, 50),
                      # Remove global rotation every 50 steps.
                      RotationRemover(0, None, 50),
                      # Write every fifth step to the trajectory file.
                      TrajectoryOutput(trajectory, ("time", "energy",
                                                    "thermodynamic",
                                                    "configuration"),
                                       0, None, 10),
                      # Log output to screen every 100 steps.
                      StandardLogOutput(100)])
trajectory.close()