New RDF method with flexible pair exclusions defined by an arbitrary bond depth. - #149
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
==========================================
+ Coverage 96.24% 96.29% +0.04%
==========================================
Files 8 8
Lines 773 810 +37
==========================================
+ Hits 744 780 +36
- Misses 29 30 +1
🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
|
I did some re-arranging. From |
There was a problem hiding this comment.
Pull request overview
This PR refactors the gsd_rdf function to support flexible pair exclusions based on bond graph depth, replacing the previous molecule-level exclude_bonded option. It also reorganizes code by moving get_quaternions to cmeutils/geometry.py, get_centers to cmeutils/gsd_utils.py, and removes the all_atom_rdf function (its functionality is subsumed by the updated gsd_rdf with A_name=None, B_name=None).
Changes:
- Rewrote
gsd_rdfwith newexclude_bond_depthandexclude_all_bondedparameters, plus supporting functionsget_excluded_pairsandfilter_nlistthat use networkx bond graphs. - Moved
get_quaternionsfromstructure.pytogeometry.pyandget_centersfromstructure.pytogsd_utils.py, updating tests and imports accordingly. - Added new test fixtures (
AB_chain_gsd,LJ_gsd) and comprehensive tests for the new RDF exclusion logic.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| cmeutils/structure.py | Rewrote gsd_rdf with bond-depth exclusions; added get_excluded_pairs and filter_nlist; removed get_quaternions, get_centers, all_atom_rdf |
| cmeutils/gsd_utils.py | Added snapshot_to_graph and moved get_centers here |
| cmeutils/geometry.py | Moved get_quaternions here from structure.py |
| cmeutils/tests/test_structure.py | Updated RDF tests for new API; moved get_quaternions/get_centers tests out |
| cmeutils/tests/test_gsd.py | Added get_centers test |
| cmeutils/tests/test_geometry.py | Added get_quaternions test |
| cmeutils/tests/base_test.py | Added AB_chain_gsd and LJ_gsd fixtures |
| cmeutils/init.py | Reformatted __all__ list |
| cmeutils/tests/assets/AB-traj.gsd | New test asset for chain RDF tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
As of now, the normalization correction isn't accounting for updated bond graphs. We could compute single-frame RDFs and keep a list of normalization corrections (instead of using freud's accumulation). This would let us return standard deviations at each r value as well. |
|
I'm just going to remove the |


The current
gsd_rdfmethod lets you exclude all pairs that belong to the same molecule. This was done initially to reduce huge signals in the RDF resulting from bonded neighbors. But, it's often too extreme of a correction, especially for polymers where you want to capture distances resulting from chains folding onto themselves. Instead, this new method lets you set bond exclusions based on bond depth (counted in steps down a bond graph). So, for a polymer, you might set an excluded depth to prevent pairs within a stiff region, but include pairs further down the chain.I've tested it out with some simple single-chain trajectories, and it seems to be working exactly as intended. I'll try it on some bulk systems too.
Still left to do is make sure the normalization is being handled correctly.
Also, still need to get it working for excluding all bonded (to keep the old behavior).