04 May 2012

135. Oniom in gaussian -- with a little bit of help from gromacs and openbabel

Example -- I want to do explicit solvent modelling of methanol in water. This is obviously an articifical approach, but generally applicable.

This is a rough approach to doing oniom calculations using gaussian 09

1. Pre-optimisation
Draw methanol and set up a simple calc using e.g. ecce to pre-optimise the structure with e.g. an implicit solvent model. Here's g03.g03in:

  1 %nprocshared=4
  2 %Chk=g09_oniom.chk
  3 #P rb3lyp/GEN 5D Opt=()  Freq=()  Punch=(MO) Pop=() scrf=(pcm,solvent=water)
  4 
  5 g09_oniom
  6 
  7 0 1 ! charge and multiplicity
  8  C     0.00000     0.00000     0.00000
  9  H     -0.675500     -0.675500     0.675500
 10  H     0.675500     -0.675500     -0.675500
 11  H     -0.675500     0.675500     -0.675500
 12  O     0.866025     0.866025     0.866025
 13  H     1.51843     0.213620     1.51843
 14 
 15  H  0
 16  S   3  1.00
 17       18.73113700      0.03349500
 18        2.82539400      0.23472700
 19        0.64012200      0.81375700
 20  S   1  1.00
 21        0.16127800      1.00000000
 22  ****
 23  O  0
 24  S   6  1.00
 25     5484.67170000      0.00183100
 26      825.23495000      0.01395000
 27      188.04696000      0.06844500
 28       52.96450000      0.23271400
 29       16.89757000      0.47019300
 30        5.79963500      0.35852100
 31  SP  3  1.00
 32       15.53961600     -0.11077800      0.07087400
 33        3.59993400     -0.14802600      0.33975300
 34        1.01376200      1.13076700      0.72715900
 35  SP  1  1.00
 36        0.27000600      1.00000000      1.00000000
 37  SP  1  1.00
 38        0.08450000      1.00000000      1.00000000
 39  D   1  1.00
 40        0.80000000      1.00000000
 41  ****
 42  C  0
 43  S   6  1.00
 44     3047.52490000      0.00183500
 45      457.36951000      0.01403700
 46      103.94869000      0.06884300
 47       29.21015500      0.23218400
 48        9.28666300      0.46794100
 49        3.16392700      0.36231200
 50  SP  3  1.00
 51        7.86827200     -0.11933200      0.06899900
 52        1.88128800     -0.16085400      0.31642400
 53        0.54424900      1.14345600      0.74430800
 54  SP  1  1.00
 55        0.16871400      1.00000000      1.00000000
 56  SP  1  1.00
 57        0.04380000      1.00000000      1.00000000
 58  D   1  1.00
 59        0.80000000      1.00000000
 60  ****

2. Solvation using gromacs
Take the output, g03.g03out, and use babel to export the optimised structure
babel -ig09 g03.g03out -oxyz molecule.xyz

The next few steps require gromacs:
editconf -f molecule.xyz -o molecule.gro -box 2 2 2
genbox -cp molecule.gro -cs spc216.gro -o solvated.gro
babel -igro solvated.gro -oxyz solvated.xyz

Because I'm lazy, I then add an extra column for high/low, chop off the first few lines, and add a column with zeros...because that works. Not sure what that's actually for. Molecule?

tail -n +3 solvated.xyz | gawk '{print $1,"0",$2,$3,$4,"Low"}'>oniom.xyz

Edit oniom.xyz by hand and change the lines with "Low" to "High" (or just H) for the atoms in the methanol molecule.

C 0 10.14000 10.34000 10.00000 High
H 0 9.65000 10.75000 10.90000 High
H 0 9.65000 10.75000 9.10000 High
H 0 11.19000 10.65000 10.00000 High
O 0 10.14000 8.91000 10.00000 High
H 0 9.22000 8.60000 10.00000 High
O 0 5.69000 12.75000 11.65000 Low
H 0 4.76000 12.68000 11.28000 Low
H 0 5.80000 13.64000 12.09000 Low
O 0 15.55000 15.11000 7.03000 Low
[..]
cp oniom.xyz oniom.in

Edit oniom.in and put in your gaussian instructions, e.g.:

%chk=methanol_explicit.chk
%mem=500MB
%nprocshared=3
#Oniom(rb3lyp/6-31+g*:uff) maxdisk=6000MB opt=()

Methanol in explicit water

0 1 0 1 0 1
C 0 10.14000 10.34000 10.00000 High
[...]
So, you specify Oniom(high level:low level) -- here dft and MM (via uff -- amber and charmm are available too -- but then you must carefully define the atom types. See here).

You don't always, but sometimes, have to specify the spin/multiplicity of the high and low level systems as well as the total spin and multiplicity. Anyway, you can: First the overall, the the high, then the low level. E.g. we have a chromium compound with an unpaired spin of 1 (multiplicity=2) and a charge of +3, and have a MM shell with five sodium atoms and a multiplicity of 1 (spin=0). The total charge is 8 and total multiplicity is 2. The line would read 8 2 3 2 0 1.

That's it! You're ready to roll.

The run takes about 3 minutes.

That's it!







134. Introducing a CA certificate in debian

So, for some reason you've been issued a CA certificate. Now what?

I've presumed that you've somehow downloaded both the root certificate (cacert.crt) and your personal certificate (usercert.pem). You'll need both.


Openssl

Convert to .p12
openssl pkcs12 -export -in usercert.pem -inkey userkey.pem -out usercert.p12

Verify
You can verify your issued certificate, e.g.
openssl verify  -CAfile ~/Downloads/cacert.crt ~/.globus/usercert.pem


Browsers:

Iceweasel/Firefox 
Go to Edit, Preferences, Advanced, Encryption: View certificates. Click import under Your Certificates and select your usercert.p12 (see above for conversion).  Got to servers, import cacert.crt.

Make sure that your cert authority shows up under the authority tab (otherwise try importing cacert.crt). Highlight the relevant authority, and click on edit trust: select the relevant fields of identification (e.g. website and/or email).


Chrome/Chromium
Click on the spanner icon, go to Settings, Under the bonnet, Manage Certificates and select Import under Your Certificates. Click on server, import the cacert.crt. Approve the certificate authority for the intended uses of the certificate. If you did it already in firefox it may have carried over.


Email:

Evolution
First go to Edit, Preferences, scroll down to Certificates and import your certificate and, under authorities, import the root certificate (cacert.crt).

Under the Authorities tab, select the issuing authority, click on edit and set the trust level (probably all)


Next, go to Edit, Preferences, Mail Accounts, Select an account and click on Edit. Select the Security tab


Repeat this for all accounts you want to use this certificate with.

Test it:


Send it. Receive it.

If all is correct, this is what greets you

If you don't add the certificate authority as being trusted -- and this will be the case for some of your recipients, this is what you see. Signature no good.


Thunderbird
Go to Edit, Account Settings... and under each account click on Security, then on View Certificates -- import your certificate and the issuing authority's certificate here, or you won't be able to Select the certificates under Digital Signing and Encryption.

Also, under View Certificates, highlight the certificate authority and select Edit Trust -- click on Edit CA trust, select website, mail etc., then select I do trust...
I presume that you do trust the authority or this is an exercise in futility.
You need to do this for ALL accounts that you intend to use, or you'll run into trust issues.

You can select/de-select signing when composing using the S/MIME menu.

If all goes well, users which also have the same certificate authority listed as trusted (probably not the case, but whatever) will see a sealed envelope (this message has been signed by pgp as well as S/MIME:

03 May 2012

133. Compiling Openbabel 2.3.1 and CMake on ROCKS/centos

Open Babel is a convenient tool for converting between chemistry-related file formats. Sadly, it's not included in ROCKS 5.4.3 from what I can see and I could only install a severely outdated rpm package which doesn't support gaussian 09 and nwchem well.

The easiest way to compile openbabel is by using cmake.

Cmake:
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
tar -xvf cmake-2.8.8.tar.gz
cd cmake-2.8.8.8/
./configure --prefix=/home/me/.cmake
make
make install

Add the following to your ~/.bashrc and source it:
export PATH=$PATH:/home/me/.cmake/bin

Note: this works in Scientific Linux (Boron) 5.4 as well

Openbabel
wget http://downloads.sourceforge.net/project/openbabel/openbabel/2.3.1/openbabel-2.3.1.tar.gz?r=http%3A%2F%2Fopenbabel.org%2Fwiki%2FGet_Open_Babel&ts=1336048328&use_mirror=aarnet
tar -xvf openbabel-2.3.1.tar.gz
cd openbabel-2.3.1/
cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/me/.babel
make
make install

Add the following to your ~/.bashrc and source it:
export PATH=$PATH:/home/me/.babel/bin

Note: this works in Scientific Linux (Boron) 5.4 as well

Do
babel -L formats 
to get a list of formats.