Skip to content

Commit

Permalink
if cp2k output is not converged, return the sys len = 0 (#184)
Browse files Browse the repository at this point in the history
* if cp2k output is not converged, return the sys len = 0

* modify the cp2k output code
1. use fp.seek(0) to avoid open file twice
2. add 'scf run' line in cp2k_output to read the output content, just to
   test the parser.

* add cp2k non converge output unittest

* add unittest for noncon output

* modify the unittest name
  • Loading branch information
robinzyb authored Aug 9, 2021
1 parent 73ad164 commit 674a95f
Show file tree
Hide file tree
Showing 4 changed files with 4,378 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dpdata/cp2k/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,22 @@ def get_frames (fname) :
eV = 2.72113838565563E+01 # hatree to eV
angstrom = 5.29177208590000E-01 # Bohr to Angstrom
GPa = 160.21766208 # 1 eV/(Angstrom^3) = 160.21 GPa
fp = open(fname)
atom_symbol_list = []
cell = []
coord = []
force = []
stress = []
cell_count = 0
coord_count = 0

fp = open(fname)
# check if output is converged, if not, return sys = 0
content = fp.read()
count = content.count('SCF run converged')
if count == 0:
return [], [], [], [], [], [], [], []

fp.seek(0)
for idx, ii in enumerate(fp) :
if ('CELL| Vector' in ii) and (cell_count < 3) :
cell.append(ii.split()[4:7])
Expand Down
Loading

0 comments on commit 674a95f

Please sign in to comment.