[ase-users] Changing atom indices in an existing atoms object

Andrew Rosen rosen at u.northwestern.edu
Wed Nov 29 18:53:14 CET 2017


Hi Ask,

Thanks for the info. I figured there'd be a roundabout way to do so by
playing around with the atoms object, and what you said suggested would
work. Thanks. To provide context, I asked this question because sometimes
I'll set up NEB runs but my initial and final state will have different
atom indices, which then results in really bizarre interpolated images.

(Sorry I went off-list by accident)

On Wed, Nov 29, 2017 at 11:46 AM Ask Hjorth Larsen <asklarsen at gmail.com>
wrote:

> Hi Andrew,
>
> 2017-11-29 18:17 GMT+01:00 Andrew Rosen via ase-users
> <ase-users at listserv.fysik.dtu.dk>:
> > Hi ASE users,
> >
> > Given an existing atoms object, is there a way to swap the indices of
> > certain atoms? Each atom in the atoms object has an index property, but
> > changing it only changes the copy.
>
> I think you cannot because Atoms (apparently) does not implement
> __setitem__.  One could well implement it, and it would be logical to
> have.
>
> Meanwhile one would have to do something terrible like:
>
> atoms2 = atoms[my_permutation_indices]
> del atoms[:]
> atoms += atoms2
>
> Now the atoms object was changed in-place :)
>
> Best regards
> Ask
>
> >
> > Andrew
> >
> > _______________________________________________
> > ase-users mailing list
> > ase-users at listserv.fysik.dtu.dk
> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20171129/1a90babc/attachment.html>


More information about the ase-users mailing list