-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to select MSD algorithm #291
Conversation
Speed up trajectory._unwrap_pbc
This PR also closes #290 |
Refer to this notebook for an overview of this PR |
Can you say a little bit what this PR does? |
The goal of this PR is to allow the user to select the desired algorithm to measure the MSD and the MSAD. The same choice is made available for the plotting functions in For the MSD the user can select how many 'starting points' to use via The same approach has been implemented for the MSAD (and Additionally, this PR also addresses some minor improvements, like implementing the time units on the msd plots, normalizing the autocorrelation and plotting the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SCiarella just made a first pass. Plots look great as always 🚀
I'm not entirely convinced that we need numba over some vectorized numpy code (see comments).
I also do not understand why we need nstarts
as an argument it adds, for me it complicates things. What would be the most optimal way to calculate the msd? That should be the one we support.
Finally, can you add some unit tests (not integration) for the new code?
src/gemdat/rotations.py
Outdated
@@ -298,45 +299,93 @@ def calculate_spherical_areas(shape: tuple[int, int], | |||
return areas | |||
|
|||
|
|||
def autocorrelation(trajectory: np.ndarray) -> tuple[np.ndarray, np.ndarray]: | |||
"""Compute the autocorrelation of the trajectory using FFT. | |||
def mean_squared_angular_displacement( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me like this should be a method on Trajectory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the input trajectory for mean_squared_angular_displacement
is a unit vector trajectory that gets returned from Orientations
directly as a np.ndarray. We should address the output of Orientations
in a future PR.
Update: After the optimization happening in this PR, GEMDAT will support only the most efficient methods for the MSD and the MSAD, which are the FFT methods. The results of a comparison available here show that: (3) the MSAD direct method converges toward the FFT results |
This PR closes #274 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This PR closes #285.