@ -16,8 +16,8 @@ import uuid 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# from iodata import IOData  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  test_can_construct ( ) :  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    JSMEEditor (  )  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# def test_can_construct() : 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					#     JSMEEditor( ) 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  cmmde_gui ( ) :  
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -27,28 +27,62 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    editor  =  JSMEEditor ( value  =  "   " , height = 500 , format = " smiles " , subscriptions = [ ' smiles ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					       
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# Name your molecule  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Molecule_input  =  pn . widgets . TextInput ( name = " Molecule name " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    id_input  =  pn . widgets . TextInput ( name = " Input your name " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    charge  =  pn . widgets . TextInput ( name = " Charge " , value = " 0 " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    mult  =  pn . widgets . TextInput ( name = " Spin multiplicity " , value = " 1 " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    workdir  =  os . getenv ( " HOME " )  +  " / "  +  " scr "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# Terminal widget  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    TextArea =  pn . widgets . TextAreaInput ( value  =  " Computational Molecular and Material Design Environment \n  Authors: \n  Universitas Pertamina \n  Institut Teknologi Sumatera \n  Masyarakat Komputasi Indonesia \n \n Supported by: \n  Konsorsium Pengembangan Sains Komputasi \n " ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    TextArea =  pn . widgets . TextAreaInput ( value  =  " Computational Molecular and Material Design Environment \n  Authors: \n  Universitas Pertamina \n  Institut Teknologi Sumatera \n  Institut Teknologi Bandung \n   Masyarakat Komputasi Indonesia \n \n Supported by: \n  Konsorsium Pengembangan Sains Komputasi \n " ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        height  =  500 ,  disabled = True   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# CMMDE software options  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    software_bt n  =  pn . widgets . Select ( name = " Software selections " , value = ' Orca ' , options = [ ' Orca ' , ' GROMACS ' , ' Dcdftbmd ' , ' Quantum Espresso ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    software_mai n  =  pn . widgets . Select ( name = " Software selections " , value = ' Orca ' , options = [ ' Orca ' , ' GROMACS ' , ' Dcdftbmd ' , ' Quantum Espresso ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    software  =  { ' Orca ' : ' orca ' , ' GROMACS ' : ' gromacs ' , ' Dcdftbmd ' : ' dcdftb ' , ' Quantum Espresso ' : ' qe ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# 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_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 ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    dispersion_cor  =  pn . widgets . Select ( name = " Dispersion corrections " , value = ' None ' , options = [ ' None ' , ' D3 ' , ' D3BJ ' , ' D4 ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    solvent  =  pn . widgets . Select ( name = ' Solvent ' , value = ' None ' , options = [ ' None ' , ' water ' , ' acetone ' , ' acetonitrile ' , ' aniline ' , ' benzaldehyde ' , ' benzene ' , ' CH2Cl2 ' , ' CHCl3 ' , ' CS2 ' , ' dioxane ' , ' DMF ' , ' ethanol ' , ' ether ' , ' ethylacetate ' , ' furane ' , ' hexadecane ' , ' hexane ' , ' ocatnol ' , ' octanol(wet) ' , ' phenol ' , ' toluene ' , ' THF ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    run_orca_btn  =  pn . widgets . Button ( name = " Run Orca! " , button_type = ' primary ' )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  run_orca ( event ) :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # RunMessage.value = " "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # terminal.clear()   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # unik = str(uuid.uuid4().hex)   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        Folder  =  workdir  +  " / "  +  id_input . value  +  " / "  +  Molecule_input . value    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        os . chdir ( Folder )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        job_list  =  [ job [ i ]  for  i  in  job_orca . value ]    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        jobs  =  " , " . join ( job_list )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  editor . value  ==  " " :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            FileInput . save ( " geom.xyz " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            geom  =  " geom.xyz "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        else :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            geom  =  editor . value   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					              
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        TextArea . value  =  TextArea . value  +  " \n "  +  " Mempersiapkan Struktur 3 Dimensi! "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        cmd  =  subprocess . run ( [ " cmmde.py " , " -i " , " {} " . format ( geom ) , " -s " , " orca " , " -j " , " {} " . format ( jobs ) , " -m " , " {} " . format ( method [ method_orca . value ] ) , " -c " , " {} " . format ( charge . value ) , " -mult " , " {} " . format ( mult . value ) ] , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        #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 = pn.widgets.StaticText()   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    run_orca_btn . on_click ( run_orca )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# CMMDE job options  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    job_btn  =  pn . widgets . MultiSelect ( name = " Job selections " , value = [ ' Single point calculation ' ] , options = [ ' Single point calculation ' , ' Geometry optimization ' , ' Frequency calculation ' , ' Molecular dynamics ' , ' Metadynamics ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    job  =  { ' Single point calculation ' : ' sp ' , ' Geometry optimization ' : ' opt ' , ' Frequency calculation ' : ' freq ' , ' Molecular dynamics ' : ' md ' , ' Metadynamics ' : ' mtd ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    job_mai n  =  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 ' , ' DFTB2 ' , ' DFTB2-gammah ' , ' DFTB3 ' , ' DFTB3-diag ' , ' B3LYP/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 ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    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 ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# Name your molecule/Material  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Molecule_input  =  pn . widgets . TextInput ( name = " Molecule name " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    id_input  =  pn . widgets . TextInput ( name = " Input your name " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    workdir  =  os . getenv ( " HOME " )  +  " / "  +  " scr "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# File input (if you don't want to draw the structure)  
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -61,8 +95,7 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# CMMDE running button  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    Run_btn  =  pn . widgets . Button ( name = " Run CMMDE! " , button_type = ' primary ' )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    # RunMessage = pn.widgets.StaticText()   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    charge  =  pn . widgets . TextInput ( name = " Charge " , value = " 0 " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    mult  =  pn . widgets . TextInput ( name = " Spin multiplicity " , value = " 1 " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    def  run ( event ) :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # RunMessage.value = " "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # terminal.clear()   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -73,7 +106,7 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        os . chdir ( Folder )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        job_list  =  [ job [ i ]  for  i  in  job_bt n . value ]    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        job_list  =  [ job [ i ]  for  i  in  job_mai n . value ]    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        jobs  =  " , " . join ( job_list )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  editor . value  ==  " " :   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -83,8 +116,17 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            geom  =  editor . value   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					              
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        TextArea . value  =  TextArea . value  +  " \n "  +  " Mempersiapkan Struktur 3 Dimensi! "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        cmd  =  subprocess . run ( [ " cmmde.py " , " -i " , " {} " . format ( geom ) , " -s " , " {} " . format ( software [ software_btn . value ] ) , " -j " , " {} " . format ( jobs ) , " -m " , " {} " . format ( method [ method_btn . value ] ) , " -c " , " {} " . format ( charge . value ) , " -mult " , " {} " . format ( mult . value ) ] , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        #terminal.subprocess.run("cmmde.py","-i{}".format(editor.value),"-s{}".format(software[software_btn.value]), "-j{}".format(jobs), "-m{}".format(method[method_btn.value]))   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        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 ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  dispersion_cor . value  !=  ' None ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            new_commands  =  [ " -disp " , " {} " . format ( dispersion_cor . value ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            for  i  in  new_commands :     
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                list_commands . append ( i )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  solvent . value  !=  ' None ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            new_commands  =  [ " -solvent " , " {} " . format ( solvent . value ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            for  i  in  new_commands :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                list_commands . append ( i )     
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        cmd  =  subprocess . run ( list_commands , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        #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! "   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					          
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -118,8 +160,8 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    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 ' , ' IR plot ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					# Post Calculation CMMDE software options  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    post_software_bt n  =  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_mai n  =  pn . widgets . Select ( name = " Software selections for post calculations " , value = ' Orca ' , options = [ ' Orca ' , ' Dcdftbmd ' , ' Quantum Espresso ' ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    post_software  =  { ' Orca ' : ' orca ' , ' Dcdftbmd ' : ' dcdftb ' , ' Quantum Espresso ' : ' qe ' }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    # Post CMMDE method options   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    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 ' }   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -127,37 +169,47 @@ def cmmde_gui(): 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # terminal.clear()   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        Folder  =  workdir  +  " / "  +  id_input . value  +  " / "  +  Molecule_input . value    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        os . chdir ( Folder )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  post_calc [ post_btn . value ]  ==  ' thermo '  and  post_software [ post_software_bt n . value ]  ==  ' orca ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  post_calc [ post_btn . value ]  ==  ' thermo '  and  post_software [ post_software_mai n . 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_bt n . value ] ) ] , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            cmd  =  subprocess . run ( [ " cmmdepost.py " , " -j " , " {} " . format ( post_calc [ post_btn . value ] ) , " -s " , " {} " . format ( post_software [ post_software_mai n . 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_bt n . value ]  ==  ' orca ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        elif  post_calc [ post_btn . value ]  ==  ' ir '  and  post_software [ post_software_mai n . 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_bt n . value ] ) ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            cmd  =  subprocess . run ( [ " cmmdepost.py " , " -j " , " {} " . format ( post_calc [ post_btn . value ] ) , " -s " , " {} " . format ( post_software [ post_software_mai n . 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_bt n.value]))   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        elif  post_calc [ post_btn . value ]  ==  ' opt '  and  post_software [ post_software_bt n . value ]  ==  ' orca ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            # terminal.subprocess.run("cmmdepost.py","-j{}".format(post_calc[post_btn.value]),"-s{}".format(post_software[post_software_mai n.value]))   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        elif  post_calc [ post_btn . value ]  ==  ' opt '  and  post_software [ post_software_mai n . value ]  ==  ' orca ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            # Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            # os.chdir(Folder)   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            cmd  =  subprocess . run ( [ " cmmdepost.py " , " -j " , " {} " . format ( post_calc [ post_btn . value ] ) , " -s " , " {} " . format ( post_software [ post_software_bt n . 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_mai n . 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)    
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            os . makedirs ( post_calc [ post_btn . value ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  not  os . path . exists ( post_calc [ post_btn . value ] ) :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                os . makedirs ( post_calc [ post_btn . value ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            os . chdir ( post_calc [ post_btn . value ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            cmd  =  subprocess . run ( [ " cmmde.py " , " -i " , " {} " . format ( " ../cmmd.xyz " ) , " -s " , " {} " . format ( post_software [ post_software_btn . value ] ) , " -j " , " {} " . format ( post_calc [ post_btn . value ] ) , " -m " , " {} " . format ( post_method [ post_method_btn . value ] ) ] , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            # terminal.subprocess.run("cmmde.py","-i{}".format("../cmmd.xyz"),"-s{}".format(post_software[post_software_btn.value]), "-j{}".format(post_calc[post_btn.value]), "-m{}".format(post_method[post_method_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 ] ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  dispersion_cor . value  !=  ' None ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                new_commands  =  [ " -disp " , " {} " . format ( dispersion_cor . value ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                for  i  in  new_commands :     
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                    list_commands . append ( i )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  solvent . value  !=  ' None ' :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                new_commands  =  [ " -solvent " , " {} " . format ( solvent . value ) ]   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                for  i  in  new_commands :   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                    list_commands . append ( i )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            cmd  =  subprocess . run ( list_commands , capture_output = True , text = True )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            # terminal.subprocess.run("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]))   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            TextArea . value  =  TextArea . value  +  " \n "  +  cmd . stdout   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    runpost_btn  =  pn . widgets . Button ( name = " Run post calculation! " , button_type = ' primary ' )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    runpost_btn . on_click ( post_calculation )   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -314,7 +366,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_btn , job_bt n , 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_bt n , 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 ) ] ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        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_mai n , 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_mai n , 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 ) ] ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        header_background = accent ,  accent_base_color = accent   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    )