Skip to content

Commit bc6508b

Browse files
authored
fix(abacus): do not collect the unconverged structure for AIMD (#368)
1 parent e8a2fbe commit bc6508b

File tree

9 files changed

+5417
-1
lines changed

9 files changed

+5417
-1
lines changed

dpdata/abacus/md.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
from .scf import ry2ev, bohr2ang, kbar2evperang3, get_block, get_geometry_in, get_cell, get_coords
55
import re
6+
import warnings
67

78
# Read in geometries from an ABACUS MD trajectory.
89
# The atomic coordinates are read in from generated files in OUT.XXXX.
@@ -80,6 +81,10 @@ def get_energy(outlines, ndump, dump_freq):
8081
if nenergy%dump_freq == 0:
8182
energy.append(float(line.split()[-2]))
8283
nenergy+=1
84+
elif "!! convergence has not been achieved" in line:
85+
if nenergy%dump_freq == 0:
86+
energy.append(np.nan)
87+
nenergy+=1
8388
assert(ndump == len(energy)), "Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check."%(len(energy), ndump)
8489
energy = np.array(energy)
8590
return energy
@@ -113,6 +118,20 @@ def get_frame (fname):
113118
with open(os.path.join(path_out, "running_md.log"), 'r') as fp:
114119
outlines = fp.read().split('\n')
115120
energy = get_energy(outlines, ndump, dump_freq)
121+
122+
unconv_stru = ''
123+
for i,iene in enumerate(energy):
124+
if np.isnan(iene):
125+
coords = np.delete(coords,i-ndump,axis=0)
126+
cells = np.delete(cells,i-ndump,axis=0)
127+
force = np.delete(force,i-ndump,axis=0)
128+
stress = np.delete(stress,i-ndump,axis=0)
129+
energy = np.delete(energy,i-ndump,axis=0)
130+
unconv_stru += "%d " % i
131+
ndump = len(energy)
132+
if unconv_stru != '':
133+
warnings.warn(f"Structure %s are unconverged and not collected!" % unconv_stru)
134+
116135
for iframe in range(ndump):
117136
stress[iframe] *= np.linalg.det(cells[iframe, :, :].reshape([3, 3]))
118137
if np.sum(np.abs(stress[0])) < 1e-10:

tests/abacus.md.unconv/INPUT

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
INPUT_PARAMETERS
2+
calculation md
3+
ntype 2
4+
nbands 8
5+
6+
ecutwfc 50.000000
7+
scf_thr 1.000000e-07
8+
scf_nmax 100
9+
10+
basis_type lcao
11+
dft_functional lda
12+
gamma_only 1
13+
14+
mixing_type pulay
15+
mixing_beta 0.400000
16+
smearing_method gaussian
17+
smearing_sigma 0.020000
18+
19+
cal_force 1
20+
cal_stress 1
21+
22+
md_type 0
23+
md_nstep 10
24+
md_tfirst 10
25+
md_dt 1
26+
chg_extrap second-order
27+
28+
deepks_scf 1
29+
deepks_bandgap 0
30+
deepks_model model.ptg
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
MDSTEP: 0
2+
LATTICE_CONSTANT: 1.889726125458
3+
LATTICE_VECTORS
4+
14.524509151052 0.000000000000 0.000000000000
5+
-0.014055052628 15.127720223676 0.000000000000
6+
-0.442369434823 0.417648184158 14.953520775918
7+
VIRIAL (KBAR)
8+
0.117880839971 0.348548064508 0.269730962791
9+
0.348548064508 -1.559580670587 -1.949852828444
10+
0.269730962791 -1.949852828444 -2.332929959367
11+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
12+
0 H 10.872796345708 0.993283528438 3.293903479774 0.203673227663 -0.476188513340 -0.673198308232
13+
1 H 10.341931867316 14.686041612304 2.160229648207 -0.497679578285 3.938931579746 4.649209009347
14+
2 O 10.133374044868 0.350751910571 3.193008852361 0.294006350622 -3.462743066406 -3.976010701114
15+
16+
17+
MDSTEP: 1
18+
LATTICE_CONSTANT: 1.889726125458
19+
LATTICE_VECTORS
20+
14.524509151052 0.000000000000 0.000000000000
21+
-0.014055052628 15.127720223676 0.000000000000
22+
-0.442369434823 0.417648184158 14.953520775918
23+
VIRIAL (KBAR)
24+
-0.052861928550 0.190313757600 0.235641072577
25+
0.190313757600 -1.590040770984 -1.856968175095
26+
0.235641072577 -1.856968175095 -2.206369542675
27+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
28+
0 H 10.875596899173 0.988023063544 3.294283265923 -0.254022717293 -0.877700208440 -0.747314202230
29+
1 H 10.340932440770 14.707241014770 2.180444767744 -0.497860772145 3.864467170520 4.570589962154
30+
2 O 10.131572917949 0.334812972999 3.172413946676 0.751883489438 -2.986766962080 -3.823275759924
31+
32+
33+
MDSTEP: 2
34+
LATTICE_CONSTANT: 1.889726125458
35+
LATTICE_VECTORS
36+
14.524509151052 0.000000000000 0.000000000000
37+
-0.014055052628 15.127720223676 0.000000000000
38+
-0.442369434823 0.417648184158 14.953520775918
39+
VIRIAL (KBAR)
40+
-0.316210888687 -0.207283827612 0.007046496091
41+
-0.207283827612 -1.346616360903 -1.287258423394
42+
0.007046496091 -1.287258423394 -1.415183801991
43+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
44+
0 H 10.875946508110 0.974294086278 3.287452572336 -1.045230179415 -1.628147086821 -0.958970724628
45+
1 H 10.335129392135 14.765726825200 2.244759338627 -0.207420915322 2.933943064626 3.340010877721
46+
2 O 10.137026357647 0.290056139835 3.114930069379 1.252651094738 -1.305795977804 -2.381040153093
47+
48+
49+
MDSTEP: 3
50+
LATTICE_CONSTANT: 1.889726125458
51+
LATTICE_VECTORS
52+
14.524509151052 0.000000000000 0.000000000000
53+
-0.014055052628 15.127720223676 0.000000000000
54+
-0.442369434823 0.417648184158 14.953520775918
55+
VIRIAL (KBAR)
56+
-0.260134638405 -0.993002747244 -0.895525915647
57+
-0.993002747244 0.262836092646 1.051311229863
58+
-0.895525915647 1.051311229863 1.805220211014
59+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
60+
0 H 10.866211187568 0.944855891202 3.271369225774 -1.519717284879 -2.134878371745 -1.173199796326
61+
1 H 10.327325037621 14.852520858530 2.341300087841 2.109118093970 -3.394877057008 -5.282580352734
62+
2 O 10.154566032703 0.232700301582 3.034472666728 -0.589400809091 5.529755428753 6.455780149060
63+
64+
65+
MDSTEP: 4
66+
LATTICE_CONSTANT: 1.889726125458
67+
LATTICE_VECTORS
68+
14.524509151052 0.000000000000 0.000000000000
69+
-0.014055052628 15.127720223676 0.000000000000
70+
-0.442369434823 0.417648184158 14.953520775918
71+
VIRIAL (KBAR)
72+
0.504846487933 -0.963922770050 -1.396738517223
73+
-0.963922770050 2.096159352353 2.997442421390
74+
-1.396738517223 2.997442421390 4.270661113979
75+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
76+
0 H 10.841812836866 0.894819268862 3.243966231690 -0.065851648219 -0.473828154419 -0.442665692581
77+
1 H 10.339870561687 14.906559335828 2.386871728651 4.482678409108 -9.390324011782 -13.734305291761
78+
2 O 10.166418859339 0.228698446623 3.016304020001 -4.416826760889 9.864152166202 14.176970984342
79+
80+
81+
MDSTEP: 5
82+
LATTICE_CONSTANT: 1.889726125458
83+
LATTICE_VECTORS
84+
14.524509151052 0.000000000000 0.000000000000
85+
-0.014055052628 15.127720223676 0.000000000000
86+
-0.442369434823 0.417648184158 14.953520775918
87+
VIRIAL (KBAR)
88+
2.301988732603 2.106077476560 0.632201255105
89+
2.106077476560 1.094304604347 -0.313178332666
90+
0.632201255105 -0.313178332666 -0.819241722779
91+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
92+
0 H 10.816779114892 0.840210903747 3.212292166621 6.855059278224 5.454541643043 1.016758449181
93+
1 H 10.395667320285 14.869995037486 2.299927582003 -0.960810002863 1.486842944666 2.333454697801
94+
2 O 10.135655822714 0.319871110080 3.134922231718 -5.894249275361 -6.941384587709 -3.350213146982
95+
96+
97+
MDSTEP: 6
98+
LATTICE_CONSTANT: 1.889726125458
99+
LATTICE_VECTORS
100+
14.524509151052 0.000000000000 0.000000000000
101+
-0.014055052628 15.127720223676 0.000000000000
102+
-0.442369434823 0.417648184158 14.953520775918
103+
VIRIAL (KBAR)
104+
0.224387150431 1.128837044998 1.081862730682
105+
1.128837044998 -0.268818497136 -1.093793836625
106+
1.081862730682 -1.093793836625 -2.004917355086
107+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
108+
0 H 10.857886603488 0.838230819836 3.190428320831 1.363129257990 1.501361774798 0.692219305499
109+
1 H 10.442193679586 14.847776580413 2.235497831256 -2.370639635238 2.295060837375 4.247420933792
110+
2 O 10.048021974818 0.344069651064 3.221215828255 1.007510377248 -3.796422612173 -4.939640239291
111+
112+
113+
MDSTEP: 7
114+
LATTICE_CONSTANT: 1.889726125458
115+
LATTICE_VECTORS
116+
14.524509151052 0.000000000000 0.000000000000
117+
-0.014055052628 15.127720223676 0.000000000000
118+
-0.442369434823 0.417648184158 14.953520775918
119+
VIRIAL (KBAR)
120+
-1.914534915401 0.160753699840 1.525216417878
121+
0.160753699840 -0.780431878582 -0.977244043867
122+
1.525216417878 -0.977244043867 -2.191357680684
123+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
124+
0 H 10.912146278758 0.850736662489 3.175243370290 -2.896292249377 -0.849289935513 1.095057694700
125+
1 H 10.465846863187 14.847702075120 2.212049427419 -2.832220895025 2.019939251673 4.270685618311
126+
2 O 9.970109115947 0.331638313704 3.259849182634 5.728513144402 -1.170649316160 -5.365743313011
127+
128+
129+
MDSTEP: 8
130+
LATTICE_CONSTANT: 1.889726125458
131+
LATTICE_VECTORS
132+
14.524509151052 0.000000000000 0.000000000000
133+
-0.014055052628 15.127720223676 0.000000000000
134+
-0.442369434823 0.417648184158 14.953520775918
135+
VIRIAL (KBAR)
136+
-2.513125907165 -0.154419226124 1.580371274213
137+
-0.154419226124 -0.825335562412 -0.815094290966
138+
1.580371274213 -0.815094290966 -2.050106792249
139+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
140+
0 H 10.938461005959 0.855048109998 3.170624111252 -3.822684404614 -1.352624889240 1.151176221490
141+
1 H 10.462173292782 14.867117004122 2.229806840379 -2.984053847480 1.788365306177 4.125001485576
142+
2 O 9.947467959151 0.307911937194 3.246711028711 6.806738252094 -0.435740416937 -5.276177707066
143+
144+
145+
MDSTEP: 9
146+
LATTICE_CONSTANT: 1.889726125458
147+
LATTICE_VECTORS
148+
14.524509151052 0.000000000000 0.000000000000
149+
-0.014055052628 15.127720223676 0.000000000000
150+
-0.442369434823 0.417648184158 14.953520775918
151+
VIRIAL (KBAR)
152+
-1.921730659733 -0.250128628384 1.045305625840
153+
-0.250128628384 -0.550642430618 -0.443385704265
154+
1.045305625840 -0.443385704265 -1.253788166285
155+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
156+
0 H 10.927892467255 0.846308722497 3.177112004724 -3.263179899026 -1.178327094849 0.932844111407
157+
1 H 10.429708004337 14.903787020423 2.287364433146 -2.485295875334 1.119241763062 3.025686004957
158+
2 O 9.990501786298 0.279981308393 3.182665542472 5.748475774360 0.059085331787 -3.958530116363
159+
160+
161+
MDSTEP: 10
162+
LATTICE_CONSTANT: 1.889726125458
163+
LATTICE_VECTORS
164+
14.524509151052 0.000000000000 0.000000000000
165+
-0.014055052628 15.127720223676 0.000000000000
166+
-0.442369434823 0.417648184158 14.953520775918
167+
VIRIAL (KBAR)
168+
0.125490523345 -0.470583331016 -0.646063109567
169+
-0.470583331016 0.977542641385 1.479381534553
170+
-0.646063109567 1.479381534553 2.154282026823
171+
INDEX LABEL POSITIONS FORCE (eV/Angstrom)
172+
0 H 10.885839055837 0.826200216607 3.192600467891 -0.652935734428 0.144670019023 0.624517068595
173+
1 H 10.373263276599 14.951256068815 2.374115432862 1.613773327904 -3.964330561830 -5.728774672298
174+
2 O 10.088999925455 0.252620765891 3.080426079588 -0.960837593476 3.819660542807 5.104257603703
175+
176+

0 commit comments

Comments
 (0)