from xmlrpclib import ServerProxy
from IPython.display import Image
import os, sys
import scipy as sp
from scipy import constants
from scipy.constants import codata
import numpy as np
import __main__
__main__.pymol_argv = [ 'pymol', '-cp' ]
import pymol
pymol.finish_launching()
from pymol import cmd
from IPython.display import Image
%%bash
export PATH=${PATH}:/home/preps/golovin/progs/bin
export MOPAC_LICENSE=/home/preps/golovin/progs/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/preps/golovin/progs/lib
cd /home/students/y12/rita501/term8/pr3
%%bash
echo 'C1=CC=C2C=CC=C2C=C1 Azulene' > azulene.smi
obgen azulene.smi > azulene.mol
cmd.do('''
reinit
bg white
load azulene.mol
orient azulene
show spheres, all
set sphere_scale, 0.2
set valence, on
ray
png pic1.png
''')
Image(filename='pic1.png')
cmd.save('azulene.pdb', 'azulene')
cmd.do('''
bg white
rotate x, -90
ray
png pic2.png
''')
Image(filename='pic2.png')
%%bash
babel -ipdb azulene.pdb -omop azulene_opt.mop -xk "PM6"
%%bash
MOPAC2009.exe azulene_opt.mop
%%bash
babel -imopout azulene_opt.out -omol azulene_opt.mol
%%bash
echo 'c1ccc2ccccc2c1 Naphthalene' > naphthalene.smi
obgen naphthalene.smi > naphthalene.mol
cmd.do('''
reinit
bg white
load naphthalene.mol
orient azulene
show spheres, all
set sphere_scale, 0.2
set valence, on
ray
png pic3.png
''')
Image(filename='pic3.png')
cmd.save('naphthalene.pdb', 'naphthalene')
cmd.do('''
bg white
rotate x, -90
ray
png pic4.png
''')
Image(filename='pic4.png')
%%bash
babel -ipdb naphthalene.pdb -omop naphthalene_opt.mop -xk "PM6"
%%bash
MOPAC2009.exe naphthalene_opt.mop
%%bash
babel -imopout naphthalene_opt.out -omol naphthalene_opt.mol
%%bash
babel -imol azulene.mol -ogamin azu_opt.inp
babel -imol naphthalene.mol -ogamin nap_opt.inp
with open("azu_opt.inp") as f,open("azu_opt_new.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS SCFTYP=RHF RUNTYP=OPTIMIZE $END\n $BASIS GBASIS=N31 NGAUSS=6 $end\n $system mwords=2 $end")
o.write(data)
with open("nap_opt.inp") as f,open("nap_opt_new.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS SCFTYP=RHF RUNTYP=OPTIMIZE $END\n $BASIS GBASIS=N31 NGAUSS=6 $end\n $system mwords=2 $end")
o.write(data)
%%bash
#Запускаем GAMESS
gms nap_opt_new.inp 1 >& nap_opt.log
gms azu_opt_new.inp 1 >& azu_opt.log
%%bash
#строим файл на каждую молекулу, проводя расчёт методом Хартри-Фока
babel -igamout azu_opt.log -ogamin azu_hart.inp
babel -igamout nap_opt.log -ogamin nap_hart.inp
with open("azu_hart.inp") as f,open("azu_hart_n.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS SCFTYP=RHF RUNTYP=ENERGY $END\n $BASIS GBASIS=N31 NGAUSS=6\n POLAR=POPN31 NDFUNC=1 $END\n $GUESS GUESS=HUCKEL $END\n $system mwords=2 $end")
o.write(data)
with open("nap_hart.inp") as f,open("nap_hart_n.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS SCFTYP=RHF RUNTYP=ENERGY $END\n $BASIS GBASIS=N31 NGAUSS=6\n POLAR=POPN31 NDFUNC=1 $END\n $GUESS GUESS=HUCKEL $END\n $system mwords=2 $end")
o.write(data)
%%bash
#строим файл на каждую молекулу, проводя расчёт по теории функционала плотности
babel -igamout azu_opt.log -ogamin azu_th.inp
babel -igamout nap_opt.log -ogamin nap_th.inp
with open("azu_th.inp") as f,open("azu_th_n.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS dfttyp=b3lyp RUNTYP=ENERGY $END\n $BASIS GBASIS=N31 NGAUSS=6\n POLAR=POPN31 NDFUNC=1 $END\n $GUESS GUESS=HUCKEL $END\n $system mwords=2 $end")
o.write(data)
with open("nap_th.inp") as f,open("nap_th_n.inp",'w') as o:
data=f.read()
data=data.replace("$CONTRL COORD=CART UNITS=ANGS $END","$CONTRL COORD=CART UNITS=ANGS dfttyp=b3lyp RUNTYP=ENERGY $END\n $BASIS GBASIS=N31 NGAUSS=6\n POLAR=POPN31 NDFUNC=1 $END\n $GUESS GUESS=HUCKEL $END\n $system mwords=2 $end")
o.write(data)
%%bash
#рассчет энергий
gms azu_hart_n.inp 1 >& azu_hart_n.log
gms azu_th_n.inp 1 >& azu_th_n.log
gms nap_hart_n.inp 1 >& nap_hart_n.log
gms nap_th_n.inp 1 >& nap_th_n.log