[ase-users] Split POSCAR/CONTCAR files

Oscar Xavier Guerrero oscarxavier.ox at gmail.com
Tue Apr 18 22:53:59 CEST 2017


Hello Fabian,

You can read POSCAR/CONTCAR files with ase.io.read, you get an atoms object
with all the information the file had. Then you can copy parts of that
atoms object into other atoms object. Then use the ase.io.write function to
write POSCAR files for each of the new atoms objects. Since you have a slab
and an adsorbate, you can use the height as a threshold. It really depends
on your systems.

Here's an example:

from ase.io import read, write
atoms = read('CONTCAR')
# assuming the slab is only composed of Cu and the adsorbate has no Cu
slab = [a for a in atoms if a.symbol == 'Cu']
ads = [a for a in atoms if a.symbol != 'Cu']
# you could also use height as the threshold
th = max(a.z for a in atoms if a.symbol == 'Cu')
# you can also use constraints to set the th
slb = {atoms[i].symbol for i in atoms.constraints[0].index}
th = max(a.z for a in atoms if a.symbol in alb)

slab = [a for a in atoms if a.z <= th]
ads = [a for a in atoms if a.z > th]

write('slab.vasp', slab, vasp5=True, sort=True, direct=True, format='vasp')
write('ads.vasp', ads, vasp5=True, sort=True, direct=True, format='vasp')

If you have any questions I'm happy to help.

P.S. heres my github with some of my scripts.
https://github.com/izxle/VaspTools








2017-04-18 2:52 GMT-05:00 fabian via ase-users <
ase-users at listserv.fysik.dtu.dk>:

> Dear all,
>
> I want to perform a series of charge density difference calculations. Therefore i want to split the geometry optimised CONTCAR file
> containing the coordinates from the slab and the Molecule into tow files containing only slab or Molecule coordinates. At the moment i am doing this
> manually. Can someone give me a hint how to read positions and constraints as well as atom types from the POSCAR/CONTCAR files and later write them into two new POSCAR Files?
> I would like to be able to either fix all atomic coordinates or leave the as they are.
> Atom types could also be extracted from OUTCAR or POTCAR files. For now it is sufficient to perform the split based on the ATOM tag.
> Unfortunately i am completely stuck.
>
> 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/20170418/61bf3e68/attachment.html>


More information about the ase-users mailing list