[ase-users] Sorting the atoms by type is ASE Atoms object
Spencer Hills
spencer.hills at my.wheaton.edu
Tue Jan 9 16:42:57 CET 2018
Hi Ask,
This seems to work!
Thanks,
Spencer
On Mon, Jan 8, 2018 at 11:03 AM, Ask Hjorth Larsen <asklarsen at gmail.com>
wrote:
> Hi,
>
> 2018-01-08 17:48 GMT+01:00 Spencer Hills via ase-users
> <ase-users at listserv.fysik.dtu.dk>:
> > Hello,
> >
> > I am taking two atoms objects and combining them together in ASE. When I
> > combine the atoms objects together, the atoms in it become ordered based
> on
> > the atoms object that they came from, not the atom type. Is there a
> method
> > in the atoms object that will sort the atoms based in type?
> >
> > For example, say I have a little IrO2 cluster:
> >
> > Ir 22.6334501337769005 19.6996362359443431 21.0784105283482646
> >
> > Ir 20.2595762079976787 22.4702461104581452 20.7038624595503258
> >
> > O 19.3965392350654007 23.4514891890007426 22.1970325117515728
> >
> > O 24.0620720990382466 21.0803337056451703 21.1448758079263861
> >
> > O 15.7084192410784240 19.4294461605727591 20.5780672191905865
> >
> > O 19.7168563866926618 21.1123958649343066 24.2764522228896453
> >
> > Ir 21.3230402254681302 16.6020447883440561 17.0235124864985607
> >
> > O 23.2085293491334674 22.2830325778158311 19.4895699171266834
> >
> > O 18.7714791811689601 19.4119976460262293 16.9011321089083033
> >
> >
> > But I want it to look like this:
> >
> > Ir 22.6334501337769005 19.6996362359443431 21.0784105283482646
> >
> > Ir 20.2595762079976787 22.4702461104581452 20.7038624595503258
> >
> > Ir 21.3230402254681302 16.6020447883440561 17.0235124864985607
> >
> > O 19.3965392350654007 23.4514891890007426 22.1970325117515728
> >
> > O 24.0620720990382466 21.0803337056451703 21.1448758079263861
> >
> > O 15.7084192410784240 19.4294461605727591 20.5780672191905865
> >
> > O 19.7168563866926618 21.1123958649343066 24.2764522228896453
> >
> > O 23.2085293491334674 22.2830325778158311 19.4895699171266834
> >
> > O 18.7714791811689601 19.4119976460262293 16.9011321089083033
> >
> >
> > Is there a way to do that?
>
> import numpy as np
> permutation = np.argsort(atoms.numbers)
> atoms = atoms[permutation]
>
> You may wish to map the atomic numbers to a different set of numbers
> to customize the sort; for example map Ir to something smaller than O
> if that is important.
>
> Best regards
> Ask
>
> >
> >
> > Thanks,
> >
> > Spencer
> >
> >
> > _______________________________________________
> > 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/20180109/7c1b97f2/attachment-0001.html>
More information about the ase-users
mailing list