-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhlcluster.py
165 lines (155 loc) · 6.9 KB
/
hlcluster.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/env python
import sys
import VASP
import re
pos1 = [[ 8.52663112, 14.79337948, 14.52301881],
[ 16.47997580, 14.79343097, 14.51908835],
[ 11.14789630, 14.85687226, 14.51622011],
[ 13.85760488, 14.85722967, 14.51548506],
[ 9.78287211, 12.49254211, 14.51553649],
[ 15.22261961, 12.49238169, 14.51371286],
[ 11.13563815, 10.14933498, 14.51532174],
[ 13.86597088, 10.14847010, 14.51428049],
[ 12.50012880, 7.90943392, 14.51976956],
[ 12.50372460, 12.50075283, 14.72163059],
[ 9.78440676, 17.09766453, 14.48773211],
[ 15.22295554, 17.09739644, 14.48602752],
[ 7.15981020, 12.55477124, 14.48660210],
[ 17.84482988, 12.55353408, 14.48367771],
[ 12.50374400, 17.08727980, 14.47394451],
[ 9.87605186, 7.84598863, 14.48403817],
[ 15.12400216, 7.84505696, 14.48361730],
[ 8.52637045, 10.20520181, 14.47173998],
[ 16.47553419, 10.20431563, 14.47057725],
[ 12.50162082, 15.62744811, 12.44805426],
[ 9.78981284, 10.93427811, 12.44606936],
[ 15.21142132, 10.93350182, 12.44513778],
[ 9.80328010, 15.61779801, 12.45193423],
[ 15.19879468, 15.61737840, 12.45016375],
[ 8.44957785, 13.27629042, 12.45064043],
[ 16.55283128, 13.27448455, 12.44803144],
[ 11.14706080, 8.60486927, 12.44908613],
[ 13.85249392, 8.60483110, 12.44875320],
[ 11.14080909, 13.28417801, 12.37402178],
[ 13.86129087, 13.28384618, 12.37357051],
[ 12.50040244, 10.93013268, 12.37344562],
[ 11.16790993, 17.86382119, 12.37953773],
[ 13.83623659, 17.86393157, 12.37839810],
[ 7.18532081, 10.97162350, 12.37640674],
[ 17.81618039, 10.96917629, 12.37482430],
[ 8.52043182, 8.66069151, 12.37565154],
[ 16.47890651, 8.65897510, 12.37489045],
[ 7.19477108, 15.56239596, 12.31904726],
[ 17.80774841, 15.56122995, 12.31656077],
[ 12.49966163, 6.37471536, 12.31590153],
[ 8.55158958, 17.88809068, 12.32062468],
[ 16.45265851, 17.88723731, 12.31870385],
[ 5.85767123, 13.22339656, 12.31734762],
[ 19.14459556, 13.22189528, 12.31494919],
[ 9.80713808, 6.38527824, 12.31505608],
[ 15.19009880, 6.38373013, 12.31477027],
[ 7.17419958, 18.59601593, 10.22637496],
[ 17.82830097, 18.59530226, 10.22321914],
[ 4.55461164, 14.05906469, 10.22249110],
[ 20.44650799, 14.05754717, 10.21944311],
[ 8.42136455, 16.41006373, 10.18936218],
[ 16.58069447, 16.40942145, 10.18738731],
[ 12.50057691, 14.05937074, 10.21535316],
[ 9.87962931, 4.83952796, 10.21780715],
[ 15.11771081, 4.83864890, 10.21828204],
[ 11.14849921, 11.71880557, 10.21433043],
[ 13.85197245, 11.71839398, 10.21388722],
[ 7.07163033, 14.07557769, 10.18966559],
[ 17.92981245, 14.07451466, 10.18715058],
[ 11.15032078, 7.01258145, 10.18585555],
[ 13.84805427, 7.01260553, 10.18468742],
[ 11.15374139, 16.38258017, 10.19406419],
[ 13.84797712, 16.38262181, 10.19305577],
[ 8.46142283, 11.72200026, 10.19193337],
[ 16.53912952, 11.72137050, 10.19082751],
[ 9.80868275, 9.39175408, 10.19042848],
[ 15.19121513, 9.39139801, 10.19000713],
[ 12.50135228, 18.62698462, 10.16962569],
[ 7.19030646, 9.43427206, 10.16393883],
[ 17.80928245, 9.43264096, 10.16320550],
[ 9.81079791, 18.65246946, 10.15161108],
[ 15.19173033, 18.65258132, 10.15047131],
[ 5.82378702, 11.74973673, 10.14719363],
[ 19.17687861, 11.74901365, 10.14552497],
[ 8.51399694, 7.09243078, 10.14437820],
[ 16.48462386, 7.09196221, 10.14483167],
[ 9.86853781, 14.01808792, 10.15838631],
[ 15.13244188, 14.01737556, 10.15760583],
[ 12.49981106, 9.46102591, 10.15664749],
[ 5.85053309, 16.33653652, 10.14074533],
[ 19.15069695, 16.33600992, 10.13783351],
[ 12.49931777, 4.82427576, 10.13718242],
[ 7.18523207, 17.13677427, 8.01539152],
[ 17.81493362, 17.13612020, 8.01291170],
[ 5.82590638, 14.78219838, 8.01390731],
[ 19.17465308, 14.78132898, 8.01158728],
[ 11.14006478, 5.58027740, 8.01015883],
[ 13.85860959, 5.58043958, 8.00916219],
[ 8.53147710, 19.37002966, 8.00455541],
[ 16.46920527, 19.36960314, 8.00259121],
[ 8.46738535, 14.82637476, 8.00658441],
[ 16.53288730, 14.82600301, 8.00537653],
[ 11.13861128, 14.84751514, 8.00240172],
[ 13.86148623, 14.84720046, 8.00199886],
[ 12.49994745, 12.50006125, 8.00063110],
[ 9.78416859, 17.21308386, 7.99515119],
[ 15.21588849, 17.21290637, 7.99420108],
[ 4.56377466, 12.49940921, 7.99904840],
[ 20.43610028, 12.49779898, 7.99698832],
[ 12.49920704, 7.84559494, 8.00242003],
[ 7.05812000, 12.49413290, 7.99278396],
[ 17.94178450, 12.49358184, 7.99141504],
[ 9.78582520, 12.50421909, 8.00089516],
[ 15.21413615, 12.50369827, 8.00052122],
[ 12.50007180, 17.15587369, 7.99900446],
[ 11.14649591, 10.14802062, 7.99941063],
[ 13.85314391, 10.14774254, 7.99948145],
[ 9.77481016, 7.79245421, 7.98959054],
[ 15.22469429, 7.79201704, 7.98943559],
[ 8.46632515, 10.17202968, 7.99540983],
[ 8.53256540, 5.62907836, 7.99458204],
[ 16.46612157, 5.62801086, 7.99582303],
[ 16.53337285, 10.17092209, 7.99467923],
[ 11.13544681, 19.42130452, 7.97773530],
[ 13.86508896, 19.42136867, 7.97785955],
[ 5.82074273, 10.21941636, 7.97126648],
[ 19.17882835, 10.21844766, 7.97010409],
[ 7.18631774, 7.85639597, 7.96997322],
[ 17.81284174, 7.85499234, 7.97028496]]
# hlcluster.py inputfile.gjf -n +n n-n
lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, coordinates, selective = VASP.read_poscar('POSCAR')
with open(sys.argv[1]) as IN:
input_file = IN.readlines()
space = re.compile(r'\s+')
a = int(sys.argv[2]) - 1
b = int(sys.argv[3]) - 1
temp = sys.argv[4].split('-')
c = int(temp[0]) - 1
d = int(temp[1])
gjfcoord = []
for i in xrange(5, len(input_file)):
if input_file[i].strip() == '':
break
line = space.split(input_file[i].strip())
gjfcoord.append([float(line[1]), float(line[2]), float(line[3]), line[0]])
coor = []
elements = elements[:1]
num_atoms = num_atoms[:1]
prev_element = ''
for i in xrange(c, d):
if gjfcoord[i][3] != prev_element:
elements.append(gjfcoord[i][3])
prev_element = gjfcoord[i][3]
num_atoms.append(1)
else:
num_atoms[-1] += 1
v1 = gjfcoord[i][0] - gjfcoord[a][0] + pos1[b][0]
v2 = gjfcoord[i][1] - gjfcoord[a][1] + pos1[b][1]
v3 = gjfcoord[i][2] - gjfcoord[a][2] + pos1[b][2]
pos1.append([v1, v2, v3])
VASP.write_poscar('POSCAR', lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, pos1, selective)