# Siesta计算禁带宽度

Siesta 把能量本征值存储在 *.EIG 文件中，但这个文件本身不太适合各种数据处理软件读取。

Siesta 将“费米能级”写在 *.EIG 文件的第一行。但对于半导体和绝缘体，这个“费米能级”是按照禁带中心取的，并非像 VASP 一样取在价带顶。

using System;

using System.IO;

using System.Text;

using System.Text.RegularExpressions;

// Extract band gap from Siesta

// Written by Kanhao XUE

public class SiestaGap

{

public static void Main()

{

StreamWriter sw = new StreamWriter(@"D:Eig.txt");

double Ef, Gap, VBM = -1000, CBM = 1000;

int M, N, P, Q, i, j, l;

string[] lineDetails = Regex.Split(line, @"s+");

N =   int.Parse(lineDetails[0]);

M =   int.Parse(lineDetails[2]);

Console.WriteLine("Fermi level: " + Ef.ToString());

Console.WriteLine("K points: " + M.ToString());

Console.WriteLine("Band count: " + N.ToString());

P = N / 10;

Q = N % 10;

for (i=0; i<M; i++)

{

sw.Write(line);

// First line has 11 elements

lineDetails = Regex.Split(line, @"s+");

for (l=1; l<=10; l++)

{

double val = double.Parse(lineDetails[l]);

if (val>Ef)

{

if (val < CBM) CBM = val;

}

else

{

if (val > VBM) VBM = val;

}

}

for (j=1; j<P; j++)

{

sw.Write(line);

lineDetails = Regex.Split(line, @"s+");

for (l=0; l<10; l++)

{

double val = double.Parse(lineDetails[l]);

if (val>Ef)

{

if (val < CBM) CBM = val;

}

else

{

if (val > VBM) VBM = val;

}

}

}

sw.Write(line);

lineDetails = Regex.Split(line, @"s+");

if (Q != 0)

{

sw.Write(line);

for (l=0; l<Q; l++)

{

double val = double.Parse(lineDetails[l]);

if (val>Ef)

{

if (val < CBM) CBM = val;

}

else

{

if (val > VBM) VBM = val;

}

}

}

sw.WriteLine();

}

sr.Close();

sw.Close();

Gap = CBM - VBM;

Console.WriteLine("VBM: " + VBM.ToString());

Console.WriteLine("CBM: " + CBM.ToString());

Console.WriteLine("Band gap: " + Gap.ToString());

}

}

Fermi level: -13.762

K points: 8125

Band count: 92

VBM: -17.91691

CBM: -9.68061

Band gap: 8.2363

https://wap.sciencenet.cn/blog-365047-748807.html

## 相关博文

GMT+8, 2022-6-30 22:23