[ase-users] swap atoms
Tristan Maxson
tgmaxson at gmail.com
Fri Jul 28 05:44:02 CEST 2017
I think a function like this is reasonable, but the following can be done
just as easily. I can put in a pull request for the next version of ASE
with something like this, we can work out details on naming on the request.
Try something like this
atoms[i_a].position, atoms.position[i_b] = atoms.position[i_b],
atoms.position[i_a]
This could get pretty ugly looking in code very quickly though and a helper
function makes sense. Thank you for the suggestion.
Tristan Maxson
On Thu, Jul 27, 2017 at 10:42 PM, Oscar Xavier Guerrero via ase-users <
ase-users at listserv.fysik.dtu.dk> wrote:
> Hello,
>
> I am interested in swapping the positions of two atoms.
>
> This is what I'm doing right now:
>
> atoms = init_atoms.copy()
> atoms[i_a].position = init_atoms[i_b].get('position')
> atoms[i_b].position = init_atoms[i_a].get('position')
>
> Here i_a and i_b are the indices of the two atoms I want to swap. Should
> there be a function in the atoms object that mutates it or returns a copy?
> Something like:
>
> atoms.exchange(i_a, i_b)
> atoms.swap(i_a, i_b)
>
>
>
>
>
>
> _______________________________________________
> 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/20170727/937bf156/attachment.html>
More information about the ase-users
mailing list