Skip to content

CP2K

CP2K

CP2K is a powerful and versatile software package designed for atomistic and molecular simulations. It specializes in performing simulations based on density functional theory (DFT) and a wide range of other quantum mechanical methods. CP2K is particularly well-suited for modeling the electronic structure and properties of complex molecular systems, making it a valuable tool for researchers in fields such as computational chemistry, materials science, and solid-state physics.

Key Features of CP2K

  1. Quantum Mechanical Simulations: CP2K excels at performing quantum mechanical calculations, including DFT calculations with various exchange-correlation functionals, wave function-based methods, and hybrid approaches. This makes it suitable for studying electronic properties, energy landscapes, and reaction mechanisms.

  2. Molecular Dynamics: In addition to static electronic structure calculations, CP2K supports ab initio molecular dynamics (AIMD) simulations, enabling researchers to investigate the dynamics of molecules and materials at the atomic level. This is crucial for understanding the behavior of systems at finite temperatures.

  3. Parallelization: CP2K is designed to efficiently utilize high-performance computing (HPC) resources. It offers parallelization capabilities that allow it to run on supercomputers and HPC clusters, making it suitable for simulating large and complex systems.

  4. Biomolecular Simulations: While CP2K is known for its strength in electronic structure calculations, it can also handle biomolecular systems, including proteins, nucleic acids, and lipids. This versatility makes it a valuable tool for researchers in both the biological and chemical sciences.

  5. User-Friendly Input: CP2K provides a user-friendly input file format that allows users to specify simulation parameters, molecular structures, and other settings in a straightforward manner. This makes it accessible to researchers with varying levels of computational expertise.

Usage

CP2K may have different versions available on our HPC system. You can typically load a specific version using a module system. Here's an example:

module load CP2K/2023.1-foss-2022b

CP2K's version numbering may vary, so be sure to use the appropriate version for your research needs:

$ module spider CP2K

-----------------------------------------------------
  CP2K:
-----------------------------------------------------
 Description:
      CP2K is a freely available (GPL) program, written in Fortran 95, to perform atomistic and molecular simulations of solid state, liquid, molecular and biological systems.
      It provides a general framework for different methods such as e.g. density functional theory (DFT) using a mixed Gaussian and plane waves approach (GPW), and classical
      pair and many-body potentials. 

     Versions:
        CP2K/9.1-foss-2022a
        CP2K/2023.1-foss-2022b

-------------------------------------------------------
  For detailed information about a specific "CP2K" package (including how to load the modules) use the module's full name.
  Note that names that have a trailing (E) are extensions provided by other modules.
  For example:

     $ module spider CP2K/2023.1-foss-2022b
-------------------------------------------------------

Software version

Here you can check the available versions for CP2K in the different clusters

CP2K/4.1-intel-2017a
CP2K/5.1-intel-2017b
CP2K/9.1-intel-2021a
CP2K/2023.2-foss-2022b-kovaltasha
CP2K/2023.2-foss-2022b
CP2K/6.1-intel-2020a
CP2K/7.1-intel-2020a
CP2K/9.1-intel-2021a-CUDA-11.2.1
CP2K/9.1-intel-2021a-CUDA-11.3.1
CP2K/9.1-intel-2021a
CP2K/2023.1-intel-2022a
CP2K/2023.2-foss-2022b
CP2K/9.1-foss-2022a
CP2K/2023.1-foss-2022b
CP2K/2023.2-foss-2022b

Running CP2K

A generic batch script for parallel execution of 2023.1 version of CP2K looks like this:

#!/bin/bash
#SBATCH --qos=regular
#SBATCH --job-name=CP2K_job
#SBATCH --mem=200gb
#SBATCH --cpus-per-task=1
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=48
#SBATCH --output=%x-%j.out
#SBATCH --error=%x-%j.err

module load CP2K/2023.1-foss-2022b

srun cp2k.popt -i input.inp

Restarting Your Calculation

CP2K provides a straightforward way to restart your calculations using a restart input file. There may be various reasons why you need to restart a CP2K calculation:

  1. Hardware Failure: In case of unexpected hardware failures or job interruptions, you can restart your calculation from the point of interruption without losing the progress made so far.

  2. Batch System Time Limit: If your calculation exceeds the allotted time, you can restart it later, continuing from the last saved checkpoint.

  3. Need for More MD Sampling: For MD simulations, you might require longer sampling times to obtain meaningful results. Restarting allows you to extend your simulation without starting from scratch.

To restart a CP2K run, follow these general steps. Note that these instructions might need to be adapted slightly depending on the specific type of calculation you're performing:

1. Ensure Output Files Are Intact:

Ensure you have the relevant output files from the initial run. Important files can include:

  • The restart file (.restart), which contains wavefunction information and is automatically saved during the run.
  • The coordinate file (e.g., .xyz or .pdb) which might contain the last coordinates of your atoms if you were running a dynamic simulation.

2. Modify Input File"

To restart a run, you typically need to modify your CP2K input file (*.inp) in specific sections, including:

  • RESTART:

In the &MOTION section (for molecular dynamics runs) or other relevant sections, adjust the settings related to restarting the simulation. For instance, using &MD subsection, ensure that the RESTART keyword is set to .TRUE..

&MOTION
  &MD
    RESTART .TRUE.
    ...
  &END MD
&END MOTION
  • EXT_RESTART:

The &EXT_RESTART section can be included in the &MOTION section to specify restart options.

&EXT_RESTART
  RESTART_FILE_NAME [Your_restart_file_name.restart]
  ...
&END EXT_RESTART
Replace [Your_restart_file_name.restart] with the name of your restart file.

  • WAVEFUNCTIONS:

If you were running electronic structure calculations, you might need to specify the wavefunction restart file in the &SCF section using the RESTART_FILE_NAME keyword.

&SCF
  SCF_GUESS RESTART
  RESTART_FILE_NAME [Your_wavefunction_filename.restart]
  ...
&END SCF
Replace [Your_wavefunction_filename.restart] with the name of your wavefunction restart file.

3. Re-run the Simulation:

Once you have modified your input file, you can re-run the CP2K simulation using the modified input file. Typically, this might look like:

cp2k.popt -i modified_input_file.inp

Note

  • Make sure to thoroughly check your input file to ensure all paths and filenames are specified correctly.
  • Test the restart with a short run before initiating a long job to ensure everything is configured correctly.
  • Ensure that your computational resources (e.g., allocated time on the HPC platforms) are sufficient for the rest of the simulation.