Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpdata/cp2k/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def get_frames(fname):
atom_types = []
atom_numbs = []
# preserve the atom_name order
atom_names = atom_symbol_list[np.sort(symbol_idx)]
atom_names = atom_symbol_list[np.sort(symbol_idx, kind="stable")]
for jj in atom_symbol_list:
for idx, ii in enumerate(atom_names):
if jj == ii:
Expand Down
4 changes: 3 additions & 1 deletion dpdata/lammps/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ def system_data(lines, type_map=None, type_idx_zero=True, unwrap=False):
system["cells"].append(cell)
atype = get_atype(array_lines[ii], type_idx_zero=type_idx_zero)
# map atom type; a[as[a][as[as[b]]]] = b[as[b][as^{-1}[b]]] = b[id]
idx = np.argsort(atype)[np.argsort(np.argsort(system["atom_types"]))]
idx = np.argsort(atype, kind="stable")[
np.argsort(np.argsort(system["atom_types"], kind="stable"), kind="stable")
]
system["coords"].append(
safe_get_posi(array_lines[ii], cell, np.array(orig), unwrap)[idx]
)
Expand Down
2 changes: 1 addition & 1 deletion dpdata/md/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def compute_rdf(box, posis, atype, sel_type=[None, None], max_r=5, nbins=100):


def _compute_rdf_1frame(box, posis, atype, sel_type=[None, None], max_r=5, nbins=100):
all_types = list(set(list(np.sort(atype))))
all_types = list(set(list(np.sort(atype, kind="stable"))))
if sel_type[0] is None:
sel_type[0] = all_types
if sel_type[1] is None:
Expand Down
2 changes: 1 addition & 1 deletion dpdata/qe/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_coords(lines, cell):
atom_types = []
atom_numbs = []
# preserve the atom_name order
atom_names = atom_symbol_list[np.sort(symbol_idx)]
atom_names = atom_symbol_list[np.sort(symbol_idx, kind="stable")]
for jj in atom_symbol_list:
for idx, ii in enumerate(atom_names):
if jj == ii:
Expand Down
4 changes: 2 additions & 2 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def sort_atom_types(self) -> np.ndarray:
idx : np.ndarray
new atom index in the Axis.NATOMS
"""
idx = np.argsort(self.data["atom_types"])
idx = np.argsort(self.data["atom_types"], kind="stable")
for tt in self.DTYPES:
if tt.name not in self.data:
# skip optional data
Expand Down Expand Up @@ -767,7 +767,7 @@ def replicate(self, ncopy):
np.array(np.copy(data["atom_numbs"])) * np.prod(ncopy)
)
tmp.data["atom_types"] = np.sort(
np.tile(np.copy(data["atom_types"]), np.prod(ncopy))
np.tile(np.copy(data["atom_types"]), np.prod(ncopy)), kind="stable"
)
tmp.data["cells"] = np.copy(data["cells"])
for ii in range(3):
Expand Down
8 changes: 5 additions & 3 deletions dpdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ def sort_atom_names(data, type_map=None):
# a[as[a]] == b[as[b]] as == argsort
# as[as[b]] == as^{-1}[b]
# a[as[a][as[as[b]]]] = b[as[b][as^{-1}[b]]] = b[id]
idx = np.argsort(data["atom_names"])[np.argsort(np.argsort(type_map))]
idx = np.argsort(data["atom_names"], kind="stable")[
np.argsort(np.argsort(type_map, kind="stable"), kind="stable")
]
else:
# index that will sort an array by alphabetical order
idx = np.argsort(data["atom_names"])
idx = np.argsort(data["atom_names"], kind="stable")
# sort atom_names, atom_numbs, atom_types by idx
data["atom_names"] = list(np.array(data["atom_names"])[idx])
data["atom_numbs"] = list(np.array(data["atom_numbs"])[idx])
data["atom_types"] = np.argsort(idx)[data["atom_types"]]
data["atom_types"] = np.argsort(idx, kind="stable")[data["atom_types"]]
return data


Expand Down
192 changes: 96 additions & 96 deletions tests/poscars/POSCAR.P42nmc.replace
Original file line number Diff line number Diff line change
Expand Up @@ -6,99 +6,99 @@ Hf24 O64 Zr8
Hf O Zr
24 64 8
Cartesian
0.0000000000 0.0000000000 0.0000000000
7.5009600000 7.5009600000 5.0819200000
7.5009600000 7.5009600000 0.0000000000
7.5009600000 2.5003200000 10.1638400000
2.5003200000 7.5009600000 5.0819200000
2.5003200000 7.5009600000 10.1638400000
2.5003200000 2.5003200000 5.0819200000
2.5003200000 2.5003200000 10.1638400000
5.0006400000 2.5003200000 7.6228800000
10.0012800000 7.5009600000 2.5409600000
0.0000000000 2.5003200000 7.6228800000
0.0000000000 2.5003200000 2.5409600000
7.5009600000 5.0006400000 7.6228800000
7.5009600000 5.0006400000 2.5409600000
10.0012800000 7.5009600000 7.6228800000
7.5009600000 0.0000000000 2.5409600000
0.0000000000 0.0000000000 5.0819200000
0.0000000000 5.0006400000 5.0819200000
7.5009600000 0.0000000000 7.6228800000
5.0006400000 0.0000000000 5.0819200000
2.5003200000 0.0000000000 2.5409600000
5.0006400000 0.0000000000 10.1638400000
2.5003200000 0.0000000000 7.6228800000
2.5003200000 5.0006400000 7.6228800000
1.2501600000 8.7511200000 1.0558196992
1.2501600000 8.7511200000 3.5967796992
1.2501600000 3.7504800000 8.6786996992
1.2501600000 3.7504800000 3.5967796992
6.2508000000 8.7511200000 6.1377396992
6.2508000000 8.7511200000 1.0558196992
6.2508000000 3.7504800000 6.1377396992
8.7511200000 1.2501600000 8.6786996992
6.2508000000 3.7504800000 1.0558196992
1.2501600000 3.7504800000 1.0558196992
1.2501600000 8.7511200000 8.6786996992
8.7511200000 6.2508000000 3.5967796992
8.7511200000 6.2508000000 8.6786996992
1.2501600000 8.7511200000 6.1377396992
1.2501600000 3.7504800000 6.1377396992
6.2508000000 3.7504800000 3.5967796992
6.2508000000 6.2508000000 1.4851403008
6.2508000000 8.7511200000 3.5967796992
6.2508000000 1.2501600000 9.1080203008
6.2508000000 1.2501600000 4.0261003008
1.2501600000 6.2508000000 9.1080203008
1.2501600000 6.2508000000 4.0261003008
1.2501600000 1.2501600000 9.1080203008
1.2501600000 1.2501600000 4.0261003008
6.2508000000 6.2508000000 6.5670603008
8.7511200000 1.2501600000 3.5967796992
6.2508000000 1.2501600000 6.5670603008
6.2508000000 1.2501600000 1.4851403008
1.2501600000 6.2508000000 6.5670603008
1.2501600000 6.2508000000 1.4851403008
1.2501600000 1.2501600000 6.5670603008
1.2501600000 1.2501600000 1.4851403008
6.2508000000 8.7511200000 8.6786996992
6.2508000000 3.7504800000 8.6786996992
3.7504800000 6.2508000000 8.6786996992
8.7511200000 8.7511200000 9.1080203008
3.7504800000 1.2501600000 8.6786996992
3.7504800000 3.7504800000 1.4851403008
3.7504800000 3.7504800000 6.5670603008
3.7504800000 8.7511200000 1.4851403008
3.7504800000 8.7511200000 6.5670603008
8.7511200000 3.7504800000 1.4851403008
8.7511200000 3.7504800000 6.5670603008
8.7511200000 8.7511200000 1.4851403008
8.7511200000 8.7511200000 6.5670603008
3.7504800000 6.2508000000 3.5967796992
3.7504800000 3.7504800000 9.1080203008
3.7504800000 8.7511200000 4.0261003008
3.7504800000 8.7511200000 9.1080203008
3.7504800000 3.7504800000 4.0261003008
8.7511200000 3.7504800000 9.1080203008
3.7504800000 1.2501600000 3.5967796992
8.7511200000 3.7504800000 4.0261003008
8.7511200000 6.2508000000 1.0558196992
8.7511200000 1.2501600000 6.1377396992
8.7511200000 1.2501600000 1.0558196992
8.7511200000 6.2508000000 6.1377396992
3.7504800000 6.2508000000 1.0558196992
3.7504800000 1.2501600000 6.1377396992
3.7504800000 1.2501600000 1.0558196992
6.2508000000 6.2508000000 4.0261003008
8.7511200000 8.7511200000 4.0261003008
3.7504800000 6.2508000000 6.1377396992
6.2508000000 6.2508000000 9.1080203008
7.5009600000 2.5003200000 5.0819200000
5.0006400000 7.5009600000 7.6228800000
5.0006400000 7.5009600000 2.5409600000
5.0006400000 2.5003200000 2.5409600000
2.5003200000 5.0006400000 2.5409600000
5.0006400000 5.0006400000 5.0819200000
5.0006400000 5.0006400000 10.1638400000
0.0000000000 5.0006400000 10.1638400000
0.000000 0.000000 0.000000
0.000000 0.000000 5.081920
0.000000 5.000640 5.081920
5.000640 0.000000 10.163840
5.000640 0.000000 5.081920
2.500320 0.000000 2.540960
2.500320 0.000000 7.622880
2.500320 5.000640 7.622880
7.500960 0.000000 2.540960
7.500960 0.000000 7.622880
7.500960 5.000640 2.540960
7.500960 5.000640 7.622880
0.000000 2.500320 2.540960
0.000000 2.500320 7.622880
10.001280 7.500960 2.540960
10.001280 7.500960 7.622880
5.000640 2.500320 7.622880
2.500320 2.500320 10.163840
2.500320 2.500320 5.081920
2.500320 7.500960 10.163840
2.500320 7.500960 5.081920
7.500960 2.500320 10.163840
7.500960 7.500960 0.000000
7.500960 7.500960 5.081920
3.750480 3.750480 1.485140
3.750480 3.750480 6.567060
3.750480 8.751120 1.485140
3.750480 8.751120 6.567060
8.751120 3.750480 1.485140
8.751120 3.750480 6.567060
8.751120 8.751120 1.485140
8.751120 8.751120 6.567060
3.750480 3.750480 4.026100
3.750480 3.750480 9.108020
3.750480 8.751120 4.026100
3.750480 8.751120 9.108020
8.751120 3.750480 4.026100
8.751120 3.750480 9.108020
8.751120 8.751120 4.026100
8.751120 8.751120 9.108020
3.750480 1.250160 1.055820
3.750480 1.250160 6.137740
3.750480 6.250800 1.055820
3.750480 6.250800 6.137740
8.751120 1.250160 1.055820
8.751120 1.250160 6.137740
8.751120 6.250800 1.055820
8.751120 6.250800 6.137740
3.750480 1.250160 3.596780
3.750480 1.250160 8.678700
3.750480 6.250800 3.596780
3.750480 6.250800 8.678700
8.751120 1.250160 3.596780
8.751120 1.250160 8.678700
8.751120 6.250800 3.596780
8.751120 6.250800 8.678700
1.250160 3.750480 1.055820
1.250160 3.750480 6.137740
1.250160 8.751120 1.055820
1.250160 8.751120 6.137740
6.250800 3.750480 1.055820
6.250800 3.750480 6.137740
6.250800 8.751120 1.055820
6.250800 8.751120 6.137740
1.250160 3.750480 3.596780
1.250160 3.750480 8.678700
1.250160 8.751120 3.596780
1.250160 8.751120 8.678700
6.250800 3.750480 3.596780
6.250800 3.750480 8.678700
6.250800 8.751120 3.596780
6.250800 8.751120 8.678700
1.250160 1.250160 1.485140
1.250160 1.250160 6.567060
1.250160 6.250800 1.485140
1.250160 6.250800 6.567060
6.250800 1.250160 1.485140
6.250800 1.250160 6.567060
6.250800 6.250800 1.485140
6.250800 6.250800 6.567060
1.250160 1.250160 4.026100
1.250160 1.250160 9.108020
1.250160 6.250800 4.026100
1.250160 6.250800 9.108020
6.250800 1.250160 4.026100
6.250800 1.250160 9.108020
6.250800 6.250800 4.026100
6.250800 6.250800 9.108020
0.000000 5.000640 10.163840
5.000640 5.000640 10.163840
5.000640 5.000640 5.081920
2.500320 5.000640 2.540960
5.000640 2.500320 2.540960
5.000640 7.500960 2.540960
5.000640 7.500960 7.622880
7.500960 2.500320 5.081920