Aditya Wibawa Sakti 2 years ago
parent b179cb1f37
commit c4340c96c6
  1. 54
      cmmde_gui/gui.py
  2. 24
      cmmde_gui/ts_finder.py

@ -38,8 +38,8 @@ def cmmde_gui():
height = 500, disabled=True
)
# CMMDE software options
software_main = pn.widgets.Select(name="Software selections",value='Orca',options=['Orca','GROMACS','Dcdftbmd','Quantum Espresso'])
software = {'Orca':'orca','GROMACS':'gromacs','Dcdftbmd':'dcdftb','Quantum Espresso':'qe'}
software_main = pn.widgets.Select(name="Software selections",value='Orca',options=['Orca','XTB','Dcdftbmd','Quantum Espresso','GROMACS'])
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'])
@ -74,10 +74,12 @@ def cmmde_gui():
TextArea.value = TextArea.value + "\n" + "Perhitungan anda telah tersubmit!"
# RunMessage = pn.widgets.StaticText()
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 = {'Single point calculation':'sp','Geometry optimization':'opt','Frequency calculation':'freq'}
# CMMDE method options
method_btn = pn.widgets.Select(name="Method selections",value='GFN2-xTB',options=['GFN2-xTB','GFN1-xTB','B3LYP/def2-svp','M06/def2-svp','DFTB2','DFTB2-gammah','DFTB3','DFTB3-diag'])
method = {'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'}
@ -166,40 +168,43 @@ def cmmde_gui():
post_method_btn = pn.widgets.Select(name="Method selections for post calculations",value='GFN2-xTB',options=['GFN2-xTB','GFN1-xTB','DFTB2','DFTB2-gammah','DFTB3','DFTB3-diag','B3LYP/def2-svp'])
post_method = {'GFN2-xTB':'XTB2', 'GFN1-xTB':'XTB1','DFTB2':'DFTB2','DFTB2-gammah':'DFTB2_gammah','DFTB3':'DFTB3','DFTB3-diag':'DFTB3-diag','B3LYP/def2-svp':'B3LYP def2-svp'}
def post_calculation(event):
# terminal.clear()
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder)
# terminal.clear()
if post_calc[post_btn.value] == 'thermo' and post_software[post_software_main.value] == 'orca':
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
if not os.path.exists(post_calc[post_btn.value]):
os.makedirs(post_calc[post_btn.value])
os.chdir(post_calc[post_btn.value])
os.system("cp ../freq/cmmd.out .")
Post_folder = Folder + "/" + post_calc[post_btn.value]
if not os.path.exists(Post_folder):
os.makedirs(Post_folder)
os.chdir(Post_folder)
os.system("cp {}/freq/cmmd.out .".format(Folder))
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_main.value])],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout
elif post_calc[post_btn.value] == 'ir' and post_software[post_software_main.value] == 'orca':
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
if not os.path.exists(post_calc[post_btn.value]):
os.makedirs(post_calc[post_btn.value])
os.chdir(post_calc[post_btn.value])
os.system("cp ../freq/cmmd.out .")
Post_folder = Folder + "/" + post_calc[post_btn.value]
if not os.path.exists(Post_folder):
os.makedirs(Post_folder)
os.chdir(Post_folder)
os.system("cp {}/freq/cmmd.out .".format(Folder))
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_main.value])])
TextArea.value = TextArea.value + "\n" + "Plot spektrum IR berhasil dilakukan"
# terminal.subprocess.run("cmmdepost.py","-j{}".format(post_calc[post_btn.value]),"-s{}".format(post_software[post_software_main.value]))
elif post_calc[post_btn.value] == 'opt' and post_software[post_software_main.value] == 'orca':
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
os.chdir(Folder)
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_main.value]),"-m","{}".format(post_method[post_method_btn.value])],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout
else:
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
if not os.path.exists(post_calc[post_btn.value]):
os.makedirs(post_calc[post_btn.value])
os.chdir(post_calc[post_btn.value])
list_commands = ["cmmde.py","-i","{}".format("../cmmd.xyz"),"-s","{}".format(post_software[post_software_main.value]),"-j","{}".format(post_calc[post_btn.value]),"-m","{}".format(post_method[post_method_btn.value])]
Post_folder = Folder + post_calc[post_btn.value]
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])]
if dispersion_cor.value != 'None':
new_commands = ["-disp","{}".format(dispersion_cor.value)]
for i in new_commands:
@ -221,16 +226,25 @@ def cmmde_gui():
TextArea.value = TextArea.value + "\n" + cmd.stdout
Progress_btn = pn.widgets.Button(name="Check queue",button_type='primary')
Progress_btn.on_click(progress)
# Check the calculation progress
def calc_progress(event):
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder)
cmd = subprocess.run(["tail", "-n", "10", "cmmd.out"],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout
Checkcalc_btn_main = pn.widgets.Button(name="Check calculation",button_type='primary')
Checkcalc_btn_main.on_click(calc_progress)
def calc_progress_post(event):
Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value + post_calc[post_btn.value]
os.chdir(Folder)
cmd = subprocess.run(["tail", "-n", "10", "cmmd.out"],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout
Checkcalc_btn = pn.widgets.Button(name="Check calculation",button_type='primary')
Checkcalc_btn.on_click(calc_progress)
Checkcalc_btn_post = pn.widgets.Button(name="Check 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")
@ -366,7 +380,7 @@ def cmmde_gui():
site="Computational Molecular and Material Design Environment",
title="CMMDE",
main=[TextArea, editor, xyzviewer],
sidebar=[pn.Card(id_input,title="User Information",collapsed=True),pn.Card(Molecule_input,charge,mult,checkdir_btn,TextWarning,pn.Card(FileInput,title="Upload molecule",collapsed=True),title="Molecule Information",collapsed=True),pn.Card(Material_input, materialdir_btn,TextWarning, pn.Card(Material_upload,title="Unit cell",collapsed=True),hkl_input,size_input,layer_input,pn.Row(slabbuilder_btn,visual_btn),pn.Row(download_xyz,download_slab),title="Surface Builder",collapsed=True),pn.Card(software_main,job_main,method_btn, dispersion_cor,solvent, pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),download_xyz,title="Main Calculation",collapsed=True),pn.Card(post_software_main,post_btn,post_method_btn,dispersion_cor,solvent,pn.Row(runpost_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),pn.Row(download_spec_raw,download_spec_plot),pn.Row(download_opt_raw,download_opt_plot),title="Post-Calculation",collapsed=True)],
sidebar=[pn.Card(id_input,title="User Information",collapsed=True),pn.Card(Molecule_input,charge,mult,checkdir_btn,TextWarning,pn.Card(FileInput,title="Upload molecule",collapsed=True),title="Molecule Information",collapsed=True),pn.Card(Material_input, materialdir_btn,TextWarning, pn.Card(Material_upload,title="Unit cell",collapsed=True),hkl_input,size_input,layer_input,pn.Row(slabbuilder_btn,visual_btn),pn.Row(download_xyz,download_slab),title="Surface Builder",collapsed=True),pn.Card(software_main,job_main,method_btn, dispersion_cor,solvent, pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn_main,visual_btn),download_xyz,title="Main Calculation",collapsed=True),pn.Card(post_software_main,post_btn,post_method_btn,dispersion_cor,solvent,pn.Row(runpost_btn,Progress_btn),pn.Row(Checkcalc_btn_post),pn.Row(download_spec_raw,download_spec_plot),pn.Row(download_opt_raw,download_opt_plot),title="Post-Calculation",collapsed=True)],
header_background=accent, accent_base_color=accent
)

@ -0,0 +1,24 @@
import os
import panel as pn
import subprocess
def path(workdir,id_input,textarea):
reaktan_input = pn.widgets.FileInput(name="Struktur reaktan",accept='.xyz')
produk_input = pn.widgets.FileInput(name="Struktur produk", accept='.xyz')
path_name = pn.widgets.TextInput(name="Directory name")
alp = pn.widgets.TextInput(name="Bias energy",value="1.2")
kpush = pn.widgets.TextInput(name="Push force",value="0.003")
kpull = pn.widgets.TextInput(name="Pull force",value="-0.015")
ppull = pn.widgets.TextInput(name="Histogram bin",value="0.05")
def run_path(event):
reaktan_input.save("reaktan.xyz")
reaktan = "reaktan.xyz"
produk_input.save("produk.xyz")
produk = "produk.xyz"
Folder = workdir + "/" + id_input + "/" + path_name
if os.path.exists(Folder):
textarea = textarea + "Directory exists! Please change!"
else:
os.makedirs(Folder)
os.chdir(Folder)
cmd = subprocess.run(["cmmde.py","-s","xtb","-i","{}".format(reaktan),"-j","path","-produk","{}".format(produk),"-alp","{}".format(alp.value)])
Loading…
Cancel
Save