! h2o_gapw_allelectron.inp - all-electron GAPW calculation of H2O (PBE)
! Tutorial: CP2K chapter 3, section 9.  Works with CP2K 2023.x - 2026.2.
!
! GAPW (&QS METHOD GAPW) + all-electron basis + POTENTIAL ALL. No pseudopotential:
! O has 8 and H has 1 electron(s), 10 electrons in total.
!
! Variable AEB selects the all-electron basis (both files below are read):
!   SVP-MOLOPT-PBE-ae   (default; alias SVP-MOLOPT-GGA-ae, file BASIS_MOLOPT_UZH)
!   TZVPP-MOLOPT-PBE-ae (alias TZVPP-MOLOPT-GGA-ae, file BASIS_MOLOPT_UZH)
!   6-31Gx              (= 6-31G*, file EMSL_BASIS_SETS)
!
!   cp2k.ssmp -i h2o_gapw_allelectron.inp -o h2o_gapw_svp.out
!   cp2k.ssmp -E AEB=TZVPP-MOLOPT-PBE-ae -i h2o_gapw_allelectron.inp -o h2o_gapw_tzvpp.out
!   cp2k.ssmp -E AEB=6-31Gx -i h2o_gapw_allelectron.inp -o h2o_gapw_631gs.out
!
! GAPW parameters follow the tested values of the official GAPW documentation
! example; tighten or loosen them only after checking the electron count.

&GLOBAL
  PROJECT h2o_gapw_${AEB-SVP-MOLOPT-PBE-ae}
  RUN_TYPE ENERGY
  PRINT_LEVEL MEDIUM
&END GLOBAL

&FORCE_EVAL
  METHOD QS
  &DFT
    BASIS_SET_FILE_NAME BASIS_MOLOPT_UZH
    BASIS_SET_FILE_NAME EMSL_BASIS_SETS
    POTENTIAL_FILE_NAME ALL_POTENTIALS
    &MGRID
      CUTOFF 800              ! the soft density still needs a fine grid in GAPW
      REL_CUTOFF 80
    &END MGRID
    &QS
      METHOD GAPW             ! default is GPW
      EPS_DEFAULT 1.0E-12
      EPSFIT 1.0E-6           ! hard/soft split of the Gaussian exponents (default 1.0E-4)
      EPSRHO0 1.0E-8          ! range of the hard compensation density (default 1.0E-6)
      EPSSVD 1.0E-10          ! SVD tolerance for the projectors (default 1.0E-8)
    &END QS
    &POISSON
      PERIODIC NONE
      POISSON_SOLVER MT
    &END POISSON
    &SCF
      EPS_SCF 1.0E-6
      MAX_SCF 30
      &OT ON
        MINIMIZER DIIS
        PRECONDITIONER FULL_SINGLE_INVERSE
      &END OT
      &OUTER_SCF ON
        EPS_SCF 1.0E-6
        MAX_SCF 10
      &END OUTER_SCF
    &END SCF
    &XC
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
    &PRINT
      &MOMENTS ON
        PERIODIC .FALSE.
        REFERENCE COM
      &END MOMENTS
    &END PRINT
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom] 10.0 10.0 10.0
      PERIODIC NONE
    &END CELL
    &COORD
      O   0.000000   0.000000   0.117300
      H   0.000000   0.756990  -0.468540
      H   0.000000  -0.756990  -0.468540
    &END COORD
    &TOPOLOGY
      &CENTER_COORDINATES
      &END CENTER_COORDINATES
    &END TOPOLOGY
    &KIND O
      BASIS_SET ${AEB-SVP-MOLOPT-PBE-ae}
      POTENTIAL ALL           ! full nuclear potential, all 8 electrons
      LEBEDEV_GRID 110        ! angular points of the atom-centred grid (default 50)
      RADIAL_GRID 80          ! radial points of the atom-centred grid (default 50)
    &END KIND
    &KIND H
      BASIS_SET ${AEB-SVP-MOLOPT-PBE-ae}
      POTENTIAL ALL
      LEBEDEV_GRID 110
      RADIAL_GRID 80
    &END KIND
  &END SUBSYS
&END FORCE_EVAL
