Skip to content

Commit 1355f7b

Browse files
Fix bug when reading file in "pwmat/movement" format (#599)
PWmat adds `nonperiodic_Position` block to MOVEMENT file, used to output the atomic positions without non periodic boundary conditions. Due to the fact that dpdata previously locates the number of atoms based on the keyword `Position`, when MOVEMENT contains `nonperiodic_Position`, it will cause the number of atoms to double, resulting in a bug. --------- Co-authored-by: Uper <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f22e66d commit 1355f7b

File tree

6 files changed

+976
-2
lines changed

6 files changed

+976
-2
lines changed

dpdata/pwmat/movement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def system_info(lines, type_idx_zero=False):
1818
nelm = 100
1919
atomic_number = []
2020
for idx, ii in enumerate(lines):
21-
if "Position" in ii:
21+
if ("Position" in ii) and ("nonperiodic_Position" not in ii):
2222
for kk in range(idx + 1, idx + 1 + natoms):
2323
min = kk
2424
for jj in range(kk + 1, idx + 1 + natoms):
@@ -175,7 +175,7 @@ def analyze_block(lines, ntot, nelm):
175175
# cell.append([float(ss)
176176
# for ss in tmp_l.split()[0:3]])
177177
# virial = np.zeros([3,3])
178-
elif "Position" in ii:
178+
elif ("Position" in ii) and ("nonperiodic_Position" not in ii):
179179
for kk in range(idx + 1, idx + 1 + ntot):
180180
min = kk
181181
for jj in range(kk + 1, idx + 1 + ntot):

0 commit comments

Comments
 (0)