[ase-users] Split POSCAR/CONTCAR files

Oscar Xavier Guerrero oscarxavier.ox at gmail.com
Wed Apr 19 18:11:35 CEST 2017


No, you would have to use in:

slab_elms = ['Cu', 'O']
slab_i = [a.index for a in atoms if a.symbol *in slab_elms*]

This is correct only if you have no O in your adsorbate. Otherwise, it
would be better to use height to separate.


2017-04-19 2:56 GMT-05:00 fabian <Fabian.T89 at web.de>:

> Dear Oscar,
> Thank you very much for your fast reply! This is exactly what i want to do!
>
>
> If my slab consist of different species , for example Cu and O atoms, is
> it correct to change this line
>
>
> slab_i = [a.index for a in atoms if a.symbol == 'Cu']
>
>
> to
>
>
>
> slab_i = [a.index for a in atoms if a.symbol == 'Cu','O'] ?
>
>
> All the best
>
>
> fabian
>
>
> Am 18.04.2017 um 23:25 schrieb Oscar Xavier Guerrero:
>
> Sorry, in the previous example I forgot to convert from list to an atoms
> object.
>
> This should work:
>
> from ase.io import read, write
> from ase.atoms import Atoms
> atoms = read('CONTCAR')
> # assuming the slab is only composed of Cu and the adsorbate has no Cu
> slab_i = [a.index for a in atoms if a.symbol == 'Cu']
> ads_i = [a.index 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_i = [a.index for a in atoms if a.z <= th]
> ads_i = [a.index for a in atoms if a.z > th]
>
> # this is a quick fix, maybe there's a better method
> slab = atoms.copy()
> for i in sorted(ads_i, reverse=True):
>     del slab[i]
> ads = atoms.copy()
> for i in sorted(slab_i, reverse=True):
>     del ads[i]
>
> # or you could use Atoms
> slab = Atoms([a for a in atoms if a.index in slab_i])
> ads = Atoms([a for a in atoms if a.index in ads_i])
> cell = atoms.get_cell()
> slab.set_cell(cell)
> ads.set_cell(cell)
> constraint = atoms.constraints[0]
> slab.set_constraints(constraint)
> ads.set_constraints(constraint)
>
> 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.
>
>
> 2017-04-18 15:53 GMT-05:00 Oscar Xavier Guerrero <oscarxavier.ox at gmail.com
> >:
>
>> 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/iz
>> xle/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/20170419/cf3362d9/attachment.html>


More information about the ase-users mailing list