ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/utilities/affineScale
(Generate patch)

Comparing trunk/src/applications/utilities/affineScale (file contents):
Revision 1383 by gezelter, Thu Oct 22 19:12:14 2009 UTC vs.
Revision 1919 by jmarr, Wed Jul 31 18:03:35 2013 UTC

# Line 1 | Line 1
1 < #!/usr/bin/env python
1 > #!@PYTHON_EXECUTABLE@
2   """MetaData affine scaling transform
3  
4   Takes a MetaData file and scales both the periodic box and the
# Line 24 | Line 24 | __author__ = "Dan Gezelter (gezelter@nd.edu)"
24   """
25  
26   __author__ = "Dan Gezelter (gezelter@nd.edu)"
27 < __version__ = "$Revision: 1.3 $"
28 < __date__ = "$Date: 2009-10-22 19:12:14 $"
27 > __version__ = "$Revision$"
28 > __date__ = "$Date$"
29   __copyright__ = "Copyright (c) 2009 by the University of Notre Dame"
30   __license__ = "OpenMD"
31  
# Line 41 | Line 41 | p = []
41   indices = []
42   pvqj = []
43   p = []
44 + wrap = []
45   v = []
46   q = []
47   j = []
# Line 52 | Line 53 | def readFile(mdFileName):
53  
54   def readFile(mdFileName):
55      mdFile = open(mdFileName, 'r')        
56 <    # Find OOPSE version info first
56 >    # Find OpenMD version info first
57      line = mdFile.readline()
58      while 1:
59 <        if '<OOPSE version=' in line:
60 <            OOPSEversion = line
59 >        if '<OOPSE version=' in line or '<OpenMD version=' in line:
60 >            OpenMDversion = line
61              break
62          line = mdFile.readline()
63          
# Line 123 | Line 124 | def readFile(mdFileName):
124                          y = float(L[3])
125                          z = float(L[4])
126                          p.append([x, y, z])
127 +                        wrap.append([0,0,0])
128                          vx = float(L[5])
129                          vy = float(L[6])
130                          vz = float(L[7])
# Line 153 | Line 155 | def writeFile(outputFileName,repeatX,repeatY,repeatZ):
155   def writeFile(outputFileName,repeatX,repeatY,repeatZ):
156      outputFile = open(outputFileName, 'w')
157  
158 <    outputFile.write("<OOPSE version=4>\n");
158 >    outputFile.write("<OpenMD version=1>\n");
159  
160      print "writing MetaData"
161      for metaline in metaData:
# Line 206 | Line 208 | def writeFile(outputFileName,repeatX,repeatY,repeatZ):
208  
209      outputFile.write("    </StuntDoubles>\n")
210      outputFile.write("  </Snapshot>\n")
211 <    outputFile.write("</OOPSE>\n")
211 >    outputFile.write("</OpenMD>\n")
212      outputFile.close()
213  
214   def roundMe(x):
# Line 217 | Line 219 | def wrapVector(myVect):
219  
220   def wrapVector(myVect):
221      scaled = [0.0, 0.0, 0.0]
222 +    wrappingNumber = [0,0,0]
223      for i in range(3):
224          scaled[i] = myVect[i] * BoxInv[i]
225 <        scaled[i] = scaled[i] - roundMe(scaled[i])
225 >        wrappingNumber[i] = roundMe(scaled[i])
226 >        scaled[i] = scaled[i] - wrappingNumber[i]
227          myVect[i] = scaled[i] * Hmat[i][i]
228 <    return myVect
228 >    return myVect, wrappingNumber
229  
230   def dot(L1, L2):
231      myDot = 0.0
# Line 251 | Line 255 | def mapToBox():
255          dpos.append(p[i][0])
256          dpos.append(p[i][1])
257          dpos.append(p[i][2])
258 <        p[i] = wrapVector(dpos)
258 >        p[i], wrap[i] = wrapVector(dpos)
259  
260   def scaleBox(scaleX, scaleY, scaleZ):
261      for i in range(3):
# Line 265 | Line 269 | def scaleCoordinates(scaleX, scaleY, scaleZ):
269  
270   def scaleCoordinates(scaleX, scaleY, scaleZ):
271      for i in range(len(indices)):
272 <        p[i][0] = p[i][0]*scaleX
273 <        p[i][1] = p[i][1]*scaleY
274 <        p[i][2] = p[i][2]*scaleZ
272 >        p[i][0] = p[i][0]*scaleX + wrap[i][0] * Hmat[0][0]
273 >        p[i][1] = p[i][1]*scaleY + wrap[i][1] * Hmat[1][1]
274 >        p[i][2] = p[i][2]*scaleZ + wrap[i][2] * Hmat[2][2]
275  
276   def main(argv):
277      _haveMDFileName = 0

Comparing trunk/src/applications/utilities/affineScale (property svn:keywords):
Revision 1383 by gezelter, Thu Oct 22 19:12:14 2009 UTC vs.
Revision 1919 by jmarr, Wed Jul 31 18:03:35 2013 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines