[ase-users] Translate only atoms of a certain type

Zeyuan Tang zeyuan.tang at outlook.com
Wed Nov 15 16:37:40 CET 2017


Dear fabian

First, you can select a molecule on your surface slab based on atomic symbol, height or other types.
Then, build a new molecule using the indices above and do translations or rotations on this new molecule.
Finally, replace the molecule on your surface slab with this new molecule.

Here is my scipt:

from ase.io import read
slab = read('CONTCAR')

# select a molecule by atom.symbol or atom.z
sub_indices = [atom.index for atom in slab if atom.symbol in ['C', 'H']]
#sub_indices = [atom.index for atom in slab if atom.z > 10]

sub = slab[sub_indices]

# translate a molecule
sub.translate([0.5, -1, 0])

# rotate a molecule
sub.rotate(20, slab[57].position-slab[54].position, center=sub[0].position)
#sub.rotate(30, '-x', center=sub[0].position)

slab.positions[sub_indices] = sub.positions

Best regards,

Zeyuan Tang
Institute of Functional Nano and Soft Materials
Soochow University
215123, Suzhou, China
Website: tangzeyuan.com<http://tangzeyuan.com/>



________________________________
From: ase-users-bounces at listserv.fysik.dtu.dk <ase-users-bounces at listserv.fysik.dtu.dk> on behalf of fabian via ase-users <ase-users at listserv.fysik.dtu.dk>
Sent: Wednesday, November 15, 2017 22:59
To: ase-users at listserv.fysik.dtu.dk
Subject: [ase-users] Translate only atoms of a certain type

Dear all

I  want to translate a molecule on my surface slab. At the moment i am
doing this "by Hand" in the CONTCAR file after a calculation is done.

Is there a way to translated all the atoms of a certain type or over a
certain height threshold by for example half a lattice vector within ASE?

I would be glad for any pointers in the right direction


All the best


fabian

_______________________________________________
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/20171115/90023928/attachment.html>


More information about the ase-users mailing list