Révision 24 database/import_data.py
import_data.py (revision 24) | ||
---|---|---|
5 | 5 |
from ase.db import connect |
6 | 6 |
from ase.calculators.vasp import Vasp |
7 | 7 |
|
8 |
|
|
8 | 9 |
def import_vasp_calculations(path,con,include_dir=[],exclude_dir=[]): |
9 | 10 |
log = open('success.log','w') |
10 | 11 |
errlog = open('err.log','w') |
... | ... | |
17 | 18 |
for files in _all: |
18 | 19 |
vasp_out = [i for i in range(len(files[2])) if ('OUTCAR' in files[2][i] and files[2][i][:6]=='OUTCAR')] |
19 | 20 |
condition1 = (read_all_dir or files[0].split('/')[-1] in include_dir) |
20 |
condition2 = not files[0].split('/')[-1] in exclude_dir |
|
21 |
if len(vasp_out) != 0 and condition1 and condition2: |
|
21 |
#condition2 = not files[0].split('/')[-1] in exclude_dir |
|
22 |
condition3 = [ i for i, x in enumerate(exclude_dir) if x in files[0] ] |
|
23 |
if len(vasp_out) != 0 and condition1 and not condition3 : |
|
22 | 24 |
ncalc = 0 |
23 | 25 |
for f in vasp_out: |
24 | 26 |
try: |
... | ... | |
49 | 51 |
read_para = 1 |
50 | 52 |
elif read_para: |
51 | 53 |
if 'LEXCH' in line: |
52 |
xc_flag = line.split()[-1].upper() |
|
54 |
xc_flag = line.split()[2].upper() |
|
55 |
print xc_flag |
|
53 | 56 |
if xc_flag not in xc_dict.keys(): |
54 | 57 |
raise ValueError('Unknown xc-functional flag found in POTCAR,' |
55 | 58 |
' LEXCH=%s' % xc_flag) |
... | ... | |
73 | 76 |
elif '-'*104 in line: |
74 | 77 |
break |
75 | 78 |
line = outcar.readline() |
76 |
con.write(Atoms,creator='rkerber',path=files[0],code=calc.name,filename=files[2][f], version=version, potential=pot, functional=xc,encut=encut, enaug=enaug, lsol=lsol, ldipol=ldipol, nkpts=nkpts)
|
|
79 |
con.write(Atoms,functional = xc, creator='rkerber',path=files[0],code=calc.name,filename=files[2][f], version=version, potential=pot, encut=encut, enaug=enaug, lsol=lsol, ldipol=ldipol, nkpts=nkpts)
|
|
77 | 80 |
print >> log, files[0] |
78 | 81 |
except (IndexError, ValueError): |
79 | 82 |
print >> errlog, files[0] |
... | ... | |
105 | 108 |
|
106 | 109 |
con = connect('test.db') |
107 | 110 |
#import_vasp_calculations('/data/users/tjiang/rkerber', con) |
108 |
import_vasp_calculations('.', con, include_dir=['test1']) |
|
111 |
import_vasp_calculations('.', con, include_dir=['<opt_dir>'], exclude_dir=['<to_exclude_dir1>', '<to_exclude_dir2>']) |
Formats disponibles : Unified diff