MacOS Mojave for Computational Materials Science in 2019

May 3, 2019

Where does two years go? Yet another update of previous entries for setting up an Apple computer for scientific computing. It is not an absolute guide, but simply one way to get going.  I started with a clean install of Mac OS 10.14.4 (Mojave) on a MacBook in May 2019.

Awaken UNIX

The first step is to install the command line tools. Open a Terminal and type make which triggers the system to install command line tools module (basic UNIX commands including a gcc compiler). Be sure to set up your bash_profile, ssh config, and vimrc files to make working faster and more comfortable.

Later we will also need some compiler files that are no longer installed by default, so also run:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Basics

My base applications include: (standard office) Dropbox, Slack, MS Office (Imperial link), Mactex, Texmaker, Zotero; (scientific computing) latest gcc/gfortraniTerm, Textmate, XQuartz, Atom, Cyberduck, GitHub client(materials modelling) VESTA, Avogadro. For video and image editing ffmpeg and imagemagick are essential.

  • Python

Python package and environment maintenance can cause headaches, so I now use Conda for Mac as standard.

  • Fortran and C

It is possible to survive using gnu compilers and freely available maths libraries, but Intel Fortran and MKL tend to be faster and better tested (easier to compile). For non-commericial purposes Intel Composer is free for OS X. The C and Fortran packages install in a few clicks, but be sure source the variables in your .bash_profile:
source /opt/intel/mkl/bin/mklvars.sh intel64
source /opt/intel/bin/compilervars.sh intel64

The outcome:
% ifort --version
ifort (IFORT) 19.0.3.199

  • Openmpi

To enable parallelism, I downloaded the latest source code of openmpi (4.0.1).
./configure -prefix=/usr/local/openmpi-4.0.1 CC=icc CXX=icpc FC=ifort F77=ifort FCFLAGS='-O1' CFLAGS='-O1' CXXFLAGS='-O1' --disable-dlopen
make
sudo make install

be patient… it can easily take 20 minutes. Finally add to your .bash_profile:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/openmpi-4.0.1/lib/
export PATH=./:/usr/local/openmpi-4.0.1/bin:$PATH
export OMP_NUM_THREADS=1

The outcome:
% mpif90 --version
ifort (IFORT) 19.0.3

  • Phonopy

I use this open-source lattice-dynamics package a lot. The installation used to be multi-step, but Conda makes life easier:

conda install -c conda-forge phonopy h5py

To run: phonopy

  • VASP

I use a range of electronic structure packages, but VASP is the old reliable. I downloaded the latest version (5.4.4), which has streamlined the install process. Enter the main folder and
cp ./arch/makefile.include.linux_intel ./makefile.include

The file needs to be modified to point to the correct compilers (I used icc, icpc, and mpifort). We will also remove DscaLAPACK from the pre-compiler options and set SCALAPACK =  . There is one bug to fix before you type make: in ./src/lib/getshmem.c add #define SHM_NORESERVE 010000 to the end of the include statements.

make

The outcome:
% mpirun -np 4 ../vasp_std
running on 4 total cores
distrk: each k-point on 4 cores, 1 groups
distr: one band on 1 cores, 4 groups
using from now: INCAR
vasp.5.4.4

  • ASE

The atomistic simulation environment is a useful set of Python tools and modules. It now installs, including the gui, in one command:

pip install --upgrade --user ase

The outcome:ase-gui

ASE

I will update with more codes and tools as I find time, and always happy to receive suggestions.