最新完全版CP2K-9.1编译安装教程
东条希锡硒
2022年02月11日 23:21

CP2K是功能最强大的计算化学-计算物理学-计算生物学程序之一。它为不同的方法提供了一个通用框架:密度泛函理论(DFT) 使用混合高斯和平面波方法(GPW) 通过LDA、GGA、MP2或RPA理论水平、经典对和多体势、半经验( AM1 , PM3 , MNDO , MNDOd, PM6) 和紧束缚哈密顿量,以及依赖静电势高斯展开 (GEEP) 的量子力学/分子力学(QM/MM) 混合方案。高斯和增强平面波方法 (GAPW) 作为 GPW 方法的扩展允许全电子计算。CP2K 进行分子动力学(MD)、元动力学(Metadynamics)、蒙特卡罗(MC)、埃伦费斯特动力学(Ehrenfest dynamics)、从头算动力学(AIMD)、振动分析核心能级光谱、能量最小化以及使用NEB或Dimer方法进行过渡态优化的模拟。

CP2K

前段日子发布了最新版的CP2K-9.1,相比8.2有了以下改进:

  • Fix MacOS build (#1316)

  • Add NEWTONX interface (#1794)

  • Add Gromacs QM/MM support (see also)

  • Add experimental support for HIP and OpenCL to DBCSR

  • Adopt BSD3 license for new performance critical code (#1632)

  • Add GAL21 forcefield (#1579)

  • Upgrade to MPI_THREAD_SERIALIZED (#1564)

  • Add new pseudopotentials and basis sets (#1547, #​1551)

  • Add analytical derivatives of the MO coefficients wrt nuclear coordinates (#1706)

  • Add forces for RI-HFX (#1688)

  • Add forces for TDDFT (#1670, #​1759)

  • Regularized RI for periodic GW (#1776)

  • Add beadwise constraints to PINT (#1734)

  • Add analytical stress tensor for NNP (#1783)

  • Add ghost particles and tip scan for xTB (#1578)

  • Add forces and stress tensor for MP2-based double-hybrids (#1647)

  • Rewrite regtesting script in Python, arguments changed slightly (#1548)

https://github.com/cp2k/cp2k/releases/

开始编译:

数学库采用intel mkl

配置好环境

代码块
JavaScript
自动换行
复制代码
source /home/nozomiTojo/intel2020/mkl/bin/mklvars.sh  intel64
source /home/nozomiTojo/intel2020/parallel_studio_xe_2020/psxevars.sh
export PATH=/home/nozomiTojo/intel2020/compilers_and_libraries_2020.4.304/linux/mkl:$PATH
复制成功

编译环境GCC 9.3.0

代码块
JavaScript
自动换行
复制代码
nozomiTojo@lovelive:~/cp2k-9.1/tools/toolchain$ ./install_cp2k_toolchain.sh --math-mode=mkl --with-mkl=system--with-openblas=no --with-openmpi=install --with-gcc=system --with-scalapack=no--with-ptscotch=install --with-superlu=install --with-pexsi=install--with-quip=install --with-plumed=install
复制成功

一步完成所有插件编译,没有任何报错。

代码块
JavaScript
自动换行
复制代码
plumed=install
MPI is detected and it appears to be OpenMPI
Compiling with 56 processes.
==================== Finding GCC from system paths ====================
path to gcc is  /usr/bin/gcc
path to g++ is  /usr/bin/g++
path to gfortran is  /usr/bin/gfortran
Found include directory /usr/include
Step gcc took 0.00 seconds.
==================== Getting proc arch info using OpenBLAS tools ====================
OpenBLAS-0.3.19.tar.gz is found
OpenBLAS detected LIBCORE = haswell
OpenBLAS detected ARCH    = x86_64
==================== Installing CMake ====================
cmake-3.22.1-Linux-x86_64.sh is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/cmake-3.22.1
Step cmake took 2.00 seconds.
==================== Installing OpenMPI ====================
openmpi-4.1.1.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/openmpi-4.1.1
Step openmpi took 440.00 seconds.
==================== Finding MKL from system paths ====================
MKLROOT is found to be /opt/intel2020/compilers_and_libraries_2020.4.304/linux/mkl
libm is found in ld search path
libdl is found in ld search path
Step mkl took 0.00 seconds.
Step fftw took 0.00 seconds.
==================== Installing LIBINT ====================
libint-v2.6.0-cp2k-lmax-5.tgz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5
Step libint took 277.00 seconds.
==================== Installing LIBXC ====================
libxc-5.1.7.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/libxc-5.1.7
Step libxc took 53.00 seconds.
Step libsmm took 0.00 seconds.
==================== Installing Libxsmm ====================
libxsmm-1.17.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/libxsmm-1.17
Step libxsmm took 28.00 seconds.
Step scalapack took 0.00 seconds.
==================== Installing COSMA ====================
COSMA-v2.5.1.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/COSMA-2.5.1
Step cosma took 23.00 seconds.
==================== Installing ELPA ====================
elpa-2021.11.001.tar.gz is found
patching file nvcc_wrap
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/elpa-2021.11.001/cpu
Step elpa took 241.00 seconds.
==================== Installing PT-Scotch ====================
scotch_6.0.0.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/scotch-6.0.0
Step ptscotch took 4.00 seconds.
==================== Installing SuperLU_DIST ====================
superlu_dist_6.1.0.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/superlu_dist-6.1.0
Step superlu took 9.00 seconds.
==================== Installing PEXSI ====================
pexsi_v1.2.0.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/pexsi-1.2.0
Step pexsi took 80.00 seconds.
==================== Installing QUIP ====================
QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd
Step quip took 241.00 seconds.
==================== Installing gsl ====================
gsl-2.7.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/gsl-2.7
Step gsl took 62.00 seconds.
==================== Installing PLUMED ====================
plumed-2.7.3.tgz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/plumed-2.7.3
Step plumed took 50.00 seconds.
==================== Installing hdf5 ====================
hdf5-1.12.0.tar.bz2 is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/hdf5-1.12.0
Step hdf5 took 114.00 seconds.
Step libvdwxc took 0.00 seconds.
==================== Installing spglib ====================
spglib-1.16.2.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/spglib-1.16.2
Step spglib took 6.00 seconds.
==================== Installing libvori ====================
libvori-210412.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/libvori-210412
Step libvori took 19.00 seconds.
==================== Installing spfft ====================
SpFFT-1.0.5.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/SpFFT-1.0.5
Step spfft took 5.00 seconds.
==================== Installing spla ====================
SpLA-1.5.2.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/SpLA-1.5.2
Step spla took 8.00 seconds.
==================== Installing SIRIUS ====================
sirius_7.3.0.tar.gz is found
Installing from scratch into /home/hxu/cp2k-9.1/tools/toolchain/install/sirius-7.3.0
patching file cmake/cudalibs_target.cmake
Step sirius took 67.00 seconds.
==================== generating arch files ====================
arch files can be found in the /home/hxu/cp2k-9.1/tools/toolchain/install/arch subdirectory
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local.ssmp
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local_static.ssmp
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local.sdbg
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local.psmp
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local.pdbg
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local_static.psmp
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local_warn.psmp
Wrote /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/local_coverage.pdbg
========================== usage =========================
Done!
Now copy:
  cp /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/arch/* to the cp2k/arch/ directory
To use the installed tools and libraries and cp2k version
compiled with it you will first need to execute at the prompt:
  source /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/setup
To build CP2K you should change directory:
  cd cp2k/
  make -j 96 ARCH=local VERSION="ssmp sdbg psmp pdbg"

arch files for GPU enabled CUDA versions are named "local_cuda.*"
arch files for GPU enabled HIP versions are named "local_hip.*"
arch files for coverage versions are named "local_coverage.*"

Note that these pre-built arch files are for the GNU compiler, users have to adapt them for other compilers.
It is possible to use the provided CP2K arch files as guidance.
nozomiTojo@lovelive:~/cp2k-9.1/tools/toolchain$ 
复制成功

紧接着把~/cp2k-9.1/tools/toolchain/install/arch/下所有文件拷到~/cp2k-9.1/arch目录下

然后运行以下命令

代码块
JavaScript
自动换行
复制代码
source /home/nozomiTojo/cp2k-9.1/tools/toolchain/install/setup
cd /home/nozomiTojo/cp2k-9.1
make -j 96 ARCH=local VERSION="ssmp sdbg psmp pdbg"
复制成功

正式开始编译CP2K-9.1

代码块
JavaScript
自动换行
复制代码
nozomiTojo@lovelive:~/cp2k-9.1/tools/toolchain$  make -j 96 ARCH=local VERSION="ssmp sdbg psmp pdbg"
>>>>>>>>>>>>>>>>>>>>>>等待约5min>>>>>>>>>>>>>>>>>>>>>>>
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld:warning: libgfortran.so.3, needed by /usr/lib64/mpich/lib/libmpich.so.10, mayconflict with libgfortran.so.5
cd /home/nozomiTojo/softwares/cp2k-9.1/exe/local;ln -sf cp2k.psmp cp2k_shell.psmp
cd /home/nozomiTojo/softwares/cp2k-9.1/exe/local;ln -sf cp2k.psmp cp2k.popt
复制成功

测试,最重要的是psmp版本的CP2K

代码块
JavaScript
自动换行
复制代码
nozomiTojo@lovelive:~/cp2k-9.1/tools/toolchain$  make -j 96 ARCH=local VERSION="ssmp sdbg psmp pdbg" test
--------------------------------- Timings --------------------------------
Plot: name="timings", title="Timing Distribution", ylabel="time [s]"
PlotPoint: name="100th_percentile", plot="timings", label="100th %ile", y=73.89, yerr=0.0
PlotPoint: name="99th_percentile", plot="timings", label="99th %ile", y=30.819400000000098, yerr=0.0
PlotPoint: name="98th_percentile", plot="timings", label="98th %ile", y=20.51059999999989, yerr=0.0
PlotPoint: name="95th_percentile", plot="timings", label="95th %ile", y=12.764499999999998, yerr=0.0
PlotPoint: name="90th_percentile", plot="timings", label="90th %ile", y=8.28, yerr=0.0
PlotPoint: name="80th_percentile", plot="timings", label="80th %ile", y=4.358000000000001, yerr=0.0
--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 0
Number of CORRECT tests 3392
Total number of   tests 3392
GREPME 0 0 3392 0 3392 X
Summary: correct: 3392 / 3392; 9min
Status: OK
--------------------------------------------------------------------------
Regtest took 526.00 seconds.
--------------------------------------------------------------------------
*************************** testing ended ********************************
复制成功

最后是正式跑任务,跑一个173原子的AIMD,优于基本上都是金属原子,采用对角化方法。

代码块
JavaScript
自动换行
复制代码
 DBCSR| CPU Multiplication driver                                           XSMM
 DBCSR| Multrec recursion limit                                              512
 DBCSR| Multiplication stack size                                           1000
 DBCSR| Maximum elements for images                                    UNLIMITED
 DBCSR| Multiplicative factor virtual images                                   1
 DBCSR| Use multiplication densification                                       T
 DBCSR| Multiplication size stacks                                             3
 DBCSR| Use memory pool for CPU allocation                                     F
 DBCSR| Number of 3D layers                                               SINGLE
 DBCSR| Use MPI memory allocation                                              F
 DBCSR| Use RMA algorithm                                                      F
 DBCSR| Use Communication thread                                               T
 DBCSR| Communication thread load                                             87
 DBCSR| MPI: My node id                                                        0
 DBCSR| MPI: Number of nodes                                                  64
 DBCSR| OMP: Current number of threads                                         1
 DBCSR| OMP: Max number of threads                                             1
 DBCSR| Split modifier for TAS multiplication algorithm                  1.0E+00


  **** **** ******  **  PROGRAM STARTED AT               2022-01-06 17:34:15.707
 ***** ** ***  *** **   PROGRAM STARTED ON                      ce0303.para.bscc
 **    ****   ******    PROGRAM STARTED BY                                pg2090
 ***** **    ** ** **   PROGRAM PROCESS ID                                  9496
  **** **  *******  **  PROGRAM STARTED IN /public1/home/pg2090/D2T/pg2090/pg209
                                           0/test/cp2k-AIMD/Ni100-Fe4S4-CO2-H2

 CP2K| version string:                                          CP2K version 9.1
 CP2K| source code revision number:                                  git:d8d7100
 CP2K| cp2kflags: omp libint fftw3 libxc elpa parallel mpi3 scalapack quip xsmm 
 CP2K|            plumed2 spglib mkl sirius libvori libbqb
 CP2K| is freely available from                            https://www.cp2k.org/
 CP2K| Program compiled at                          Tue Jan  4 16:47:38 CST 2022
 CP2K| Program compiled on                                        ln71.para.bscc
 CP2K| Program compiled for                                                local
 CP2K| Data directory path                         /home/nozomiTojo/softwares/cp
 CP2K| Input file name                                                  cp2k.inp

 GLOBAL| Force Environment number                                              1
 GLOBAL| Basis set file name            /public1/home/pg2090/D2T/pg2090/pg2090/s
 GLOBAL| Potential file name            /public1/home/pg2090/D2T/pg2090/pg2090/s
 GLOBAL| MM Potential file name                                     MM_POTENTIAL
 GLOBAL| Coordinate file name                                      __STD_INPUT__
 GLOBAL| Method name                                                        CP2K
 GLOBAL| Project name                                                       cp2k
 GLOBAL| Run type                                                             MD
 GLOBAL| FFT library                                                       FFTW3
 GLOBAL| Diagonalization library                                            ELPA
 GLOBAL| Minimum number of eigenvectors for ELPA usage                        16
 GLOBAL| Orthonormality check for eigenvectors                          DISABLED
 GLOBAL| Matrix multiplication library                                 ScaLAPACK
 GLOBAL| All-to-all communication in single precision                          F
 GLOBAL| FFTs using library dependent lengths                                  F
 GLOBAL| Grid backend                                                       AUTO
 GLOBAL| Global print level                                                  LOW
 GLOBAL| MPI I/O enabled                                                       T
 GLOBAL| Total number of message passing processes                            64
 GLOBAL| Number of threads for this process                                    1
 GLOBAL| This output is from process                                           0
 GLOBAL| Stack size for threads created by OpenMP (OMP_STACKSIZE)        default
 GLOBAL| CPU model name             Intel(R) Xeon(R) Platinum 9242 CPU @ 2.30GHz
 GLOBAL| CPUID                                                              1003

 MEMORY| system memory details [Kb]
 MEMORY|                        rank 0           min           max       average
 MEMORY| MemTotal            394848216     394848216     394848216     394848216
 MEMORY| MemFree             358622876     358622600     358622876     358622604
 MEMORY| Buffers                     0             0             0             0
 MEMORY| Cached               10143584      10143364      10143584      10143367
 MEMORY| Slab                  1361612       1361580       1361612       1361583
 MEMORY| SReclaimable           281200        281168        281200        281171
 MEMORY| MemLikelyFree       369047660     369047132     369047660     369047143


 GENERATE|  Preliminary Number of Bonds generated:                             0
 GENERATE|  Achieved consistency in connectivity generation.

 *******************************************************************************
 *******************************************************************************
 **                                                                           **
 **     #####                         ##              ##                      **
 **    ##   ##            ##          ##              ##                      **
 **   ##     ##                       ##            ######                    **
 **   ##     ##  ##   ##  ##   #####  ##  ##   ####   ##    #####    #####    **
 **   ##     ##  ##   ##  ##  ##      ## ##   ##      ##   ##   ##  ##   ##   **
 **   ##  ## ##  ##   ##  ##  ##      ####     ###    ##   ######   ######    **
 **    ##  ###   ##   ##  ##  ##      ## ##      ##   ##   ##       ##        **
 **     #######   #####   ##   #####  ##  ##  ####    ##    #####   ##        **
 **           ##                                                    ##        **
 **                                                                           **
 **                                                ... make the atoms dance   **
 **                                                                           **
 **            Copyright (C) by CP2K developers group (2000-2021)             **
 **                      J. Chem. Phys. 152, 194103 (2020)                    **
 **                                                                           **
 *******************************************************************************


 TOTAL NUMBERS AND MAXIMUM NUMBERS

  Total number of            - Atomic kinds:                                   6
                             - Atoms:                                        173
                             - Shell sets:                                   173
                             - Shells:                                      1353
                             - Primitive Cartesian functions:               1025
                             - Cartesian basis functions:                   5192
                             - Spherical basis functions:                   4365

  Maximum angular momentum of- Orbital basis functions:                        3
                             - Local part of the GTH pseudopotential:          2
                             - Non-local part of the GTH pseudopotential:      3


 SCF PARAMETERS         Density guess:                                   RESTART
                        --------------------------------------------------------
                        max_scf:                                             500
                        max_scf_history:                                       0
                        max_diis:                                              4
                        --------------------------------------------------------
                        eps_scf:                                        3.00E-06
                        eps_scf_history:                                0.00E+00
                        eps_diis:                                       1.00E-01
                        eps_eigval:                                     1.00E-05
                        --------------------------------------------------------
                        level_shift [a.u.]:                                 0.00
                        added MOs                                       500  500
                        --------------------------------------------------------
                        Mixing method:                            BROYDEN_MIXING
                                                charge density mixing in g-space
                        --------------------------------------------------------
                        Smear method:                                FERMI_DIRAC
                        Electronic temperature [K]:                        300.0
                        Electronic temperature [a.u.]:                  9.50E-04
                        Accuracy threshold:                             1.00E-10
                        --------------------------------------------------------
                        Outer loop SCF in use 
                        No variables optimised in outer loop
                        eps_scf                                         1.00E-05
                        max_scf                                                4
                        No outer loop optimization
                        step_size                                       5.00E-01

 MD_PAR| Molecular dynamics protocol (MD input parameters)
 MD_PAR| Ensemble type                                                       NVT
 MD_PAR| Number of time steps                                             500000
 MD_PAR| Time step [fs]                                                 0.500000
 MD_PAR| Temperature [K]                                              600.000000
 MD_PAR| Temperature tolerance [K]                                      0.000000
 MD_PAR| Constraints activated
 MD_PAR| Tolerance for shake                                            0.000001
 MD_PAR| Print MD information every                                    1 step(s)
 MD_PAR| File type   Print frequency [steps]                          File names
 MD_PAR| Coordinates          1                                   cp2k-pos-1.xyz
 MD_PAR| Velocities           1                                   cp2k-vel-1.xyz
 MD_PAR| Energies             1                                      cp2k-1.ener
 MD_PAR| Dump                20                                   cp2k-1.restart

 ROT| Rotational analysis information
 ROT| Principal axes and moments of inertia [a.u.]
 ROT|                           1                   2                   3
 ROT| Eigenvalues      1.28006357352E+09   1.84053523676E+09   2.51370587038E+09
 ROT|      x              0.999989770475      0.001922990665      0.004094026402
 ROT|      y             -0.001851975145      0.999848977558     -0.017279822480
 ROT|      z             -0.004126637049      0.017272063681      0.999842310909
 ROT| Number of rotovibrational vectors                                        6

 DOF| Calculation of degrees of freedom
 DOF| Number of atoms                                                        173
 DOF| Number of intramolecular constraints                                   240
 DOF| Number of intermolecular constraints                                     0
 DOF| Invariants (translations + rotations)                                    3
 DOF| Degrees of freedom                                                     276

 DOF| Restraints information
 DOF| Number of intramolecular restraints                                      0
 DOF| Number of intermolecular restraints                                      0

 THERMOSTAT| Thermostat information for PARTICLES
 THERMOSTAT| Type of thermostat                               Nose-Hoover-Chains
 THERMOSTAT| Nose-Hoover-Chain length                                          3
 THERMOSTAT| Nose-Hoover-Chain time constant [fs]                      33.356410
 THERMOSTAT| Order of Yoshida integrator                                       3
 THERMOSTAT| Number of multiple time steps                                     2
 THERMOSTAT| Initial potential energy                         0.000000000000E+00
 THERMOSTAT| Initial kinetic energy                           0.950044602986E-03
 THERMOSTAT| End of thermostat information for PARTICLES

 MD_VEL| Velocities initialization
 MD_VEL| Initial temperature [K]                                      600.000000
 MD_VEL| COM velocity             0.0000000000    -0.0000000000    -0.0000000000

 Spin 1

 Number of electrons:                                                       1493
 Number of occupied orbitals:                                               1493
 Number of molecular orbitals:                                              1993

 Spin 2

 Number of electrons:                                                       1493
 Number of occupied orbitals:                                               1493
 Number of molecular orbitals:                                              1993

 Number of orbital functions:                                               4365
 Number of independent orbital functions:                                   4365

 Extrapolation method: initial_guess

 *** WARNING in qs_initial_guess.F:309 :: User requested to restart the    ***
 *** wavefunction from the file named: cp2k-RESTART.wfn. This file does    ***
 *** not exist. Please check the existence of the file or change properly  ***
 *** the value of the keyword WFN_RESTART_FILE_NAME. Calculation continues ***
 *** using ATOMIC GUESS.                                                   ***



 SCF WAVEFUNCTION OPTIMIZATION

  Step     Update method      Time    Convergence         Total energy    Change
  ------------------------------------------------------------------------------
     1 NoMix/Diag. 0.10E+00    3.8     0.98981243    -27709.5377999228 -2.77E+04
     2 Broy./Diag. 0.10E+00    4.5     0.94791197    -27116.8815093516  5.93E+02
     3 Broy./Diag. 0.10E+00    4.5     0.25130183    -27315.3799838482 -1.98E+02
     4 Broy./Diag. 0.10E+00    4.5     0.16735894    -27365.8869319842 -5.05E+01
     5 Broy./Diag. 0.10E+00    4.6     0.63917314    -27426.6855833155 -6.08E+01
     6 Broy./Diag. 0.10E+00    4.6     0.19357095    -27541.1558850289 -1.14E+02
     7 Broy./Diag. 0.10E+00    4.6     0.56734511    -27631.6869384625 -9.05E+01
复制成功

完全成功,收工!