@ -38,8 +38,8 @@ def cmmde_gui():
height = 500 , disabled = True
height = 500 , disabled = True
)
)
# CMMDE software options
# CMMDE software options
software_main = pn . widgets . Select ( name = " Software selections " , value = ' Orca ' , options = [ ' Orca ' , ' GROMACS ' , ' Dcdftbmd ' , ' Quantum Espresso ' ] )
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 ' }
software = { ' Orca ' : ' orca ' , ' GROMACS ' : ' gromacs ' , ' Dcdftbmd ' : ' dcdftb ' , ' Quantum Espresso ' : ' qe ' , ' XTB ' : ' xtb ' }
# Orca card
# 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 . 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! "
TextArea . value = TextArea . value + " \n " + " Perhitungan anda telah tersubmit! "
# RunMessage = pn.widgets.StaticText()
# RunMessage = pn.widgets.StaticText()
run_orca_btn . on_click ( run_orca )
run_orca_btn . on_click ( run_orca )
# CMMDE job options
# 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 . 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 ' }
job = { ' Single point calculation ' : ' sp ' , ' Geometry optimization ' : ' opt ' , ' Frequency calculation ' : ' freq ' }
# CMMDE method options
# 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_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 ' }
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_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 ' }
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 ) :
def post_calculation ( event ) :
# terminal.clear()
Folder = workdir + " / " + id_input . value + " / " + Molecule_input . value
Folder = workdir + " / " + id_input . value + " / " + Molecule_input . value
# terminal.clear()
os . chdir ( Folder )
if post_calc [ post_btn . value ] == ' thermo ' and post_software [ post_software_main . value ] == ' orca ' :
if post_calc [ post_btn . value ] == ' thermo ' and post_software [ post_software_main . value ] == ' orca ' :
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
# os.chdir(Folder)
if not os . path . exists ( post_calc [ post_btn . value ] ) :
Post_folder = Folder + " / " + post_calc [ post_btn . value ]
os . makedirs ( post_calc [ post_btn . value ] )
if not os . path . exists ( Post_folder ) :
os . chdir ( post_calc [ post_btn . value ] )
os . makedirs ( Post_folder )
os . system ( " cp ../freq/cmmd.out . " )
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 )
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
TextArea . value = TextArea . value + " \n " + cmd . stdout
elif post_calc [ post_btn . value ] == ' ir ' and post_software [ post_software_main . value ] == ' orca ' :
elif post_calc [ post_btn . value ] == ' ir ' and post_software [ post_software_main . value ] == ' orca ' :
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
# os.chdir(Folder)
if not os . path . exists ( post_calc [ post_btn . value ] ) :
Post_folder = Folder + " / " + post_calc [ post_btn . value ]
os . makedirs ( post_calc [ post_btn . value ] )
if not os . path . exists ( Post_folder ) :
os . chdir ( post_calc [ post_btn . value ] )
os . makedirs ( Post_folder )
os . system ( " cp ../freq/cmmd.out . " )
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 ] ) ] )
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 "
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]))
# 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 ' :
elif post_calc [ post_btn . value ] == ' opt ' and post_software [ post_software_main . value ] == ' orca ' :
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
# 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 )
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
TextArea . value = TextArea . value + " \n " + cmd . stdout
else :
else :
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
# os.chdir(Folder)
# os.chdir(Folder)
if not os . path . exists ( post_calc [ post_btn . value ] ) :
Post_folder = Folder + post_calc [ post_btn . value ]
os . makedirs ( post_calc [ post_btn . value ] )
if not os . path . exists ( Post_folder ) :
os . chdir ( post_calc [ post_btn . value ] )
os . makedirs ( Post_folder )
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 ] ) ]
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 ' :
if dispersion_cor . value != ' None ' :
new_commands = [ " -disp " , " {} " . format ( dispersion_cor . value ) ]
new_commands = [ " -disp " , " {} " . format ( dispersion_cor . value ) ]
for i in new_commands :
for i in new_commands :
@ -219,7 +224,6 @@ def cmmde_gui():
# terminal.subprocess.run("squeue")
# terminal.subprocess.run("squeue")
cmd = subprocess . run ( [ " squeue " ] , capture_output = True , text = True )
cmd = subprocess . run ( [ " squeue " ] , capture_output = True , text = True )
TextArea . value = TextArea . value + " \n " + cmd . stdout
TextArea . value = TextArea . value + " \n " + cmd . stdout
Progress_btn = pn . widgets . Button ( name = " Check queue " , button_type = ' primary ' )
Progress_btn = pn . widgets . Button ( name = " Check queue " , button_type = ' primary ' )
@ -227,10 +231,20 @@ def cmmde_gui():
# Check the calculation progress
# Check the calculation progress
def calc_progress ( event ) :
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 )
cmd = subprocess . run ( [ " tail " , " -n " , " 10 " , " cmmd.out " ] , capture_output = True , text = True )
TextArea . value = TextArea . value + " \n " + cmd . stdout
TextArea . value = TextArea . value + " \n " + cmd . stdout
Checkcalc_btn = pn . widgets . Button ( name = " Check calculation " , button_type = ' primary ' )
Checkcalc_btn_post = pn . widgets . Button ( name = " Check calculation " , button_type = ' primary ' )
Checkcalc_btn . on_click ( calc_progress )
Checkcalc_btn_post . on_click ( calc_progress_post )
# # Download Button
# # Download Button
download_xyz = pn . widgets . FileDownload ( file = " cmmd.xyz " , filename = " optimized.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 " )
@ -366,7 +380,7 @@ def cmmde_gui():
site = " Computational Molecular and Material Design Environment " ,
site = " Computational Molecular and Material Design Environment " ,
title = " CMMDE " ,
title = " CMMDE " ,
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_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
header_background = accent , accent_base_color = accent
)
)