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

Comparing trunk/src/applications/utilities/md2md (file contents):
Revision 1383 by gezelter, Thu Oct 22 19:12:14 2009 UTC vs.
Revision 2043 by gezelter, Fri Nov 14 19:04:27 2014 UTC

# Line 1 | Line 1
1 < #!/usr/bin/env python
1 > #!@PYTHON_EXECUTABLE@
2   """MetaData file remapper
3  
4   Takes a MetaData file and maps all StuntDoubles back to the periodic box.
# Line 24 | Line 24 | __author__ = "Dan Gezelter (gezelter@nd.edu)"
24   """
25  
26   __author__ = "Dan Gezelter (gezelter@nd.edu)"
27 < __version__ = "$Revision: 1.4 $"
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__ = "OOPSE"
30 > __license__ = "OpenMD"
31  
32   import sys
33   import getopt
# Line 52 | Line 52 | def readFile(mdFileName):
52  
53   def readFile(mdFileName):
54      mdFile = open(mdFileName, 'r')        
55 <    # Find OOPSE version info first
55 >    # Find OpenMD version info first
56      line = mdFile.readline()
57      while 1:
58 <        if '<OOPSE version=' in line:
59 <            OOPSEversion = line
58 >        if '<OOPSE version=' in line or '<OpenMD version=' in line:
59 >            OpenMDversion = line
60              break
61          line = mdFile.readline()
62          
# Line 119 | Line 119 | def readFile(mdFileName):
119                          myIndex = int(L[0])
120                          indices.append(myIndex)
121                          pvqj.append(L[1])
122 <                        x = float(L[2])
123 <                        y = float(L[3])
124 <                        z = float(L[4])
125 <                        p.append([x, y, z])
126 <                        vx = float(L[5])
127 <                        vy = float(L[6])
128 <                        vz = float(L[7])
129 <                        v.append([vx, vy, vz])
130 <                        if 'pvqj' in L[1]:
131 <                            qw = float(L[8])
132 <                            qx = float(L[9])
133 <                            qy = float(L[10])
134 <                            qz = float(L[11])
135 <                            q.append([qw, qx, qy, qz])
136 <                            jx = float(L[12])
137 <                            jy = float(L[13])
138 <                            jz = float(L[14])
139 <                            j.append([jx, jy, jz])
122 >                        i = 2
123 >                        if 'p' in L[1]:                              
124 >                            x = float(L[i])
125 >                            y = float(L[i+1])
126 >                            z = float(L[i+2])                            
127 >                            p.append([x, y, z])
128 >                            i = i+3
129 >                        else:
130 >                            p.append([0.0, 0.0, 0.0])
131 >                        if 'v' in L[1]:                              
132 >                            vx = float(L[i])                                
133 >                            vy = float(L[i+1])
134 >                            vz = float(L[i+2])
135 >                            v.append([vx, vy, vz])
136 >                            i = i+3
137                          else:
138 +                            v.append([0.0, 0.0, 0.0])
139 +                        if 'q' in L[1]:
140 +                            qw = float(L[i])
141 +                            qx = float(L[i+1])
142 +                            qy = float(L[i+2])
143 +                            qz = float(L[i+3])
144 +                            q.append([qw, qx, qy, qz])
145 +                            i = i+4
146 +                        else:
147                              q.append([0.0, 0.0, 0.0, 0.0])
148 +                        if 'j' in L[1]:
149 +                            jx = float(L[i])
150 +                            jy = float(L[i+1])
151 +                            jz = float(L[i+2])
152 +                            j.append([jx, jy, jz])
153 +                            i = i+3
154 +                        else:
155                              j.append([0.0, 0.0, 0.0])
156                                                
157                          line = mdFile.readline()
# Line 153 | Line 166 | def writeFile(outputFileName,repeatX,repeatY,repeatZ):
166   def writeFile(outputFileName,repeatX,repeatY,repeatZ):
167      outputFile = open(outputFileName, 'w')
168  
169 <    outputFile.write("<OOPSE version=4>\n");
169 >    outputFile.write("<OpenMD version=1>\n");
170  
171      print "writing MetaData"
172      for metaline in metaData:
# Line 187 | Line 200 | def writeFile(outputFileName,repeatX,repeatY,repeatZ):
200      deco = [ (index, i) for i, index in enumerate(indices) ]
201      deco.sort()
202      whichSD = 0
203 <    for index in range(len(deco)):
204 <        (index,i) = deco[index]
205 <        print i
206 <        for ii in range(repeatX):
207 <            for jj in range(repeatY):
208 <                for kk in range(repeatZ):                    
203 >    for ii in range(repeatX):
204 >        for jj in range(repeatY):
205 >            for kk in range(repeatZ):
206 >                for index in range(len(deco)):
207 >                    (index,i) = deco[index]
208 >                    print i
209                      myP = []
210                      myP.append(p[i][0] + ii*Hmat[0][0] + jj*Hmat[1][0] + kk*Hmat[2][0])
211                      myP.append(p[i][1] + ii*Hmat[0][1] + jj*Hmat[1][1] + kk*Hmat[2][1])
212                      myP.append(p[i][2] + ii*Hmat[0][2] + jj*Hmat[1][2] + kk*Hmat[2][2])
213 <                        
214 <                    if (pvqj[i] == 'pv'):
215 <                        outputFile.write("%10d %7s %18.10g %18.10g %18.10g %14e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2]))
213 >    
214 >                    if (pvqj[i] == 'p'):
215 >                        outputFile.write("%10d %7s %18.10g %18.10g %18.10g\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2]))
216 >
217 >                    elif (pvqj[i] == 'pv'):
218 >                        outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2]))
219 >                    elif (pvqj[i] == 'pq'):
220 >                        outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], q[i][0], q[i][1], q[i][2], q[i][3]))
221                      elif (pvqj[i] == 'pvqj'):
222                          outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2], q[i][0], q[i][1], q[i][2], q[i][3], j[i][0], j[i][1], j[i][2]))
223                      whichSD = whichSD + 1
224  
225      outputFile.write("    </StuntDoubles>\n")
226      outputFile.write("  </Snapshot>\n")
227 <    outputFile.write("</OOPSE>\n")
227 >    outputFile.write("</OpenMD>\n")
228      outputFile.close()
229  
230   def roundMe(x):

Comparing trunk/src/applications/utilities/md2md (property svn:keywords):
Revision 1383 by gezelter, Thu Oct 22 19:12:14 2009 UTC vs.
Revision 2043 by gezelter, Fri Nov 14 19:04:27 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines