ASE - generate POSCAR

Art is long, but life is short.

人生有限, 学问无涯

Updated time: 12/24 2023.

Generating the POSCAR file of gold with hcp and fcc structures

Noted that: bulk and 12-layer closed-packaged plane

INPUT: a, num_layers, Miller index of fcc and hcp

OUTPUT: POSCAR_gold_fcc, POSCAR_gold_hcp

Reference: Surfaces — ASE documentation (dtu.dk)

from numpy import sqrt
from ase import Atoms
from ase.build import bulk, fcc111, surface
from ase.io import write
from ase.visualize import view

Define the lattice parameters for hcp structure

## Function: 
## INPUT :   a, num_layers, Miller index of fcc and hcp
## OUTPUT:   POSCAR_gold_fcc, POSCAR_gold_hcp
# Define the lattice parameters for hcp structure
a = 2.95  # lattice constant
# Create an bulk hcp structure for gold
Goldbulk_hcp = bulk('Au', 'hcp', a=a, covera=sqrt(8.0/3.0))
# slice
# Set the number of layers to 12
num_layers = 12
num_rep_z = int(num_layers/len(Goldbulk_hcp.numbers))
gold_hcp = surface(Goldbulk_hcp, (0,0,1), num_rep_z)
gold_hcp.center(vacuum=20, axis=2)
# print(Goldbulk_hcp)
# print(gold_hcp)
# Write POSCAR file using the ase write function
write('POSCAR_gold_hcp', gold_hcp, format='vasp', direct=True, vasp5=True)
# gold_hcp.edit()
view(gold_hcp)

Define the lattice parameters for fcc structure

## no INPUT
Goldbulk_fcc = bulk('Au', 'fcc', a=a*sqrt(2.0))

num_rep_z = int(num_layers/len(Goldbulk_fcc.numbers))
gold_fcc = surface(Goldbulk_fcc, (1, 1, 1), num_rep_z)
gold_fcc.center(vacuum=20, axis=2)

# print(Goldbulk_fcc)
# print(gold_fcc)
# Write POSCAR file using the ase write function
write('POSCAR_gold_fcc', gold_fcc, format='vasp', direct=True, vasp5=True)
# gold_fcc.edit()
view(gold_fcc)

Questions

  • ASE 中,surface 和 cut 的区别?(只有我一个人觉得 ASE 的 manual 很乱吗)
  • surface method 返回值离面方向 lengths of basis vector 为 0 . 所以必须加真空层,显示就正常了。
  • ASE 还能生成别的输入文件吗?INCAR, KPOINTS。但是感觉这不是ASE的强项

Please indicate the source when reprinting. Please verify the citation sources in the article and point out any errors or unclear expressions.