ase.visualize.view(atoms, data=None, viewer=None, repeat=None)
from ase.io import read,write
from ase.visualize import view
CN=read('POSCAR0',format='vasp')#读入结构信息,转为atoms object
view(CN)#显示图形,viewer='VMD'可以选择显示器
write('image.png',CN)#讲atoms object图形化,保存为图片
from ase.build import fcc111
import matplotlib.pyplot as plt
from ase.visualize.plot import plot_atoms
slab = fcc111('Pt', size=(4,4,3), vacuum=16.0)#建立4×4×3的Pt(111)平面,真空层16
fig, ax = plt.subplots(dpi=300,figsize=(2, 5))
plot_atoms(slab, ax, radii=0.3, rotation=('0x,0y,0z'))#radii时设置原子显示大小,rotation设置显示角度
fig.savefig("ase_slab.png")
from ase.build import fcc111
import matplotlib.pyplot as plt
from ase.visualize.plot import plot_atoms
slab = fcc111('Pt', size=(4,4,3), vacuum=16.0)#建立4×4×3的Pt(111)平面,真空层16
fig, axarr = plt.subplots(1,4, dpi=300,figsize=(15, 10))
plot_atoms(slab, axarr[0], radii=0.3, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[1], scale=0.7, offset=(3, 4), radii=0.3, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[2], scale=0.3, offset=(3, 4), radii=0.3, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[3], radii=0.3, rotation=('45x,45y,0z'))
axarr[0].set_title("radii=0.3")
axarr[1].set_title("offset=(3, 4)")
axarr[2].set_title("scale=0.3")
axarr[3].set_title("rotation=('45x,45y,0z')")
fig, axarr = plt.subplots(1,4, dpi=300,figsize=(15, 10))
plot_atoms(slab, axarr[0], radii=0.5, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[1], scale=0.7, offset=(1, 2), radii=0.3, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[2], scale=0.7, offset=(3, 4), radii=0.3, rotation=('0x,0y,0z'))
plot_atoms(slab, axarr[3], radii=0.5, rotation=('45x,45y,0z'))
axarr[0].set_title("radii=0.5")
axarr[1].set_title("offset=(1, 2)")
axarr[2].set_title("scale=0.7")
axarr[3].set_title("rotation=('45x,45y,0z')")
ase.build.add_adsorbate(slab, adsorbate, height, position=(0, 0), offset=None, mol_index=0)
例如在Pt(111)平面吸附O
下面考察几种吸附形式:‘ontop’,‘fcc’,‘hcp’,‘bridge’
from ase.visualize import view
from ase.build import fcc111, add_adsorbate
site_list=['ontop','fcc','hcp','bridge']#吸附位置,也可以使用坐标来表示
fig, axarr = plt.subplots(1,4, dpi=300,figsize=(20, 5))
for i in range(0,len(site_list)):
slab = fcc111('Pt', size=(4,4,3), vacuum=16.0)#建立4×4×3的Pt(111)平面,真空层16
adsorption=add_adsorbate(slab, 'O', 1.5, site_list[i])#1.5为高度
plot_atoms(slab, axarr[i], radii=0.5, rotation=('0x,0y,0z'))
fig, axarr = plt.subplots(1,4, dpi=300,figsize=(20, 5))
for i in range(0,len(site_list)):
slab = fcc111('Pt', size=(4,4,3), vacuum=16.0)#建立4×4×3的Pt(111)平面,真空层16
adsorption=add_adsorbate(slab, 'O', 1.5, site_list[i])#1.5为高度
plot_atoms(slab, axarr[i], radii=0.5, rotation=('-90x,-90y,0z'))