@@ -273,8 +273,7 @@ def write_energy(self, output_file) -> None:
273
273
)
274
274
a , b , c = kpt .frac_coords
275
275
file .write (f"{ a :12.8f} { b :12.8f} { c :12.8f} { len (eigs )} \n " )
276
- for e in eigs :
277
- file .write (f"{ sign * float (e ):18.8f} \n " )
276
+ file .writelines (f"{ sign * float (e ):18.8f} \n " for e in eigs )
278
277
279
278
else :
280
279
for i , kpt in enumerate (self ._bs .kpoints ):
@@ -301,8 +300,7 @@ def write_energy(self, output_file) -> None:
301
300
a , b , c = kpt .frac_coords
302
301
file .write (f"{ a :12.8f} { b :12.8f} { c :12.8f} { len (eigs )} \n " )
303
302
304
- for e in eigs :
305
- file .write (f"{ float (e ):18.8f} \n " )
303
+ file .writelines (f"{ float (e ):18.8f} \n " for e in eigs )
306
304
307
305
def write_struct (self , output_file ) -> None :
308
306
"""Write the structure to an output file.
@@ -332,8 +330,7 @@ def write_struct(self, output_file) -> None:
332
330
file .write (f"{ len (ops )} \n " )
333
331
334
332
for op in ops :
335
- for row in op :
336
- file .write (f"{ ' ' .join (map (str , row ))} \n " )
333
+ file .writelines (f"{ ' ' .join (map (str , row ))} \n " for row in op )
337
334
338
335
def write_def (self , output_file ) -> None :
339
336
"""Write the def to an output file.
@@ -392,8 +389,7 @@ def write_proj(self, output_file_proj: str, output_file_def: str) -> None:
392
389
tmp_proj .append (self ._hl )
393
390
a , b , c = kpt .frac_coords
394
391
file .write (f"{ a :12.8f} { b :12.8f} { c :12.8f} { len (tmp_proj )} \n " )
395
- for t in tmp_proj :
396
- file .write (f"{ float (t ):18.8f} \n " )
392
+ file .writelines (f"{ float (t ):18.8f} \n " for t in tmp_proj )
397
393
with open (output_file_def , mode = "w" , encoding = "utf-8" ) as file :
398
394
so = ""
399
395
if self ._bs .is_spin_polarized :
@@ -451,10 +447,8 @@ def write_intrans(self, output_file) -> None:
451
447
fout .write (f"{ self .tauref } { self .tauexp } { self .tauen } 0 0 0\n " )
452
448
fout .write (f"{ 2 * len (self .doping )} \n " )
453
449
454
- for d in self .doping :
455
- fout .write (str (d ) + "\n " )
456
- for d in self .doping :
457
- fout .write (str (- d ) + "\n " )
450
+ fout .writelines (str (d ) + "\n " for d in self .doping )
451
+ fout .writelines (str (- d ) + "\n " for d in self .doping )
458
452
459
453
elif self .run_type == "FERMI" :
460
454
with open (output_file , mode = "w" , encoding = "utf-8" ) as fout :
0 commit comments