Updated 2022-02-14
Run CP2K on the Cluster¶
Overview¶
- CP2K is a quantum chemistry and solid state physics software package that can perform atomistic simulations of solid state, liquid, molecular, periodic, material, crystal, and biological systems.
- This guide will cover how to run CP2K with a batch script on the cluster.
- Here is a link to CP2K's homepage that can provide more information.
Tips¶
- Here is a link to the manual provided by CP2K to give more information on different functions.
- You can find more exercises and examples other than the one covered in this guide here.
Walkthrough: Run CP2K on the Cluster¶
- In this example, we will illustrate how to relax the structure of a system (without changing the cell dimensions) using the relaxation of a water molecule as an example.
- This example is directly taken from an exercise posted on CP2K's website. You can visit the link for more information about what each section in the input file means.
- Some of the files needed for this example are stored inside the cp2k module. You can copy those files to your current directory with the following command after first loading the cp2k module:
module load cp2k
cp $(dirname $(which cp2k.popt))/../share/data/{BASIS_SET,POTENTIAL} .
- Create a basic
H2O.inp
input file with this content:
&GLOBAL
PROJECT H2O
RUN_TYPE GEO_OPT
PRINT_LEVEL LOW
&END GLOBAL
&FORCE_EVAL
METHOD QS
&SUBSYS
&CELL
ABC 12.4138 12.4138 12.4138
&END CELL
&COORD
O 12.235322 1.376642 10.869880
H 12.415139 2.233125 11.257611
H 11.922476 1.573799 9.986994
&END COORD
&KIND H
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q1
&END KIND
&KIND O
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q6
&END KIND
&END SUBSYS
&DFT
BASIS_SET_FILE_NAME ./BASIS_SET
POTENTIAL_FILE_NAME ./POTENTIAL
&QS
EPS_DEFAULT 1.0E-7
&END QS
&MGRID
CUTOFF 200
NGRIDS 4
REL_CUTOFF 30
&END MGRID
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-05
MAX_SCF 200
&DIAGONALIZATION T
ALGORITHM STANDARD
&END DIAGONALIZATION
&MIXING T
ALPHA 0.5
METHOD PULAY_MIXING
NPULAY 5
&END MIXING
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&END DFT
&END FORCE_EVAL
&MOTION
&GEO_OPT
TYPE MINIMIZATION
MAX_DR 1.0E-03
MAX_FORCE 1.0E-03
RMS_DR 1.0E-03
RMS_FORCE 1.0E-03
MAX_ITER 200
OPTIMIZER CG
&CG
MAX_STEEP_STEPS 0
RESTART_LIMIT 9.0E-01
&END CG
&END GEO_OPT
&CONSTRAINT
&FIXED_ATOMS
COMPONENTS_TO_FIX XYZ
LIST 1
&END FIXED_ATOMS
&END CONSTRAINT
&END MOTION
- The PBS Script can be found below.
- You can transfer the files to your account on the cluster to follow along. The file transfer guide may be helpful.
Part 1: The PBS Script¶
#!/bin/bash
#PBS -N cp2kTest
#PBS -A [Account]
#PBS -l nodes=1:ppn=24
#PBS -l walltime=15:00
#PBS -q hive-all
#PBS -j oe
#PBS -o cp2kTest.out
cd $PBS_O_WORKDIR
module load cp2k/6.1-mva2
mpirun cp2k.popt -o H2O.out H2O.inp
- The
#PBS
directives request 15 minutes of walltime with 1 node and 24 cores. More on#PBS
directives can be found in the PBS guide $PBS_O_WORKDIR
is a variable that represents the directory you submit the PBS script from. Make sure the files you want to use are in the same directory you put the PBS script.- Output Files will also show up in this directory as well.
module load cp2k/6.1-mva2
loads the 6.1 version of CP2K. To see what CP2K versions are available, runmodule spider cp2k
, and load the one you want. The other modules are dependencies for the cp2k module and must be loaded prior to loading the cp2k module.cp2k.popt -o H2O.out H2O.inp &
passes theH2O.inp
input file to thecp2k.popt
function to run the program.
Part 2: Submit Job and Check Status¶
- Make sure you're in the dir that contains the
PBS
Script as well as theCP2K
program - Submit as normal, with
qsub <pbs script name>
. In this caseqsub cp2kTest.pbs
- Check job status with
qstat -t 22182721
, replacing the number with the job id returned after running qsub. - You can delete the job with
qdel 22182721
, again replacing the number with the jobid returned after running qsub.
Part 3: Collecting Results¶
-
In the directory where you submitted the
PBS
script, you should see the following files generated from the job:H2O.out
H2O-pos-1.xyz
H2O-1.restart
H2O-1.restart.bak-1
H2O-1.restart.bak-2
H2O-1.restart.bak-3
-
Use
cat
or open the file in a text editor to take a look. - After the result files are produced, you can move the files off the cluster, refer to the file transfer guide for help.
- Congratulations! You successfully ran CP2K on the cluster.