CP2K: Difference between revisions

From RCSWiki
Jump to navigation Jump to search
 
(28 intermediate revisions by the same user not shown)
Line 37: Line 37:
= CP2K on ARC =
= CP2K on ARC =


CP2K application is available on on ARC in forms of
Various versions of CP2K software package is available on on ARC as
* '''Natively installed''' applications, or
* '''Natively installed''' application -- the application is '''compiled and built on ARC''' using source codes.
* '''Apptainer containers".  
* '''Apptainer containers''' -- Containerized version of '''CP2K is compiled by the developers''' and provided '''as-is''' for downloads.  


== Natively Installed CP2K ==
== Natively Installed CP2K ==


Currently there are several software modules on ARC that provide different versions of '''GROMACS'''.
The versions differ in the release date as well as the CPU architecture the software is compiled for.
You can see them using the <code>module</code> command:
<pre>
$ module avail cp2k
---------------------- /global/software/Modules/5.5.0/modulefiles -----------------------------------
cp2k/7.1-legacy  cp2k/7.1-skylake
</pre>
The names of the modules give hints on the specific version of '''CP2K''' they provide access to.
* The '''legacy''' module activates the version capable of running on older hardware, such as the '''legacy''' partition on ARC.
* The '''skylake''' module activates the version built for newer compute nodes, such as '''cpu2019''' and newer.
=== Activating natively installed CP2K ===
Before CP2K can be used, it has to be '''activated'''.
To activate the specific version of CP2K, a corresponding '''module has to be loaded'''. Like this:
<pre>
$ cp2k
bash: cp2k: command not found...
$ module load cp2k/7.1-legacy 
...
</pre>


== CP2K Official Containers ==
== CP2K Official Containers ==


The more recent versions of '''CP2K''' installed on ARC have been built as [[Apptainer]] containers based off of the official docker containers available on Dockerhub.
The more recent versions of '''CP2K''' installed on ARC have been built as [[Apptainer]] containers based off of the official docker containers available on Dockerhub.
* Official documentation on the CP2K containers:
: https://github.com/cp2k/cp2k-containers


The path to the directory with the container files is <code>/global/software/cp2k/containers</code>.
The path to the directory with the container files is <code>/global/software/cp2k/containers</code>.
Line 52: Line 82:
To see what versions of containerized '''CP2K''' are available, simply list the content of the corresponding directory:
To see what versions of containerized '''CP2K''' are available, simply list the content of the corresponding directory:
<pre>
<pre>
$ ls -l /global/software/cp2k/containers/
$ ls -lh /global/software/cp2k/containers/


-rwxr-xr-x 1 drozmano drozmano 1.2G Sep 16 12:56 cp2k-2025.1-openmpi-skylake-avx512-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 1.2G Sep 16 12:56 cp2k-2025.1-openmpi-x86_64-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 666M Sep 16 12:56 cp2k-2025.2-openmpi-cascadelake-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 661M Sep 16 12:57 cp2k-2025.2-openmpi-x86_64-psmp.sif
</pre>
</pre>


The '''.sif''' files are the containers.
'''CP2K''' is installed in <code>/opt/cp2k/</code> directory of the container.
* <code>cp2k-2025.2-openmpi-x86_64-psmp.sif</code> - provides the '''psmp''' build of the '''2025.2''' version of '''CP2K''', generic.
* <code>cp2k-2025.2-openmpi-cascadelake-psmp.sif</code> - '''psmp''' build of the '''2025.2''' version, more recent CPUs.
* <code>cp2k-2025.1-openmpi-x86_64-psmp.sif</code> - provides the '''psmp''' build of the '''2025.1''' version of '''CP2K''', generic.
* <code>cp2k-2025.1-openmpi-skylake-avx512-psmp.sif</code> - '''psmp''' build of the '''2025.1''' version, more recent CPUs.
=== Running commands from the containers ===
=== Running commands from the containers ===


You can run a command from the container of your choice with the command line like this:
You can run a command from the container of your choice with the command line like this:
  $ apptainer exec <container> <command> [command arguments]
  $ apptainer run <container> <command> [command arguments]
 
The <code><container></code> should be pointing to the container to be used, for example
<code>/global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif</code>.
 
<pre>
apptainer run /global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif cp2k -v
 
SIRIUS 7.7.0, git hash: https://api.github.com/repos/electronic-structure/SIRIUS/git/ref/tags/v7.7.0
CP2K version 2025.2
Source code revision c3a8adfec5
...
...
</pre>
To make it easier to type the long container file name, it can be assigned to an environmental variable, <code>CONT</code>(ainer), for example:
<pre>
$ export CONT=/global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif
 
$ apptainer run $CONT cp2k -h
SIRIUS 7.7.0, git hash: https://api.github.com/repos/electronic-structure/SIRIUS/git/ref/tags/v7.7.0
 
cp2k [-c|--check] [-e|--echo] [-h|--help]
      [-i] <input_file>
      [-mpi-mapping|--mpi-mapping] <method>
      [-o] <output_file>
      [-r|-run] [-s|--shell] [--xml]
 
starts the CP2K program, see <https://www.cp2k.org/>
 
The easiest way is cp2k <input_file>
 
The following options can be used:
 
  -i <input_file>      : provides an input file name, if it is the last
....
....
</pre>
 
= Running CP2K jobs on ARC =
 
== CP2K Examples ==
 
'''Several examples''' suitable for benchmarking are available on ARC.
The are in the <code>/global/software/cp2k/examples/2025.2</code> directory.
<pre>
$ ls -l /global/software/cp2k/examples/2025.2/
total 124
-rw-r--r-- 1 drozmano drozmano 21629 Sep 26 13:44 H2O-128_md.inp
-rw-r--r-- 1 drozmano drozmano  6359 Sep 26 13:44 H2O-32_md.inp
-rw-r--r-- 1 drozmano drozmano 82685 Sep 26 13:44 H2O-512_md.inp
</pre>
These are systems of TIP5P water of 32, 128 and 512 molecules.
 
The examples '''can be copied''' to your test directory, or they '''can be used directly from that location'''.
 
== Running CP2K jobs using containers ==
 
=== Multi-process MPI job on one node ===
 
One node '''MPI muti-process''' based job script example, <code>mpi.slurm</code>:
<source lang=bash>
#! /bin/bash
# ------------------------------------------------------------
#SBATCH --job-name=cp2k-mpi-test
 
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=40
#SBATCH --cpus-per-task=1
#SBATCH --mem=20gb
#SBATCH --time=0-01:00:00
 
#SBATCH --partition=cpu2019-bf05
# ------------------------------------------------------------
CONT=/global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif
echo "Start: `date`"
 
INPUT=/global/software/cp2k/examples/2025.2/H2O-128_md.inp
 
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
apptainer run -B/work,/bulk,/global/software $CONT mpiexec -n $SLURM_TASKS_PER_NODE cp2k -i $INPUT
 
echo "End: `date`"
# ------------------------------------------------------------
</source>
Note, that this script requests a compute node from the '''cpu2019-bf05''' partition.
The nodes in this partitions have '''40 cpu-cores each''', this is why the script also requests '''40 single-threaded MPI processes''' for the '''CP2K''' code.
 
This job should run for about '''3 min 50 sec''' and use about '''16GB of memory'''.
The CPU utilization should be about '''98%'''.


= Links =
= Links =
[[ARC Software]]
[[ARC Software]]

Latest revision as of 22:26, 26 September 2025

Background


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 provides a general framework for different modeling methods such as DFT using the mixed Gaussian and plane waves approaches GPW and GAPW. Supported theory levels include DFT, MP2, RPA, GW, tight-binding (xTB, DFTB), semi-empirical methods (AM1, PM3, PM6, RM1, MNDO, ...), and classical force fields (AMBER, CHARMM, ...). CP2K can do simulations of molecular dynamics, metadynamics, Monte Carlo, Ehrenfest dynamics, vibrational analysis, core level spectroscopy, energy minimization, and transition state optimization using NEB or dimer method.


CP2K is written in Fortran 2008 and can be run efficiently in parallel using a combination of multi-threading, MPI, and CUDA.

Types of Executable files

CP2K provides a single and only Makefile in cp2k/makefiles/ directory. The actual compilation settings are set in cp2k/arch/arch.version files. The arch file is included in the Makefile during a building run.

Conventionally, there are four versions:

  • sopt - serial
  • popt - parallel (only MPI) - recommended for general usage
  • ssmp - parallel (only OpenMP)
  • psmp - parallel (MPI + OpenMP)

CP2K on ARC

Various versions of CP2K software package is available on on ARC as

  • Natively installed application -- the application is compiled and built on ARC using source codes.
  • Apptainer containers -- Containerized version of CP2K is compiled by the developers and provided as-is for downloads.

Natively Installed CP2K

Currently there are several software modules on ARC that provide different versions of GROMACS. The versions differ in the release date as well as the CPU architecture the software is compiled for.

You can see them using the module command:

$ module avail cp2k
---------------------- /global/software/Modules/5.5.0/modulefiles -----------------------------------
cp2k/7.1-legacy  cp2k/7.1-skylake 

The names of the modules give hints on the specific version of CP2K they provide access to.

  • The legacy module activates the version capable of running on older hardware, such as the legacy partition on ARC.
  • The skylake module activates the version built for newer compute nodes, such as cpu2019 and newer.

Activating natively installed CP2K

Before CP2K can be used, it has to be activated. To activate the specific version of CP2K, a corresponding module has to be loaded. Like this:

$ cp2k 
bash: cp2k: command not found...

$ module load cp2k/7.1-legacy  
...

CP2K Official Containers

The more recent versions of CP2K installed on ARC have been built as Apptainer containers based off of the official docker containers available on Dockerhub.

  • Official documentation on the CP2K containers:
https://github.com/cp2k/cp2k-containers


The path to the directory with the container files is /global/software/cp2k/containers.

To see what versions of containerized CP2K are available, simply list the content of the corresponding directory:

$ ls -lh /global/software/cp2k/containers/

-rwxr-xr-x 1 drozmano drozmano 1.2G Sep 16 12:56 cp2k-2025.1-openmpi-skylake-avx512-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 1.2G Sep 16 12:56 cp2k-2025.1-openmpi-x86_64-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 666M Sep 16 12:56 cp2k-2025.2-openmpi-cascadelake-psmp.sif
-rwxr-xr-x 1 drozmano drozmano 661M Sep 16 12:57 cp2k-2025.2-openmpi-x86_64-psmp.sif

The .sif files are the containers.

CP2K is installed in /opt/cp2k/ directory of the container.

  • cp2k-2025.2-openmpi-x86_64-psmp.sif - provides the psmp build of the 2025.2 version of CP2K, generic.
  • cp2k-2025.2-openmpi-cascadelake-psmp.sif - psmp build of the 2025.2 version, more recent CPUs.
  • cp2k-2025.1-openmpi-x86_64-psmp.sif - provides the psmp build of the 2025.1 version of CP2K, generic.
  • cp2k-2025.1-openmpi-skylake-avx512-psmp.sif - psmp build of the 2025.1 version, more recent CPUs.

Running commands from the containers

You can run a command from the container of your choice with the command line like this:

$ apptainer run <container> <command> [command arguments]

The <container> should be pointing to the container to be used, for example /global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif.

apptainer run /global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif cp2k -v

SIRIUS 7.7.0, git hash: https://api.github.com/repos/electronic-structure/SIRIUS/git/ref/tags/v7.7.0
 CP2K version 2025.2
 Source code revision c3a8adfec5
...
...

To make it easier to type the long container file name, it can be assigned to an environmental variable, CONT(ainer), for example:

$ export CONT=/global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif

$ apptainer run $CONT cp2k -h
SIRIUS 7.7.0, git hash: https://api.github.com/repos/electronic-structure/SIRIUS/git/ref/tags/v7.7.0

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

 starts the CP2K program, see <https://www.cp2k.org/>

 The easiest way is cp2k <input_file>

 The following options can be used:

  -i <input_file>      : provides an input file name, if it is the last
....
....

Running CP2K jobs on ARC

CP2K Examples

Several examples suitable for benchmarking are available on ARC. The are in the /global/software/cp2k/examples/2025.2 directory.

$ ls -l /global/software/cp2k/examples/2025.2/
total 124
-rw-r--r-- 1 drozmano drozmano 21629 Sep 26 13:44 H2O-128_md.inp
-rw-r--r-- 1 drozmano drozmano  6359 Sep 26 13:44 H2O-32_md.inp
-rw-r--r-- 1 drozmano drozmano 82685 Sep 26 13:44 H2O-512_md.inp

These are systems of TIP5P water of 32, 128 and 512 molecules.

The examples can be copied to your test directory, or they can be used directly from that location.

Running CP2K jobs using containers

Multi-process MPI job on one node

One node MPI muti-process based job script example, mpi.slurm:

#! /bin/bash
# ------------------------------------------------------------
#SBATCH --job-name=cp2k-mpi-test

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=40
#SBATCH --cpus-per-task=1
#SBATCH --mem=20gb
#SBATCH --time=0-01:00:00

#SBATCH --partition=cpu2019-bf05
# ------------------------------------------------------------
CONT=/global/software/cp2k/containers/cp2k-2025.2-openmpi-x86_64-psmp.sif
echo "Start: `date`"

INPUT=/global/software/cp2k/examples/2025.2/H2O-128_md.inp

export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
apptainer run -B/work,/bulk,/global/software $CONT mpiexec -n $SLURM_TASKS_PER_NODE cp2k -i $INPUT

echo "End: `date`"
# ------------------------------------------------------------

Note, that this script requests a compute node from the cpu2019-bf05 partition. The nodes in this partitions have 40 cpu-cores each, this is why the script also requests 40 single-threaded MPI processes for the CP2K code.

This job should run for about 3 min 50 sec and use about 16GB of memory. The CPU utilization should be about 98%.

Links

ARC Software