Quality Check
pysammos.data_handle.contacts.qualitycheck package
Subpackage for performing quality checks on contact data.
Duplicates module
pysammos.data_handle.contacts.qualitycheck.duplicates module
This module provides functionality to identify and remove duplicate particle pairs from contact data. It ensures that each unique pair of particles is represented only once, regardless of their order (i.e., (A, B) is considered the same as (B, A)). It is particularly useful in DEM simulations computed in parallel, where duplicate pairs may arise due to the use of ghost particles or other parallelization artifacts.
- This module contains two main functions:
get_unique_pairs(): Identifies and filters duplicate particle pairs from two arrays.delete(): Removes duplicate particle pairs and their associated data from the original contact list.
- pysammos.data_handle.contacts.qualitycheck.duplicates.delete(Particle_LL_OG, Particle_I_OG, Fij_OG, Contacts_OG)[source]
Remove duplicate particle interaction pairs and associated data.
Uses get_unique_pairs() to retain only the first occurrence of each particle pair (treating (A, B) and (B, A) as duplicates).
- Return type:
Tuple[ndarray,ndarray,Optional[ndarray]]
Inputs
- Particle_LL_OGndarray, shape (N,).
Particle A IDs for original contact list.
- Particle_I_OGndarray, shape (N,).
Particle B IDs for original contact list.
- Fij_OGndarray, shape (N, 3).
Contact force vectors corresponding to particle pairs.
- Contacts_OGndarray or None, optional, shape (N, 3).
Contact point coordinates. If None, no contact points are returned.
Outputs
- Particle_LLndarray, shape (M,).
Filtered Particle A IDs.
- Particle_Indarray, shape (M,).
Filtered Particle B IDs.
- Fijndarray, shape (M, 3).
Filtered contact forces.
- Contactsndarray or None, shape (M, 3), optional.
Filtered contact points if provided.
- pysammos.data_handle.contacts.qualitycheck.duplicates.get_unique_pairs(LL_py, I_py)[source]
Identify and filter duplicate particle pairs.
Given two arrays representing particle interactions, this function identifies all unique unordered pairs (i.e., (A, B) and (B, A) are treated as the same) and returns the indices of the first occurrence of each pair.
- Return type:
ndarray
Inputs
- LL_pyndarray, shape (N,).
First particle ID array.
- I_pyndarray, shape (N,).
Particle that particle LL is interacting with.
Outputs
- keep_indicesndarray, shape (M,).
Indices of the first occurrence of each unique pair.
Examples
>>> LL_py = np.array([1, 2, 1, 4, 1, 3, 7]) # Particle A IDs with duplicates >>> I_py = np.array([2, 1, 2, 3, 3, 1, 4]) # Particle B IDs with duplicates >>> keep_indices = get_unique_pairs(LL_py, I_py) >>> print(keep_indices) [0 3 4 6] This indicates that the unique pairs are found at indices 0, 3, 4, and 6 of the original arrays.