User Tools

Site Tools


exercises:2016_uzh_cmest:band_structure_calculation

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
exercises:2016_uzh_cmest:band_structure_calculation [2016/11/06 15:04] tmuellerexercises:2016_uzh_cmest:band_structure_calculation [2020/08/21 10:15] (current) – external edit 127.0.0.1
Line 97: Line 97:
   * By specifying the ''KPOINT'' section you are enabling the K-Point calculation.   * By specifying the ''KPOINT'' section you are enabling the K-Point calculation.
   * While you could specify the K-Points directly, we are using the Monkhorst-Pack scheme [(http://journals.aps.org/prb/abstract/10.1103/PhysRevB.13.5188)] to generate them. The numbers following the keyword ''MONKHORST-PACK'' specify the tiling of the brillouin zone.   * While you could specify the K-Points directly, we are using the Monkhorst-Pack scheme [(http://journals.aps.org/prb/abstract/10.1103/PhysRevB.13.5188)] to generate them. The numbers following the keyword ''MONKHORST-PACK'' specify the tiling of the brillouin zone.
-  * After the basic calculation, CP2K calculates the energies along certain lines, denoted as ''KPOINT_SET'' (when you check [https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/KPOINTS/BAND_STRUCTURE/KPOINT_SET.html|the documentation] you will note that this section can be repeated).+  * After the basic calculation, CP2K calculates the energies along certain lines, denoted as ''KPOINT_SET'' (when you check [[https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/KPOINTS/BAND_STRUCTURE/KPOINT_SET.html|the documentation]] you will note that this section can be repeated).
   * The keyword ''NPOINTS'' specifies how many points (in the addition to the starting point) should be sampled between two special points.   * The keyword ''NPOINTS'' specifies how many points (in the addition to the starting point) should be sampled between two special points.
   * The ''SPECIAL_POINT'' keyword is used to specify the start-, mid- and endpoints of the line. Those points usually denote special points in the reciprocal lattice/unit cell, like the $\Gamma$, $M$ or $K$ point. You can find the definition for these in the appendix section of [[http://www.sciencedirect.com/science/article/pii/S0927025610002697|this paper]]. This keyword can also be specified multiple times, making it possible to directly get the band structure for a complete //path//.   * The ''SPECIAL_POINT'' keyword is used to specify the start-, mid- and endpoints of the line. Those points usually denote special points in the reciprocal lattice/unit cell, like the $\Gamma$, $M$ or $K$ point. You can find the definition for these in the appendix section of [[http://www.sciencedirect.com/science/article/pii/S0927025610002697|this paper]]. This keyword can also be specified multiple times, making it possible to directly get the band structure for a complete //path//.
Line 123: Line 123:
 Your tasks: Your tasks:
  
-  * Lookup the special points for the $\Gamma$, $M$, $K$ points in the mentioned paper (make sure you choose the right lattice). Calculate and plot the band structure for graphene from $\Gamma$ over $M$, $K$ back to $\Gamma$ (you are free to decide whether to use multiple K-Point sets are multiple special points in a single set). Mark the special points.+  * Lookup the special points for the $\Gamma$, $M$, $K$ points in the mentioned paper (make sure you choose the right lattice). Calculate and plot the band structure for graphene from $\Gamma$ over $M$, $K$ back to $\Gamma$ (you are free to decide whether to use multiple K-Point sets are multiple special points in a single set). Mark the special points. Choose an appropriate number of interpolation points to get a smooth plot.
   * Compare your plot with plots from literature. What is different?   * Compare your plot with plots from literature. What is different?
   * Why do you get 8 orbital energies? Try to change the input to get more unoccupied orbitals.   * Why do you get 8 orbital energies? Try to change the input to get more unoccupied orbitals.
  
-To convert the band structure file to a file which can be loaded directly into MATLAB for example, you can use the script ''/users/tiziano/bin/cp2k_bs2csv.py'' which when passed a band structure file ''graphene.bs'' as an argument will write files ''graphene.bs-setN.csv'' for each set containing the K-Point coordinates and the energies in one line.+To convert the band structure file to a file which can be loaded directly into MATLAB for example, you can use the script ''cp2k_bs2csv.py'' from below, which when passed a band structure file ''graphene.bs'' as an argument will write files ''graphene.bs-setN.csv'' for each set containing the K-Point coordinates and the energies in one line. 
 + 
 +<file python cp2k_bs2csv.py> 
 +#!/usr/bin/env python 
 +""" 
 +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__': 
 +    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() 
 + 
 +    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: 
 +                print(("writing point set {}" 
 +                       " (total number of k-points: {totalpoints})" 
 +                       .format(filename, **kpoint_set.groupdict()))) 
 + 
 +                print("  with the following special points:"
 +                for point in SPOINTS_MATCH.finditer(set_content): 
 +                    print("  {pointnr}: {a}/{b}/{c}".format( 
 +                        **point.groupdict())) 
 + 
 +                for point in POINTS_MATCH.finditer(set_content): 
 +                    results = point.groupdict() 
 +                    results['values'] = " ".join(results['values'].split()) 
 +                    csvout.write("{a} {b} {c} {values}\n".format(**results)) 
 + 
 +</file> 
exercises/2016_uzh_cmest/band_structure_calculation.1478444698.txt.gz · Last modified: 2020/08/21 10:15 (external edit)