1、本文搬運自ETasci-2013-SurfacePreparationHowTo,簡單總結一下,方便大家
2、首先講一下思路:我們要找到新的單胞,然后我們做晶格基矢轉換再加一個真空層就行了,其實很簡單。下面講解步驟。
首先你需要兩個東西,一個是晶格結構,需要時VESTA能夠打開的格式,這里以Material Project上下載下來的*.cif文件為例。然后把文件拖入到VESTA中。

然后就是找新的單胞,首先我們要找到單胞對應的6個平面,當然在這之前要先擴展成超胞看起來比較方便。(這一步的所有步驟都沒有改變元胞信息只是為了我們看著方便,包括下面的刪除原子之類的。)點左邊的Boundary,然后把x,y,z改成3 3 3

然后我們的模型就變成超胞了。


點左上角的
Edit,然后點Lattice Planes,就出來編輯平面的窗口
然后點
New,就可以新建平面,新建完了以后會顯示在左邊,這里添加6個平面,得到新的單胞,如下圖所示。

刪除多余的原子,用最左側邊欄上的第二個鼠標指針選中然后按鍵盤上的Del鍵即可刪除

然后我們就得到了新的單胞,這里丟失了一些原子。

這里因為晶格間距和例子中的不一樣,所以截出來的單胞并不是很理想,所以拿上面那個PDF中的來說吧,實際操作中根據(jù)自己的需要來截,這一步是最關鍵的。

這個就是PDF中的例子給出的單胞,頂點上有4個原子,像上邊一樣用左邊欄第二個箭頭選中4個原子下面的窗口會給出4個原子現(xiàn)在的坐標,分別減去新的原點O‘的坐標,就得到了新的晶格基矢與原來的基矢的關系
終于得到了晶格變換矩陣
注意:到這里為止我們都沒有實際上改變原來的晶格結構文件。下面我們就要改了
點Edit>>Edit data>>Unit cell然后點Transform在Rotation matrixP中填上剛才得到的變換矩陣就得到了新的單胞,下面就是添加真空層了,只需要File>>Export data選VASP的格式然后選笛卡爾坐標,再把c方向加大就行了。PP
VESTA建立截止面/移除部分isosurface
添加平面不僅可以幫助簡立新的單胞,還可以幫助截取isosurface的一部分。
我在畫電荷密度的時候,有時候會遇到想去掉自己不想要的isosurface部分的想法但是直接像刪除原子那樣的方式是刪不掉的,說明書里有一個如何截圖像的方法,名字叫做建立邊界平面。
同時按ctrl、shift、B就可以打開建立截止面的界面,然后輸入自己想要的截止面就可以了!
VESTA變換元胞后保持矢量與之前一致
按照上面描述的方法變換元胞之后,原來設置的矢量有可能會改變方向,因為元胞的基矢被改變了,但是我發(fā)現(xiàn)只要在變換的時候選擇第二個選項就可以保持矢量不變,但是需要重新設置矢量和原子的對應順序。
VESTA 批量添加矢量
VESTA里面添加矢量比較麻煩,手動一個一個點,能不能通過腳本來實現(xiàn)呢?答案是可以的,因為VESTA的輸入文件prefix.vesta實際上是一個文本文檔,所有的信息都以文本的方式存在里面,那么只需要按照VESTA的格式把矢量寫進去就可以了,上網(wǎng)一搜有人寫過了,于是就直接拿過來了。腳本來自GitHub - hzr-piggy/plot_vec_VESTA,他參考了另一個人的寫法GitHub - lucydot/vesta_vectors。非常感謝他們!
輸入文件就是兩個,一個是需要修改的VESTA輸入文件,還有一個就是記錄矢量的文本文檔,大致格式是這樣的
-0.05
-0.05
-0.05
0.1
0.1
0.1
就是把矢量分成每行一個數(shù)就可以了。這里只加了兩個矢量,需要加更多只需要也參照這個格式加下去就可以了。
def plot_vec(vesta_file, vec_file,
cutoff = 0.1,
radius=0.5, color=[255,0,0], penetrate = True, add_atom_radius = False,
scale_factor = 1,
delim = None, vec_type = "Cart", lat = None,
output_suffix = "_vec"):
# vesta_file: A *.vesta file
# vec_file: A file containing vectors having dimensions of 3N*1 (or 1*3N)
# with delimiter=delim i.e.
# x1
# y1
# z1
# x2
# y2
# z2
# .
# .
# .
# cutoff (Double): Angstrom below which vector will not show
# radius (Double): Set radius of vector
# color (Double 0-255): Set color of vector
# penetrate (Bool): Set whether vector penetrate atom
# add_atom_radius (Bool):Set whether to add atom radius to vector modulus
# scale_factor (Double): Scale vector in the figure
# delim: Delimiter in the vec_file
# vec_type: Type of vectors, can be "Cart" (Cartesian), "Lat" (Lattice vector notation [u v w], in reduced coord)
# or "Modulus" (Modulus along crystallographic axis). Default is 'Cart'
# lat: 3-by-3 lattice parameter in Angstrom required if vec_type == 'Cart'
import numpy as np
import re
import os
# Read input files
vesta_data = open(vesta_file,'r').read()
temp = np.loadtxt(vec_file,delimiter=delim)
N_dim = temp.shape[0]
temp = temp.reshape((N_dim//3,3))
# Convert to Modulus along crystallographic axis
if vec_type == 'Lat':
struct_match=re.findall(r'CELLP\n\s+(\d+\.\d+\s+\d+\.\d+\s+\d+\.\d+\s+)',vesta_data)[0]
cell = np.array([float(x) for x in struct_match.split()]) # cell lengths in angstrong
temp *= cell
elif vec_type == 'Cart':
assert lat is not None, '3-by-3 lattice parameter in Angstrom required if vec_type == Cart'
temp = temp@np.linalg.inv(lat)*np.linalg.norm(lat,axis=1)
# print(lat)
vectors = np.around(temp*scale_factor,decimals=3) # Round the disp to 3 decimals
# Find unique vectors
print(vectors)
vectors_unique = np.unique(vectors,axis=0)
# Vector penetrate atom or add atomic radius?
flag = int(penetrate)+int(add_atom_radius)*2
VECTR_str=r"\1"
VECTT_str=r"\1"
i = 1
for v in vectors:
if np.linalg.norm(v) > cutoff: # only create vector with modules > cutoff
VECTR_str += " {0} {1} {2} {3} 0\n".format(i,v[0],v[1],v[2]) # create vectors
atom_list = np.where((vectors == v).all(axis=1))[0]
for atom in atom_list:
print(atom)
VECTR_str += " {0} 0 0 0 0\n".format(atom+1) # create atom labels start from 1
VECTR_str += "0 0 0 0 0\n"
VECTT_str += " {0} {1} {2} {3} {4} {5}\n".format(i,radius, color[0], color[1], color[2], flag)
i += 1
output_data = re.sub(r"(VECTR\n)",VECTR_str,vesta_data)
output_data = re.sub(r"(VECTT\n)",VECTT_str,output_data)
# print(output_data)
name, ext = os.path.splitext(vesta_file)
file_out = open(name+output_suffix+ext,'w+')
file_out.write(output_data)
file_out.close()
mode = 12
plot_vec('NbAs.vesta', 'NbAs_vector'+str(mode)+'.dat',
cutoff = 0.1,
radius=0.4, color=[255,0,0], penetrate = False, add_atom_radius = False,
scale_factor =-1,
delim = None, vec_type = "Cart", lat = [[6.374959638, 0.003597502 , -0.000000000],
[ 4.478346762 , 4.537022058 , -0.000000000],
[-5.426653274 ,-2.270309811 , 2.457085633]],
output_suffix = "_vec"+str(mode))
VESTA保存帶電荷密度圖
VESTA為了保持vesta文件格式的簡介一致性,將電荷密度這一類數(shù)據(jù)在保存的時候就刪掉了,想要保存這一類數(shù)據(jù)需要將其再保存為一個XX.ggrid文件,然后打開的時候 Edit > volumetric-data 導入進去就可以了。
VESTA 調節(jié)isosurface 透明度,
VESTA中如果想要調節(jié)isosurface的透明度,是在properties里面然后打開isosurface選項里就可以調,關鍵在于理解兩個透明度的意思是什么,

這一點從這個圖上可以看出來,其中O1和O2分別代變兩個方向的透明度,分別對應opacity1和opacity2,然后前面那個render from front to back 影響也很大。