Dissociation of Hydrogen with CP2K¶
In this example, we are going to study dissociation of hydrogen using CP2K. The goal of this example is to show how CP2K can be interfaced with PyRETIS for a relatively simple system.
In this example, we will make use of CP2K [1] for running the dynamics. The example is structured as follows:
Verification status: engine – see Tutorial map.
Tutorial quick start¶
Best starting point:
examples/tutorials/path_sampling/cp2k/H2/retis/.Requirements: a working CP2K executable.
cp2k_input/holds the CP2K input, the initial configuration and the two CP2K data files the input names,GTH_BASIS_SETSandGTH_POTENTIALS; see The CP2K engine.Edit first:
retis.tomlfor the[engine]section andcp2k_input/cp2k.inpfor the CP2K-side dynamics settings.Run:
pyretis run -i retis.toml -p.Analyse:
pyretis analyse -i retis.toml– the analysis reads the same input file as the run.Expected output: standard RETIS ensemble folders plus CP2K files managed through the external engine interface.
Related check:
examples/tests/test-cp2k/; see Example test status.
The order parameter we will consider in this example will just be given by the distance between the two hydrogen atoms.
Creating the PyRETIS input file¶
The input file for PyRETIS follows the structure we have used in the previous examples and we will not go into details about all sections here. In the following, we will just describe the section for using the CP2K engine in more detail. The full input file for the RETIS simulation is given at the end of this section.
In order to make use of CP2K, we add the following engine section to the input file:
[engine]
class = "cp2k"
cp2k = "cp2k"
input_path = "cp2k_input"
timestep = 0.5
subcycles = 1
cp2k_format = "xyz"
extra_files = [
"GTH_BASIS_SETS",
"GTH_POTENTIALS",
]
Here, we make use of the following keywords:
class = "cp2k"which specifies the engine we will use (here: cp2k).cp2k = "cp2k"which specifies the CP2K executable. On your system, this might be named differently.input_path = "cp2k_input"which specifies the directory where PyRETIS will look for the input files for CP2K. PyRETIS assumes that, at least, the following files are in this folder:initial.xyzwhich contain the initial configuration. This file can be downloaded here:initial.xyz.cp2k.inpwhich contains the settings for the CP2K simulation. This file can be downloaded here:cp2k.inp.
timestep = 0.5which is the time step to use in the CP2K simulations.subcycles = 1which is the number of subcycles CP2K will complete before PyRETIS re-calculates the order parameter.cp2k_format = "xyz"which is the format of the initial configuration,initial.xyz; without it, PyRETIS takes the format from the extension of theinitialfile incp2k_input.extra_files = ['GTH_BASIS_SETS', 'GTH_POTENTIALS']which contain extra files CP2K will need in order to execute. Here, we are using two files to define the basis set and the potential functions. These files are part of the CP2K distribution and can be found in the folder$CP2K_HOME/data/(or/usr/share/cp2k). PyRETIS expects that all the files you list here are included in thecp2k_inputdirectory.
The temperature of the run is set in cp2k.inp, by
TEMPERATURE in its MOTION / MD section (300 K here):
PyRETIS draws new velocities at this temperature. Leave
[system] temperature out of the input, as here, or set it to the
same value: a different value stops the run before it starts (see the
temperature keyword
of the system section).
This specifies and selects the CP2K engine for use with PyRETIS. The full input file for the RETIS simulation is given below:
Show/hide the input file for the CP2K simulation. »
[simulation]
task = "retis"
steps = 100
interfaces = [
0.78,
0.8,
0.82,
0.84,
0.86,
0.87,
0.88,
0.9,
0.92,
0.95,
]
[system]
units = "cp2k"
[engine]
class = "cp2k"
cp2k = "cp2k"
input_path = "cp2k_input"
timestep = 0.5
subcycles = 1
cp2k_format = "xyz"
extra_files = [
"GTH_BASIS_SETS",
"GTH_POTENTIALS",
]
[orderparameter]
class = "pyretis_distance"
index = [
0,
1,
]
periodic = true
[output]
archive_every = 50
order-file = 1
[tis]
freq = 0.5
maxlength = 20000
allowmaxlength = false
zero_momentum = false
rescale_energy = false
sigma_v = -1
seed = 0
[initial-path]
method = "kick"
kick-from = "previous"
[retis]
swapfreq = 0.5
Running the RETIS simulation with PyRETIS¶
In order to run the RETIS simulation, the following steps are suggested:
Create a new folder for the simulation named
cp2k-hydrogenand enter this directory.Create a new file
retis.tomlwith the input settings for the simulation.Copy the input files for CP2K from
examples/tutorials/path_sampling/cp2k/H2/retis/cp2k_input/into a new directory namedcp2k_input:initial.xyz,cp2k.inp, andGTH_BASIS_SETSandGTH_POTENTIALS, copies of the files of the CP2K distribution.Run the RETIS simulation using:
pyretis run -i retis.toml -p
Tested by¶
The CP2K engine setup is represented by
examples/tests/test-cp2k/. That fixture checks a shorter
external-engine run and should be used as the regression target; this
page explains how to adapt the same file layout for a user simulation.