Aditya Wibawa Sakti 2 years ago
parent 760c3fbf66
commit fabcee5d27
  1. 6
      README.md
  2. 18
      bin/cmmdepost.py
  3. 43
      cmmde_gui/gui.py

@ -22,9 +22,6 @@ CMMDE is a set of tools based on Python for running computational jobs, as well
Tahap kedua peluncuran CMMDE, didahului workshop: Tahap kedua peluncuran CMMDE, didahului workshop:
**Senin, 15 Agustus 2022 (10:00 WIB):**</br>
Penyiapan Server Komputasi</br>
Tautan: [https://mki.ac/CMMD-server](https://mki.ac/CMMD-server)
**Selasa, 16 Agustus 2022 (13:00 WIB):**</br> **Selasa, 16 Agustus 2022 (13:00 WIB):**</br>
Workshop on Text-Based CMMDE</br> Workshop on Text-Based CMMDE</br>
@ -40,6 +37,9 @@ Launching Consortium on Computational Science Development</br>
(Konsorsium Pengembangan Sains Komputasi)</br> (Konsorsium Pengembangan Sains Komputasi)</br>
Tautan: [https://mki.ac/cmsd-launch]( https://mki.ac/cmsd-launch) Tautan: [https://mki.ac/cmsd-launch]( https://mki.ac/cmsd-launch)
**Kamis, 18 Agustus 2022 (13:00 WIB):**</br>
Penyiapan Server Komputasi</br>
Tautan: [https://mki.ac/CMMD-server](https://mki.ac/CMMD-server)
Informasi lebih lanjut: cmmde@mki.or.id Informasi lebih lanjut: cmmde@mki.or.id

@ -63,7 +63,7 @@ ev2kcal = 23.060541945329334
Ha2kj = 2625.5 Ha2kj = 2625.5
ev2kj = 96 ev2kj = 96
# Analisis Output # Analisis Output
method = opt.method
if opt.job == 'sp' and opt.software == 'orca' and not (opt.method == 'XTB' or opt.method == 'XTB2'): if opt.job == 'sp' and opt.software == 'orca' and not (opt.method == 'XTB' or opt.method == 'XTB2'):
if os.path.isfile('cmmd.out'): if os.path.isfile('cmmd.out'):
with open('cmmd.out','r') as f: with open('cmmd.out','r') as f:
@ -101,6 +101,7 @@ elif opt.job == 'sp' and opt.software == 'orca':
if opt.job == 'opt' and opt.software == 'orca': if opt.job == 'opt' and opt.software == 'orca':
Energy = [] Energy = []
Gradient = [] Gradient = []
TotalEnergy = []
if os.path.isfile('cmmd.out'): if os.path.isfile('cmmd.out'):
with open('cmmd.out','r') as f: with open('cmmd.out','r') as f:
for line in f: for line in f:
@ -110,8 +111,12 @@ if opt.job == 'opt' and opt.software == 'orca':
if "Current gradient" in line: if "Current gradient" in line:
arr = line.split() arr = line.split()
Gradient.append(float(arr[4])) Gradient.append(float(arr[4]))
if "TOTAL ENERGY" in line:
arr = line.split()
TotalEnergy.append(float(arr[3]))
Optstep = range(0,len(Energy)) Optstep = range(0,len(Energy))
print("Total energi elektronik = {} Hartree = {} kJ/mol".format(TotalEnergy[-1],TotalEnergy[-1]*Ha2kj))
if method != "XTB1" and method != "xtb1" and method != "XTB2" and method != "xtb2" and method != "XTB" and method != "xtb":
with open('cmmd.out','r') as f: with open('cmmd.out','r') as f:
lines = f.readlines() lines = f.readlines()
occ = [] occ = []
@ -138,6 +143,15 @@ if opt.job == 'opt' and opt.software == 'orca':
print('Energi HOMO = {:.2f} eV'.format(E_HOMO)) print('Energi HOMO = {:.2f} eV'.format(E_HOMO))
print('Energi LUMO = {:.2f} eV'.format(E_LUMO)) print('Energi LUMO = {:.2f} eV'.format(E_LUMO))
print('Gap HOMO-LUMO = {:.2f} eV'.format(E_LUMO-E_HOMO)) print('Gap HOMO-LUMO = {:.2f} eV'.format(E_LUMO-E_HOMO))
else:
Gaps = []
with open("cmmd.out", 'r') as f:
print('######INFORMASI ENERGI HOMO & LUMO######')
for line in f:
if "GAP" in line:
arr = line.split()
Gaps.append(float(arr[3]))
print("Gap HOMO-LUMO = {:.2f} eV".format(Gaps[-1]))
with open('optimized.dat','w') as fout: with open('optimized.dat','w') as fout:
print("#Step Energy Gradient", file=fout) print("#Step Energy Gradient", file=fout)

@ -42,11 +42,11 @@ def cmmde_gui():
job = {'Single point calculation':'sp','Geometry optimization':'opt','Frequency calculation':'freq','Molecular dynamics':'md','Metadynamics':'mtd'} job = {'Single point calculation':'sp','Geometry optimization':'opt','Frequency calculation':'freq','Molecular dynamics':'md','Metadynamics':'mtd'}
# CMMDE method options # 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']) 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'} 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'}
# Name your molecule/Material # Name your molecule/Material
Name_input = pn.widgets.TextInput(name="Molecule name") Molecule_input = pn.widgets.TextInput(name="Molecule name")
id_input = pn.widgets.TextInput(name="Input your name") id_input = pn.widgets.TextInput(name="Input your name")
workdir = os.getenv("HOME") + "/" + "scr" workdir = os.getenv("HOME") + "/" + "scr"
@ -68,7 +68,7 @@ def cmmde_gui():
# terminal.clear() # terminal.clear()
# unik = str(uuid.uuid4().hex) # unik = str(uuid.uuid4().hex)
Folder = workdir + "/" + id_input.value + "/" + Name_input.value Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder) os.chdir(Folder)
@ -96,7 +96,7 @@ def cmmde_gui():
checkdir_btn = pn.widgets.Button(name="Generate work directory",type="primary") checkdir_btn = pn.widgets.Button(name="Generate work directory",type="primary")
TextWarning = pn.widgets.StaticText() TextWarning = pn.widgets.StaticText()
def checkdir(event): def checkdir(event):
Folder = workdir + "/" + id_input.value + "/" + Name_input.value Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
isExist = os.path.exists(Folder) isExist = os.path.exists(Folder)
TextWarning.value = "" TextWarning.value = ""
if isExist: if isExist:
@ -110,9 +110,11 @@ 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'} post_calc = {'Frequency calculation':'freq', 'Radial distribution function':'rdf','Mean Square Displacement':'msd','Time-dependent calculation':'td','Thermochemistry calculation':'thermo','Optimized energy':'opt'}
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']) 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 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'}
@ -125,8 +127,11 @@ def cmmde_gui():
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
# 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':
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)
TextArea.value = TextArea.value + "\n" + cmd.stdout
else: else:
Folder = workdir + "/" + id_input.value + "/" + Name_input.value Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder) os.chdir(Folder)
os.makedirs(post_calc[post_btn.value]) os.makedirs(post_calc[post_btn.value])
os.chdir(post_calc[post_btn.value]) os.chdir(post_calc[post_btn.value])
@ -163,8 +168,24 @@ def cmmde_gui():
size_input = pn.widgets.TextInput(name="Dimension",placeholder="Example: 2x2") size_input = pn.widgets.TextInput(name="Dimension",placeholder="Example: 2x2")
layer_input = pn.widgets.TextInput(name="Layer",placeholder="Example: 2") layer_input = pn.widgets.TextInput(name="Layer",placeholder="Example: 2")
slabbuilder_btn = pn.widgets.Button(name="Build it!",button_type="primary") slabbuilder_btn = pn.widgets.Button(name="Build it!",button_type="primary")
Material_input = pn.widgets.TextInput(name="Material name")
# Generate material folder button
materialdir_btn = pn.widgets.Button(name="Generate work directory",type="primary")
TextWarning = pn.widgets.StaticText()
def materialgen(event):
Folder = workdir + "/" + id_input.value + "/" + Material_input.value
isExist = os.path.exists(Folder)
TextWarning.value = ""
if isExist:
TextWarning.value = "Directory exists! Change the material name!"
else:
os.makedirs(Folder)
TextWarning.value = "Successfully create the directory!"
materialdir_btn.on_click(materialgen)
def slab_builder(event): def slab_builder(event):
Folder = workdir + "/" + id_input.value + "/" + Name_input.value Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder) os.chdir(Folder)
os.system("mv geom.xyz POSCAR") os.system("mv geom.xyz POSCAR")
hkl = hkl_input.value hkl = hkl_input.value
@ -200,7 +221,7 @@ def cmmde_gui():
def visualize(event): def visualize(event):
xyzview = py3Dmol.view() xyzview = py3Dmol.view()
Folder = workdir + "/" + id_input.value + "/" + Name_input.value Folder = workdir + "/" + id_input.value + "/" + Molecule_input.value
os.chdir(Folder) os.chdir(Folder)
with open('cmmd.xyz','r') as f: with open('cmmd.xyz','r') as f:
xyz = f.read() xyz = f.read()
@ -237,7 +258,7 @@ def cmmde_gui():
site="CMMDE-GUI", site="CMMDE-GUI",
title="CMMDE Editor", title="CMMDE Editor",
main=[editor, TextArea, pn.Tabs(xyzviewer)], main=[editor, TextArea, pn.Tabs(xyzviewer)],
sidebar=[pn.Card(id_input,Name_input,charge,mult,checkdir_btn,TextWarning,pn.Card(FileInput,title="Upload molecule",collapsed=True),pn.Card(pn.Card(FileInput,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),title="Pre-Calculation",collapsed=True),pn.Card(pn.Card(software_btn,job_btn,method_btn,pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),title="General calculation",collapsed=True),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),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, pn.Card(FileInput,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(pn.Card(software_btn,job_btn,method_btn,pn.Row(Run_btn,Progress_btn),pn.Row(Checkcalc_btn,visual_btn),title="General calculation",collapsed=True),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),title="Post-Calculation",collapsed=True)],
header_background=accent, accent_base_color=accent header_background=accent, accent_base_color=accent
) )

Loading…
Cancel
Save