From ceb27125d789e84462be6d2840d4a1c10f9bbc43 Mon Sep 17 00:00:00 2001 From: matteobecchi Date: Wed, 30 Jul 2025 21:46:06 +0200 Subject: [PATCH] Solved bug in orientational_order_parameter(). --- src/dynsight/_internal/descriptors/misc.py | 10 +++++----- tests/trajectory/files/psi.npy | Bin 11384 -> 11384 bytes 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dynsight/_internal/descriptors/misc.py b/src/dynsight/_internal/descriptors/misc.py index b9af561c..b897b38b 100644 --- a/src/dynsight/_internal/descriptors/misc.py +++ b/src/dynsight/_internal/descriptors/misc.py @@ -79,17 +79,17 @@ def orientational_order_param( frame = universe.atoms.positions[:, :2].copy() for i, atom_i in enumerate(frame): - tmp = 0.0 neighbors = neigh_list_per_frame[t][i] + if len(neighbors) <= 2: # noqa: PLR2004 + # if neighbors are none or just 1, psi = 0 + continue + tmp = 0.0 for j in neighbors: if j != i: x, y = frame[j] - atom_i theta = np.mod(np.arctan2(y, x), 2 * np.pi) tmp += np.exp(1j * order * theta) - - if len(neighbors) > 1: - tmp /= len(neighbors) - 1 - + tmp /= len(neighbors) - 1 psi[i][t] = np.abs(tmp) return psi diff --git a/tests/trajectory/files/psi.npy b/tests/trajectory/files/psi.npy index 151a395f0d526c061fbd2d6e0edbf1960651b236..5240bf8943d05e3c2ac6e3a9e9d99d55a3f5626c 100644 GIT binary patch delta 106 ocmewn@grhF+h%pi5T?xrlHMc|34EIwH&;u)W+b3DfhT|w0O%7R3IG5A literal 11384 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I%|ItoSxhMGDGwF+bcE(S38U=N{(D>>Z#H(cY5+Wx|t4ip#|u!>XLa(bEf z;Q#;k!#qF3f^w+F+hBD!rS76sKP+BH1U*#pDIMK8RMHQz?j%+nS?QhD@j`3!$?`O9 zG|@Dkkep1ZJ-GDa5=XLnlu4}+pjW;i!Jg6hr&i<+0&^6GS$_m6NJmOKrHMaDC=ZZ= ze3Ur?LV(=#My|dQ5TpzYgFU|ul=}wC-Vu@L2B9Z$#W%V*I-d$&87-fv5Qw8jU=INY z)4vZ#$T&In02n!%z;1VY{=%{TTx$YoVA649|F!<6pss18WJ=XB0LHS4(cVTtx5Eg`mGmOUN e6+-g3^o@!S`VbhY`C_>Hd${|Lt{ID>@(%z98>C7A