error when calculating center of mass

Skip to first unread message

Jun 7, 2022, 6:55:31 AMJun 7
to MDnalysis discussion
Dear all:

I got a problem when calculating center of mass of some atoms, I used the following code:

pos = u.select_atoms("all").center_of_mass()

I got the following error:

AtomGroup has no attribute center_of_mass

Any suggesting where I am wrong?

Thanks very much,
Ruo-Xu Gu

Jun 7, 2022, 7:09:38 AMJun 7
to MDnalysis discussion
It is found to be an error of my input files. Please ignore this message, and sorry for the disturbe.

Oliver Beckstein

Jun 7, 2022, 12:29:24 PMJun 7
to mdnalysis-discussion
No problem! You can also answer your own question, it may well be of interest to others what the problem was.

Let me add an answer anyway because often people look through the email archive and then they are happy when they find an answer:

For many methods, MDAnalysis needs additional information, such as the mass for AtomGroup.center_of_mass(). If the mass is not provided by the input files then an error like the one you saw occurs. (Masses can also be guessed but that can fail and then you need to look out for a warning.)

The User Guide lists the Topology-specific attributes of an AtomGroup together with the information needed

Oliver Beckstein (he/his/him)

GitHub: @orbeckst

MDAnalysis – a NumFOCUS fiscally sponsored project

Reply all
Reply to author
0 new messages