Skip to content

Instantly share code, notes, and snippets.

@orbeckst
Last active June 29, 2023 12:05
Show Gist options
  • Save orbeckst/b611626e7640f399580e233195c6429c to your computer and use it in GitHub Desktop.
Save orbeckst/b611626e7640f399580e233195c6429c to your computer and use it in GitHub Desktop.
Radial distribution function (RDF) calculation of the centers of mass of molecules with MDAnalysis.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
Copy link
Author

The first version that I posted was incorrect – the way that one replaces coordinates in the transformation is crucial: This is correct

self.com_atoms.positions = self.get_com()

but the following does not work

self.com_atoms.positions[:] = self.get_com()    # INCORRECT

(The reason is that .positions is a managed attribute that handles setting in a special way — you can't assume that you can just manipulate positions like a simple numpy array.)

@orbeckst
Copy link
Author

Also note that the COM RDF looks a bit funny because it gets very close to r=0 even though self-distances had been excluded.

There's a possibility that this is a problem with unwrap=True. Please check carefully for your own system and let us know on the mailing list https://groups.google.com/group/mdnalysis-discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment