openbabel oneliners

openBabel File Conversion

What do you do if you have multiple files in a folder, and you want to convert them all to a different filetype and retain the filenames? Use openBabel, of course!

Here is a very simple one-liner to convert multiple files from one format to another while retaining the original filename.

 babel -ig09 *.log -omol -m 

In this example, a Gaussian output file is converted into a molfile.  For XYZ to pdb the change would be:

 babel -ixyz *.xyz -opdb -m 


Making GIF animations on a Mac.

On a Mac, you can make GIF animations without downloading any additional software. GIFs are useful in presentations or on the web when you need a small file size or low bandwidth option.

To make a GIF, you will need the image frames that you want to animate and Preview, which can be found in the Applications folder. I have made a quick video showing how to do this.

Creating GIFs using Preview on Mac from Benjamin M Ridgway on Vimeo.

However, please note that this will make a GIF that will animate only once. To make your GIF loop endlessly, you can use the image editor GIMP.

Computational Chemistry

Driver calculations in Orca

In this example, we will set up and run a driver calculation in Orca. In this type of calculation, one variable (an angle or bond length) is varied while the energy is minimised. This type of calculation can be useful for exploring reaction pathways. In this example, we will use the dissociation of a carbonyl ligand from a rhodium-phosphine complex. These types of complexes are common in industrial chemistry for a variety of catalytic reactions; however, typically more complicated phosphine or phosphite ligands, either mono- or bidentate, are used. For computational simplicity, I am using phosphine (PH3) as the ligand.

Setting up the calculation

For simplicity, we will use a split valence basis on all atoms except rhodium. On rhodium, we will use a Stuttgart-Dresden ECP with the def2-tzvp basis set modelling the valence electrons. The calculation uses BP86 and Grimme’s D3 dispersion correction with Becke-Johnson damping. Below is the input for this driver calculation.

! noautostart slowconv tightscf d3bj opt bp86 pal2 def2-svp def2-svp/j ri ecp{def2-sd=[Rh], def2-tzvp, def2-tzvp/j}
%geom scan
B 0 11 = 1.909, 4.0, 8
*xyz 0 1

Concerning the topic of this post, i.e., the driver calculation, the most important part of this input file is the part describing the bond length that we are ‘driving’. In this example, the Rh-C bond length. In the XYZ coordinates, Rh and C (of carbonyl) are the first and twelfth atoms, respectively. Orca numbers atoms from 0 (zero) upwards, so it is important to remember that the nth numbered atom is the n-1th atom in Orca. Here, the command ‘B 0 11 = 1.909, 4.0, 8’ indicates that a bond (B) is changed from 1.909 to 4 Å in eight steps, i.e., 2.6 Å per step.

In addition, the ‘simple’ command line contains several additional elements. The first command ‘noautostart’ indicates that we do not want to read from an existing wavefunction file, should it exist. ‘slowconv’ and ‘tightscf’ are commands that control the SCF calculation, and these are useful for transition metal complexes. The command ‘d3bj’ indicates that we want to model dispersion interactions using Grimme’s D3 correction with Becke-Johnson damping, and ‘opt’ indicates that this is an optimisation, that is, optimising everything other than the coordinate being driven. ‘pal2’ indicates that this is a parallel calculation, running on two openmpi processes. ‘def2-svp def2-svp/j ri ecp{def2-sd=[Rh], def2-tzvp, def2-tzvp/j}’ are commands related to the basis sets on the atoms in this system. A split basis (def2-svp) is being used on all atoms; however, on Rhodium, an electron core potential is being used to model the core electrons, and a triple-zeta basis is used for the valence electrons. In addition, the RI approximation is used to speed up the calculations, and this si the reason for the basis sets appended with ‘/j’, i.e., these are the density fitting basis sets.

About the calculation

The GIF below shows the eight steps of the relaxed driver calculation; for fun, it is a stereogram. The Rh-C bond was lengthened in steps of about 0.3 A. At each step, an optimization was carried out, but the Rh-C distance was kept constant.


As the carbonyl ligand moves away from the rhodium atom, the Rh-C-O bond angle changes. Starting off linear at 177.2 degrees; it becomes bent with an angle of about 109.

Charting the Rh-C-O bond angle versus the Rh-C bond length.

Of course, after a certain point there is no interaction between Rh and the C of the carbonyl ligand; this is given by the dissociation limit of the complex. The Rh-C-O tilt angle shows how the bonding interaction changes from a ligand sigma bonded with π-backbonding to a free ligand, and this is nicely shown by the shortening of the C-O bond length from 1.16 A to 1.14 A as the carbonyl ligand dissociates.

Analysing the data

Energy profile for the driver calculation.

The results of the calculation are shown to the left. As you can see, the CO-metal bond elongates, followed by a tilting of CO and its slow drift away from the complex. The energy of the complex increases until it reaches the dissociation limit; here, the energy levels off to a constant value.

In fact, we can fit the energy profile to the Morse potential and get an idea of the dissociation limit and the equilibrium distance for the Rh–C bond length.

The Morse equation is y = D \times(1-exp(-a\times (x-e)))^2 where D is the dissociation limit, a is the well depth, and e is the equilibrium distance.

Fitting of a Morse curve to the driver data.
Fitting of a Morse curve to the driver data.

Fitting this equation to the data, The morse curve gives values for D, a, and e of 26.92 kcal/mol, 2.81 kcal/mol, and 1.92 A, respectively.

chemistry, writing

Common mistakes in science writing (and their solutions)

This is a very basic list, but the aim is to help prevent those small errors that are easy to make and a pain to fix (usually because there are many of them).

  • Negative numbers
    Use the negative symbol or an ‘en dash’ but not a hyphen.
  • Degrees Celsius
    Use the degree symbol from the ‘Symbol’ font, followed by a capital letter C in the typeface you are using. For example, °C. Do not use a superscripted o or 0.
  • Units and their quantities
    Make sure there is a space between the number and the unit, e.g., 3 g, 4 kj/mol, and 6 h, but 57%.
  • Consistency with units
    The symbol for liter is L; for milliliter, it is ml or mL. Make sure that you are consistent and do not mix up ml and mL.
  • a and an
    If the following word begins with a vowel or vowel sound (read it out loud), use ‘an’; if it begins with a consonant, use ‘a’.
  • Number ranges
    Separate ranges of numbers with an en dash, for example, in a list of references: 4–11 or 4,7,11–19. Remember, do not use a dash-separator if only two numbers are consecutive.

You can download a PDF of this file, here: Common mistakes


A photo a day from BA: Parroquia Inmaculada Concepcion

A photo a day had to take a (rather long) break recently, due various recent developments, and today’s post is rather short.

Today’s photo is of the Parroquia Inmaculada Concepcion: the church of the immaculate conception, in Belgrano. The church is located at the intersection of Juramento and Cabildo. On this day, there was a artisan’s market in the plaza in front of the church.

A photo a day

A photo a day from BA: Facultad de Medicina and Plaza Houssay.

 A series of photos from BA. Today’s photo is of the University of Buenos Aires Faculty of Medicine, which is located in the neighborhood of Recoleta (or Barrio Norte, depending on who you ask). It is the centre for medical studies in UBA and all around it are shops selling medical textbooks, instruments and clothing. At its side is the Hospital de Clinicas, a public hospital. In front (in fact, this photo shows the back of the building) of the faculty building is Plaza Houssay, currently undergoing renovation. In the centre of the plaza you can see the small gothic church of the parish of San Lucas. The plaza is named after Bernard Houssay, an Argentine physiologist, who won the 1947 Nobel Prize in Physiology (jointly with Ferdinand and Gerty Corri). As such, he was the first Argentine Nobel Prize winner. On the other side of Cordoba street is the Faculty of Economics, housed in the original Faculty of Medicine.

chemistry, Computational Chemistry

Checking on geometry optimisations in Gaussian.

This is a useful oneliner that uses egrep to check on the status of a geometry optimisation. It is taken from Exploring chemistry with electronic structure methods: a guide to using Gaussian*, a very useful, albeit old, book about Gaussian 98. I usually copy the code below into a bash script, change its mode with chmod** and then place it in my personal script folder (which is indicated in my path). You could alternatively just put the egrep line as an alias in your shell profile.

egrep 'out of| SCF Don|Converged| NO |YES|exceeded' $file | grep -v '\\\\'

*Foresman, James B., and Æleen Frisch. Exploring chemistry with electronic structure methods: a guide to using Gaussian. Gaussian, 1993.

** chmod u+x