From 207ffdea02fe3ff26bd0223e04908614b820b5fb Mon Sep 17 00:00:00 2001 From: Han Wang Date: Thu, 16 Apr 2020 22:23:08 +0800 Subject: [PATCH 1/2] fix bug in lammps/dump, fractional coord should not shift origin --- dpdata/lammps/dump.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpdata/lammps/dump.py b/dpdata/lammps/dump.py index 06da27c81..8c9a293c1 100644 --- a/dpdata/lammps/dump.py +++ b/dpdata/lammps/dump.py @@ -83,9 +83,9 @@ def get_posi_frac(lines) : posis = np.array(posis) return posis[:,1:4] -def safe_get_posi(lines, cell): +def safe_get_posi(lines, cell, orig = np.zeros(3)): try: - posis = get_posi(lines) + posis = get_posi(lines) - orig except ValueError: fposis = get_posi_frac(lines) posis = fposis @ cell @@ -173,7 +173,7 @@ def system_data(lines, type_map = None, type_idx_zero = True) : system['cells'] = [np.array(cell)] natoms = sum(system['atom_numbs']) system['atom_types'] = get_atype(lines, type_idx_zero = type_idx_zero) - system['coords'] = [safe_get_posi(lines, cell) - np.array(orig)] + system['coords'] = [safe_get_posi(lines, cell, np.array(orig))] for ii in range(1, len(array_lines)) : bounds, tilt = get_dumpbox(array_lines[ii]) orig, cell = dumpbox2box(bounds, tilt) From a9e726a07a43f7d7f72484f246f15936d0376a71 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Thu, 16 Apr 2020 23:07:49 +0800 Subject: [PATCH 2/2] fix bug in lammps/dump --- dpdata/lammps/dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpdata/lammps/dump.py b/dpdata/lammps/dump.py index 8c9a293c1..74fdb6530 100644 --- a/dpdata/lammps/dump.py +++ b/dpdata/lammps/dump.py @@ -178,7 +178,7 @@ def system_data(lines, type_map = None, type_idx_zero = True) : bounds, tilt = get_dumpbox(array_lines[ii]) orig, cell = dumpbox2box(bounds, tilt) system['cells'].append(cell) - system['coords'].append(safe_get_posi(array_lines[ii], cell) - np.array(orig)) + system['coords'].append(safe_get_posi(array_lines[ii], cell, np.array(orig))) system['cells'] = np.array(system['cells']) system['coords'] = np.array(system['coords']) return system