@@ -38,12 +38,16 @@ def extract_keyword(fout, keyword, down_line_num, begin_column, column_num):
38
38
else :
39
39
flag = 0
40
40
continue
41
- for i in range (begin_column , column_num ):
42
- if not value .split ()[i ].isalpha ():
43
- ret .append (float (value .strip ().split ()[i ]))
44
- else :
45
- ret .append (value .strip ().split ()[i ])
46
- continue
41
+ if len (value .split ()) >= column_num :
42
+ for i in range (begin_column , column_num ):
43
+ if not value .split ()[i ].isalpha ():
44
+ ret .append (float (value .strip ().split ()[i ]))
45
+ else :
46
+ ret .append (value .strip ().split ()[i ])
47
+ ## compatible siesta-4.0.2 and siesta-4.1-b4
48
+ else :
49
+ flag = 0
50
+ idx = 0
47
51
file .close ()
48
52
return ret
49
53
@@ -55,6 +59,17 @@ def get_atom_types(fout, atomnums):
55
59
atomtype .append (int (covert_type [i ]) - 1 )
56
60
return atomtype
57
61
62
+ def get_atom_name (fout ):
63
+ file = open (fout , 'r' )
64
+ ret = []
65
+ for value in file :
66
+ if 'Species number:' in value :
67
+ for j in range (len (value .split ())):
68
+ if value .split ()[j ] == 'Label:' :
69
+ ret .append (value .split ()[j + 1 ])
70
+ break
71
+ file .close ()
72
+ return ret
58
73
59
74
def get_atom_numbs (atomtypes ):
60
75
atom_numbs = []
@@ -79,12 +94,11 @@ def get_virial(fout, cells):
79
94
80
95
def obtain_frame (fname ):
81
96
NumberOfSpecies = int (get_single_line_tail (fname , 'redata: Number of Atomic Species' )[0 ])
82
- atom_names = extract_keyword (fname , 'initatom: Reading input for the pseudopotentials and atomic orbitals' , NumberOfSpecies , 4 , 5 )
97
+ atom_names = get_atom_name (fname )
83
98
tot_natoms = int (get_single_line_tail (fname , 'Number of atoms' , 3 )[0 ])
84
99
atom_types = get_atom_types (fname , tot_natoms )
85
100
atom_numbs = get_atom_numbs (atom_types )
86
101
assert (max (atom_types ) + 1 == NumberOfSpecies )
87
-
88
102
cell = extract_keyword (fname , 'outcell: Unit cell vectors (Ang):' , 3 , 0 , 3 )
89
103
coord = extract_keyword (fname , 'outcoor: Atomic coordinates (Ang):' , tot_natoms , 0 , 3 )
90
104
energy = get_single_line_tail (fname , 'siesta: E_KS(eV) =' )
0 commit comments