In [1]:
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
In [2]:
import __main__
__main__.pymol_argv = [ 'pymol', '-cp' ]
import pymol
pymol.finish_launching()
from pymol import cmd
In [3]:
from IPython.display import Image
In [4]:
%%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
In [5]:
cd /home/students/y12/rita501/term8/pr3
In [6]:
%%bash
echo 'C1=CC=C2C=CC=C2C=C1    Azulene' >  azulene.smi
obgen azulene.smi > azulene.mol
In [22]:
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
''')
In [23]:
Image(filename='pic1.png')
Out[23]:
In [24]:
cmd.save('azulene.pdb', 'azulene')
In [25]:
cmd.do('''
bg white
rotate x, -90
ray
png pic2.png
''')
In [26]:
Image(filename='pic2.png')
Out[26]:
In [10]:
%%bash 
babel -ipdb azulene.pdb -omop azulene_opt.mop -xk "PM6"
In []:
%%bash
MOPAC2009.exe azulene_opt.mop
In [27]:
%%bash
babel -imopout azulene_opt.out -omol azulene_opt.mol
In [28]:
%%bash
echo 'c1ccc2ccccc2c1   Naphthalene' >  naphthalene.smi
obgen naphthalene.smi > naphthalene.mol
In [29]:
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
''')
In [30]:
Image(filename='pic3.png')
Out[30]:
In [35]:
cmd.save('naphthalene.pdb', 'naphthalene')
In [31]:
cmd.do('''
bg white
rotate x, -90
ray
png pic4.png
''')
In [32]:
Image(filename='pic4.png')
Out[32]:
In [36]:
%%bash 
babel -ipdb naphthalene.pdb -omop naphthalene_opt.mop -xk "PM6"
In []:
%%bash
MOPAC2009.exe naphthalene_opt.mop
In [37]:
%%bash
babel -imopout naphthalene_opt.out -omol naphthalene_opt.mol
In [49]:
%%bash
babel -imol azulene.mol -ogamin azu_opt.inp
babel -imol naphthalene.mol -ogamin nap_opt.inp
In [52]:
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)
In [53]:
%%bash
#Запускаем GAMESS
gms nap_opt_new.inp  1 >& nap_opt.log 
gms azu_opt_new.inp  1 >& azu_opt.log
In [54]:
%%bash
#строим файл на каждую молекулу, проводя расчёт методом Хартри-Фока
babel -igamout azu_opt.log -ogamin azu_hart.inp
babel -igamout nap_opt.log -ogamin nap_hart.inp
In [55]:
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)
In [56]:
%%bash
#строим файл на каждую молекулу, проводя расчёт по теории функционала плотности
babel -igamout azu_opt.log -ogamin azu_th.inp
babel -igamout nap_opt.log -ogamin nap_th.inp
In [57]:
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)
In [58]:
%%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
In []: