****
CP2K
****

.. py:class:: CP2K

This interface supports energy and gradient evaluations with the
`CP2K <https://www.cp2k.org/>`_ electronic structure package
(version 8.1.0 or later)

A CP2K :ref:`Theory <theories>` object can be specified as follows::

  my_frag = Fragment(...)

  my_theory = CP2K(frag=my_frag,
                   functional='PBE',
                   basis='DZVP-GTH-PADE',
                   ...)

which would then be called as ``theory=my_theory`` in subsequent tasks 
(see :ref:`Tasks <tasks>`).

General options
===============

.. py:attribute:: basis
   :noindex:

   (default: ``'DZVP'``) CP2K basis set name

   Allowed types of value:

   * A Python :py:class:`str` for basis set name, for example: ``'DZVP-GTH-PADE'``

   * A Python :py:class:`dict` of element---to---basis-set mapping, for example: ``{'Pd':'SZV-MOLOPT-SR-GTH', 'O':'TZV2P-MOLOPT-GTH'}``

.. py:attribute:: basis_file

   (default: ``''``) CP2K basis set filename: when this is not specified, ChemShell will try to search into the CP2K data library

   Allowed types of value:

   * A Python :py:class:`str` for filename, for example: ``'BASIS_SET'``

   * A Python :py:class:`list` of multiple filenames, for example: ``[ 'BASIS_SET', 'BASIS_MOLOPT' ]``

.. py:attribute:: diag_method

   Algorithm for diagonalization. Allowed values are ``'DAVIDSON'``, ``'FILTER_MATRIX'``, ``'LANCZOS'``, ``'OT'``, and ``'STANDARD'`` (default)

.. py:attribute:: functional
   :noindex:

   Allowed values are ``'B3LYP'``, ``'BEEFVDW'``, ``'BLYP'``, ``'BP'``, ``'HCTH120'``, ``'LDA'``, ``'NONE'``, ``'NO_SHORTCUT'``, ``'OLYP'``, ``'PADE'`` (default), ``'PBE'``, ``'PBE0'``, and ``'TPSS'``

.. py:attribute:: grid_cutoff

   (default: ``280.0`` Rydberg) The cutoff of the finest grid level. See: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/MGRID.html>`__

.. py:attribute:: grid_real_cutoff

   (default: ``40.0`` Rydberg) The grid at which a Gaussian is mapped

.. py:attribute:: guess
   :noindex:

   (default: ``'ATOMIC'``) Initial guess for SCF if the job is not a restarted one

.. py:attribute:: input
   :noindex:

   (default: ``'_cp2k.inp'``) Filename of CP2K input script

.. py:attribute:: kpoints_method

   (default: ``'MONKHORST-PACK'``) K-points scheme to be used. Available options are ``'NONE'``, ``'GAMMA'``, ``'MONKHORST-PACK'``, ``'MACDONALD'``, and ``'GENERAL'``

.. py:attribute:: lattice_scale

   (default: ``1.0000``) Used for scaling the non-periodic vector in :ref:`qmme` only

.. py:attribute:: maxiter_outer

   (default: ``50``) Maximum number of iterations for :py:attr:`outer SCF <outer_scf>`

.. py:attribute:: mixing_alpha

   (default: ``0.3``) Fraction of new density to be included. The default value is ``0.4`` in CP2K, see: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/SCF/MIXING.html#list_ALPHA>`__

.. py:attribute:: mixing_method

   Allowed values are ``'BROYDEN_MIXING'``, ``'BROYDEN_MIXING_NEW'``, ``'DIRECT_P_MIXING'`` (default), ``'KERKER_MIXING'``, ``'MULTISECANT_MIXING'``, ``'NONE'``, and ``'PULAY_MIXING'``. For the 2nd QM energy evaluation (without adsorbate) in :ref:`qmme`, only ``'DIRECT_P_MIXING'`` can be used

.. py:attribute:: mixing_gmix_p

   (default: ``False``) Toggle the mixing of the density matrix, see `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/SCF/MIXING.html#GMIX_P>`__

.. py:attribute:: ngrids

   (default: ``4``) The number of multigrids to use

.. py:attribute:: nmos_added

   (default: ``10``) Number of additional MOs added for each spin. For the QM energy evaluation in :ref:`qmme`, smearing should be switched on in order to avoid numerical instabilities due to discontunuous occupation numbers around the Fermi level.  When smearing is used, make sure to use a basis set which provides enough vacant orbitals so that ``nmos_added`` does not exceed the maximum unoccupied orbitals. In CP2K it is defaulted to ``0``, see: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/SCF.html#ADDED_MOS>`__

.. py:attribute:: outer_scf

   (default: ``False``) Toggle outer SCF loop

.. py:attribute:: output
   :noindex:

   (default: ``'_cp2k.out'``) Name of CP2K output file

.. py:attribute:: periodic

   (default: ``'XYZ'``) For :ref:`qmme` calculations 2D periodicity is imposed and the value for :py:attr:`periodic` is automatically detected (``XY``, ``XZ``, or ``YZ``) according to the system's orientation. This value also determines the :py:attr:`Poisson solver <poisson_solver>` 

.. py:attribute:: poisson_solver

   (default: ``'PERIODIC'``) ``'PERIODIC'`` is only available for 3D systems. For :ref:`qmme` calculations, ChemShell automatically determines which method to use:

   * ``'ANALYTIC'``: When :py:attr:`periodic` is ``'XY'`` or ``'YZ'``

   * ``'WAVELET'``: When :py:attr:`periodic` is ``'XZ'``

.. py:attribute:: potential_file

   (default: ``''``) Name of pseudo potential file. ChemShell will find one according to :py:attr:`pseudopotential` from the CP2K data library if the value is ``''``

.. py:attribute:: precision_all

   (default: ``1.0E-10``) A universal EPS energy criterion for Quickstep (QS)

.. py:attribute:: precision_gvg

   (default: ``1.0E-8``) Precision of the real-space Kohn-Sham matrix element integration for Quickstep (QS)

.. py:attribute:: precision_rho

   (default: ``1.0E-10``) Precision of the density mapping on the grids for Quickstep (QS)

.. py:attribute:: smear

   (default: ``True``) Toggle DFT SCF smearing, see: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/SCF/SMEAR.html>`__

.. py:attribute:: smear_method

   Allowed values:

   * ``'ENERGY_WINDOW'``: (default) See also :py:attr:`smear_temperature` and :py:attr:`smear_window`

   * ``'FERMI_DIRAC'``: This is the default method for :ref:`qmme` calculations

   * ``'LIST'``: Use a fixed list of occupations


.. py:attribute:: smear_temperature

   (default: ``300.0`` Kelvin) Electronic temperature in the case of ``'FERMI-DIRAC'`` :py:attr:`smearing method <smear_method>`

.. py:attribute:: smear_window

   (default: ``0.02`` Hartree) In CP2K it is ``0.0`` by default but we use ``0.02`` for :ref:`qmme`

.. py:attribute:: symmetry

   Allowed values:

   * ``'auto'``: (default) Let ChemShell automatically detect the system's symmetry. Available symmetries are: CUBIC, HEXAGONAL, MONOCLINIC, MONOCLINIC_GAMMA_AB, ORTHORHOMBIC, RHOMBOHEDRAL, TETRAGONAL_AB, TETRAGONAL_AC, TETRAGONAL_BC, TRICLINIC, and NONE

   * ``''`` or ``None`` or ``False``: No symmetry

.. py:attribute:: wavefunction

   (default: ``'_cp2k.wfn'``) Wavefunction restart filename

.. py:attribute:: xc_derivative

   (default: ``'SPLINE2_SMOOTH'``) The method used to compute the XC derivatives. Defaulted to ``'PW'`` in CP2K, see: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/XC/XC_GRID.html#list_XC_DERIV>`__

.. py:attribute:: xc_finer_grid

   (default: ``False``) Uses a finer grid only to calculate the XC

.. py:attribute:: xc_smooth_rho

   (default: ``'SPLINE2'``) Density smoothing method used for the XC calculation. ``'NONE'`` by default in CP2K, see: `CP2K Manual <https://manual.cp2k.org/trunk/CP2K_INPUT/FORCE_EVAL/DFT/XC/XC_GRID.html#XC_SMOOTH_RHO>`__






