Skip to content

Commit

Permalink
Fix bug when reading file in "pwmat/movement" format (#599)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored Jan 24, 2024
1 parent f22e66d commit 1355f7b
Show file tree
Hide file tree
Showing 6 changed files with 976 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dpdata/pwmat/movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def system_info(lines, type_idx_zero=False):
nelm = 100
atomic_number = []
for idx, ii in enumerate(lines):
if "Position" in ii:
if ("Position" in ii) and ("nonperiodic_Position" not in ii):
for kk in range(idx + 1, idx + 1 + natoms):
min = kk
for jj in range(kk + 1, idx + 1 + natoms):
Expand Down Expand Up @@ -175,7 +175,7 @@ def analyze_block(lines, ntot, nelm):
# cell.append([float(ss)
# for ss in tmp_l.split()[0:3]])
# virial = np.zeros([3,3])
elif "Position" in ii:
elif ("Position" in ii) and ("nonperiodic_Position" not in ii):
for kk in range(idx + 1, idx + 1 + ntot):
min = kk
for jj in range(kk + 1, idx + 1 + ntot):
Expand Down
Loading

0 comments on commit 1355f7b

Please sign in to comment.