Adding support for iterating through MDAnalysis trajectories#522
Adding support for iterating through MDAnalysis trajectories#522
Conversation
|
Adding a comment to ensure there's a note regarding the compatibility between the Omni runner and this implementation of the Simulation and to make sure this is the intended functionality. Should Omni runner dt passed be altered or use a different method especially given all current protocols (this PR excluded) only advance to the next step regardless. |
| else: | ||
| universe = mda.Universe(structure) | ||
|
|
||
| return cls(name=name, universe=universe) |
There was a problem hiding this comment.
I'm beginning to think this whole constructor doesn't make sense, and we should only have from_universe instead of proxying the Universe constructor.
I'd remove from_path and have the CLI just construct the universe itself before passing it in.
As far as I remember, For this PR it probably makes sense to just pick some sensible mapping factor of real world time to simulation time (possibly exposed as a property for convenience) and leave it at that. Recording/trajectory playback is underdesigned so I don't think there's much more to be done there in this PR. |
|
I updated the |
If you're using the 3TIC (ose) simulation in the notebook for testing, the lack of an observed change is due to my previous comment regarding advancing by seconds in real world vs. simulation time. Assuming the runner interval is set at roughly 30 FPS the simulation will attempt to jump 33 frames - as the simulation only has 24, it just loops back to the beginning so you don't see any change. |
…eal world -> simulation time.
…tion if dt is too low.
|
I've made an update based on trying to get the trajectory playback notebook to work reasonably: the simulation keeps track of simulation time elapsed during playback rather than only which frame is it currently on--this way even a small dt eventually adds up to enough time passing to advance between frames. This is similar to how the recording playback works. Advancing by a step snaps the simulation time to the first time where the next frame would be shown. Do you see any issue with this? The notebook is the only in-repo example of using I put it on another branch so I don't overwrite anything: https://github.com/IRL2/nanover-server-py/compare/feature/mdanalysis_sim_variant |
|
The |
|
With your changes it works as expected in the notebook, which is good, but he logic of how it works seems quite convoluted and difficult to follow. The two ways simulations are advanced are
In I didn't realise this before but
Because this is quite difficult to reason about and there seem to be a few unused or misleading parts, I'm going to switch us to the simplified version I made in the other branch. Let's use that as a base and we can discuss if it's its missing some important behavior from the previous version. |
3dd9587 to
2383e08
Compare
I disagree, the new implementation makes a number of odd choices regarding naming that do not conform to the existing Protocol the class is derived from and a number of regressive edits handling edge cases that will need to be addressed again. The previous implementation aimed to enable 3 distinct functionality via the
The new implenentation does not allow for this. I would argue playback mapping to real world seconds is a more niche usecase than simply advancing a fixed time step every frame. Further removing
The goal of the
This can be None when the default time to step (
Happy to change
The goal of Also, from what I understand of this current implementation, the |
|
I addressed things individually, but the long and the short of it for me is still: the previous version was difficult to follow and the complexity obscured what seem to be a number of redundancies and bugs. The alternate implementation is two completely linear methods to implement the two required methods of the
My point here was that
My point here is that 1. The existing recording playback
Since the methods for jumping to particular timestamps/frames don't form part of the
The rationale for mapping time is just that since the trajectories can have different time resolutions and different frequency of frame reporting, it will lead to different rates of frame playback that can end up being way too slow or way to fast. The existing example for trajectory playback (https://github.com/IRL2/nanover-server-py/blob/main/tutorials/mdanalysis/mdanalysis_trajectory.ipynb) provided
I don't really understand the motivation for this functionality--who is it for? It only works when you call In any case I think it obscures things 1. that it is a seperate class, and 2. that its presented as an iterator, when it encapsulates logic that is only used in exactly one place ( My intention with reworking it is just be explicit that there are two ways to manipulate this object--go to the next frame, or go to a point in the playback time--and then to make the implementations of those two operations completely clear about what they are doing: determine the current frame and move to the next one and update time, or update time and determine the resulting frame. It's difficult to follow the original version where the internal state of playback is hidden inside Similar, to me it's clearer to be explicit about what duration each loop is supposed to be by writing: Whereas, as far as I can tell, using
The intention here was just to avoid having to handle looping as a special case, but if the users find it confusing, it can be changed of course. |
|
For the minor stuff, e.g. frame jump computations - I don't have any super critical issues its mostly semantic issues or me attempting to future proof the code for future issues I see arising.
That said, I still believe there are 2 key issues to be resolved: Regarding the 3 seperate functionalities: Regarding handling jumping to a timepoint that is out of bounds for the simulation (e.g. asking to |
|
I have taken the current implementation + tests and merged them (#539), but with the-non protocol methods private so they can easily be renamed at a later date. This puts main in a state where What more to add/expose or not e.g advance to next report, seeking, timing control, improving the looping behaviour etc we can continue discussing after Christmas. If I have time I'll try to respond to your points above but our office closes in the next few days. |
Quick PR to add ability for MDAnalysisSimulation protocols to iterate through Universes.