# Vaspkit对格点文件进行平面平均

1. Example, Work-function of Au(111) slab with five atomic layers.

VASP计算结果的电荷密度(CHGCAR，PARCHG)，静电势（LOCPOT），ELF（ELFCAR）都是格点文件，可以用VESTA直接打开。

VASP输出的所有格点文件Fortran语言的书写顺序如下：

For one selected direction, such as z direction. VASPKIT do an average in XY plane on each NZ,
$$\sum_{i j} \Delta x_{i} \Delta y_{j} \rho_{i, j} / \sum_{i j} \Delta x_{i} \Delta y_{j}$$

The output POTPAVG.dat contains two columns. First column is z coordinate (in Å), Second column is Planar Average-Potential (in eV) or Densitiy (in e).

Here, take LOCPOT as an example. It contains total local potential (in eV) when LVTOT = .TRUE. exists in the INCAR file, or contains electrostatic potential (in eV) when LVHAR = .TRUE. exists in the INCAR file. Electrostatic potential is desirable for the evaluation of the work-function, because the electrostatic potential converges more rapidly to the vacuum level than the total potential. To get the work-function, potential along z direction (i.e. slab normal direction) must be averaged in the slab planes.

Hamiltonian of Kohn-Sham is:

\begin{align}
\hat{H}=-\frac{1}{2} \nabla^{2}-\sum_{A} \frac{Z_{A}}{\left|\boldsymbol{r}-\boldsymbol{R}_{A}\right|}+\int_{\infty} \frac{\rho\left(\boldsymbol{r}^{\prime}\right)}{\left|\boldsymbol{r}-\boldsymbol{r}^{\prime}\right|} d \boldsymbol{r}^{\prime}+v_{x c}[\rho(\boldsymbol{r})
\end{align}

Electrostatic potential is the summation of second (ionic) and third (hartree) parts of Hamiltonian .

#### Example, Work-function of Au(111) slab with five atomic layers.

(1) Do an optimization and a single-point calculation to get the LOCPOT file, single-point INCAR as following:

(2) Run VASPKIT 426 function, and select the surface normal direction:

So, the Vacuum-Level is 6.695, POTPAVG.dat as following:

(3) Get the fermi level by:

(4) Draw the Plane-averaged electrostatic potential figure.

python3 ./planeavg.py 1.5199

The obtained Plane-averaged electrostatic potential figure:

So, work function can be calculated as:
$$\Phi=E_{\mathrm{vac}}-E_{\mathrm{F}}$$
$\Phi$ = 6.695 - 1.5199 = 5.1751 eV