[ase-users] Multipurpose variable needed for atoms

Ask Hjorth Larsen asklarsen at gmail.com
Thu May 16 12:57:50 CEST 2019


Dear Michael,

Am Do., 16. Mai 2019 um 09:18 Uhr schrieb Michael Walter via ase-users
<ase-users at listserv.fysik.dtu.dk>:
>
> Dear all,
>
> I propose to have a multipurpose variable in atoms that can store any data needed. I propose to use tag for that.
>
> A possible example is the corehole energy, which is not defined for H. The following code should be possible (it is not currently)
>
> from ase import Atoms
>
> corehole_energies = [288.25, None]
>
> atoms = Atoms('CH', tags=corehole_energies)
> assert atoms.get_array('tags') == corehole_energies
>
> This fails as atoms.get_array('tags') gives [288, 0] as if there would be a core-hole energy of 0, which is obviously wrong. One may catch this, but what in case that 0 would be a possible value ? The restriction to ints further cuts the value for 'C'.
>
> The good thing top have a multipurpose value is that we could color the atoms according to this value in the gui (and leave atoms with None white).
>
> One could also misuse 'charge' or 'magmom' for that (I often did that), but 'tag' would be more logical in my opinion. One could also introduce a new variable 'property' (or a better name).
>
> Any thoughts or complains?

Maybe play around with:

atoms.set_array('corehole_energies', myarray)

myarray can then be a float array.  But if you are serious about None,
you could try dtype=object.  I suspect that the 'misleading zero'
might not be such a big problem though.

The GUI is only aware of our 'own' arrays, but it would be nice if it
could show which custom arrays are present and use them for colouring.

Best regards
Ask


More information about the ase-users mailing list