I cannot think of a simple way to change the index, there’s certainly no way to just relabel the ID.
If you have an array of new indices, let’s say new_indices where
new_indices[0] = index of O atom in water 0 that should come at index 0
new_indices[1] = index of H1 atom in water 0 that should come at index 1
new_indices[2] = index iof H2 atom in water 0 that should come at index 2
new_indices[3] = index of O atom in water 1 that should come at index 3
new_indices[4] = index of H1 atom in water 1 that should come at index 4
…
i.e., a permutation of the original indices so that you have the O H H O H H … ordering, then you could use a transformation
def reorder_waters(ts, new_indices=new_indices):
ts.positions = ts.positions[new_indices]
return ts
and then apply the transformation to the universe
u.add_transformations(reorder_water)
This is will ONLY change the coordinates around. Any topology information is still in the original order. I can’t guarantee that this will work with water dynamics. However, this might give you an idea how to get started if you want to change coordinate ordering on the fly.
Oliver