howto:static_calculation

In this tutorial, we are going to show the reader how to perform a
simple static self-consistent Kohn-Sham Density Functional Theory
energy and force calculation on a system using `QUICKSTEP`

.

We will use face centred cubic bulk Si, with 8 atoms in a cubic unit
cell as an example. The example files are contained in static_calculation.tgz. The calculations were carried out with
`CP2K`

version 2.4.

The reader should note that the integration grid settings used in the example calculations have already chosen to be sufficient for the given accuracy. A separate tutorial is available to show how to achieve this.

We first look at the input files required for this calculation. The necessary input files are:

`Si_bulk8.inp`

: the main input file for the calculation, which defines the system and the job parameters`BASIS_SET`

: file containing parameters for the basis sets that can be used by`CP2K`

for this calculation`GTH_POTENTIALS`

: file containing parameters for the pseudopotentials that can be used by`CP2K`

for this calculation

A list of basis set and pseudopotential files may be found in
`cp2k/data/`

that comes with a `cp2k`

source release. These
should cover most of the commonly used elements. The user will,
however, need to produce their own main input file for a given
calculation.

Let us look at the main input: `Si_bulk8.inp`

in detail. The name of
this file can be arbitrary, so is the file extension. The input file
is structured into ordered blocks and keywords, the order of which
are unimportant. Each input block is referred to as a “section” in
this tutorial, and some sections are “subsections” of other
sections. Full definitions of the input file format and keywords is
available via the ''CP2K'' input reference manual.

The input file is shown below:

&GLOBAL PROJECT Si_bulk8 RUN_TYPE ENERGY_FORCE PRINT_LEVEL LOW &END GLOBAL &FORCE_EVAL METHOD Quickstep &SUBSYS &KIND Si ELEMENT Si BASIS_SET DZVP-GTH-PADE POTENTIAL GTH-PADE-q4 &END KIND &CELL A 5.430697500 0.000000000 0.000000000 B 0.000000000 5.430697500 0.000000000 C 0.000000000 0.000000000 5.430697500 &END CELL &COORD Si 0.000000000 0.000000000 0.000000000 Si 0.000000000 2.715348700 2.715348700 Si 2.715348700 2.715348700 0.000000000 Si 2.715348700 0.000000000 2.715348700 Si 4.073023100 1.357674400 4.073023100 Si 1.357674400 1.357674400 1.357674400 Si 1.357674400 4.073023100 4.073023100 Si 4.073023100 4.073023100 1.357674400 &END COORD &END SUBSYS &DFT BASIS_SET_FILE_NAME BASIS_SET POTENTIAL_FILE_NAME GTH_POTENTIALS &QS EPS_DEFAULT 1.0E-10 &END QS &MGRID NGRIDS 4 CUTOFF 300 REL_CUTOFF 60 &END MGRID &XC &XC_FUNCTIONAL PADE &END XC_FUNCTIONAL &END XC &SCF SCF_GUESS ATOMIC EPS_SCF 1.0E-7 MAX_SCF 300 &DIAGONALIZATION ON ALGORITHM STANDARD &END DIAGONALIZATION &MIXING T METHOD BROYDEN_MIXING ALPHA 0.4 NBROYDEN 8 &END MIXING &END SCF &END DFT &PRINT &FORCES ON &END FORCES &END PRINT &END FORCE_EVAL

The main sections in the input file are:

- ''GLOBAL'': contains general options for the
`CP2K`

run, such as the name of the job, the type of run etc. - ''FORCE_EVAL'': contains all parameters associated with the evaluation of forces on atoms, this includes the initial atomic coordinates.

We look at each section in detail. The `GLOBAL`

section in
`Si_bulk8.inp`

is presented below:

&GLOBAL PROJECT Si_bulk8 RUN_TYPE ENERGY_FORCE PRINT_LEVEL LOW &END GLOBAL

We will be doing a static energy and force calculation, in this
case, we must set ''RUN_TYPE'' to `ENERGY_FORCE`

. Keyword ''PROJECT'' is an
alias for `PROJECT_NAME`

, which sets the root-name of the
calculation, in this case `Si_bulk8`

. Any output files automatically
generated by `CP2K`

will have the name prefixed by
`Si_bulk8`

. ''PRINT_LEVEL'' controls the default verbosity of the main
output of `CP2K`

, in this example, it is set to “low”. The
verbosity of the output can be fine-tuned by overriding this setting
in each individual subsection of the input.

We now explain the section `FORCE_EVAL`

line-by-line.

METHOD Quickstep

The keyword ''METHOD'' chooses the method for evaluating the forces on
atoms to `QUICKSTEP`

, i.e. Density Functional Theory using the
Gaussian and Planewaves (GPW) method.

&SUBSYS &KIND Si ELEMENT Si BASIS_SET DZVP-GTH-PADE POTENTIAL GTH-PADE-q4 &END KIND &CELL A 5.430697500 0.000000000 0.000000000 B 0.000000000 5.430697500 0.000000000 C 0.000000000 0.000000000 5.430697500 &END CELL &COORD Si 0.000000000 0.000000000 0.000000000 Si 0.000000000 2.715348700 2.715348700 Si 2.715348700 2.715348700 0.000000000 Si 2.715348700 0.000000000 2.715348700 Si 4.073023100 1.357674400 4.073023100 Si 1.357674400 1.357674400 1.357674400 Si 1.357674400 4.073023100 4.073023100 Si 4.073023100 4.073023100 1.357674400 &END COORD &END SUBSYS

The subsection ''SUBSYS'' defines the simulation unit cell and the initial coordinates of atoms in the calculation.

The subsection ''KIND'' gives definitions of elements in the
calculation. There must be one `KIND`

subsection per element. In
this example, for Si, we have defined the basis set to be used:
`DZVP-GTH-PADE`

(double-\(\zeta\) with polarisation basis optimised
for Geodecker-Teter-Hutter PADE LDA pseudopotential); and the
pseudopotential: `GTH-PADE-q4`

(Geodecker-Teter-Hutter PADE LDA
pseudopotential with 4 valence electrons).

The basis set and pseudopotential names *must* correspond to an
existing entry in the corresponding basis set and pseudopotential
files defined by ''BASIS_SET_FILE_NAME'' and ''POTENTIAL_FILE_NAME''
keywords in ''DFT'' subsection, in `FORCE_EVAL`

section. The chosen
basis for Si corresponds to parameters:

Si DZVP-GTH-PADE 2 3 0 1 4 2 2 1.2032422345 0.3290350445 0.0000000000 0.0474539126 0.0000000000 0.4688409786 -0.2533118323 0.0000000000 -0.2594473573 0.0000000000 0.1679863234 -0.7870946277 0.0000000000 -0.5440929303 0.0000000000 0.0575619526 -0.1909898479 1.0000000000 -0.3624010364 1.0000000000 3 2 2 1 1 0.4500000000 1.0000000000

in file `BASIS_SET`

; and the chosen pseudopotential corresponds to
parameters:

Si GTH-PADE-q4 GTH-LDA-q4 2 2 0.44000000 1 -7.33610297 2 0.42273813 2 5.90692831 -1.26189397 3.25819622 0.48427842 1 2.72701346

in file `GTH_POTENTIALS`

.

The subsection ''CELL'' defines the simulation unit cell used in a calculation. In this example, we define the unit cell as cubic, with lattice constant equal to 5.4306975 Angstroms. “Angstrom” is the default unit for cell vectors. ''A'', ''B'' and ''C'' are the first, second and third lattice (cell) vectors. There are many ways to define the cell, see ''CP2K'' input reference manual for more details.

The initial atomic coordinates are specified in the ''COORD''
subsection. The default input format for atomic coordinates in
`CP2K`

is:

<ATOM_KIND> X Y Z

where `X`

, `Y`

and `Z`

are Cartesian coordinates in Angstroms. This
can be changed by configuring keyword ''SCALED'' to `.TRUE.`

, in the
`COORD`

subsection, which makes the coordinate input `X`

`Y`

`Z`

to
be fractional with respect to the lattice vectors. One can also
change the unit for the Cartesian coordinates by setting the keyword
''UNIT'' with in the subsection. `<ATOM_KIND>`

should be a label that
corresponds to the definition of the elements in the ''KIND''
subsections.

After the `SUBSYS`

section in the input file `Si_bulk8.inp`

follows
the ''DFT'' subsection, which controls all aspects of the
self-consistent Kohn-Sham Density Functional Theory
calculation. This subsection is only relevant if and only if the
`METHOD`

keyword in `FORCE_EVAL`

is set to `QUICKSTEP`

.

BASIS_SET_FILE_NAME BASIS_SET POTENTIAL_FILE_NAME GTH_POTENTIALS

As already mentioned above, the keywords ''BASIS_SET_FILE_NAME'' and ''POTENTIAL_FILE_NAME'' set the files that contains basis set and pseudopotential parameters.

&QS EPS_DEFAULT 1.0E-10 &END QS

The ''QS'' subsection contains general control parameters used by
`QUICKSTEP`

. ''EPS_DEFAULT'' sets the default value for all tolerances
used within `QUICKSTEP`

. The individual tolerances (`EPS_*`

) can be
set, and they will override the `EPS_DEFAULT`

value.

&MGRID NGRIDS 4 CUTOFF 300 REL_CUTOFF 60 &END MGRID

The ''MGRID'' subsection defines how the integration grid used in
`QUICKSTEP`

calculations should be setup. `QUICKSTEP`

uses a
multi-grid method for representing Gaussian functions numerically on
the grid. Narrow and sharp Gaussians are mapped onto a finer grid
than wider and smoother Gaussians. In this case, we are telling the
code to set up 4 levels of multi-grids, with the planewave cutoff of
the finest grid set to be 300 Ry, and with the grid spacing
underneath any Gaussian functions to be finer than the equivalent
planewave cutoff of 60 Ry. The users should read the tutorial
“Converging the CUTOFF and REL_CUTOFF” for details on how these
parameters affect the grid constructed, and how to define a
sufficient grid for their calculation. In this example, the grid
defined has already been found to be sufficient for the energy and
force calculation.

The ''XC'' subsection follows:

&XC &XC_FUNCTIONAL PADE &END XC_FUNCTIONAL &END XC

This defines which exchange-correlation density functional we want to use. In this we choose PADE LDA functional, which is consistent with the basis set and pseudopotential we have chosen.

&SCF SCF_GUESS ATOMIC EPS_SCF 1.0E-7 MAX_SCF 300 &DIAGONALIZATION ALGORITHM STANDARD &END DIAGONALIZATION &MIXING METHOD BROYDEN_MIXING ALPHA 0.4 NBROYDEN 8 &END MIXING &END SCF

The ''SCF'' subsection defines all the settings related to methods used to find a self-consistent solution of the Kohn-Sham DFT formalism.

''SCF_GUESS'' sets how the initial trial electron density function
\(\rho(\vec{r})\) is to be generated. In this example (`ATOMIC`

), the
initial density is to be generated using overlapping of atomic
charge densities. A good starting point for the electron density in
the self-consistency loop is important in obtaining a convergent
result quickly. ''EPS_SCF'' sets the tolerance of the charge density
residual. This overrides the `EPS_DEFAULT`

value set in `QS`

subsection. ''MAX_SCF'' sets the maximum number of self-consistency
loops `QUICKSTEP`

is allowed to perform for each ground-state energy
calculation.

&DIAGONALIZATION ON ALGORITHM STANDARD &END DIAGONALIZATION

The ''DIAGONALIZATION '' subsection tells the code to use the
traditional diagonalisation method for finding the ground state
Kohn-Sham energy and electron density. The subsection heading also
takes an argument, and in this case is set to “`ON`

”, which
equivalent to “`.TRUE.`

” or “`T`

”, and indicates that the
diagonalisation method is turned on. One can also omit the value of
the subsection heading, which defaults to “`.TRUE.`

”. The
alternative to diagonalisation is to use the Orbital Transform (OT)
method, in which case, the user should either delete the
`DIAGONALIZATION`

block or change “`ON`

” to “`OFF`

” (or
“`.FALSE.`

”), and add the ''OT'' subsection instead. The ''ALGORITHM''
keyword sets the algorithm to use for diagonalisation of the
Kohn-Sham Hamiltonian. “`STANDARD`

” means the standard
LAPACK/SCALAPACK subroutines are to be used for diagonalisation.

&MIXING T METHOD BROYDEN_MIXING ALPHA 0.4 NBROYDEN 8 &END MIXING

The ''MIXING'' subsection contains all the parameters associated with
charge mixing in a self-consistency calculation. The subsection also
admits a value, which can be either `.TRUE.`

(`T`

) or `.FALSE.`

(`F`

), which switches charge mixing on or off. The default is
`.TRUE.`

. Note that this subsection *only applies to the traditional
diagonalisation method*. The OT method uses a different approach for
charge mixing, and is explained in other tutorials. The keyword
''ALPHA'' sets the mixing parameter; in this example 0.4 of the output
density will be mixed with 0.6 of the input density to form the new
input density in the next SCF iteration. The keyword ''METHOD'' sets
the mixing method; in this case, we will use Broyden mixing. The
keyword ''NBROYDEN'' is an alias to the parameter `NBUFFER`

, and it
sets the number of histories to be used in the Broyden mixing
algorithm.

The final ''PRINT'' subsection in `FORCE_EVAL`

section:

&PRINT &FORCES ON &END FORCES &END PRINT

tells `CP2K`

, in this case, to print out atomic forces in the main
output of the calculation.

To run the calculation, the reader needs to have a working `CP2K`

package compiled, and with the path to its binaries in the system
`PATH`

. The files `Si_bulk8.inp`

, `BASIS_SET`

and `GTH_POTENTIAL`

should be in the same working directory. In this example, we will
use the MPI version of `CP2K`

. Type command:

mpirun -n 2 cp2k.popt -o Si_bulk8.out Si_bulk8.inp &

in the working directory to run `CP2K`

in parallel with 2 MPI
processes in the background. The `-o`

option redirects the `CP2K`

output to file `Si_bulk8.out`

. Note that the `-o`

option *appends*
output of successive runs to `Si_bulk8.out`

, so if the reader wants
to start completely from afresh, they must delete `Si_bulk8.out`

before running a new calculation.

After the job has finished, we should obtain the following files:

`Si_bulk8.out`

`Si_bulk8-RESTART.wfn`

`Si_bulk8-RESTART.wfn.bak-1`

The file `Si_bulk8.out`

contains the main output of the
job. `Si_bulk8-RESTART.wfn`

is the final Kohn-Sham wavefunctions
from the calculation. `Si_bulk8-RESTART.wfn.bak-<n>`

records the
Kohn-Sham wavefunctions obtained from the `<n>`

-th previous SCF
step; in this case, `Si_bulk8-RESTART.wfn.bak-1`

contains the
wavefunctions obtained from the last SCF step. Should the reader
want to start a new calculation from the previous calculated
wavefunctions, they need to change the `SCF_GUESS`

keyword in `SCF`

subsection of `FORCE_EVAL`

section to `RESTART`

:

SCF_GUESS RESTART

provided that the new calculation shares the same `PROJECT_NAME`

as
the one that generated the wavefunctions. Otherwise, we would need
to rename the restart wavefunction files to correspond to the
project name of the new calculation.

We now look at the main `CP2K`

output in more detail.

Number of electrons: 32 Number of occupied orbitals: 16 Number of molecular orbitals: 16 Number of orbital functions: 104 Number of independent orbital functions: 104 Extrapolation method: initial_guess SCF WAVEFUNCTION OPTIMIZATION Step Update method Time Convergence Total energy Change ------------------------------------------------------------------------------ 1 NoMix/Diag. 0.40E+00 0.6 0.75558724 -32.2320848878 -3.22E+01 2 Broy./Diag. 0.40E+00 1.1 0.05667976 -31.1418135481 1.09E+00 3 Broy./Diag. 0.40E+00 1.1 0.09691469 -31.1974003416 -5.56E-02 4 Broy./Diag. 0.40E+00 1.1 0.00245608 -31.3378474040 -1.40E-01 5 Broy./Diag. 0.40E+00 1.1 0.00235460 -31.3009654398 3.69E-02 6 Broy./Diag. 0.40E+00 1.1 0.00007565 -31.2972158934 3.75E-03 7 Broy./Diag. 0.40E+00 1.1 0.00009004 -31.2977293749 -5.13E-04 8 Broy./Diag. 0.40E+00 1.1 0.00000186 -31.2978454163 -1.16E-04 9 Broy./Diag. 0.40E+00 1.1 0.00000252 -31.2978835492 -3.81E-05 10 Broy./Diag. 0.40E+00 1.1 5.6405E-09 -31.2978852054 -1.66E-06 *** SCF run converged in 10 steps ***

The above shows a typical output from a self-consistent Kohn-Sham ground state calculation. It states that we are using diagonalisation method with Broyden charge mixing, and it took 10 Broyden mixing steps (each containing a diagonalisation process to obtain the wavefunctions) to reach the required tolerance for self-consistency.

Electronic density on regular grids: -31.9999999889 0.0000000111 Core density on regular grids: 31.9999999939 -0.0000000061 Total charge density on r-space grids: 0.0000000051 Total charge density g-space grids: 0.0000000051 Overlap energy of the core charge distribution: 0.00000000005320 Self energy of the core charge distribution: -82.06393942512820 Core Hamiltonian energy: 18.06858429706010 Hartree energy: 42.41172824581682 Exchange-correlation energy: -9.71425832315952 Total energy: -31.29788520535761 ENERGY| Total FORCE_EVAL ( QS ) energy (a.u.): -31.297885372811002 ATOMIC FORCES in [a.u.] # Atom Kind Element X Y Z 1 1 Si 0.00000000 0.00000000 0.00000000 2 1 Si 0.00000000 0.00000001 0.00000001 3 1 Si 0.00000001 0.00000001 0.00000000 4 1 Si 0.00000001 0.00000000 0.00000001 5 1 Si -0.00000001 -0.00000001 -0.00000001 6 1 Si -0.00000001 -0.00000001 -0.00000001 7 1 Si -0.00000001 -0.00000001 -0.00000001 8 1 Si -0.00000001 -0.00000001 -0.00000001 SUM OF ATOMIC FORCES -0.00000000 -0.00000000 -0.00000000 0.00000000

The above shows the results on final energies and forces. One should always check if the total number of electrons calculated from the final electron density, in this case 31.9999999939, is correct.

The results show that the force on the atoms are almost zero. This means the system is more or less relaxed, and its geometry is close to its optimal at ground state.

In the example so far, we have not used any smearing on electron occupation. This is fine for system with a large band gap. However, for metals or systems with a small gap, this may cause the calculation to be unstable, and the self-consistency loop may never converge, due to the discontinuity in the electron occupation function.

To add smearing, we need to add the subsection ''SMEAR'' inside
subsection `SCF`

:

&SMEAR ON METHOD FERMI_DIRAC ELECTRONIC_TEMPERATURE [K] 300 &END SMEAR

This tells `QUICKSTEP`

to use a smearing function for the electron
occupation. In this example, we use the Fermi-Dirac smearing
function, with the electron temperature being set to 300 K. Note
that, in `CP2K`

, one can explicitly define the unit of a given input
value by using a unit enclosed in square bracket, such as “`[K]`

”,
before the value.

This is not all, since smearing may lead to occupation of molecular
orbitals in the conduction band, we must tell `CP2K`

to include
extra, empty, molecular orbitals into the calculation, which
otherwise would be omitted (for reducing computational cost). To do
this, we need to add the keyword ''ADDED_MOS'' in the `SCF`

subsection:

ADDED_MOS 10

In this example, we have asked `CP2K`

to not to omit 10 of the
lowest empty molecular orbitals in the calculation. It should be
noted that given a chosen basis set, there is a maximum number of
molecular orbitals, i.e. the number of eigenvectors of the
Hamiltonian, one can generate. In theory, the maximum should be the
rank of the Hamiltonian generated in the calculation.

In the output of the calculation using smearing, we first notice that:

Number of electrons: 32 Number of occupied orbitals: 16 Number of molecular orbitals: 26 Number of orbital functions: 104 Number of independent orbital functions: 104

unlike in the previous case with no smearing, now 26 molecular orbitals have been used during the calculation. There are a total of 104 basis functions (“atom centred orbitals” spanned by Cartesian Gaussians) used in the calculation for the given basis set, so 26 is well within the limit of the calculation.

Electronic density on regular grids: -31.9999999889 0.0000000111 Core density on regular grids: 31.9999999939 -0.0000000061 Total charge density on r-space grids: 0.0000000051 Total charge density g-space grids: 0.0000000051 Overlap energy of the core charge distribution: 0.00000000005320 Self energy of the core charge distribution: -82.06393942512820 Core Hamiltonian energy: 18.06842027191411 Hartree energy: 42.41184371469986 Exchange-correlation energy: -9.71419454555998 Electronic entropic energy: -0.00001687947145 Fermi energy: 0.20867150262130 Total energy: -31.29788686349247 ENERGY| Total FORCE_EVAL ( QS ) energy (a.u.): -31.297887031736590

In the final energy section of the output, we notice that there is an extra entropy \((TS)\) term:

Electronic entropic energy: -0.00001687947145

This should be small for the calculation to be a reliable approximation to the zero electron temperature result. The final free energy is the sum of the total DFT energy and the entropic energy. The total DFT energy is given by:

Total energy: -31.29788686349247

and the final free energy extrapolated for \(TS \to 0\) is given by:

ENERGY| Total FORCE_EVAL ( QS ) energy (a.u.): -31.297887031736590

This is the energy to be quoted as the final result.

howto/static_calculation.txt · Last modified: 2018/07/09 15:32 by oschuett

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-ShareAlike 4.0 International