add IR spectra and download features

Aditya Wibawa Sakti 2 years ago
parent d2410c6c7d
commit 285fc15a27
  1. 30
      cmmde_gui/gui.py

@ -115,8 +115,8 @@ def cmmde_gui():
# Post calculations # Post calculations
post_calc = {'Frequency calculation':'freq', 'Radial distribution function':'rdf','Mean Square Displacement':'msd','Time-dependent calculation':'td','Thermochemistry calculation':'thermo','Optimized energy':'opt'} post_calc = {'Frequency calculation':'freq', 'Radial distribution function':'rdf','Mean Square Displacement':'msd','Time-dependent calculation':'td','Thermochemistry calculation':'thermo','Optimized energy':'opt','IR plot':'ir'}
post_btn = pn.widgets.Select(name="Job Selection",value='Frequency calculation', options=['Frequency calculation','Radial distribution function', 'Mean Square Displacement','Time-dependent calculation','Thermochemistry calculation','Optimized energy']) post_btn = pn.widgets.Select(name="Job Selection",value='Frequency calculation', options=['Frequency calculation','Radial distribution function', 'Mean Square Displacement','Time-dependent calculation','Thermochemistry calculation','Optimized energy','IR plot'])
# Post Calculation CMMDE software options # Post Calculation CMMDE software options
post_software_btn = pn.widgets.Select(name="Software selections for post calculations",value='Orca',options=['Orca','GROMACS','Dcdftbmd','Quantum Espresso']) post_software_btn = pn.widgets.Select(name="Software selections for post calculations",value='Orca',options=['Orca','GROMACS','Dcdftbmd','Quantum Espresso'])
post_software = {'Orca':'orca','GROMACS':'gromacs','Dcdftbmd':'dcdftb','Quantum Espresso':'qe'} post_software = {'Orca':'orca','GROMACS':'gromacs','Dcdftbmd':'dcdftb','Quantum Espresso':'qe'}
@ -126,8 +126,23 @@ def cmmde_gui():
def post_calculation(event): def post_calculation(event):
# terminal.clear() # terminal.clear()
if post_calc[post_btn.value] == 'thermo' and post_software[post_software_btn.value] == 'orca': if post_calc[post_btn.value] == 'thermo' and post_software[post_software_btn.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 .")
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_btn.value])],capture_output=True,text=True) cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_btn.value])],capture_output=True,text=True)
TextArea.value = TextArea.value + "\n" + cmd.stdout TextArea.value = TextArea.value + "\n" + cmd.stdout
elif post_calc[post_btn.value] == 'ir' and post_software[post_software_btn.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 .")
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_btn.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_btn.value])) # terminal.subprocess.run("cmmdepost.py","-j{}".format(post_calc[post_btn.value]),"-s{}".format(post_software[post_software_btn.value]))
elif post_calc[post_btn.value] == 'opt' and post_software[post_software_btn.value] == 'orca': elif post_calc[post_btn.value] == 'opt' and post_software[post_software_btn.value] == 'orca':
cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_btn.value]),"-m","{}".format(post_method[post_method_btn.value])],capture_output=True,text=True) cmd = subprocess.run(["cmmdepost.py","-j","{}".format(post_calc[post_btn.value]),"-s","{}".format(post_software[post_software_btn.value]),"-m","{}".format(post_method[post_method_btn.value])],capture_output=True,text=True)
@ -161,10 +176,12 @@ def cmmde_gui():
Checkcalc_btn = pn.widgets.Button(name="Check calculation",button_type='primary') Checkcalc_btn = pn.widgets.Button(name="Check calculation",button_type='primary')
Checkcalc_btn.on_click(calc_progress) Checkcalc_btn.on_click(calc_progress)
# # Download Button # # Download Button
download_xyz = pn.widgets.FileDownload(file="cmmd.xyz",filename="cmmd.xyz") download_xyz = pn.widgets.FileDownload(file="cmmd.xyz",filename="optimized.xyz")
download_slab = pn.widgets.FileDownload(file="slab.vasp",filename="slab.vasp") download_slab = pn.widgets.FileDownload(file="slab.vasp",filename="slab.vasp")
download_spectrum = pn.widgets.FileDownload(file="IR.pdf",filename="IR.pdf") 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 # Slab Builder
hkl_input = pn.widgets.TextInput(name="Miller index (hkl)",placeholder="Example: 100") hkl_input = pn.widgets.TextInput(name="Miller index (hkl)",placeholder="Example: 100")
size_input = pn.widgets.TextInput(name="Dimension",placeholder="Example: 2x2") size_input = pn.widgets.TextInput(name="Dimension",placeholder="Example: 2x2")
@ -289,10 +306,11 @@ def cmmde_gui():
#### Wrap them all together ########## #### Wrap them all together ##########
return pn.template.MaterialTemplate( return pn.template.MaterialTemplate(
sidebar_width=410,
site="CMMDE-GUI", site="CMMDE-GUI",
title="CMMDE Editor", title="CMMDE Editor",
main=[TextArea, editor, xyzviewer], 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_btn,job_btn,method_btn,pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),download_xyz,title="Main Calculation",collapsed=True),pn.Card(post_software_btn,post_btn,post_method_btn,pn.Row(runpost_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),download_spectrum,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_btn,job_btn,method_btn,pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),download_xyz,title="Main Calculation",collapsed=True),pn.Card(post_software_btn,post_btn,post_method_btn,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)],
header_background=accent, accent_base_color=accent header_background=accent, accent_base_color=accent
) )

Loading…
Cancel
Save