Installation

The diagonalisation component of Hammer has been tested extensively on ubuntu, slackware and SLES Linux systems. It should in principle work on any operating system which has the required packages installed. Here we give some quick installation instructions for those running ubuntu (either 14.04 or 14.10), followed by more detailed instructions in case something goes wrong, or if you are using a different OS. There is also a docker image provided which should work on Linux, Mac OS X and windows. This is probably the best option for those running windows. See section below for details on how to use this image.

Quick install instructions (ubuntu only)

There are pacakges for PETSc, SLEPc and their python wrappers in the standard ubuntu repositories. However these are not built with support for complex numbers so we will use some custom versions. Use the following commands to add the custom ppa repository and install these packages.:

sudo apt-add-repository ppa:niall-moran/hammer
sudo apt-get update
sudo apt-get install python-petsc4py python-slepc4py python-cython

There are some additional python pacakges and dependencies which need to be installed. The easiest was to install these is with the pip python package manager. The following commands will install pip and some additional dependencies which we will need later.:

sudo apt-get install python-pip python-dev libhdf5-dev libopenmpi-dev liblapack-dev libblas-dev gfortran build-essential

Now we download the source by cloning the git repository.:

sudo apt-get install git
git clone https://bitbucket.org/nmoran/hammer.git

You should how have a folder called hammer. The diagonalisation component is in the hammer/Hammer folder. Change to this folder and install the remaining dependencies using pip

cd hammer/Hammer
cat requirements.txt | xargs sudo pip install

Now we are ready to build and install our code. From the hammer folder run.

sudo python setup_f2py.py install
sudo python setup.py install

The executable scripts will get installed to your system path and you should now be able to try out the examples given in the tutorials.

You can run tests to ensure everything is working with:

python setup.py test

Docker image

A docker image for hammer is available at https://hub.docker.com/r/nmoran/hammer/. For instructions about installing docker, see https://docs.docker.com/. Once docker is installed, you can run things directly in the docker container. For example to run the tests use the command

docker run -w /usr/local/hammer/Hammer nmoran/hammer  python setup.py test

This first time this is run, it will download the image, so will take a little time. It will then create a new container from the image, run the tests and then close the image. To use the image interactively one can use

docker run -it nmoran/hammer bash

You will be able to run all the utilities, however any files that are modified or created will not persist when the container is closed (achieved by typing exit). To work with files on the disk and keep changes, it is recommended that one mount a directory as a volume on the container. For example to create a test folder, mount it at /data, run a small calculation in the container and exit, one would enter

mkdir test
docker run -v test:/data -w /data nmoran/hammer Diagonaise.py

After running, the output files should appear in the test folder.

Manually installing PETSc, SLEPc, petsc4py and slepc4py

Installing PETSc and SLEPc

PETSc

  • Download PETSc from http://www.mcs.anl.gov/petsc/download/index.html

  • Extract and set environment variables PETSC_DIR and PETSC_ARCH to the petsc directory and a string to identify the current petsc build. For example:

    export PETSC_DIR=`pwd`
    export PETSC_ARCH=linux-gnu-cxx-complex
    
  • Configure with:

    ./configure --with-clanguage=C++ --with-cxx-support=1 --with-gcov=1 --with-scalar-type=complex --with-shared-libraries=1 --with-debugging=0 --with-scientific-python=1
    

If support for complex numbers is not required set the scalar type to real instead. If there are problems finding mpi, lapack or blas, make sure these are installed and specify paths. See ./configure –help for further help and options. - Once the configure completes successfully. Start building with make

SLEPc

  • Download SLEPc from http://www.grycap.upv.es/slepc/

  • Extract and run configure wth ./configure. This should find your PETSc build via PETSC_DIR and PETSC_ARCH variables set during the PETSc install.

  • Set SLEPC_DIR to the slepc directory

    export SLEPC_DIR=`pwd`
    

petsc4py

You will need to have numpy installed and also the PETSc environment variables set. - Once this has finished install using

sudo python setup.py install

If you do not have permissions to install to the system directory you can create a local python environment with virtualenv (the –user install from petsc4py appears to give problems). To do this install virtualenv

pip install --user virtualenv

Setup new python environment:

virtualenv --system-site-packages ENV

Activate this:

source ENV/bin/activate

Then build and install:

python setup.py build
python setup.py install

slepc4py

  • Download slepc4py from https://bitbucket.org/slepc/slepc4py/

  • Extract and build using the same method as for petsc4py above.

  • Other python modules mpi4py, numpy, scipy and cython may already be installed or can be installed using pip with commands.

    pip install mpi4py
    pip install numpy
    pip install scipy
    pip install cython
    

Building with intel compilers

The intel compilers can give a performance boost. To compile the these use the following command instead.

sudo python setup_f2py.py build --fcompiler=intelem install