You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I need to add some more attributes to the Atom class. How can I do it, without changing your Atom and Structures classes?
For instance, I need to add the atomic mass information. I was using settattr to add it to each Atom instance, as follows:
for i in range(atom_num):
# some code here...
setattr(atoms[i], 'mass', mass_value)
s = Structure(atoms, lattice=lattice, title=title)
This solution is partially working, because the information is saved in the Atom instance, and I can get it as, for instance, s[5].mass (where 5 is the index of the 6th atom in the list), but s[5:7].mass generates the following error:
AttributeError: 'Structure' object has no attribute 'mass'
Is there a better to fix this issue?
Thank you
The text was updated successfully, but these errors were encountered:
Hi,
I need to add some more attributes to the Atom class. How can I do it, without changing your Atom and Structures classes?
For instance, I need to add the atomic mass information. I was using
settattr
to add it to each Atom instance, as follows:This solution is partially working, because the information is saved in the Atom instance, and I can get it as, for instance,
s[5].mass
(where 5 is the index of the 6th atom in the list), buts[5:7].mass
generates the following error:AttributeError: 'Structure' object has no attribute 'mass'
Is there a better to fix this issue?
Thank you
The text was updated successfully, but these errors were encountered: