@@ -116,12 +116,8 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
116
116
# Subtract 1 to skip the average
117
117
num_bonds = int (parameters [0 ]) - 1
118
118
self .efermi = float (parameters [- 1 ])
119
- if int (parameters [1 ]) == 2 :
120
- spins = [Spin .up , Spin .down ]
121
- self .is_spin_polarized = True
122
- else :
123
- spins = [Spin .up ]
124
- self .is_spin_polarized = False
119
+ self .is_spin_polarized = int (parameters [1 ]) == 2
120
+ spins = [Spin .up , Spin .down ] if int (parameters [1 ]) == 2 else [Spin .up ]
125
121
126
122
# The COHP data start in row num_bonds + 3
127
123
data = np .array ([np .array (row .split (), dtype = float ) for row in contents [num_bonds + 3 :]]).transpose ()
@@ -135,22 +131,22 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
135
131
136
132
orb_cohp : dict [str , Any ] = {}
137
133
# present for Lobster versions older than Lobster 2.2.0
138
- veryold = False
134
+ very_old = False
139
135
# the labeling had to be changed: there are more than one COHP for each atom combination
140
136
# this is done to make the labeling consistent with ICOHPLIST.lobster
141
- bondnumber = 0
137
+ bond_num = 0
142
138
for bond in range (num_bonds ):
143
139
bond_data = self ._get_bond_data (contents [3 + bond ])
144
140
145
- label = str (bondnumber )
141
+ label = str (bond_num )
146
142
147
143
orbs = bond_data ["orbitals" ]
148
144
cohp = {spin : data [2 * (bond + s * (num_bonds + 1 )) + 3 ] for s , spin in enumerate (spins )}
149
145
150
146
icohp = {spin : data [2 * (bond + s * (num_bonds + 1 )) + 4 ] for s , spin in enumerate (spins )}
151
147
if orbs is None :
152
- bondnumber = bondnumber + 1
153
- label = str (bondnumber )
148
+ bond_num = bond_num + 1
149
+ label = str (bond_num )
154
150
cohp_data [label ] = {
155
151
"COHP" : cohp ,
156
152
"ICOHP" : icohp ,
@@ -172,11 +168,11 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
172
168
)
173
169
else :
174
170
# present for Lobster versions older than Lobster 2.2.0
175
- if bondnumber == 0 :
176
- veryold = True
177
- if veryold :
178
- bondnumber += 1
179
- label = str (bondnumber )
171
+ if bond_num == 0 :
172
+ very_old = True
173
+ if very_old :
174
+ bond_num += 1
175
+ label = str (bond_num )
180
176
181
177
orb_cohp [label ] = {
182
178
bond_data ["orb_label" ]: {
@@ -189,7 +185,7 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
189
185
}
190
186
191
187
# present for lobster older than 2.2.0
192
- if veryold :
188
+ if very_old :
193
189
for bond_str in orb_cohp :
194
190
cohp_data [bond_str ] = {
195
191
"COHP" : None ,
@@ -302,18 +298,12 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
302
298
303
299
# If the calculation is spin polarized, the line in the middle
304
300
# of the file will be another header line.
305
- if "distance" in data [len (data ) // 2 ]:
306
- # TODO: adapt this for orbitalwise stuff
307
- self .is_spin_polarized = True
308
- else :
309
- self .is_spin_polarized = False
301
+ # TODO: adapt this for orbitalwise stuff
302
+ self .is_spin_polarized = "distance" in data [len (data ) // 2 ]
310
303
311
304
# check if orbitalwise ICOHPLIST
312
305
# include case when there is only one ICOHP!!!
313
- if len (data ) > 2 and "_" in data [1 ].split ()[1 ]:
314
- self .orbitalwise = True
315
- else :
316
- self .orbitalwise = False
306
+ self .orbitalwise = len (data ) > 2 and "_" in data [1 ].split ()[1 ]
317
307
318
308
if self .orbitalwise :
319
309
data_without_orbitals = []
@@ -364,7 +354,7 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s
364
354
length = float (line [3 ])
365
355
translation = [int (line [4 ]), int (line [5 ]), int (line [6 ])]
366
356
icohp [Spin .up ] = float (line [7 ])
367
- num = int ( 1 )
357
+ num = 1
368
358
369
359
if self .is_spin_polarized :
370
360
icohp [Spin .down ] = float (data_without_orbitals [bond + num_bonds + 1 ].split ()[7 ])
@@ -1141,10 +1131,7 @@ def __init__(self, filenames=".", vasprun="vasprun.xml", Kpointsfile="KPOINTS"):
1141
1131
linenumbers .append (iline )
1142
1132
1143
1133
if ifilename == 0 :
1144
- if len (linenumbers ) == 2 :
1145
- self .is_spinpolarized = True
1146
- else :
1147
- self .is_spinpolarized = False
1134
+ self .is_spinpolarized = len (linenumbers ) == 2
1148
1135
1149
1136
if ifilename == 0 :
1150
1137
eigenvals = {}
0 commit comments