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
%%bash
cd
cd Term6
cd Practice3
echo 'C1=CC=C2C=CC=C2C=C1 Azulene' > azulene.smi
obgen azulene.smi > azulene.mol
babel -imol azulene.mol -omop azulene_opt.mop -xk "PM6"
MOPAC2009.exe azulene_opt.mop
%%bash
cd
cd Term6
cd Practice3
babel -imopout azulene_opt.out -opdb azulene_opt.pdb
cmd.do('''
reinitialize
set ray_trace_mode, 0; red
set ray_opaque_background, off
set antialias, .5
set light_count, 8
set ambient, 0.5
set ray_trace_color, red
set cartoon_side_chain_helper, on
cd /home/students/y12/iltarn/Term6/Practice3
load azulene_opt.pdb
orient azulene_opt
as sticks, azulene_opt
zoom azulene_opt, 4
label all, " %s" % ID
set label_color, black
rotate x, -90
ray
png pic1.png
''')
Image(filename='pic1.png')
Видим, что молекула не плоская. Займемся магией - попробуем разные силовые поля (MMFF94, MMFF94s, UFF) в obgen.
%%bash
obgen azulene.smi -ff MMFF94 > azulene_MMFF94.mol
babel -imol azulene_MMFF94.mol -omop azulene_MMFF94_opt.mop -xk "PM6"
MOPAC2009.exe azulene_MMFF94_opt.mop
%%bash
cd
cd Term6
cd Practice3
babel -imopout azulene_MMFF94_opt.out -opdb azulene_MMFF94_opt.pdb
cmd.do('''
delete all
load azulene_MMFF94_opt.pdb
orient azulene_MMFF94_opt
as sticks, azulene_MMFF94_opt
zoom azulene_MMFF94_opt, 4
label all, " %s" % ID
set label_color, black
rotate x, -90
ray
png pic3.png
''')
Image(filename='pic3.png')
Ничего не изменилось
%%bash
obgen azulene.smi -ff UFF > azulene_UFF.mol
babel -imol azulene_UFF.mol -omop azulene_UFF_opt.mop -xk "PM6"
MOPAC2009.exe azulene_UFF_opt.mop
%%bash
cd
cd Term6
cd Practice3
babel -imopout azulene_UFF_opt.out -opdb azulene_UFF_opt.pdb
cmd.do('''
delete all
load azulene_UFF_opt.pdb
orient azulene_UFF_opt
as sticks, azulene_UFF_opt
zoom azulene_UFF_opt, 4
label all, " %s" % ID
set label_color, black
rotate x, -90
ray
png pic4.png
''')
Image(filename='pic4.png')
Молекула стала плоской. Преобразуем ее в azu.mol
%%bash
babel -imopout azulene_UFF_opt.out -omol azu.mol
%%bash
cd
cd Term6
cd Practice3
echo 'c1ccc2ccccc2c1 Naphthalene' > naphthalene.smi
obgen naphthalene.smi > naphthalene.mol
babel -imol naphthalene.mol -omop naphthalene_opt.mop -xk "PM6"
MOPAC2009.exe naphthalene_opt.mop
%%bash
cd
cd Term6
cd Practice3
babel -imopout naphthalene_opt.out -opdb naphthalene_opt.pdb
cmd.do('''
delete all
cd /home/students/y12/iltarn/Term6/Practice3
load naphthalene_opt.pdb
orient naphthalene_opt
as sticks, naphthalene_opt
zoom naphthalene_opt, 4
label all, " %s" % ID
set label_color, black
rotate x, -30
rotate y, 30
ray
png pic2.png
''')
Image(filename='pic2.png')
cmd.do('''
rotate y, -30
rotate x, -60
ray
png pic2_90.png
''')
Image(filename='pic2_90.png')
Молекула плоская. Делаем из нее nap.mol
%%bash
babel -imopout naphthalene_opt.out -omol nap.mol
%%bash
babel -imol azu.mol -ogamin azu_opt.inp
babel -imol nap.mol -ogamin nap_opt.inp
with open("azu_opt.inp") as f,open("azu_opt_h.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_h.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
gms nap_opt_h.inp 1 >& nap_opt.log
gms azu_opt_h.inp 1 >& azu_opt.log
%%bash
# Переформатирование... Добавляем текст в файл .log
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
# Переформатирование... Добавляем текст в файл .log
babel -igamout azu_opt.log -ogamin azu_th.inp
babel -igamout nap_opt.log -ogamin nap_th.inp
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)
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)
%%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
%%bash
awk '/TOTAL ENERGY =/{print $4}' *_n.log
# Вывод значений в алфавитном порядке по именам файлов.
Вещество |
E Naphthalene |
E Azulene |
ΔE , Hartree |
ΔE, kCal/mol |
Хартри-Фок |
-383.3549297881 |
-383.2824173049 |
0.072512483 |
45.50226983 |
DFT |
-385.6401629708 |
-385.5855568639 |
0.054606107 |
34.26584914 |