Skip to content

Commit 8f371fb

Browse files
authored
fix: fix the judgement of convergence in abacus/scf (#360)
1 parent bb75d0f commit 8f371fb

File tree

5 files changed

+652
-11
lines changed

5 files changed

+652
-11
lines changed

dpdata/abacus/scf.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,11 @@ def get_energy(outlines):
104104
Etot = float(line.split()[1]) # in eV
105105
break
106106
if not Etot:
107-
not_converge = False
108-
for line in outlines:
109-
if "convergence has NOT been achieved!" in line:
110-
not_converge = True
111-
raise RuntimeError("convergence has NOT been achieved in scf!")
112-
break
113-
if not not_converge:
114-
raise RuntimeError("Final total energy cannot be found in output. Unknown problem.")
115-
return Etot
107+
raise RuntimeError("Final total energy cannot be found in output. Unknown problem.")
108+
for line in outlines:
109+
if "convergence has NOT been achieved!" in line:
110+
return Etot,False
111+
return Etot,True
116112

117113
def get_force (outlines, natoms):
118114
force = []
@@ -156,7 +152,15 @@ def get_frame (fname):
156152
celldm, cell = get_cell(geometry_inlines)
157153
atom_names, natoms, types, coords = get_coords(celldm, cell, geometry_inlines, inlines)
158154

159-
energy = get_energy(outlines)
155+
energy,converge = get_energy(outlines)
156+
if not converge:
157+
return {'atom_names':atom_names,\
158+
'atom_numbs':natoms,\
159+
'atom_types':types,\
160+
'cells':[],\
161+
'coords':[],\
162+
'energies':[],\
163+
'forces':[]}
160164
force = get_force (outlines, natoms)
161165
stress = get_stress(outlines)
162166
if stress is not None:

tests/abacus.scf/INPUT.fail

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
INPUT_PARAMETERS
2+
#Parameters (General)
3+
suffix ch4fail
4+
stru_file STRU.ch4 #the filename of file containing atom positions
5+
kpoint_file KPT.ch4 #the name of file containing k points
6+
pseudo_dir ./
7+
ntype 2
8+
nbands 8
9+
#Parameters (Accuracy)
10+
ecutwfc 100
11+
symmetry 1
12+
scf_nmax 50
13+
smearing_method gauss #type of smearing: gauss; fd; fixed; mp; mp2; mv
14+
smearing_sigma 0.01
15+
mixing_type plain
16+
mixing_beta 0.5
17+
cal_force 1
18+
cal_stress 1
File renamed without changes.

0 commit comments

Comments
 (0)