From 260d2bd43f5a9c15f9ebcc47cb3c2157d305397b Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Thu, 19 Mar 2026 14:00:41 +0000 Subject: [PATCH 1/2] Fix issue in counting num excluded pairs --- cmeutils/structure.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmeutils/structure.py b/cmeutils/structure.py index 4ee10f7..0b18a2e 100644 --- a/cmeutils/structure.py +++ b/cmeutils/structure.py @@ -528,7 +528,13 @@ def gsd_rdf( [i * max_idx + j for i, j in excluded_pairs] ) - n_excluded = len(excluded_pairs) + n_excluded = sum( + 1 + for i, j in excluded_pairs + if (i in type_A and j in type_B) + or (j in type_A and i in type_B) + ) + if A_name == B_name or not any( [A_name, B_name] ): # Using same type or all particles From 9067d1111bc00b26a74d50304385e3d751a42f51 Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Thu, 19 Mar 2026 14:49:13 +0000 Subject: [PATCH 2/2] Fix exclusion counting issues, add new tests, update gsd file for testing --- cmeutils/structure.py | 8 ++++++-- cmeutils/tests/assets/AB-traj.gsd | Bin 5648 -> 6728 bytes cmeutils/tests/test_structure.py | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/cmeutils/structure.py b/cmeutils/structure.py index 0b18a2e..b63f598 100644 --- a/cmeutils/structure.py +++ b/cmeutils/structure.py @@ -502,13 +502,16 @@ def gsd_rdf( # These 2 *_indices variables store global particle indices (Before filtering by type) # If excluding by bond depth, these need to be passed into filter_nlist type_A_indices = np.where(type_A)[0] + type_A_set = set(type_A_indices) type_B_indices = np.where(type_B)[0] + type_B_set = set(type_B_indices) exclude_ii = A_name == B_name else: # Use all particles for this RDF type_A = type_B = np.ones( snap.particles.N, dtype=bool ) # Array of True at all indices type_A_indices = type_B_indices = np.arange(snap.particles.N) + type_A_set = type_B_set = type_A_indices exclude_ii = True # Build up pair exclusions if exclude_bond_depth or exclude_all_bonded @@ -528,11 +531,12 @@ def gsd_rdf( [i * max_idx + j for i, j in excluded_pairs] ) + # Only count excluded pairs if they are being used in the RDF calculation n_excluded = sum( 1 for i, j in excluded_pairs - if (i in type_A and j in type_B) - or (j in type_A and i in type_B) + if (i in type_A_set and j in type_B_set) + or (j in type_A_set and i in type_B_set) ) if A_name == B_name or not any( diff --git a/cmeutils/tests/assets/AB-traj.gsd b/cmeutils/tests/assets/AB-traj.gsd index 58755f52389973d4cc8d717d905456fdb65b4b46..1774fb59da6f11bab466e14286cdb673f78aaab9 100644 GIT binary patch delta 1526 zcmZ9Kc~sO@6vuxvjKHwYs7MkbU`lQ%9Fk$)!{7a(AcWgdF_jP%6I9fWsepjLArz2J z8UqTH85atZ5K>v@Jy}dP!5CaZOmn~`(*!KkjtLVUq!WDqx$oZ3_n!Cexi4czgPU5& z3z$Kfyp57^g9n3wAY#Of@NIpFCyn55d~YLMSbDkMB!q79^z!;9; zVebsTz-R>5jo`*3_^R>$?{^Rn%s8l_3ADou;rlMb3prt7!UtZZZkt6d;SpCrs&bY@<~{FT`u4xkf0P zuL7_51ln_|n8Gw2e3$5m-43k7EM_=|x*ED$ZA~5ZmfZE3Qo2LdP2N0^o9T79-pY>` zS=*z`Kh*Tvd?m?>jA6s4A?mfHhVH6lV1DgF+}ykb-_x=%roEdK8*e7F4HZyEo#d$& z-Xz9T4Hvg79z3?=@nzE@jZ0k&+c$rMM~%)M@BXZhwK>*}5_TLyvZnxZXa-SkZbnI) z72y6T6ZLAZVbdonXn)=%j|=PZ2=J|jkHhYfhLlh$x_%cfFZM!2!aJSBDNW4ly1x2%{abFkNIKc_K%Xyy7SF!5L~W59}ooi_Pe$&?+dL zbc&uXUPNbB+y!m@Z^V15BYw9{4}mFZ70>LdkkUxP=>yW_(f8+(CXW!xSZ~wRH8h|b z&arG}&34?ZmgDFT``OO)k4TBnc(lR~Ab$a0QelT1X)RVjY1T8%t1dC#x?K&0O-~7A zIN>{+s$r^6knGIlGUQ!<7w&s#NW#7tEFSn=4Ub*u7Js1oS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