-
Notifications
You must be signed in to change notification settings - Fork 823
Description
Is your feature request related to a problem? Please describe.
Currently, all functions that operate (especially in-place) on atom positions obtain a copy of atom positions via AtomGroup.positions, regardless of whether positions are modified in- or out-of-place, or they are merely input data that is not altered. In some (if not many) cases, a tremendous speed-up could be achieved if the respective functions could obtain a view instead of a copy of an AtomGroup's positions. At the moment, this is not possible for two reasons:
AtomGroup.positionsgets its data fromUniverse.trajectory.ts.positionsvia fancy indexing, and fancy indexing means copying.- More importantly,
Universe.trajectory.ts.positionsrefers tocoordinates.base.Timestep._pos, which is a Fortran-contiguous array. Therefore, potentially obtained views of that array are unsuitable for use with C-level functions.
Describe the solution you'd like
Change coordinates.base.Timestep.order from 'F' to 'C' and provide a way of obtaining a (if possible, C-contiguous) view of an AtomGroup's positions.
Describe alternatives you've considered
Invent computers with two-dimensional main memory...
Additional context
Two candidates that come to my mind in terms of speed-up are *Group.center*() and *Group.wrap()
when the index array *Group.atoms.ix is a (contiguous) range.
A possible drawback of changing the positions/velocities/forces memory layout is that reading and (probably to a lesser extent) writing of DCD trajectories will be a bit slower since DCD stores positions etc. as Fortran-contiguous arrays.
If you have any additional concerns, please let me know!