11import os
22import re
3- import sys
43import warnings
5- from ast import dump
64
75import numpy as np
86
97from .scf import (
108 bohr2ang ,
11- get_block ,
129 get_cell ,
1310 get_coords ,
1411 get_geometry_in ,
1512 kbar2evperang3 ,
16- ry2ev ,
1713)
1814
1915# Read in geometries from an ABACUS MD trajectory.
@@ -166,12 +162,12 @@ def get_frame(fname):
166162 path_in = os .path .join (fname , "INPUT" )
167163 else :
168164 raise RuntimeError ("invalid input" )
169- with open (path_in , "r" ) as fp :
165+ with open (path_in ) as fp :
170166 inlines = fp .read ().split ("\n " )
171167 geometry_path_in = get_geometry_in (fname , inlines ) # base dir of STRU
172168 path_out = get_path_out (fname , inlines )
173169
174- with open (geometry_path_in , "r" ) as fp :
170+ with open (geometry_path_in ) as fp :
175171 geometry_inlines = fp .read ().split ("\n " )
176172 celldm , cell = get_cell (geometry_inlines )
177173 atom_names , natoms , types , coords = get_coords (
@@ -182,11 +178,11 @@ def get_frame(fname):
182178 # ndump = int(os.popen("ls -l %s | grep 'md_pos_' | wc -l" %path_out).readlines()[0])
183179 # number of dumped geometry files
184180 # coords = get_coords_from_cif(ndump, dump_freq, atom_names, natoms, types, path_out, cell)
185- with open (os .path .join (path_out , "MD_dump" ), "r" ) as fp :
181+ with open (os .path .join (path_out , "MD_dump" )) as fp :
186182 dumplines = fp .read ().split ("\n " )
187183 coords , cells , force , stress = get_coords_from_dump (dumplines , natoms )
188184 ndump = np .shape (coords )[0 ]
189- with open (os .path .join (path_out , "running_md.log" ), "r" ) as fp :
185+ with open (os .path .join (path_out , "running_md.log" )) as fp :
190186 outlines = fp .read ().split ("\n " )
191187 energy = get_energy (outlines , ndump , dump_freq )
192188
@@ -201,7 +197,7 @@ def get_frame(fname):
201197 unconv_stru += "%d " % i
202198 ndump = len (energy )
203199 if unconv_stru != "" :
204- warnings .warn (f "Structure %s are unconverged and not collected!" % unconv_stru )
200+ warnings .warn ("Structure %s are unconverged and not collected!" % unconv_stru )
205201
206202 for iframe in range (ndump ):
207203 stress [iframe ] *= np .linalg .det (cells [iframe , :, :].reshape ([3 , 3 ]))
0 commit comments