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 [5]:
os.environ['PATH']=os.environ['PATH']+'/home/preps/golovin/progs/bin'
os.environ['MOPAC_LICENSE'] ='/home/preps/golovin/progs/bin'
os.environ['LD_LIBRARY_PATH']='/home/preps/golovin/progs/bin'
In [6]:
%%bash
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/preps/golovin/progs/lib
In [7]:
%%bash 
echo 'C1=CC=C2C=CC=C2C=C1' >  azulene.smi
In [8]:
%%bash 
obgen azulene.smi -ff UFF > azulene.mol
In [9]:
cmd.delete('all')
cmd.load('azulene.mol')
In [10]:
cmd.refresh()
cmd.do('''
bg_color white
as sticks, all
orient, all
show sticks
set valence, on
set stick_ball, on
set stick_ball_ratio, 3
set stick_radius, 0.12
set valence_mode, 2
set ray_trace_mode, 3
ray
png pic1.png
''')
In [11]:
Image(filename='pic1.png')
Out[11]:

Азулен получился плоский в поле UFF. Оптимизируем его с помощью MOPAC

In [12]:
cmd.save('azulene.pdb')

Запускаю MOPAC и babel через консоль

In [13]:
%%bash 
babel -ipdb azulene.pdb -omop azulene.mop -xk "PM6"
/home/preps/golovin/progs/bin/MOPAC2009.exe azulene.mop
In [39]:
%%bash 
babel -imopout azulene.out -omol azulene_new.mol
In [15]:
%%bash 
echo 'c1ccc2ccccc2c1' > naphthalene.smi
In [16]:
%%bash 
obgen naphthalene.smi > naphthalene.mol
In [17]:
cmd.delete('all')
cmd.load('naphthalene.mol')
In [18]:
cmd.refresh()
cmd.do('''
bg_color white
as sticks, all
orient, all
show sticks
set valence, on
set stick_ball, on
set stick_ball_ratio, 3
set stick_radius, 0.12
set valence_mode, 2
ray
png pic2.png
''')
In [19]:
Image(filename='pic2.png')
Out[19]:

Нафтален получился плоский. И его оптимизируем.

In [20]:
cmd.save('naphthalene.pdb')
In [21]:
%%bash 
babel -ipdb naphthalene.pdb -omop naphthalene.mop -xk "PM6"
/home/preps/golovin/progs/bin/MOPAC2009.exe naphthalene.mop
In [50]:
%%bash 
babel -imopout naphthalene.out -omol naphthalene_new.mol
In [23]:
%%bash 
babel -imol azulene_new.mol -ogamin azulene_opt.inp
babel -imol naphthalene_new.mol -ogamin naphthalene_opt.inp
In [2]:
with open("azulene_opt.inp") as f,open("azulene_opt_head.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 [3]:
with open("naphthalene_opt.inp") as f,open("naphthalene_opt_head.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 [105]:
%%bash 
gms azulene_opt_head.inp  1 >& azulene_opt_head.log 
gms naphthalene_opt_head.inp  1 >& naphthalene_opt_head.log
In [106]:
%%bash 
babel -igamout azulene_opt_head.log -ogamin azulene_opt_head1.inp
babel -igamout naphthalene_opt_head.log -ogamin naphthalene_opt_head1.inp
In [4]:
with open("naphthalene_opt_head1.inp") as f,open("naphthalene_opt_head_hf.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 [5]:
with open("naphthalene_opt_head1.inp") as f,open("naphthalene_opt_head_tfp.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 [6]:
with open("azulene_opt_head1.inp") as f,open("azulene_opt_head_hf.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 [7]:
with open("azulene_opt_head1.inp") as f,open("azulene_opt_head_tfp.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 [107]:
%%bash 
gms azulene_opt_head_hf.inp  1 >& azulene_opt_head_hf.log 
gms naphthalene_opt_head_hf.inp  1 >& naphthalene_opt_head_hf.log
In [108]:
%%bash 
gms azulene_opt_head_tfp.inp  1 >& azulene_opt_head_tfp.log 
gms naphthalene_opt_head_tfp.inp  1 >& naphthalene_opt_head_tfp.log
Вещество E Naphthalene E Azulene ΔE , Hartree ΔE, kCal/mol
Хартри-Фок -383.3549266833 -383.2824728439 0.0724538394 45.4654702889
DFT -385.6401507233 -385.5856859589 0.0544647644 34.1771553879