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 |
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 |
|
|
41 |
|
indices = [] |
42 |
|
pvqj = [] |
43 |
|
p = [] |
44 |
+ |
wrap = [] |
45 |
|
v = [] |
46 |
|
q = [] |
47 |
|
j = [] |
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 |
|
|
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]) |
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: |
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): |
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 |
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): |
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 |