Révision 50
database/import_vasp_calc (revision 50) | ||
---|---|---|
13 | 13 |
import multiprocessing |
14 | 14 |
import traceback |
15 | 15 |
|
16 |
xc_dict = {'1':'LDA(HL)', |
|
17 |
'2':'LDA(CA/PZ)', |
|
18 |
'3':'LDA(WI)', |
|
19 |
'4':'GGA(PB)', |
|
20 |
'5':'GGA(PW86)', |
|
21 |
'6':'LM', |
|
22 |
'7':'PW91', |
|
23 |
'8':'PBE', |
|
24 |
'9':'RPBE', |
|
25 |
'10':'VWN', |
|
26 |
'11':'B3LYP(VWN3 correction)', |
|
27 |
'12':'B3LYP(VWN5 correction)', |
|
28 |
'13':'AM05', |
|
29 |
'14':'PBEsol', |
|
30 |
'17':'BEEF', |
|
31 |
'100':'CO'} |
|
16 | 32 |
def error(msg, *args): |
17 | 33 |
return multiprocessing.get_logger().error(msg, *args) |
18 | 34 |
|
... | ... | |
39 | 55 |
#log = open('scan.log','w') |
40 | 56 |
_all = os.walk(os.path.abspath(path)) |
41 | 57 |
calculator=None |
42 |
xc_dict = {'8': 'PBE', '91': 'PW91', 'CA': 'LDA'} |
|
43 | 58 |
read_all_dir = 0 |
44 | 59 |
filenames = [] |
45 | 60 |
if os.path.exists(db): |
... | ... | |
90 | 105 |
t2 = time() |
91 | 106 |
print 'timing: ', t2-t1 |
92 | 107 |
if use_poscar: |
93 |
constraints = read(path+'/POSCAR').constraints |
|
108 |
try: |
|
109 |
constraints = read(path+'/POSCAR').constraints |
|
110 |
except IOError: |
|
111 |
try: |
|
112 |
constraints = read(path+'/POSCAR.gz').constraints |
|
113 |
except IOError: |
|
114 |
try: |
|
115 |
constraints = read(path+'/POSCAR.bz2').constraints |
|
116 |
except IOError: |
|
117 |
constraints = None |
|
94 | 118 |
Atoms.set_constraint(constraints) |
95 | 119 |
print 'get constraint from poscar', filetoread |
96 |
else:
|
|
120 |
if not constraints:
|
|
97 | 121 |
Atoms0 = read(filetoread, index=0) |
98 | 122 |
pos0 = Atoms0.positions |
99 | 123 |
pos = Atoms.positions |
... | ... | |
138 | 162 |
pot = 'PAW' |
139 | 163 |
else: |
140 | 164 |
pot = line[1] |
165 |
elif line.startswith(' exchange correlation table for LEXCH ='): |
|
166 |
xc_flag = line.split()[-1].upper() |
|
167 |
if xc_flag not in xc_dict.keys(): |
|
168 |
raise ValueError('Unknown xc-functional flag found in POTCAR,' |
|
169 |
' LEXCH=%s' % xc_flag) |
|
170 |
xc = xc_dict[xc_flag] |
|
141 | 171 |
elif line.startswith(' Dimension of arrays'): |
142 | 172 |
#if line.startswith(' Dimension of arrays'): |
143 | 173 |
read_para = 1 |
144 | 174 |
elif read_para: |
145 |
if 'LEXCH' in line: |
|
146 |
xc_flag = line.split()[2].upper() |
|
147 |
if xc_flag not in xc_dict.keys(): |
|
148 |
raise ValueError('Unknown xc-functional flag found in POTCAR,' |
|
149 |
' LEXCH=%s' % xc_flag) |
|
150 |
xc = xc_dict[xc_flag] |
|
151 |
elif 'NKPTS' in line: |
|
152 |
#if 'NKPTS' in line:
|
|
175 |
#if 'LEXCH' in line:
|
|
176 |
# xc_flag = line.split()[2].upper()
|
|
177 |
# if xc_flag not in xc_dict.keys():
|
|
178 |
# raise ValueError('Unknown xc-functional flag found in POTCAR,'
|
|
179 |
# ' LEXCH=%s' % xc_flag)
|
|
180 |
# xc = xc_dict[xc_flag]
|
|
181 |
#elif 'NKPTS' in line:
|
|
182 |
if 'NKPTS' in line: |
|
153 | 183 |
nkpts = int(line.split()[3]) |
154 | 184 |
elif 'ENCUT' in line: |
155 | 185 |
encut = float(line.split()[2]) |
... | ... | |
194 | 224 |
#del con[id] |
195 | 225 |
record = con.select(filename=filetoread) |
196 | 226 |
if update_method: |
197 |
id = con.reserve(filename=filetoread) |
|
198 |
con.write(Atoms,functional = xc,path=path,code='VASP',filename=filetoread, version=version, potential=pot, encut=encut, enaug=enaug, lsol=lsol, ldipol=ldipol, nkpts=nkpts, constraint=False) |
|
199 |
del con[id] |
|
200 |
record = con.select(filename=filetoread) |
|
201 |
id = next(record)['id'] |
|
202 |
con.update(id,user=user) |
|
203 |
con.update(id,calculator='vasp') |
|
227 |
try: |
|
228 |
id = con.reserve(filename=filetoread) |
|
229 |
con.write(Atoms,functional = xc,path=path,code='VASP',filename=filetoread, version=version, potential=pot, encut=encut, enaug=enaug, lsol=lsol, ldipol=ldipol, nkpts=nkpts, constraint=False) |
|
230 |
del con[id] |
|
231 |
record = con.select(filename=filetoread) |
|
232 |
id = next(record)['id'] |
|
233 |
con.update(id,user=user) |
|
234 |
con.update(id,calculator='vasp') |
|
235 |
except UnboundLocalError: |
|
236 |
print 'err:',filetoread |
|
237 |
return |
|
204 | 238 |
|
205 | 239 |
except (IndexError, ValueError): |
206 | 240 |
_log = 'failed: '+filetoread |
... | ... | |
251 | 285 |
if args.j is None: |
252 | 286 |
project = 'gaussian' |
253 | 287 |
else: |
254 |
project = int(args.j)
|
|
288 |
project = args.j
|
|
255 | 289 |
|
256 | 290 |
#import_vasp_calculations('/data/users/tjiang/rkerber', con) |
257 | 291 |
#import_vasp_calculations('.', con, include_dir=['<opt_dir>'], exclude_dir=['<to_exclude_dir1>', '<to_exclude_dir2>']) |
Formats disponibles : Unified diff