User Tools

Site Tools


exercises:common:bs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
exercises:common:bs [2022/09/08 15:28] – created jglanexercises:common:bs [2023/01/17 20:39] (current) jglan
Line 1: Line 1:
-====== Getting the band structure of WO$_3$ Lattice ======+====== Band structure of WO$_3$ Lattice ====== 
 + 
 + 
 +In this exercise, we will carry out band structure calculation using K-point sampling for Cubic lattice WO$_3$. The reference DOS and band structure you can find in [[http://pubs.acs.org/doi/abs/10.1021/cm3032225|this paper]] 
 + 
 +{{:exercises:2017_uzh_cmest:wo3.jpeg?1200|}} 
 +<note important>K-point sampling only support GGA functionals. 
 + 
 +Band structure calculations using high-level electronic structure theory, such as hybrid functionals are not available in CP2K. 
 +</note>
  
 To get the band structure for <chem>WO3</chem>, only a few changes are required compared to the previous example for [[PDOS|calculating the PDOS]]: To get the band structure for <chem>WO3</chem>, only a few changes are required compared to the previous example for [[PDOS|calculating the PDOS]]:
Line 13: Line 22:
    METHOD Quickstep    METHOD Quickstep
    &DFT    &DFT
 +      UKS
       BASIS_SET_FILE_NAME  BASIS_MOLOPT       BASIS_SET_FILE_NAME  BASIS_MOLOPT
       POTENTIAL_FILE_NAME  POTENTIAL       POTENTIAL_FILE_NAME  POTENTIAL
Line 172: Line 182:
 gnuplot>plot for [i=4:23] "WO3.bs.set-1.csv" u 0:i w l t "" gnuplot>plot for [i=4:23] "WO3.bs.set-1.csv" u 0:i w l t ""
  </code>  </code>
-<file python cp2k_bs2csv.py> +<file python plt_band.py> 
-#!/usr/bin/env python +import numpy as np 
-""" +import matplotlib.pyplot as plt
-Convert the CP2K band structure output to CSV files +
-""" +
- +
-import re +
-import argparse +
- +
-SET_MATCH = re.compile(r''' +
-[ ]* +
-  SET: [ ]* (?P<setnr>\d+) [ ]* +
-  TOTAL [ ] POINTS: [ ]* (?P<totalpoints>\d+) [ ]* +
-  \n +
-(?P<content> +
-  [\s\S]*?(?=\n.*?[ ] SET|$)  # match everything until next 'SET' or EOL +
-+
-''', re.VERBOSE) +
- +
-SPOINTS_MATCH = re.compile(r''' +
-[ ]* +
-  POINT [ ]+ (?P<pointnr>\d+) [ ]+ (?P<a>\S+) [ ]+ (?P<b>\S+) [ ]+ (?P<c>\S+) +
-''', re.VERBOSE) +
- +
-POINTS_MATCH = re.compile(r''' +
-[ ]* +
-  Nr\. [ ]+ (?P<nr>\d+) [ ]+ +
-  Spin [ ]+ (?P<spin>\d+) [ ]+ +
-  K-Point [ ]+ (?P<a>\S+) [ ]+ (?P<b>\S+) [ ]+ (?P<c>\S+) [ ]* +
-  \n +
-[ ]* (?P<npoints>\d+) [ ]* \n +
-(?P<values> +
-  [\s\S]*?(?=\n.*?[ ] Nr|$)  # match everything until next 'Nr.' or EOL +
-+
-''', re.VERBOSE)+
  
-if __name__ == '__main__': +file=np.genfromtxt('WO3.bs')
-    parser = argparse.ArgumentParser(description=__doc__) +
-    parser.add_argument('bsfilename', metavar='bandstructure-file', type=str, +
-                        help="the band structure file generated by CP2K")+
  
-    args parser.parse_args()+bs open ('WO3.bs','r'
 +line = bs.readline().split() 
 +num_points, num_k_points, num_bands = int(line[3]),int(line[6]),int(line[8]) 
 +sp=[""]*num_points 
 +i=0 
 +for i in range(num_points): 
 +    line = bs.readline().split() 
 +    sp[i] = line[7]
  
-    with open(args.bsfilename, 'r') as fhandle: 
-        for kpoint_set in SET_MATCH.finditer(fhandle.read()): 
-            filename = "{}.set-{}.csv".format(args.bsfilename, 
-                                              kpoint_set.group('setnr')) 
-            set_content = kpoint_set.group('content') 
  
-            with open(filename'w'as csvout: +new=np.resize(file,(num_k_points*2,num_bands,3)
-                print(("writing point set {}" +ener=new[:,:,1:2] 
-                       " (total number of k-points{totalpoints})" +ener=np.resize(new[:,:,1:2],(num_k_points*2,num_bands)).transpose() 
-                       .format(filename, **kpoint_set.groupdict())))+num_homo = len(new[:,:,2][1][new[:,:,2][1]==1]) 
 +num_lumo = len(new[:,:,2][1][new[:,:,2][1]==0])
  
-                print( with the following special points:"+for i in range(num_homo): 
-                for point in SPOINTS_MATCH.finditer(set_content): +    plt.plot(ener[i,::2],color='k'
-                    print("  {pointnr}: {a}/{b}/{c}".format( +for in range(num_lumo): 
-                        **point.groupdict()))+    plt.plot(ener[i+num_homo,::2],color='k',linestyle='-')
  
-                for point in POINTS_MATCH.finditer(set_content): +#plt.ylim([-4,6]
-                    results = point.groupdict(+plt.xlim([0,num_k_points-1]
-                    results['values'= " ".join(results['values'].split()) +plt.xticks(np.linspace(0,num_k_points-1,num_points),sp
-                    csvout.write("{a} {b} {c} {values}\n".format(**results))+plt.ylabel("Energy (eV)"
 +plt.show()
  
 </file> </file>
exercises/common/bs.1662650889.txt.gz · Last modified: 2022/09/08 15:28 by jglan