chemistry, crystallography, platon, programs, Uncategorized

Platon on macOS Sierra

A while ago, I wrote a post on installing Platon on a Mac. I have just reinstalled Platon on my MacBook Pro, running macOS Sierra, and it works just fine. Check out my earlier post for a more in-depth run down of how to install Platon, but, in brief, the process is this:

  1. Download a copy of XQuartz. (I did this using Homebrew, using ‘brew install Caskroom/cask/xquartz’).
  2. Install gfortran, which is included in gcc. (Again, using Homebrew this is ‘brew install gcc’).
  3. Download the platon.f.gz and xvrdr.c.gz files and (g)unzip them if Safari hasn’t already done so.
  4. In the terminal, go to the folder containing the two previously mentioned files (probably ~/Downloads).
  5. Then, type ‘gfortran -o platon platon.f xdrvr.c -I/opt/X11/include -L/opt/X11/lib -lX11’. Hopefully, this should do its thing and produce an executable file named ‘Platon’.
  6. Move the file somewhere useful, such as /opt.
  7. To make Platon run from anywhere, you have two options: add the folder you have just placed the Platon executable in to the path or make an alias to the executable. To do the first, open up your shell profile or create (i.e., vi .bash_profile or you can open a copy in Textedit, making sure that its in plain text mode, the filename is preceded by a point (.), and the file is saved to your home (i.e., /Users/[your_username])) a profile file (I am using bash) and add ‘PATH=’$PATH:/opt’. To do the second, open up your shell profile and write alias platon=”~/Users/[your_username]/[location_of_platon]”.
  8. Then, quit and reopen terminal and type ‘Platon’ and the program should run.
latex, thesis writing, writing

LaTeX commands for chemistry

LaTeX is great for writing theses, although collaboration with other authors on LaTeX files can be a pain.* Below I have listed a few LaTeX commands that I used when I was writing up my thesis. They are very basic, but they are useful because they save some typing and ensure that the same formatting is used each time. In particular, the \moles command and the \micro command for formatting moles and microanalysis** in standard notation, respectively. There are many more that I could write about, but I am short of time at the moment. Hopefully, at some point, I will update with a more substantial (and useful) list.

\newcommand{\celsius}{$^{\circ}$C} %a degrees Celcius symbol (to avoid use of superscript 'o', the bane of my life
\newcommand{\gs}[4]{$#1^#2_#3(#4)$} %Etter's graph-set notation, for hydrogen-bonded systems
\newcommand*{\moles}[2]{#1 $\times$ 10$^{#2}$ mol} formats number of moles in standard form
\newcommand*{\Moles}[2]{#1 $\times$ 10$^{#2}$ \textsc{m}} %formats molar quantities in standard form
\newcommand{\Molar}{\textsc{m}} %formats a small-caps M
\newcommand{\micro}[7]{\textbf{Microanalysis:} Calculated for \textbf{\ce{#1}} (\%) C, #2; H, #3; N, #4; Found (\%) C, #5; H, #6; N, #7.} %formatting of microanalysis results
\newcommand{\melt}[2]{m.p. #1--#2 \celsius} %melting point ranges

\newcommand{\yield}[2]{\textbf{Yield:} #1, #2 \%} %yields formatted as Yield: quantity (write number and quantity symbol, e.g., \yield{2 g}{94}

Below is the output of a few of these commands.

Example of the pdfLaTeX output

These were output by using the commands at the head of the page according to the following usage:

...forming a hydrogen-bonded \gs{R}{1}{2}{5} ring.\\

A 10 \Molar{} sodium hydroxide solution.\\

An aqueous solution of \textbf{1} (\moles{1.1}{-5}).\\

\micro{C14H30}{14}{14}{14}{14}{14}{14} \yield{2 g}{94}, \melt{100}{103}

I hope you find them useful.

*However, nowadays, many collaborative, cloud-based LaTeX services are available. e.g., Overleaf.

**Requires the mhchem package to format chemical formulae.

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

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

chemistry, Computational Chemistry, pymol

Pymol for computational chemistry.

A picture is worth a thousand words.

So goes the saying, and it is true.

The pymol wiki has lots of ideas for styling atoms. Below are instructions for styling atoms, as in the image shown below, which I think produces an image that is particularly clear (and pretty) and suited to publication in journal articles.

hide everything
show sticks
show spheres
set stick_radius, .07
set sphere_scale, .18
set sphere_scale, .13, elem H
set bg_rgb=[1, 1, 1]
set stick_quality, 50
set sphere_quality, 4
color gray85, elem C
color red, elem O
color slate, elem N
color gray98, elem H
set stick_color, black
set ray_trace_mode, 1
set ray_texture, 2
set antialias, 3
set ambient, 0.5
set spec_count, 5
set shininess, 50
set specular, 1
set reflect, .1
set dash_gap, 0
set dash_color, black
set dash_gap, .15
set dash_length, .05
set dash_round_ends, 0
set dash_radius, .05

This can be copied directly into the pymol command line, followed by enter. If you have non-bonded atoms such as a central metal with attached ligands, for which pymol sometimes does not detect, you can use the measurement tool and then remove the labels and change dash_radius to a very small number; alternatively, use the bond command.

An image of xantphos rendered in PyMol
An image of xantphos rendered in PyMol and in stereo. Cross your eyes to see a three-dimensional image.

Another nice effect is to change the display types of certain atoms. For example, I have highlighted the  coordination of the oxygen atoms in the crown ether molecules by hiding the spheres:

 hide spheres, elem C

Also, shown below is a GIF animation an animation of an optimization of the crown ether complex.






chemistry, crystallography, platon, programs

Platon on Mac OS X Yosemite (10.10)

UPDATE (16 March, 2017): This also works on macOS Sierra (10.12.3).
UPDATE: This also works on Mac OS X El Capitan (10.11.5).

One of the most popular pages here (well, there is little else) is the page about Platon for Mac OS X.

I mainly use a computer running Ubuntu for crystallography at work so I haven’t had to compile Platon, the essential crystallographic program, for my Mac. I have seen that some people have had problems compiling the program (remember you do need Xquartz, and a compiler for Fortran and C). I compiled platon, but I also had some difficulty doing so, although I have compiled previous versions without a problem. So, if you have a problem compiling using the standard instructions on the platon website, try this, and you should be able to compile it, without sudo, using:

gfortran -o platon platon.f xdrvr.c -I/opt/X11/include -L/opt/X11/lib -lX11

If you don’t use -I/opt/X11/include then it won’t find the X11 libraries that are above /opt/X11/lib.

Afterwards, copy it into somewhere like sudo cp platon /opt/platon2015 (check that it has run privileges (i.e., ls -g) and, if not, run chmod u+x platon). You can then add the folder that contains the executable to your path and add an alias if in you profile script (.bashrc/.bash_profile etc.) e.g., alias platon="/opt/platon2015/platon“.

You can then run it with, for example, on a shelx res file:

platon file.res

References: A.L.Spek, Acta Cryst. 2009, D65, 148-155.