Skip to content

Commit 7d9ea9b

Browse files
committed
ad argcheck for accond, fix bug in run.py and refactor in optical_cond.py
1 parent 1b717dc commit 7d9ea9b

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

dptb/entrypoints/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def run(
9191

9292
accondcal.get_accond(struct=struct_file,
9393
AtomicData_options=jdata['AtomicData_options'],
94-
task_options=jdata['task_options'],
9594
emax=jdata['task_options'].get('emax'),
9695
num_omega=jdata['task_options'].get('num_omega',1000),
9796
mesh_grid=jdata['task_options'].get('mesh_grid',[1,1,1]),
@@ -104,7 +103,7 @@ def run(
104103
direction=jdata['task_options'].get('direction','xx'),
105104
g_s=jdata['task_options'].get('g_s',2)
106105
)
107-
accondcal.optical_plot()
106+
accondcal.accond_plot()
108107
log.info(msg='ac optical conductivity calculation successfully completed.')
109108

110109
elif task=='write_block':

dptb/postprocess/optical/optical_cond.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ def get_accond(self,
7171
np.save(f"{self.results_path}/AC_cond_sig_{delta}.npy", {'energy':self.omegas, 'ac_cond_g': self.ac_cond_gauss, 'ac_cond_l': self.ac_cond_linhard})
7272
log.info('<><><><>'*5)
7373

74-
def plot_optcond(self):
74+
def accond_plot(self):
7575
fig = plt.figure(figsize=(6,6),dpi=200)
7676
plt.plot(self.omegas, self.ac_cond_gauss.real, label='Gaussian')
7777
plt.plot(self.omegas, self.ac_cond_linhard.real, label='Linhard:real')
7878
plt.plot(self.omegas, self.ac_cond_linhard.imag, label='Linhard:real')
79+
plt.legend()
7980
plt.xlabel("Energy (eV)")
8081
plt.ylabel("sigma_xx")
8182
plt.savefig("ACxx.png")
@@ -114,7 +115,7 @@ def cal_cond(model, data, e_fermi, mesh_grid, emax, num_val=None, gap_corr=0, nu
114115
num_loop = math.ceil(tot_numk / nk_per_loop)
115116
omegas = torch.linspace(0,emax,num_omega, dtype=torch.float64)
116117

117-
log.info('tot_numk:',tot_numk, 'nk_per_loop:',nk_per_loop, 'num_loop:',num_loop)
118+
log.info(f'tot_numk: {tot_numk}, nk_per_loop: {nk_per_loop}, num_loop: {num_loop}')
118119

119120
ac_cond = np.zeros((len(omegas)),dtype=np.complex128)
120121
ac_cond_ik = np.zeros((len(omegas)),dtype=np.complex128)

dptb/utils/argcheck.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,38 @@ def task_options():
11131113
Argument("negf", dict, negf()),
11141114
Argument("tbtrans_negf", dict, tbtrans_negf()),
11151115
Argument("write_block", dict, write_block),
1116+
Argument("ac_cond", dict, ac_cond()),
11161117
],optional=False, doc=doc_task)
11171118

1119+
def ac_cond():
1120+
doc_emax = ""
1121+
doc_num_omega = ""
1122+
doc_mesh_grid = ""
1123+
doc_nk_per_loop = ""
1124+
doc_delta = ""
1125+
doc_e_fermi = ""
1126+
doc_valence_e = ""
1127+
doc_gap_corr = ""
1128+
doc_T = ""
1129+
doc_direction = ""
1130+
doc_g_s = ""
1131+
1132+
argu = [
1133+
Argument("emax", float, optional=False, default=10, doc=doc_emax),
1134+
Argument("num_omega", int, optional=False, default=1000, doc=doc_num_omega),
1135+
Argument("mesh_grid", list, optional=False, default=[1,1,1], doc=doc_mesh_grid),
1136+
Argument("nk_per_loop", [int, None], optional=True, default=None, doc=doc_nk_per_loop),
1137+
Argument("delta", float, optional=False, default=0.03, doc=doc_delta),
1138+
Argument("e_fermi", [float, int, None], optional=False, doc=doc_e_fermi),
1139+
Argument("valence_e", [float, int, None], optional=True, default=None, doc=doc_valence_e),
1140+
Argument("gap_corr", float, optional=False, default=0, doc=doc_gap_corr),
1141+
Argument("T", [float, int], optional=False, default=300, doc=doc_T),
1142+
Argument("direction", str, optional=False, default="xx", doc=doc_direction),
1143+
Argument("g_s", int, optional=False, default=2, doc=doc_g_s)
1144+
]
1145+
1146+
return argu
1147+
11181148
def band():
11191149
doc_kline_type ="""The different type to build kpath line mode.
11201150
- "abacus" : the abacus format

0 commit comments

Comments
 (0)