exercises:common:bs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
exercises:common:bs [2022/09/08 15:32] – jglan | exercises:common:bs [2022/09/22 22:15] – jglan | ||
---|---|---|---|
Line 182: | Line 182: | ||
</ | </ | ||
<file python cp2k_bs2csv.py> | <file python cp2k_bs2csv.py> | ||
- | # | + | import numpy as np |
- | """ | + | import matplotlib.pyplot as plt |
- | Convert the CP2K band structure output to CSV files | + | |
- | """ | + | |
- | import re | + | file=np.genfromtxt(' |
- | import argparse | + | |
- | SET_MATCH | + | bs = open ('band.txt','r') |
- | [ ]* | + | line = bs.readline().split() |
- | SET: [ ]* (? | + | num_points, num_k_points, |
- | | + | sp=["" |
- | \n | + | i=0 |
- | (? | + | for i in range(num_points): |
- | | + | |
- | ) | + | sp[i] = line[7] |
- | ''', | + | |
- | SPOINTS_MATCH = re.compile(r''' | ||
- | [ ]* | ||
- | POINT [ ]+ (? | ||
- | ''', | ||
- | POINTS_MATCH | + | new=np.resize(file, |
- | [ ]* | + | ener=new[:,:,1:2] |
- | Nr\. [ ]+ (? | + | ener=np.resize(new[:,:,1:2],(num_k_points*2, |
- | Spin [ ]+ (? | + | num_homo = len(new[:,:,2][1][new[:,:,2][1]==1]) |
- | K-Point | + | num_lumo = len(new[:,:,2][1][new[:,:,2][1]==0]) |
- | \n | + | |
- | [ ]* (? | + | |
- | (? | + | |
- | | + | |
- | ) | + | |
- | ''', | + | |
- | if __name__ == ' | + | for i in range(num_homo): |
- | | + | |
- | | + | for i in range(num_lumo): |
- | help=" | + | |
- | args = parser.parse_args() | + | #plt.ylim([-4,6]) |
- | + | plt.xlim([0, | |
- | with open(args.bsfilename, ' | + | plt.xticks(np.linspace(0,num_k_points-1, |
- | for kpoint_set in SET_MATCH.finditer(fhandle.read()): | + | plt.ylabel("Energy |
- | | + | plt.show() |
- | kpoint_set.group(' | + | |
- | set_content = kpoint_set.group(' | + | |
- | + | ||
- | with open(filename, ' | + | |
- | print((" | + | |
- | " | + | |
- | | + | |
- | + | ||
- | print(" | + | |
- | for point in SPOINTS_MATCH.finditer(set_content): | + | |
- | print(" | + | |
- | **point.groupdict())) | + | |
- | + | ||
- | for point in POINTS_MATCH.finditer(set_content): | + | |
- | results = point.groupdict() | + | |
- | results[' | + | |
- | | + | |
</ | </ |
exercises/common/bs.txt · Last modified: 2023/01/17 20:39 by jglan