Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding attributes to Atom class #1

Open
pcpatfire opened this issue Apr 4, 2021 · 0 comments
Open

Adding attributes to Atom class #1

pcpatfire opened this issue Apr 4, 2021 · 0 comments

Comments

@pcpatfire
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant