source: universe.py@ 3fbbfbb

Last change on this file since 3fbbfbb was 3fbbfbb, checked in by Jan Meinke <j.meinke@…>, 14 years ago

Move to doxygen comments and smmp_p.

Doxygen comments in Fortran are !> ... !! ... !<. I'm planning move the API documentation from the
lyx file into the code. This should make it easier to get documentation for all the common block
variables as well.

Use import smmp_p to indicate the parallel version of the Python bindings.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1# universe.py
2#
3# Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
4# Jan H. Meinke, Sandipan Mohanty
5#
6import smmp_p as smmp
7from math import *
8
9class Universe:
10 """Describes the environment of the simulation. Including the temperature,
11 the solvent, and the force field. This class keeps track of all the
12 molecules.
13 """
14
15 def __init__(self, T = 300, ff = 'ecepp3', st = 1, libdir = 'SMMP/'):
16 self.setTemperature(T)
17 if ff == 'ecepp3':
18 smmp.epar_l.flex = 0
19 smmp.epar_l.sh2 = 0
20 smmp.epar_l.epsd = 0
21 smmp.epar_l.ientyp=0
22 elif ff == 'ecepp2':
23 smmp.epar_l.flex = 0
24 smmp.epar_l.sh2 = 1
25 smmp.epar_l.epsd = 0
26 smmp.epar_l.ientyp=0
27 elif ff == 'flex':
28 smmp.epar_l.flex = 1
29 smmp.epar_l.sh2 = 0
30 smmp.epar_l.epsd = 0
31 smmp.epar_l.ientyp=0
32 smmp.epar_l.tesgrd = 0
33 smmp.isolty.itysol = st
34 smmp.init_energy(libdir)
35 self.__objects = []
36 self.__boxSize = 10
37 smmp.updchois.upchswitch = 0
38 smmp.updchois.rndord = 0
39 smmp.updchois.bgsprob = 0
40
41 def add(self, m):
42 self.__objects.append(m)
43
44 def energy(self):
45 """Return the total energy of this universe."""
46 return smmp.energy()
47
48 def rgyr(self):
49 """Radius of gyration of the entire system."""
50 return smmp.rgyr(0)[0]
51
52 def endToEnd(self):
53 return smmp.rgyr(0)[1]
54
55 def hbond(self):
56 """Returns the total number of hydrogen bonds in the system"""
57 mhb = 0
58 for i in self.__objects:
59 mhb = mhb + i.hbond()
60 mhb = mhb + smmp.interhbond()
61 return mhb
62
63 def helix(self):
64 return smmp.helix()
65
66 def sheet(self):
67 """Checks if we have any parallel or antiparallel beta-sheets in the
68 system.
69 """
70 minStrandContent = 2
71 minHydrogenBonds = 3
72 res = []
73 for i in range(0, len(self.__objects)):
74 if self.__objects[i].strand() >= minStrandContent:
75 for j in range(i, len(self.__objects)):
76 if smmp.h_bond.mmhb[self.__objects[i].id()][self.__objects[j].id()] >= minHydrogenBonds:
77 if self.__objects[j].strand() >= minStrandContent:
78 print "Found a candidate for a sheet between %s and %s." % (i, j)
79 dir1 = self.__objects[i].directionVector()
80 dir2 = self.__objects[j].directionVector()
81 sum = 0
82 for k in range(0, 3):
83 sum += dir1[k] * dir2[k]
84 if sum > 0.7:
85 res.append([i, j, 1])
86 elif sum < -0.7:
87 res.append([i, j, -1])
88 return res
89
90 def temperature(self):
91 """Returns the current temperature of this Universe."""
92 return 1.0 / ( smmp.bet.beta * 1.98773e-3 )
93 ## @brief Sets the temperature value of this Universe.
94 # Be aware that SMMP is not thread save. Changing the temperature may
95 # lead to strange behavior in the current sweep.
96 # @pre T > 0
97 #
98 # @param T temperature in Kelvin.
99 def setTemperature(self, T):
100 if T> 0:
101 smmp.bet.beta = 1.0 / ( T * 1.98773e-3 )
102
103 def boxSize(self):
104 return self.__boxSize
105
106 def objects(self):
107 """Returns the list of interacting things in the universe."""
108 res = self.__objects
109 return res
110
111 def save(self):
112 """Saves the state of this Universe."""
113 pass
114
115if __name__ == '__main__':
116 u=Universe()
Note: See TracBrowser for help on using the repository browser.