Skip to content

CP2K

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.

CP2K is available as a module on Apocrita.

Use Spack for additional variants

Simple variants of CP2K have been installed by the Apocrita ITSR Apps Team. Advanced users may want to self-install their own additional variants via Spack.

Versions

Regular and GPU accelerated versions have been installed on Apocrita.

Usage

To run the required version, load one of the following modules:

  • For CP2K (non-GPU), load cp2k/<version>
  • For GPU accelerated CP2K versions, load cp2k-gpu/<version>

To run the default installed version of CP2K, simply load the cp2k module:

$ module load cp2k
$ cp2k.psmp -h
Usage:
cp2k.psmp -h

 cp2k.psmp [-c|--check] [-e|--echo] [-h|--help]
           [-i] <input_file>
           [-mpi-mapping|--mpi-mapping] <method>
           [-o] <output_file>
           [-r|-run] [-s|--shell] [--xml]

For full usage documentation, run cp2k.psmp -h.

Example jobs

Serial CPU jobs

Here is an example job running on 1 core and 1GB of memory:

#!/bin/bash
#SBATCH --ntasks=1        # (or -n 1) Request 1 core
#SBATCH --mem-per-cpu=1G  # Request 1GB RAM per core (1GB total)
#SBATCH --time=1:0:0      # (or -t 1:0:0) Request 1 hour runtime

module load cp2k

cp2k.psmp -i myinput.inp -o myoutput.out

Here is an example job running on 4 cores and 4GB memory:

Core Usage

For serial multi-core jobs, the cp2k modules will automatically export the $OMP_NUM_THREADS environment variable to match your core request and automatically thread your job correctly using OpenMP. There is no need for any additional threading arguments.

#!/bin/bash
#SBATCH --ntasks=4        # (or -n 4) Request 4 cores
#SBATCH --mem-per-cpu=1G  # Request 1GB RAM per core (4GB total)
#SBATCH --time=1:0:0      # (or -t 1:0:0) Request 1 hour runtime

module load cp2k

cp2k.psmp -i myinput.inp -o myoutput.out

Parallel CPU job

Here is an example job running on 96 cores across 2 nodes with MPI:

#!/bin/bash
#SBATCH --partition=parallel  # (or -p parallel) Request parallel partition
#SBATCH --nodes=2             # (or -N 2) Request 2 nodes
#SBATCH --ntasks=96           # (or -n 96) Request 96 cores
#SBATCH --time=240:0:0        # (or -t 240:0:0) Request 240 hours runtime
#SBATCH --exclusive           # Request exclusive compute node usage
#SBATCH --mem=0               # Book all available memory on compute nodes

module load cp2k

# Slurm knows how many tasks to use for mpirun, detected automatically from
# ${SLURM_NTASKS}. Use -- to ensure arguments are passed to the application
# and not mpirun
mpirun -- \
  cp2k.psmp \
  -i myinput.inp \
  -o myoutput.out

GPU job

Here is an example job running on 1 GPU:

Core Usage

For GPU jobs, the cp2k modules will automatically export the $OMP_NUM_THREADS environment variable to match your core request and automatically thread your job correctly using OpenMP. There is no need for any additional threading arguments.

#!/bin/bash
#SBATCH --partition=gpu       # (or -p gpu) Request gpu partition
#SBATCH --ntasks=8            # (or -n 8) Request 8 cores
#SBATCH --mem-per-cpu=11G     # Request 11GB RAM per core (88GB total)
#SBATCH --cpus-per-gpu=8      # 8 cores per GPU
#SBATCH --gres=gpu:1          # Request 1 GPU of any type
#SBATCH --time=240:0:0        # (or -t 2) Request 240 hours runtime

# Load a GPU compatible version of CP2K
module load cp2k-gpu

cp2k.psmp -i myinput.inp -o myoutput.out

References