Add widget for VACF#37
Conversation
- Add a new `SlidingWindowVACF` class that is O(n) for each window - Support to compute and display particle VACFs - Support for displaying running integral of VACF - Support for configuring selection, dimension type and normalization - Add new test trajectory data file that supports velocities
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
- Add correct title, labels and units for both MSD and VACF
|
This looks great, @PardhavMaradani. If it is not too much, I would suggest you add some of the following features, if feasible:
Here, ii. Normalization usually involves normalizing the ACF by its variance or its value at
Finally, a related suggestion is to have an ACF function that takes in two selections and computes cross-correlations between them. I know this might involve a lot of code additions, so take your time and let me know if you have any questions/need any help with these code implementations. I would also be glad to contribute to some of these if you need any help! |
|
Hi @amruthesht, thanks for reviewing the changes.
Yes, this is feasible. I quickly tried this out, please see next section for some results...
I tried with this option by doing something like this: ...
current = getattr(self.ag, self.physical_property)[:, self._dim]
self.running_sum += current
self.running_count += 1
mu = self.running_sum / self.running_count
for i in range(n):
lag = n - 1 - i
_ = self.u.trajectory[i] # set trajectory to past frame
previous = getattr(self.ag, self.physical_property)
if self.centered:
corr = (current - mu) * (previous[:, self._dim] - mu)
else:
corr = current * previous[:, self._dim]
sum_corr = np.sum(corr, axis=-1)
self.acf_sums[lag] += np.mean(sum_corr)
self.acf_counts[lag] += 1
...I got plots that looked like this:
The plots labelled 'Centered' are the ones with the mean subtracted and the 'Normalized' ones are the normalized ACFs. All of them run through the same code pasted above. The VACF looks the same as before. But the ones for positions and forces don't seem right, but I don't know much and don't know if they are expected / correct. Could you please check and let me know.
Yes, this is already available for customization from the UI. Any attribute that shows up in the Here is an example (includes some of the changes suggested here):
We are currently dividing by the value at 0 as follows: ...
if normalized:
avg_acfs = avg_acfs / avg_acfs[0]
...
Could we add cross-correlations as a separate widget? The current one (if we rename as ACF instead of VACF) takes a single selection phrase. Adding another selection here might make it a bit confusing / complex code wise. A separate widget could make this a clean separation both in terms of what to expect and how we structure it? Could you please let me know if I should go ahead with the generic ACF (for velocities, positions, forces) and mean subtracted (centred) option based on your review of the plots above? (I didn't commit the changes because I wasn't sure if the plots are correct / expected) |
|
@PardhavMaradani - thanks for making the requested changes. The plots look pretty good and reasonable.
I would leave that up to you.
Here, however, the convergence of both will slightly depend on how well the system is equilibrated, so maybe you can have it as an option as to how the user wants MSDs calculated (using correlation or explicit positional subtraction) Apologies for making this progressively more complex and suggesting different implementation approaches. I would leave the final decision to you on how you implement this overall. Whether as separate widgets/functions or otherwise. But great implementation and progress so far on all the correlation and lag-time-based analyses! Everything looks robust and well implemented to me, and I'm sure it will be super useful for real-world analysis use cases! |



Changes made in this Pull Request:
SlidingWindowVACFclass that is O(n) for each windowPR Checklist
Hi @orbeckst, @jeremyleung521, @amruthesht, @HeydenLabASU,
This PR adds a new 'VACF' widget as part of issue #34.
The code for
VACFfollows exactly the same lines as that ofMSDsupport added in PR #35. I used this reference from MDAnalysis/transport-analysis for the VACF computations.Here is an example showing VACF for 'all' and 'protein'. There is support to show normalized values and also particle VACFs if required as shown below:
Based on the reference, I also added an option to show the running integral if configured as shown below:
With PR #35 and this, we will have support for both the lag-time based computations mentioned in issue #34 .
Thanks