Aditya Wibawa Sakti 2 years ago
parent 573882118a
commit ee40d7f5aa
  1. 38
      cmmde_gui/gui.py

@ -42,7 +42,7 @@ def cmmde_gui():
software = {'Orca':'orca','GROMACS':'gromacs','Dcdftbmd':'dcdftb','Quantum Espresso':'qe','XTB':'xtb'}
# Orca card
job_orca = pn.widgets.MultiSelect(name="Job selections",value=['Single point calculation'],options=['Single point calculation','Geometry optimization','Frequency calculation','TS optimizer','Nudged elastic band'])
job_orca = pn.widgets.Select(name="Job selections",value=['Single point calculation'],options=['Single point calculation','Geometry optimization','Frequency calculation','TS optimizer','Nudged elastic band'])
job_orca_dict = {'Single point calculation':'sp','Geometry optimization':'opt','Frequency calculation':'freq','TS optimizer':'ts','Nudged elastic band':'neb'}
method_orca = pn.widgets.Select(name="Method selections",value='GFN2-xTB',options=['GFN2-xTB','GFN1-xTB','B3LYP/def2-svp','M06/def2-svp'])
method_orca_dict = {'GFN2-xTB':'XTB2', 'GFN1-xTB':'XTB1','DFTB2':'DFTB2','DFTB2-gammah':'DFTB2_gammah','DFTB3':'DFTB3','DFTB3-diag':'DFTB3-diag','B3LYP/def2-svp':'B3LYP def2-svp','M06/def2-svp':'M06 def2-svp'}
@ -76,7 +76,7 @@ def cmmde_gui():
run_orca_btn.on_click(run_orca)
# CMMDE job options
job_main = pn.widgets.MultiSelect(name="Job selections",value=['Single point calculation'],options=['Single point calculation','Geometry optimization','Frequency calculation'])
job_main = pn.widgets.Select(name="Job selections",value='Single point calculation',options=['Single point calculation','Geometry optimization','Frequency calculation'])
job = {'Single point calculation':'sp','Geometry optimization':'opt','Frequency calculation':'freq'}
@ -103,16 +103,16 @@ def cmmde_gui():
# terminal.clear()
# unik = str(uuid.uuid4().hex)
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# job_list = [job[i] for i in job_main.value]
# jobs = ",".join(job_list)
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value + "/" + job[job_main.value]
if not os.path.exists(Folder):
os.makedirs(Folder)
if os.path.exists("{}/geom.smi".format(Folder)):
os.system("rm {}/geom.smi".format(Folder))
os.chdir(Folder)
job_list = [job[i] for i in job_main.value]
jobs = ",".join(job_list)
if editor.value == "":
FileInput.save("geom.xyz")
geom = "geom.xyz"
@ -120,7 +120,7 @@ def cmmde_gui():
geom = editor.value
TextArea.value = TextArea.value + "\n" + "Mempersiapkan Struktur 3 Dimensi!"
list_commands = ["cmmde.py","-i","{}".format(geom),"-s","{}".format(software[software_main.value]),"-j","{}".format(jobs),"-m","{}".format(method[method_btn.value]),"-c","{}".format(charge.value),"-mult","{}".format(mult.value)]
list_commands = ["cmmde.py","-i","{}".format(geom),"-s","{}".format(software[software_main.value]),"-j","{}".format(job[job_main.value]),"-m","{}".format(method[method_btn.value]),"-c","{}".format(charge.value),"-mult","{}".format(mult.value)]
if dispersion_cor.value != 'None':
new_commands = ["-disp","{}".format(dispersion_cor.value)]
for i in new_commands:
@ -133,10 +133,9 @@ def cmmde_gui():
#terminal.subprocess.run("cmmde.py","-i{}".format(editor.value),"-s{}".format(software[software_main.value]), "-j{}".format(jobs), "-m{}".format(method[method_btn.value]))
TextArea.value = TextArea.value + "\n" + "Perhitungan anda telah tersubmit!"
# RunMessage.value = "Perhitungan telah tersubmit!"
download_xyz = pn.widgets.FileDownload(file="{}/cmmd.xyz".format(workdir+"/"+id_input.value+"/"+Molecule_input.value+"/"+job[job_main.value]),filename="optimized.xyz")
Run_btn.on_click(run)
@ -206,7 +205,7 @@ def cmmde_gui():
if not os.path.exists(Post_folder):
os.makedirs(Post_folder)
os.chdir(Post_folder)
list_commands = ["cmmde.py","-i","{}/cmmd.xyz".format(Folder),"-s","{}".format(post_software[post_software_main.value]),"-j","{}".format(post_calc[post_btn.value]),"-m","{}".format(post_method[post_method_btn.value])]
list_commands = ["cmmde.py","-i","{}/cmmd.xyz".format(Folder+"/"+job[job_main.value]),"-s","{}".format(post_software[post_software_main.value]),"-j","{}".format(post_calc[post_btn.value]),"-m","{}".format(post_method[post_method_btn.value])]
if dispersion_cor.value != 'None':
new_commands = ["-disp","{}".format(dispersion_cor.value)]
for i in new_commands:
@ -233,7 +232,7 @@ def cmmde_gui():
# Check the calculation progress
def calc_progress(event):
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value + "/" + job[job_main.value]
os.chdir(Folder)
cmd = subprocess.run(["tail", "-n", "10", "cmmd.out"],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout
@ -247,13 +246,6 @@ def cmmde_gui():
TextArea.value = TextArea.value + "\n" + cmd.stdout
Checkcalc_btn_post = pn.widgets.Button(name="Check post-calculation",button_type='primary')
Checkcalc_btn_post.on_click(calc_progress_post)
# # Download Button
download_xyz = pn.widgets.FileDownload(file="cmmd.xyz",filename="optimized.xyz")
download_slab = pn.widgets.FileDownload(file="slab.vasp",filename="slab.vasp")
download_spec_plot = pn.widgets.FileDownload(file="IR.pdf",filename="IR.pdf")
download_spec_raw = pn.widgets.FileDownload(file="IR_fit.dat",filename="IR_fit.dat")
download_opt_plot = pn.widgets.FileDownload(file="optimized.pdf",filename="optimized.pdf")
download_opt_raw = pn.widgets.FileDownload(file="optimized.dat",filename="optimized.dat")
# Slab Builder
hkl_input = pn.widgets.TextInput(name="Miller index (hkl)",placeholder="Example: 100")
size_input = pn.widgets.TextInput(name="Dimension",placeholder="Example: 2x2")
@ -270,7 +262,13 @@ def cmmde_gui():
# Generate material folder button
materialdir_btn = pn.widgets.Button(name="Generate work directory",type="primary")
# # Download Button
download_slab = pn.widgets.FileDownload(file="{}/slab.vasp",filename="slab.vasp")
download_spec_plot = pn.widgets.FileDownload(file="IR.pdf",filename="IR.pdf")
download_spec_raw = pn.widgets.FileDownload(file="IR_fit.dat".format(workdir+"/"+id_input.value+"/"+Molecule_input.value+"/"+"ir"),filename="IR_fit.dat")
download_opt_plot = pn.widgets.FileDownload(file="optimized.pdf",filename="optimized.pdf")
download_opt_raw = pn.widgets.FileDownload(file="optimized.dat",filename="optimized.dat")
def materialgen(event):
Folder = workdir + "/" + id_input.value + "/" + Material_input.value
isExist = os.path.exists(Folder)
@ -341,7 +339,7 @@ def cmmde_gui():
xyzview = py3Dmol.view()
if Material_input.value == "":
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value + "/" + job[job_main.value]
else:
Folder = workdir + "/" + id_input.value + "/" + Material_input.value
os.chdir(Folder)

Loading…
Cancel
Save