In [252]:
import pygauss as pg
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import display
%matplotlib inline
import warnings
warnings.filterwarnings("ignore")
print 'pygauss version: {}'.format(pg.__version__)


pygauss version: 0.5.0

In [305]:
import os, platform
home = os.path.expanduser("~")
if platform.system() == 'Windows':
    pg.set_imagik_exe('convert_pdf')
    onedrive = 'SkyDrive'
else:
    onedrive = 'OneDrive'
inpath = os.path.join(home, onedrive, 
    'Imperial_2014-15', 'Project', 'Gaussian_files')

In [444]:
il_coronene = pg.Analysis(os.path.join(inpath, 'Coronene-IL'))

cerrs = il_coronene.add_runs(
    headers=['Surface', 'Cation', 'Anion', 'Diffuse', 'Initial'], 
    values=[['none'], ['emim'], ['none'], ['g', '+g'], ['none']],
    init_pattern='*_{1}_-_init.com',
    opt_pattern='*_{1}_-_6-311{3}-*_opt_.log',
    freq_pattern='*_{1}_-_6-311{3}-*_freq_.log',
    #nbo_pattern='*_{1}_-_6-311{3}-*_pop-nbo-full-_.log',
    atom_groups={'emim':range(1, 20)}, alignto=[3,2,1])
aerrs = il_coronene.add_runs(
    headers=['Surface', 'Cation', 'Anion', 'Diffuse', 'Initial'], 
    values=[['none'], ['none'], ['cl', 'bf', 'etso'], ['g', '+g'], ['none']],
    init_pattern='*_{2}_-_init.com',
    opt_pattern='*_{2}_-_6-311{3}-d-p-_gd3bj_opt_.log',
    freq_pattern='*_{2}_-_6-311{3}-d-p-_gd3bj_freq_.log')
serrs = il_coronene.add_runs(
    headers=['Surface', 'Cation', 'Anion', 'Diffuse', 'Initial'], 
    values=[['coro'], ['none'], ['none'], ['g', '+g'], ['none']],
    init_pattern='*_{0}_-_init.com',
    opt_pattern='*_{0}_-_6-311{3}-d-p-_gd3bj_opt_*.log',
    freq_pattern='*_{0}_-_6-311{3}-d-p-_gd3bj_freq_*.log')
error_df = pd.concat([cerrs, aerrs, serrs])

for anion, emim_atoms in zip(['cl', 'bf'], 
                             [range(38, 57), range(42, 61)]):

    atom_groups={'coro':range(1,37), 'coro_plane':[1,12,28], 'emim':emim_atoms, 'ce':range(1,37)+emim_atoms, 
                'emim_ring':list(reversed(emim_atoms[0:3])), 'c2':[emim_atoms[2]], 
                 'cl':[37], 'bf':range(37, 42), 'coro_plane':[4,7,9]}    
    emim_hs = [(2,7), (4,6), (5,5), ('6a',17), ('6b',18), ('6c',19), 
           ('7a',11), ('7b',12), ('8a',13), ('8b',14), ('8c',15)]
    for name, number in emim_hs:
        atom_groups['h{}'.format(name)] = emim_atoms[number-1]
        label = 'H{}_charge'.format(name)

    errors = il_coronene.add_runs(
        headers=['Surface', 'Cation', 'Anion', 'Initial', 'Diffuse'], 
        values=[['coro'], ['emim'], [anion],
               ['P-'+str(a) for a in range(0,360,30)]+['O-O', 'O-S1'], 
               ['+g']],
        init_pattern='CJS2_{0}-{1}-{2}_{3}_init.com',
        opt_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_opt_*.log',
        freq_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_freq_*.log',
        nbo_pattern='CJS6_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_pop-nbo-full-_*.log',
        atom_groups=atom_groups,
        alignto=[4,7,9], add_if_error=True, ipython_print=True)
    
    error_df = pd.concat([error_df, errors])

atom_groups={'coro':range(1,37), 'coro_plane':[1,12,28], 'emim':range(37, 56), 
             'ce':range(1,37)+range(37, 56), 'emim_ring':[39,38,37],
             'cl':[56], 'bf':range(56, 61), 'coro_plane':[4,7,9], 'c2':[39]}    
emim_hs = [(2,7), (4,6), (5,5), ('6a',17), ('6b',18), ('6c',19), 
       ('7a',11), ('7b',12), ('8a',13), ('8b',14), ('8c',15)]
for name, number in emim_hs:
    atom_groups['h{}'.format(name)] = 36+number
    
errors = il_coronene.add_runs(
    headers=['Surface', 'Cation', 'Anion', 'Initial', 'Diffuse'], 
    values=[['coro'], ['emim'], ['cl', 'bf'],
           ['O-S2'], ['+g']],
    init_pattern='CJS2_{0}-{1}-{2}_{3}_init.com',
    opt_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_opt_*.log',
    freq_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_freq_*.log',
    nbo_pattern='CJS6_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_pop-nbo-full-_*.log',
    atom_groups=atom_groups,
    alignto=[4,7,9], add_if_error=True, ipython_print=True)

error_df = pd.concat([error_df, errors])

for anion, emim_atoms in zip(['etso'], 
                             [range(49,68)]):
    atom_groups={'coro':range(1,37), 'coro_plane':[1,12,28], 'emim':emim_atoms, 'ce':range(1,37)+emim_atoms, 'emim_ring':list(reversed(emim_atoms[0:3])),
                     'etso':range(37,49), 'coro_plane':[4,7,9], 'c2':[emim_atoms[2]]}    
    emim_hs = [(2,7), (4,6), (5,5), ('6a',17), ('6b',18), ('6c',19), 
           ('7a',11), ('7b',12), ('8a',13), ('8b',14), ('8c',15)]
    for name, number in emim_hs:
        atom_groups['h{}'.format(name)] = emim_atoms[number-1]
    errors = il_coronene.add_runs(
        headers=['Surface', 'Cation', 'Anion', 'Initial', 'Diffuse'], 
        values=[['coro'], ['emim'], [anion],
               ['P2-'+str(a) for a in range(0,360,30)], 
               ['+g']],
        init_pattern='CJS2_{0}-{1}-{2}_{3}_init.com',
        opt_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_opt_*.log',
        freq_pattern='CJS2_{0}-{1}-{2}_{3}_6-311{4}-d-p-_gd3bj_freq_*.log',
        nbo_pattern='CJS6_{0}-{1}-{2}_{3}_6-311{4}-d-p-_*_pop-nbo-full-_*.log',
        atom_groups=atom_groups,
        alignto=[4,7,9], add_if_error=True, ipython_print=True)
    
    error_df = pd.concat([error_df, errors])

print 'Read Errors:'
error_df[error_df.Type!='nbo']


Read Errors:
Out[444]:
Anion Cation Diffuse Initial Surface Type File Error_Message
2 bf emim +g P-90 coro freq CJS2_coro-emim-bf_P-90_6-311+g-d-p-_gd3bj_freq... no files of format CJS2_coro-emim-bf_P-90_6-31...
10 bf emim +g O-S1 coro freq CJS2_coro-emim-bf_O-S1_6-311+g-d-p-_gd3bj_freq... no files of format CJS2_coro-emim-bf_O-S1_6-31...

In [445]:
il_coronene._df['InPlane'] = il_coronene._df.Initial.str.contains('P')
il_coronene.get_table(filters={'Anion':'cl', 'Surface':'coro'})


Out[445]:
Anion Cation Diffuse Initial Surface InPlane
ID
10 cl emim +g P-0 coro True
11 cl emim +g P-30 coro True
12 cl emim +g P-60 coro True
13 cl emim +g P-90 coro True
14 cl emim +g P-120 coro True
15 cl emim +g P-150 coro True
16 cl emim +g P-180 coro True
17 cl emim +g P-210 coro True
18 cl emim +g P-240 coro True
19 cl emim +g P-270 coro True
20 cl emim +g P-300 coro True
21 cl emim +g P-330 coro True
22 cl emim +g O-O coro False
23 cl emim +g O-S1 coro False
38 cl emim +g O-S2 coro False

In [446]:
fig, caption = il_coronene.plot_mol_images(mtype='highlight-initial',
        highlight=['emim', 'cl'], alpha=0.1, transparent=False, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        filters={'Surface':'coro', 'Anion':'cl', 'Diffuse':'+g', 'InPlane':False},
        rotations=[[0, 90, 90]], label_size=0, align_to='emim_ring', width=1000)
print caption
fig.savefig('out_of_plane_anion_positions.png', dpi=200)


(A) 22, O-O, (B) 23, O-S1, (C) 38, O-S2

In [447]:
il_coro_confs = il_coronene.copy()
non_conformers = il_coro_confs.remove_non_conformers()
#add cl back because theres a problem with it being a single atom
#and regestering it as optimised/passing frequency analysis
il_coro_confs.add_runs(
    headers=['Surface', 'Anion', 'Cation', 'Diffuse', 'Initial'], 
    values=[['none'], ['cl'], ['none'], ['g', '+g'], ['none']],
    init_pattern='*_{1}_-_init.com',
    opt_pattern='*_{1}_-_6-311{3}-d-p-_gd3bj_opt_.log',
    freq_pattern='*_{1}_-_6-311{3}-d-p-_gd3bj_freq_.log')
#similarly with coronene and a diffuse function
il_coro_confs.add_runs(
    headers=['Surface', 'Anion', 'Cation', 'Diffuse', 'Initial'], 
    values=[['coro'], ['none'], ['none'], ['+g'], ['none']],
    init_pattern='*_{0}_-_init.com',
    opt_pattern='*_{0}_-_6-311{3}-d-p-_gd3bj_opt_*.log',
    freq_pattern='*_{0}_-_6-311{3}-d-p-_gd3bj_freq_*.log')


Out[447]:

In [448]:
for anion in ['cl', 'bf', 'etso']:
    s_id, c_id, a_id = il_coro_confs.get_ids(['Surface', 'Anion', 'Cation', 'Diffuse'],
                    [['coro', 'none', 'none', '+g'], 
                     ['none', anion, 'none', '+g'], ['none', 'none', 'emim', '+g']])
    il_coro_confs.add_mol_property_subset(
        'Energy of Association (kJmol^{-1}) Uncorrected',
        'get_opt_energy', 
        kwargs={'units':'kJmol-1'}, 
        filters={'Surface':'coro', 'Diffuse':'+g',
                 'Cation':'emim', 'Anion':anion}, 
        relative_to_rows=[s_id, c_id, a_id])
    il_coro_confs.add_mol_property_subset(
        'Energy of Association (kJmol^{-1}) Corrected',
        'get_opt_energy', 
        kwargs={'units':'kJmol-1', 'zpe_correct':True}, 
        filters={'Surface':'coro', 'Diffuse':'+g',
                 'Cation':'emim', 'Anion':anion}, 
        relative_to_rows=[s_id, c_id, a_id])

for diff in ['+g', 'g']:
    ids = il_coro_confs.get_ids(
    ['Surface', 'Anion', 'Cation', 'Diffuse', 'Initial'],
    [['coro', 'none', 'none', diff, 'none'],
    ['none', 'none', 'emim', diff, 'none'],
    ['none', 'cl', 'none', diff, 'none'],
    ['none', 'bf', 'none', diff, 'none'],
    ['none', 'etso', 'none', diff, 'none']])
    df = il_coro_confs.remove_rows(ids)

In [449]:
df = il_coro_confs.get_table(
    precision=3, 
    column_index=['Energy of Association (kJmol^{-1})'])
df.sort([(' ', 'Anion'), ('Energy of Association (kJmol^{-1})','Corrected')])


Out[449]:
Energy of Association (kJmol^{-1})
Anion Cation Diffuse InPlane Initial Surface Uncorrected Corrected
ID
35 bf emim +g True P-330 coro -455.87 -442.58
31 bf emim +g True P-210 coro -451.13 -437.34
32 bf emim +g True P-240 coro -445.22 -431.83
28 bf emim +g True P-120 coro -433.93 -420.54
26 bf emim +g True P-60 coro -427.94 -415.20
24 bf emim +g True P-0 coro -428.45 -414.17
18 cl emim +g True P-240 coro -481.31 -472.45
20 cl emim +g True P-300 coro -481.25 -472.28
19 cl emim +g True P-270 coro -481.25 -472.28
21 cl emim +g True P-330 coro -481.25 -472.28
23 cl emim +g False O-S1 coro -476.88 -467.11
17 cl emim +g True P-210 coro -472.47 -463.13
16 cl emim +g True P-180 coro -472.47 -463.12
15 cl emim +g True P-150 coro -463.41 -453.41
13 cl emim +g True P-90 coro -463.41 -453.41
14 cl emim +g True P-120 coro -463.41 -453.39
11 cl emim +g True P-30 coro -457.33 -446.61
12 cl emim +g True P-60 coro -457.33 -446.61
10 cl emim +g True P-0 coro -457.33 -446.60
22 cl emim +g False O-O coro -339.93 -331.46
49 etso emim +g True P2-270 coro -485.85 -472.00
48 etso emim +g True P2-240 coro -467.69 -453.99
50 etso emim +g True P2-300 coro -466.68 -452.07
46 etso emim +g True P2-180 coro -464.76 -449.72
43 etso emim +g True P2-90 coro -455.41 -440.67
44 etso emim +g True P2-120 coro -455.15 -440.51
45 etso emim +g True P2-150 coro -455.15 -440.51

In [450]:
for anion in ['cl']:
    fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
            highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
            info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
            filters={'Surface':'coro', 'Anion':anion, 'Diffuse':'+g'},
            rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
    print caption


(A) 10, P-0, (B) 11, P-30, (C) 12, P-60, (D) 13, P-90, (E) 14, P-120, (F) 15, P-150, (G) 16, P-180, (H) 17, P-210, (I) 18, P-240, (J) 19, P-270, (K) 20, P-300, (L) 21, P-330, (M) 22, O-O, (N) 23, O-S1

In [451]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[10,11,12],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 10, P-0, (B) 11, P-30, (C) 12, P-60

In [452]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[16,17],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 16, P-180, (B) 17, P-210

In [453]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[23],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 23, O-S1

In [454]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[13,14,15],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 13, P-90, (B) 14, P-120, (C) 15, P-150

In [455]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[19,20,21],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 19, P-270, (B) 20, P-300, (C) 21, P-330

In [456]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[22],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 22, O-O

final conformers


In [457]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[10,16,23,13,19,22],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 10, P-0, (B) 16, P-180, (C) 23, O-S1, (D) 13, P-90, (E) 19, P-270, (F) 22, O-O

In [458]:
for anion in ['bf']:
    fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
            highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
            info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
            filters={'Surface':'coro', 'Anion':anion, 'Diffuse':'+g'},
            rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
    print caption


(A) 24, P-0, (B) 26, P-60, (C) 28, P-120, (D) 31, P-210, (E) 32, P-240, (F) 35, P-330

final conformers


In [459]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', 'bf'], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[24,28,31,35],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 24, P-0, (B) 28, P-120, (C) 31, P-210, (D) 35, P-330

In [460]:
for anion in ['etso']:
    fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
            highlight=['emim', anion], alpha=0.1, transparent=True, info_incl_id=True,
            info_columns=['Initial'], max_cols=2, padding=(1,1),                                   
            filters={'Surface':'coro', 'Anion':anion, 'Diffuse':'+g'},
            rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
    print caption


(A) 43, P2-90, (B) 44, P2-120, (C) 45, P2-150, (D) 46, P2-180, (E) 48, P2-240, (F) 49, P2-270, (G) 50, P2-300

In [461]:
fig, caption = il_coro_confs.plot_mol_images(mtype='highlight',
        highlight=['emim', 'etso'], alpha=0.1, transparent=True, info_incl_id=True,
        info_columns=['Initial'], max_cols=3, padding=(1,1),                                   
        rows=[43, 44, 46, 48, 49, 50],
        rotations=[[0, 0, 90], [0, 90, 90]], label_size=8, align_to='emim_ring')
print caption


(A) 43, P2-90, (B) 44, P2-120, (C) 46, P2-180, (D) 48, P2-240, (E) 49, P2-270, (F) 50, P2-300

NB: 43 is marginally different to 44 in etso4 chain orientation


In [462]:
#leaving out 22 where cl below plane
df = il_coro_confs.remove_rows(
    set(il_coro_confs.get_table().index).difference(
    [10,16,23,13,19,24,28,31,35,43,46,48,49,50]))

In [463]:
def il_coro_show(anion, letter, mtype='highlight', padding=(1,2), label_size=10):
    fig, caption = il_coro_confs.plot_mol_images(mtype=mtype, letter_prefix=letter,
            highlight=['emim', anion], alpha=0.2, transparent=False, info_incl_id=True,
            info_columns=['Initial'], max_cols=2, padding=padding,                                   
            filters={'Surface':'coro', 'Anion':anion, 'Diffuse':'+g'},
            rotations=[[0, 0, 90], [0, 90, 90]], label_size=label_size, align_to='emim_ring',
            sort_columns=['Energy of Association (kJmol^{-1}) Corrected'], width=1000)
    print caption
    return fig

fig_ecl = il_coro_show('cl', '9')
fig_ebf = il_coro_show('bf','10')
fig_eetso = il_coro_show('etso', '11', padding=(-10,2), label_size=8)


(9A) 19, P-270, (9B) 23, O-S1, (9C) 16, P-180, (9D) 13, P-90, (9E) 10, P-0
(10A) 35, P-330, (10B) 31, P-210, (10C) 28, P-120, (10D) 24, P-0
(11A) 49, P2-270, (11B) 48, P2-240, (11C) 50, P2-300, (11D) 46, P2-180, (11E) 43, P2-90

In [464]:
def il_coro_show2(anion, letter, mtype='hbond', padding=(1,2), label_size=10):
    fig, caption = il_coro_confs.plot_mol_images(mtype=mtype, letter_prefix=letter,sopt_min_energy=1,
            atom_groups=['ce', anion],
            highlight=['emim', anion], alpha=0.6, transparent=False, info_incl_id=True,
            info_columns=['Initial'], max_cols=3, padding=padding,                                   
            filters={'Surface':'coro', 'Anion':anion, 'Diffuse':'+g'},
            rotations=[[80, 0, 0]], label_size=label_size, align_to='emim_ring',
            sort_columns=['Energy of Association (kJmol^{-1}) Corrected'], width=1000)
    print caption
    return fig

fig_ecl = il_coro_show2('cl', '9')
fig_ebf = il_coro_show2('bf','10')
fig_eetso = il_coro_show2('etso', '11', padding=(1,2), label_size=10)


(9A) 19, P-270, (9B) 23, O-S1, (9C) 16, P-180, (9D) 13, P-90, (9E) 10, P-0
(10A) 35, P-330, (10B) 31, P-210, (10C) 28, P-120, (10D) 24, P-0
(11A) 49, P2-270, (11B) 48, P2-240, (11C) 50, P2-300, (11D) 46, P2-180, (11E) 43, P2-90