17 May 2012

155. Gromacs with external fftw3 and blas on debian testing

This is based on http://verahill.blogspot.com.au/2012/03/building-gromacs-with-fftw3-and-openmpi.html

Make sure your build environment is set up:
sudo apt-get install build-essential gfortran libopenmpi-dev


fftw
sudo mkdir /opt/fftw/
sudo chown ${USER} /opt/fftw
mkdir ~/tmp
cd ~/tmp
wget ftp://ftp.fftw.org/pub/fftw/fftw-3.3.2.tar.gz
tar xvf fftw-3.3.2.tar.gz
cd fftw-3.3.2/

./configure --enable-float --enable-mpi --enable-threads --with-pic --prefix=/opt/fftw/fftw-3.3.2/single
make && make install
make clean
./configure --disable-float --enable-mpi --enable-threads --with-pic --prefix=/opt/fftw/fftw-3.3.2/double

make && make install


openblas
sudo mkdir /opt/openblas
sudo chown ${USER} /opt/openblas
cd ~/tmp
wget http://nodeload.github.com/xianyi/OpenBLAS/tarball/v0.1.1
tar xvf v0.1.1
cd xianyi-OpenBLAS-e6e87a2/
wget http://www.netlib.org/lapack/lapack-3.4.1.tgz
make all BINARY=64 CC=/usr/bin/gcc FC=/usr/bin/gfortran USE_THREAD=0 INTERFACE64=1 1> make.log 2>make.err

make PREFIX=/opt/openblas install
cp lib*.*  /opt/openblas/lib

add
export LD_LIBRARY_PATH:$LD_LIBRARY_PATH:/opt/openblas/lib
to your ~/.bashrc

[for later use with nwchem and ecce, add /opt/openblas/lib to /etc/ld.so.conf and do sudo ldconfig]



gromacs


sudo mkdir /opt/gromacs
sudo chown ${USER} /opt/gromacs
cd ~/tmp
wget ftp://ftp.gromacs.org/pub/gromacs/gromacs-4.5.5.tar.gz
tar xvf gromacs-4.5.5.tar.gz
cd gromacs-4.5.5/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openmpi/lib:/opt/openblas/lib

single
export LDFLAGS="-L/opt/fftw/fftw-3.3.2/single/lib -L/opt/openblas/lib -lopenblas"
export CPPFLAGS="-I/opt/fftw/fftw-3.3.2/single/include -I/opt/openblas/include"

./configure --disable-mpi --enable-float --with-fft=fftw3 --with-external-blas --with-external-lapack --program-suffix=_sp --prefix=/opt/gromacs/gromacs-4.5.5
make -j3
make install

double
make distclean
export LDFLAGS="-L/opt/fftw/fftw-3.3.2/double/lib -L/opt/openblas/lib -lopenblas
export CPPFLAGS="-I/opt/fftw/fftw-3.3.2/double/include -I/opt/openblas/include"

./configure --disable-mpi --disable-float --with-fft=fftw3 --with-external-blas --with-external-lapack --program-suffix=_dp --prefix=/opt/gromacs/gromacs-4.5.5
make -j3
make install

single + mpi
make distclean
export LDFLAGS="-L/opt/fftw/fftw-3.3.2/single/lib -L/opt/openblas/lib -lopenblas"
export CPPFLAGS="-I/opt/fftw/fftw-3.3.2/single/include -I/opt/openblas/include"

./configure --enable-mpi --enable-float --with-fft=fftw3 --with-external-blas --with-external-lapack --program-suffix=_spmpi --prefix=/opt/gromacs/gromacs-4.5.5
make -j3
make install


double + mpi
make distclean
export LDFLAGS="-L/opt/fftw/fftw-3.3.2/double/lib -L/opt/openblas/lib -lopenblas"
export CPPFLAGS="-I/opt/fftw/fftw-3.3.2/double/include -I/opt/openblas/include"

./configure --enable-mpi --disable-float --with-fft=fftw3 --with-external-blas --with-external-lapack --program-suffix=_dpmpi --prefix=/opt/gromacs/gromacs-4.5.5
make -j3
make install



Make sure to put this in your ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openmpi/lib:/opt/openblas/lib
export PATH=$PATH:/opt/gromacs/gromacs-4.5.5/bin
 You now have four versions of each binary -- with and without mpi, with single and with double precision.


154. Vim -- weird pasting behaviour

The problem:
Get this
 when you want this?


The solution:
This is perhaps a bit superfluous as it comes from the vim wiki, but it might help someone: 

Edit your ~/.vimrc and add
set pastetoggle=<F3>
Now, before you paste, hit F3 and you can paste as usual (notice the little 'paste' after the 'insert' in the screenshot below).

My full ~/.vimrc is now
set number
set pastetoggle=
set spell
set wrap
nnoremap  :set nonumber!<
Other cool stuff:

* Line number toggle -- nnoremap <F4> :set nonumber!<CR> will map line numbering on /off to F4.

* Substituting only within selection. Go to visual mode and select the text.
Then hit  : which brings up '<,'>.  Anyway, the key is \%V which confines the substitution to the visually selected area.
:'<,'>s/\%Voldphrase/newphrase/g
* Commenting out lines -- the key is ^
: %s/^/#/g 
or
 :'<,'>s/\%V^/#/g

I previously had a bigger ~/.vimrc posted here, but now, a year later, I've reduced it to what I've posted above.
Anyway, the old one is here:

set number
filetype plugin on
filetype indent on
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set spell
set lbr
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
set grepprg=grep\ -nH\ $*
let g:tex_flavor='latex'
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
set pastetoggle=<F3>
nnoremap <F4> :set nonumber!<CR>

153. dft gridsize: ecce defaults to medium for nwchem and fine for g09

I set out to reproduce Malagoli and Brédas in Chemical Physics Letter, 2000, 327, 13-17 (Link). Essentially it's a paper on calculating reorganisational energies in a few simple organic species, such as biphenyl.

I'm a computational noob -- I'm stronger in the computer department than the computational one. The following will most likely only be useful to other newcomers like myself. Anyway...

The authors used ub3lyp/g-31g** and g03. While it may have taken a substantial amount of time in 2000, today the entire paper can be reproduced in a few hours on a simple beowulf cluster. So I set out to do just that -- partly to make sure that I understood the approach, partly to make sure that g09 and g03 gave the same results, and also importantly to make sure i can use nwchem for these calculations if I so desire. I'm getting to the point where nwchem is almost as fast as gaussian for some calculations (cosmo excepted...) and I much prefer the nwchem syntax and python support.

For biphenyl, g09 gave (in Hartree)
Neutral, ground state:     -463.3219416650 (geometry opt)
Cation, neutral geometry:-463.0352702000 (single point calc)
Cation, cation geometry:  -463.0422747850 (geometry opt)
Neutral, cation geometry: -463.3157130000 (single point calc)

That works out to a total energy of ca 0.36 eV -- same as in the paper

while nwchem gave
Neutral, ground state:      -463.3219454524 (geometry opt)
Cation, neutral geometry: -459.0525026266 (single point calc)
Cation, cation geometry:  -463.0422952505 (geometry opt)
Neutral, cation geometry: -459.0556262940 (single point calc)

The order of the stabilities don't even match!

Recalculating the energies by adding

dft
    grid fine
    .....
end

gave the 'correct' results:
Cation, neutral geometry: -463.0353366421
Neutral, cation geometry: -463.3157251871

which gives about 0.36 eV

Here's what puzzles me a bit: you definitely need to add 'fine' in nwchem, and that's what g09 defaults to. But the energies reported for the optimised structures (cation, cation geometry and neutral, ground state) must have been calculated using a fine grid too or one would presume that they'd be off too. Repeating this with the other structures in the paper gives the same result.

Anyway, if you get weird and wacky energies from you single point calcs maybe you should make sure you've specified the dft grid size consistently.