! This is a standard input for CP2K.
! Before running, first export the following environmental variable:
! export CP2K_DATA_DIR=/cp2k_path/data/

@SET sysname 11
 
&GLOBAL
  RUN_TYPE               CELL_OPT
  PROJECT_NAME           ${sysname}
  PRINT_LEVEL            LOW
  PREFERRED_DIAG_LIBRARY SL
&END GLOBAL

&MOTION
  &GEO_OPT
    MAX_ITER       1000
    STEP_START_VAL 0    
  &END GEO_OPT   
  &CELL_OPT
    MAX_ITER           1000    
    EXTERNAL_PRESSURE  1.01325 ! External pressure for cell optimization (bar)
    CONSTRAINT         NONE    ! Can be e.g. Z, XY to fix corresponding cell length
    KEEP_ANGLES        F       ! If T, then cell angles will be kepted
    KEEP_SYMMETRY      F       ! If T, crystal symmetry will be kepted, and symmetry should be specified in &CELL
    TYPE               DIRECT_CELL_OPT ! Geometry and cell are optimized at the same time. Can also be GEO_OPT, MD
    PRESSURE_TOLERANCE 100             ! Pressure tolerance (w.r.t EXTERNAL_PRESSURE)
  &END CELL_OPT  
  &PRINT
    &RESTART_HISTORY
      &EACH
        CELL_OPT 100
        GEO_OPT  100
        MD       100
      &END EACH
    &END RESTART_HISTORY
  &END PRINT
&END MOTION

&FORCE_EVAL
  METHOD QS
  STRESS_TENSOR ANALYTICAL ! Pressure will be calculated.

  ! DFT configuration: PBE-D3.
  &DFT
    CHARGE       0
    MULTIPLICITY 1
    ! LSD                           ! Uncomment this for unrestricted calculations.
    BASIS_SET_FILE_NAME BASIS_MOLOPT
    POTENTIAL_FILE_NAME GTH_POTENTIALS
    &XC
      DENSITY_CUTOFF   1.E-10
      GRADIENT_CUTOFF  1.E-10
      TAU_CUTOFF       1.E-10
      &XC_FUNCTIONAL NO_SHORTCUT
        &PBE T
        &END PBE
      &END XC_FUNCTIONAL
      &VDW_POTENTIAL
        POTENTIAL_TYPE  PAIR_POTENTIAL
        &PAIR_POTENTIAL
          R_CUTOFF             10
          TYPE                 DFTD3
          PARAMETER_FILE_NAME  dftd3.dat
          REFERENCE_FUNCTIONAL PBE
        &END PAIR_POTENTIAL
      &END VDW_POTENTIAL
    &END XC    
    &SCF
      SCF_GUESS RESTART
      MAX_SCF   100
      EPS_SCF   1.E-6
      &OT ON
        PRECONDITIONER FULL_SINGLE_INVERSE
        MINIMIZER      DIIS
      &END
      &OUTER_SCF
        MAX_SCF 500
        EPS_SCF 1.E-6
      &END OUTER_SCF
    &END SCF
    &MGRID
      CUTOFF 420 ! Sometimes larger is needed.
    &END MGRID     
  &END DFT
  
  ! Structures.
  &SUBSYS
    &TOPOLOGY
      COORD_FILE_FORMAT CIF             ! XYZ, CIF
      COORD_FILE_NAME   ${sysname}.cif
      CONNECTIVITY      OFF
      &CENTER_COORDINATES
      &END CENTER_COORDINATES
    &END TOPOLOGY
    &CELL
      PERIODIC XYZ 
      CELL_FILE_FORMAT CIF
      CELL_FILE_NAME   ${sysname}.cif
    &END CELL

    ! Basis.
    &KIND Ca
      BASIS_SET DZVP-MOLOPT-SR-GTH
      POTENTIAL GTH-PBE-q10
    &END KIND
    &KIND Cl
      BASIS_SET DZVP-MOLOPT-SR-GTH
      POTENTIAL GTH-PBE-q7
    &END KIND
    &KIND C
      BASIS_SET DZVP-MOLOPT-SR-GTH
      POTENTIAL GTH-PBE-q4
    &END KIND
    &KIND O
      BASIS_SET DZVP-MOLOPT-SR-GTH
      POTENTIAL GTH-PBE-q6
    &END KIND
    &KIND H
      BASIS_SET DZVP-MOLOPT-SR-GTH
      POTENTIAL GTH-PBE-q1
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

