Skip to content

Enable kDTree optimization for PCFAngle and PCF2d#159

Open
UrbanGalaxy wants to merge 11 commits intoamepproject:leifs_editsfrom
UrbanGalaxy:pcf_angle_particleorientation
Open

Enable kDTree optimization for PCFAngle and PCF2d#159
UrbanGalaxy wants to merge 11 commits intoamepproject:leifs_editsfrom
UrbanGalaxy:pcf_angle_particleorientation

Conversation

@UrbanGalaxy
Copy link
Copy Markdown

I added a use_kDTree boolean parameter and the corresponding logic to PCFAngle and PCF2d. This allows the calculation to use a kDTree nearest-neighbor list. I also added the orientation mode for PCF2d.

Motivation/Benefits: Previously, the pair correlation was calculated over all particles. By using the kDTree, the calculation is now restricted to relevant particles within the cutoff distance (r≤rmax​), which significantly improves performance.

@kay-ro kay-ro changed the base branch from develop to release-1.3.0 February 3, 2026 09:29
@kay-ro kay-ro changed the base branch from release-1.3.0 to develop February 3, 2026 09:33
Comment thread .gitignore
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not add your personal .gitignore lines here.
you may push .vscode/ as it is a common directory but not your personal file structure please.

Comment thread amep/utils.py Outdated
Comment on lines +698 to +703
# # -> 'ni' = (N particles, 3 rotated coords)
# coords = np.einsum('nij,nj->ni', R, coords)

# # redo the shift operation
# coords = coords + center
# return coords
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please clean code and remove comments

Comment thread Compare_h5.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you created this file?
please check how tests are done properly. a minimal run of a functionality which is compared on the data level and not comparing two saved files (which would be a test on its own)

Comment thread PCF_test.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add any test to the test suite in test/test_evaluate.py for example. or test/test_spatialcor.py

Comment thread PCF_test.py
if not os.path.exists(plot_dir):
os.makedirs(plot_dir)

print("AAAAA")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment thread amep/utils.py Outdated

def rotate_coords(
coords: np.ndarray, theta: float, center: np.ndarray) -> np.ndarray:
coords: np.ndarray, theta: float | np.float32 | np.float64, center: np.ndarray) -> np.ndarray:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove np.float32 and np.float64. these should not be used for type hinting here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this modification of the test workflow?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the test run when something is pushed, this way i was able to see that is passed the tests without initiating the pull request

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though this sounds nice, this is not the aimed process. If you want to check the tests on GitHub, a pull request can be created.

Copy link
Copy Markdown
Member

@kay-ro kay-ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments. Afterwards, I can check the functionality.

@UrbanGalaxy
Copy link
Copy Markdown
Author

I think i changed everything you requested besides my modification to the test workflow.

If you want me to change it or anything else let me know.

@kay-ro kay-ro changed the base branch from develop to leifs_edits March 9, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants