This is an old revision of the document!
How to Compile and Install CP2K with PLUMED
The current svn version of cp2k is already prepared for compilation with PLUMED and contains all the relevant interface code (see www.cp2k.org)
A modified version of PLUMED as well as some test input files can be found at: https://drive.google.com/folderview?id=0B2fydPxv8acJY0Noc3ZZVlR0ek0&usp=sharing
The files metadyn.h
and metadyn.c
are modified from the official plumed-1.3 release in order to provide additional routines called by cp2k, and a plumedpatch_cp2k
script is added for easy installation.
These files are also provided separately and can simply be copied into an existing plumed distribution.
The following instructions describe how to install/compile PLUMED with cp2k.
get the latest version (newer than Sept. 2014) of cp2k from the svn repository (the is prepared for plumed)
svn checkout svn://svn.code.sf.net/p/cp2k/code/trunk cp2k-code
unpack the modified plumed-1.3 archive somewhere (the metadyn.c/.h are already updated in that archive)
tar xjfv plumed-1.3.tar.bz2
set the environment variable $plumedir to the root directory of the plumed distribution
export plumedir=/users/xyz/plumed-1.3
change into the cp2k root directory and symlink the plumed/patches/plumedpatch_cp2k.sh there
cd /users/xyz/cp2k-code/cp2k ln -s $plumedir/patches/plumedpatch_cp2k.sh ./
run the plumedpatch_cp2k script with parameter -patch, it should create a subdirectory src-plumed containing a number of cpp files and a plumed.inc
./plumedpatch_cp2k.sh -patch
Change into the src-plumed subdirectory; in the file makefile_for_plumed
change the parameter OBJDIR
to the directory where all the cp2k objects will be built. It should be something like ../obj/Linux-x86-64-gfortran/popt. The directory has to exist, even before building cp2k, so you might have to create it. You may also have to change other makefile settings depending on your local set-up.
cd src-plumed/ make -f makefile_for_cp2k
Make sure the following lines are present in your ARCH
file:
PLUMEDDIR = $(PWD)/../src-plumed PLUMEDINC = $(PLUMEDDIR)/plumed.inc include $(PLUMEDINC) EXTERNAL_OBJECTS=$(OBJ_PLUMED)
and -D__PLUMED_CP2K
is specified among the DFLAGS
.
Compile cp2k [only cp2k, not the other binaries of the package] as usual on your system
make -j ARCH=Linux-x86-64-gfortran-plumed VERSION=popt cp2k
test (e.g. using the provided testinput) and run
To use plumed, insert the following in the FREE_ENERGY section of a cp2k input file:
&METADYN USE_PLUMED .TRUE. PLUMED_INPUT_FILE ./filename.inp &END METADYN
Every time you want to rebuild cp2k you will have to go through the two-step procedure of making the plumed objects first, and then building cp2k. When running the regtest scripts, be sure to use the option -nobuild, to avoid deleting the plumed objects before running the tests.