Skip to content

Commit 216bf8a

Browse files
committed
modified: cvasp.py
modified: plotting2.py modified: readvasp/from_kpoints.py
1 parent 7df4a1d commit 216bf8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+433
-358
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"jupyter.jupyterServerType": "local"
3+
}

__pycache__/__init__.cpython-37.pyc

307 Bytes
Binary file not shown.

__pycache__/constant.cpython-37.pyc

260 Bytes
Binary file not shown.

__pycache__/constant.cpython-39.pyc

273 Bytes
Binary file not shown.

__pycache__/cvasp.cpython-37.pyc

4.25 KB
Binary file not shown.

__pycache__/cvasp.cpython-39.pyc

4.38 KB
Binary file not shown.

__pycache__/plotting2.cpython-37.pyc

9.24 KB
Binary file not shown.

__pycache__/plotting2.cpython-39.pyc

9.64 KB
Binary file not shown.

__pycache__/ultils.cpython-310.pyc

4.66 KB
Binary file not shown.

__pycache__/ultils.cpython-37.pyc

4.92 KB
Binary file not shown.

__pycache__/ultils.cpython-39.pyc

4.69 KB
Binary file not shown.
675 Bytes
Binary file not shown.
679 Bytes
Binary file not shown.
2.31 KB
Binary file not shown.

constant.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
#!/usr/bin/env python3
12
import numpy as np
2-
33
hartree2eV=13.605826
4-
au2anstrom=0.529177249
4+
au2angstrom=0.529177249
55
au2debye=2.541746
6-
c=0.26246582250210965422
6+
#c=0.26246582250210965422
7+
c=1/hartree2eV/au2angstrom/au2angstrom
78
au2fs=0.02418884326505

cvasp.py

+87-79
Original file line numberDiff line numberDiff line change
@@ -6,147 +6,155 @@
66
import yaml
77
import os
88

9+
910
def from_input(config):
10-
obj=["band","DOS","band & DOS","CHARGE"]
11-
str=''.join(['%s : [%d]\n' % (j,i) for i,j in enumerate(obj)])
12-
tmp=int(input(str))
11+
obj = ["band", "DOS", "band & DOS", "CHARGE"]
12+
str = ''.join(['%s : [%d]\n' % (j, i) for i, j in enumerate(obj)])
13+
tmp = int(input(str))
1314
config["plotset"]["object"] = obj[tmp]
14-
if tmp==0:
15-
type=int(input(
15+
if tmp == 0:
16+
type = int(input(
1617
'Type:\n'
1718
'Normal band - 0\n'
1819
'Fat band - 1\n'
1920
'Colormap band - 2\n'
20-
))
21-
if tmp==1:
22-
type=int(input(
21+
))
22+
if tmp == 1:
23+
type = int(input(
2324
'Type:\n'
2425
'Normal DOS - 0\n'
2526
'Projected DOS - 1\n'
26-
))
27-
if tmp==2:
28-
type=int(input(
27+
))
28+
if tmp == 2:
29+
type = int(input(
2930
'Type:\n'
3031
'Normal - 0\n'
3132
'Projected - 1\n'
32-
))
33+
))
3334
config["plotset"]["plot_type"] = type
3435
config["groupinfo"] = [None]
3536
if type > 0:
36-
config["Nbandpicture"]=int(input("How many bands?\n"))
37-
config["groupinfo"]=[]
37+
config["Nbandpicture"] = int(input("How many bands?\n"))
38+
config["groupinfo"] = []
3839
for N in range(config["Nbandpicture"]):
3940
print("next group\n")
40-
groups=[]
41-
tmp=input(
42-
'[Element or atomic NO.] [label] [color/colormap] \n'
43-
'specified orbital with "_" ,split with "," \n'
44-
'e.g : Cu,Ag_py,1-3,6_py,8-10_d CuAnTag red \n'
45-
'empty for end \n'
46-
)
41+
groups = []
42+
tmp = input(
43+
'[Element or atomic NO.] [label] [color/colormap] \n'
44+
'specified orbital with "_" ,split with "," \n'
45+
'e.g : Cu,Ag_py,1-3,6_py,8-10_d CuAnTag red \n'
46+
'empty for end \n'
47+
)
4748
groups.append(tmp)
4849
while tmp:
49-
tmp=input()
50+
tmp = input()
5051
if tmp:
5152
groups.append(tmp)
5253
config["groupinfo"].append(groups)
5354
tmp = input('Energy range, e.g -2 5 default is [-2 5]\n') or "-2 5"
54-
config["plotset"]['Elim']=[float(i) for i in tmp.split()]
55-
config["plotset"]['fermi']=input("Set 0eV to fermi? (VBM,CBM,band No. or any Energy)\n"
56-
"F or 0 will change nothing.\n"
57-
"e.g VBM/CBM/band_18/-2.5/F/0\n"
58-
"default is VBM") or "vbm"
55+
config["plotset"]['Elim'] = [float(i) for i in tmp.split()]
56+
config["plotset"]['fermi'] = input("Set 0eV to fermi? (VBM,CBM,band No. or any Energy)\n"
57+
"F or 0 will change nothing.\n"
58+
"e.g VBM/CBM/band_18/-2.5/F/0\n"
59+
"default is VBM") or "vbm"
5960
return config
6061

6162

6263
def ini_config():
63-
method = {"method" : "matplotlib"}
64-
plotset = {"plot_type": 0, "object" : "band","Elim":[-2,5],"fermi":"vbm","int":100}
65-
figset = {"figsize":(7,6),"dpi":150}
66-
fontset = {"fontsize" : 16,"font":"Arial"}
67-
fileset = {"eigfile":["EIGENVAL"],"dosfile":"DOSCAR","prosfile":["PROCAR"],"kptfile":["KPOINTS"],"posfile":"POSCAR"}
68-
config={"method" : method,
69-
"plotset" : plotset,
70-
"fileset" : fileset,
71-
"figset" : figset,
72-
"fontset" : fontset}
64+
method = {"method": "matplotlib"}
65+
plotset = {"plot_type": 0, "object": "band",
66+
"scale": 50,
67+
"Elim": [-2, 5], "fermi": "vbm", "int": 100}
68+
figset = {"figsize": (7, 6), "dpi": 150}
69+
fontset = {"fontsize": 16, "font": "Arial"}
70+
fileset = {"eigfile": ["EIGENVAL"], "dosfile": "DOSCAR", "prosfile": [
71+
"PROCAR"], "kptfile": ["KPOINTS"], "posfile": "POSCAR"}
72+
config = {"method": method,
73+
"plotset": plotset,
74+
"fileset": fileset,
75+
"figset": figset,
76+
"fontset": fontset}
7377
return config
7478

79+
7580
def read_config(file='cvasp.yml'):
7681
with open(file) as f:
7782
data = yaml.load(f, Loader=yaml.FullLoader)
78-
#print(data)
83+
# print(data)
7984
return data
8085

8186

82-
def cvasp(config,axs=None):
83-
plt.rc('font',family=config["fontset"]["font"],size=config["fontset"]["fontsize"])
84-
plt.rcParams['font.serif'] = [config["fontset"]["font"]] + plt.rcParams['font.serif']
87+
def cvasp(config, axs=None):
88+
# plt.rc('font',family=config["fontset"]["font"],size=config["fontset"]["fontsize"])
89+
# plt.rcParams['font.serif'] = [config["fontset"]["font"]] + plt.rcParams['font.serif']
8590
print(config["plotset"]["object"].lower())
86-
if config["plotset"]["object"].lower() == "band" :
87-
if config["plotset"]["plot_type"] > 0 :
91+
if config["plotset"]["object"].lower() == "band":
92+
if config["plotset"]["plot_type"] > 0:
8893
data = from_procar.get_procar(config["fileset"]["prosfile"])
8994
else:
9095
data = from_eigenval.get_eigenvalue(config["fileset"]["eigfile"])
9196
KPT = from_kpoints.get_kpoints(config["fileset"]["kptfile"])
92-
plotting2.plot_band(KPT,data,config,axs=axs)
93-
94-
if config["plotset"]["object"].lower() == "dos" :
97+
plotting2.plot_band(KPT, data, config, axs=axs)
98+
99+
if config["plotset"]["object"].lower() == "dos":
95100
data = from_doscar.get_doscar(config["fileset"]["dosfile"])
96-
plotting2.plot_dos(data,config,axs=axs)
101+
plotting2.plot_dos(data, config, axs=axs)
97102

98103
if "band" in config["plotset"]["object"].lower() and \
99-
"dos" in config["plotset"]["object"].lower() :
104+
"dos" in config["plotset"]["object"].lower():
100105
KPT = from_kpoints.get_kpoints(config["fileset"]["kptfile"])
101-
if config["plotset"]["plot_type"] > 0 :
106+
if config["plotset"]["plot_type"] > 0:
102107
eigdata = from_procar.get_procar(config["fileset"]["prosfile"])
103108
else:
104-
eigdata = from_eigenval.get_eigenvalue(config["fileset"]["eigfile"])
109+
eigdata = from_eigenval.get_eigenvalue(
110+
config["fileset"]["eigfile"])
105111
dosdata = from_doscar.get_doscar(config["fileset"]["dosfile"])
106-
plotting2.plot_band_dos(KPT,eigdata,dosdata,config,axs=axs)
112+
plotting2.plot_band_dos(KPT, eigdata, dosdata, config, axs=axs)
107113

108114

109115
if __name__ == "__main__":
110-
config=ini_config()
116+
config = ini_config()
111117
try:
112-
data=read_config()
118+
data = read_config()
113119
config.update(data)
114120
except Exception as e:
115-
config=from_input(config)
116-
with open('cvasp.yml',"w",encoding='utf-8') as f:
117-
yaml.dump(config,f)
118-
plt.rc('font',family=config["fontset"]["font"],size=config["fontset"]["fontsize"])
119-
plt.rcParams['font.serif'] = [config["fontset"]["font"]] + plt.rcParams['font.serif']
121+
config = from_input(config)
122+
with open('cvasp.yml', "w", encoding='utf-8') as f:
123+
yaml.dump(config, f)
124+
plt.rc('font', family=config["fontset"]
125+
["font"], size=config["fontset"]["fontsize"])
126+
plt.rcParams['font.serif'] = [config["fontset"]
127+
["font"]] + plt.rcParams['font.serif']
120128
print(config["plotset"]["object"].lower())
121-
if config["plotset"]["object"].lower() == "band" :
122-
if config["plotset"]["plot_type"] > 0 :
129+
if config["plotset"]["object"].lower() == "band":
130+
if config["plotset"]["plot_type"] > 0:
123131
data = from_procar.get_procar(config["fileset"]["prosfile"])
124132
else:
125133
data = from_eigenval.get_eigenvalue(config["fileset"]["eigfile"])
126-
ispin=data.N_spin
127-
fig, axs = plt.subplots(1,len(config["groupinfo"])*ispin,
128-
figsize=config["figset"]["figsize"],sharey=True)
134+
ispin = data.N_spin
135+
fig, axs = plt.subplots(1, len(config["groupinfo"])*ispin,
136+
figsize=config["figset"]["figsize"], sharey=True)
129137
KPT = from_kpoints.get_kpoints(config["fileset"]["kptfile"])
130-
plotting2.plot_band(KPT,data,config,axs=axs)
131-
132-
if config["plotset"]["object"].lower() == "dos" :
133-
fig , ax = plt.subplots(1, 1,
134-
figsize=config["figset"]["figsize"])
138+
plotting2.plot_band(KPT, data, config, axs=axs)
139+
140+
if config["plotset"]["object"].lower() == "dos":
141+
fig, ax = plt.subplots(1, 1,
142+
figsize=config["figset"]["figsize"])
135143
data = from_doscar.get_doscar(config["fileset"]["dosfile"])
136-
plotting2.plot_dos(data,config,ax=ax)
144+
plotting2.plot_dos(data, config, ax=ax)
137145

138146
if "band" in config["plotset"]["object"].lower() and \
139-
"dos" in config["plotset"]["object"].lower() :
147+
"dos" in config["plotset"]["object"].lower():
140148
KPT = from_kpoints.get_kpoints(config["fileset"]["kptfile"])
141-
if config["plotset"]["plot_type"] > 0 :
149+
if config["plotset"]["plot_type"] > 0:
142150
eigdata = from_procar.get_procar(config["fileset"]["prosfile"])
143151
else:
144-
eigdata = from_eigenval.get_eigenvalue(config["fileset"]["eigfile"])
145-
ispin=eigdata.N_spin
146-
fig, axs = plt.subplots(1,len(config["groupinfo"])*ispin + 1,
147-
figsize=config["figset"]["figsize"],sharey=True)
152+
eigdata = from_eigenval.get_eigenvalue(
153+
config["fileset"]["eigfile"])
154+
ispin = eigdata.N_spin
155+
fig, axs = plt.subplots(1, len(config["groupinfo"])*ispin + 1,
156+
figsize=config["figset"]["figsize"], sharey=True)
148157
dosdata = from_doscar.get_doscar(config["fileset"]["dosfile"])
149-
plotting2.plot_band_dos(KPT,eigdata,dosdata,config,axs=axs)
150-
plt.show()
151-
fig.savefig('band_dos.png',dpi=300)
152-
158+
plotting2.plot_band_dos(KPT, eigdata, dosdata, config, axs=axs)
159+
plt.show()
160+
fig.savefig('band_dos.png', dpi=300)

0 commit comments

Comments
 (0)