MSD Calculation Clarification

112 views
Skip to first unread message

Luke Kruse

unread,
Jun 13, 2023, 4:50:34 PM6/13/23
to MDnalysis discussion
Hello,
I wanted to clarify if the selection used in the MSD calculations does in fact update for each frame? 

I am trying to assess the diffusion coefficient as a function of the distance from a protein's COM and wanted to use this tool to get the MSD for sodium ions within a spherical cutoff, so I want to make sure that only the ions that remain within the cutoff are considered.

All the best,
Luke

Oliver Beckstein

unread,
Jun 13, 2023, 7:16:11 PM6/13/23
to mdnalysis-discussion
Hi Luke,

Welcome to the MDA mailing list!

On Jun 13, 2023, at 12:29 PM, Luke Kruse <kruse....@gmail.com> wrote:

Hello,
I wanted to clarify if the selection used in the MSD calculations does in fact update for each frame? 

No, it does not. It only works with static selections,


I am trying to assess the diffusion coefficient as a function of the distance from a protein's COM and wanted to use this tool to get the MSD for sodium ions within a spherical cutoff, so I want to make sure that only the ions that remain within the cutoff are considered.

Sorry, “ragged MSD”  is not implemented. See https://groups.google.com/g/mdnalysis-discussion/c/A6cVBlkfaNU/m/vxVxOdq7AAAJ for some comments (and possibly other conversations on the mailing list).

Best,
Oliver


All the best,
Luke




--
Oliver Beckstein (he/his/him)

email: orbe...@mdanalysis.org
twitter: @orbeckst
GitHub: @orbeckst

MDAnalysis – a NumFOCUS fiscally sponsored project




Luke Kruse

unread,
Jun 14, 2023, 2:16:18 PM6/14/23
to MDnalysis discussion
Thank you for the quick response Oliver! 
1) Can you verify that is the same for the MSD class/function within the waterdynamics sub-module (imported via from MDAnalysis.analysis.waterdynamics import MeanSquareDisplacement as MSD)?
2) Also, does this MSD class require a universe created with unwrapped coordinates?
All the best,
Luke

Oliver Beckstein

unread,
Jun 15, 2023, 12:49:18 PM6/15/23
to mdnalysis-discussion
Hi Luke,

Answers to the best of my knowledge/reading of our docs&code but I hope someone else is correcting me if necessary:

On Jun 14, 2023, at 11:16 AM, Luke Kruse <kruse....@gmail.com> wrote:

Thank you for the quick response Oliver! 
1) Can you verify that is the same for the MSD class/function within the waterdynamics sub-module (imported via from MDAnalysis.analysis.waterdynamics import MeanSquareDisplacement as MSD)?

no, unlike the Einstein MSD,which works with static atomgroups, the classes in waterdynamics re-evaluate the selection string for every frame and accumulate data in regions defined by the selections. (I’d still think carefully about it if you do this in thin z slices but doing that for more compact volumes such as cylinders or spheres may make sense — as always, read the referenced literature!)

2) Also, does this MSD class require a universe created with unwrapped coordinates?

By “unwrapped” do you mean (1) continuous diffusive trajectories that are never mapped back in the primary unit cell or (2) molecules made whole across boundaries. I assume you mean (1). 

I *think* that unwrapping would actually lead to wrong results because then the selections would not locate the water in the right position in the primary unit cell. I am pretty sure that any selections near the boundary of the box will be problematic. So I would only use the analysis here for the originally intended purpose: water properties in a well defined, compact volume near the center of the unit cell. In this case, don’t preprocess your trajectory (just make sure that all molecules are in the box).

As always when using someone else’s code: (1) read the papers, (2) try it on something where you know the answer to validate it, (3) be careful in interpreting the results.

We try our best to only have code in MDAnalysis that produces correct results and works well, but we don’t always succeed. Furthermore, when you use code outside its “normal” use cases then odd things may happened, just because the original authors did not think about it.

Luke Kruse

unread,
Jun 15, 2023, 1:12:07 PM6/15/23
to mdnalysis-...@googlegroups.com
Thank you Oliver! 

I think I arrived at the same conclusion for (1) by comparing results with gromacs tools and certainly understand the hesitancy in drawing too much from these analyses. For (2) I did indeed mean what you assumed. I was under the impression that traditional self-diffusion assessments ought to be done on unwrapped trajectories but curiously, when I compared the results from the aforementioned analysis with wrapped and unwrapped trajectories I obtained the same results with both xtc files (although this well could be a result of the small cutoff radius from the protein I was considering).

Thank you again for your help!
Best,
Luke


--
You received this message because you are subscribed to a topic in the Google Groups "MDnalysis discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mdnalysis-discussion/9D3sGpRG6pQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/AA28F9A4-17FB-4D63-AC98-7D468E3A2A27%40mdanalysis.org.

Hugo Macdermott-Opeskin

unread,
Jun 15, 2023, 10:36:30 PM6/15/23
to MDnalysis discussion
Hi Luke, 

What you needto run an MSD is a "nojump" trajectory in gromacs parlance. With the new NoJump transform in MDAnalysis it should be possible to nojumpify in MDA otherwise you can do it in trjconv. We have an open issue to update the docs around this.

Luke Kruse

unread,
Jun 15, 2023, 10:40:42 PM6/15/23
to mdnalysis-...@googlegroups.com
Hello, 

Thank you for the clarification. That’s was indeed what I tried when I made the comparison but I think since my box was significantly larger than the protein and the cutoff I was looking in was small, the results were appropriately the same!

Best,
Luke

From: mdnalysis-...@googlegroups.com <mdnalysis-...@googlegroups.com> on behalf of Hugo Macdermott-Opeskin <hugomac...@gmail.com>
Sent: Thursday, June 15, 2023 9:36:30 PM
To: MDnalysis discussion <mdnalysis-...@googlegroups.com>
Subject: Re: [mdnalysis-discussion] MSD Calculation Clarification
 

Oliver Beckstein

unread,
Jun 15, 2023, 11:22:35 PM6/15/23
to mdnalysis-discussion
Hi Hugo,

I understand that you need a nojump trajectory for regular bulk MSD. But what about any of the spatially resolved situations that I think Luke was inquiring about? How does a continuous trajectory help you there (unless your spatial selection is also PBC aware)? When calculating a spatially dependent diffusion coefficient D(V) (where V is a volume element of your choice) then it only makes sense to analyze waters as long as they are inside V (and maybe one time step dt after exiting V). The only time when nojump would be relevant is when V is exited across the periodic boundary as this would add a big jump to the displacement timeseries.   

As I see it, no-jumping a trajectory might actually give you incorrect results because you find fewer waters in the volume (again, if the selections are not PBC aware, which is the case for naive “z between z1 and z2”; I *think* distance-based selections might actually take PBC into account although I’d double check...)

Oliver

Hugo Macdermott-Opeskin

unread,
Jun 15, 2023, 11:28:26 PM6/15/23
to MDnalysis discussion
Hi Oliver, 

I don't think that for a D(V) volume element calculation that nojump or any unwrapping is helpful at all, and as you say should be avoided.
Again as you say the volume element would have to be PBC aware which is not easy or implemented in any package I know about. 

Sorry If i caused any confusion. 

Cheers, 

Reply all
Reply to author
Forward
0 new messages