#CPQA DEPENDS H2O_H2_pbe_mp2.inp
!  RPA (H2) embedded in PBE (H2 and H2O):
!  restart from the previously optimized
!  embedding potential (H2O_H2_pbe.inp)
&GLOBAL
  PREFERRED_DIAG_LIBRARY SL
  PRINT_LEVEL HIGH
  PROJECT h2o_h2_pbe_rpa_restart
  RUN_TYPE ENERGY
&END GLOBAL

&MULTIPLE_FORCE_EVALS
  FORCE_EVAL_ORDER 2 3 4 5
  MULTIPLE_SUBSYS T
&END MULTIPLE_FORCE_EVALS

&FORCE_EVAL
  METHOD EMBED
  &EMBED
    NGROUPS 1
    &MAPPING
      &FORCE_EVAL 1
        &FRAGMENT 1
          1 3
          MAP 1
        &END FRAGMENT
      &END FORCE_EVAL
      &FORCE_EVAL 2
        &FRAGMENT 1
          1 2
          MAP 2
        &END FRAGMENT
      &END FORCE_EVAL
      &FORCE_EVAL 3
        &FRAGMENT 1
          1 5
          MAP 3
        &END FRAGMENT
      &END FORCE_EVAL
      &FORCE_EVAL 4
        &FRAGMENT 1
          1 2
          MAP 2
        &END FRAGMENT
      &END FORCE_EVAL
      &FORCE_EVAL_EMBED
        &FRAGMENT 1
          1 3
        &END FRAGMENT
        &FRAGMENT 2
          4 5
        &END FRAGMENT
        &FRAGMENT 3
          1 5
        &END FRAGMENT
      &END FORCE_EVAL_EMBED
    &END MAPPING
  &END EMBED
  &SUBSYS
    &CELL
      ABC [angstrom] 5.000 5.000 5.000
    &END CELL
    &COORD
      O      1.75  1.5  0.0
      H      1.0   1.0  0.0
      H      2.5   1.0  0.0
      H      1.75  2.75  0.0
      H      1.75  3.50 0.0
    &END COORD
    &KIND H
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q1
    &END KIND
    &KIND O
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

! Subsys 1
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME BASIS_RI_cc-TZ
    POTENTIAL_FILE_NAME HF_POTENTIALS
    &MGRID
      CUTOFF 100
      REL_CUTOFF 20
    &END MGRID
    &POISSON
    &END POISSON
    &QS
      EPS_DEFAULT 1.0E-5
      METHOD GPW
    &END QS
    &SCF
      EPS_SCF 0.001
      SCF_GUESS ATOMIC
      &OT
        PRECONDITIONER FULL_ALL
      &END OT
      &PRINT
        &RESTART OFF
        &END RESTART
      &END PRINT
    &END SCF
    &XC
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom] 5.000 5.000 5.000
    &END CELL
    &COORD
      O      1.75  1.5  0.0
      H      1.0   1.0  0.0
      H      2.5   1.0  0.0
    &END COORD
    &KIND H
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q1
    &END KIND
    &KIND O
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

! Subsys 2
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME BASIS_RI_cc-TZ
    POTENTIAL_FILE_NAME HF_POTENTIALS
    &MGRID
      CUTOFF 100
      REL_CUTOFF 20
    &END MGRID
    &POISSON
    &END POISSON
    &QS
      CLUSTER_EMBED_SUBSYS .TRUE.
      EPS_DEFAULT 1.0E-5
      METHOD GPW
    &END QS
    &SCF
      EPS_SCF 0.001
      MAX_SCF 100
      &OT
        PRECONDITIONER FULL_ALL
      &END OT
      &PRINT
        &RESTART OFF
        &END RESTART
      &END PRINT
    &END SCF
    &XC
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom] 5.000 5.000 5.000
    &END CELL
    &COORD
      H      1.75  2.75  0.0
      H      1.75  3.50 0.0
    &END COORD
    &KIND H
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q1
    &END KIND
    &KIND O
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

! Total system
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME BASIS_RI_cc-TZ
    POTENTIAL_FILE_NAME HF_POTENTIALS
    &MGRID
      CUTOFF 100
      REL_CUTOFF 20
    &END MGRID
    &POISSON
    &END POISSON
    &PRINT
      &E_DENSITY_CUBE LOW
      &END E_DENSITY_CUBE
    &END PRINT
    &QS
      EPS_DEFAULT 1.0E-5
      METHOD GPW
      REF_EMBED_SUBSYS .TRUE.
      &OPT_EMBED
        DENS_CONV_INT 0.5
        DENS_CONV_MAX 0.025
        EMBED_RESTART_FILE_NAME h2o_h2_pbe_mp2-embed_pot_002-1_0.wfn
        GRID_OPT .FALSE.
        N_ITER 3
        OPTIMIZER QUASI_NEWTON
        READ_EMBED_POT .TRUE.
        REG_LAMBDA 0.00001
      &END OPT_EMBED
    &END QS
    &SCF
      EPS_SCF 0.001
      SCF_GUESS ATOMIC
      &OT
        PRECONDITIONER FULL_ALL
      &END OT
      &PRINT
        &RESTART OFF
        &END RESTART
      &END PRINT
    &END SCF
    &XC
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom] 5.000 5.000 5.000
    &END CELL
    &COORD
      O      1.75  1.5  0.0
      H      1.0   1.0  0.0
      H      2.5   1.0  0.0
      H      1.75  2.75  0.0
      H      1.75  3.50 0.0
    &END COORD
    &KIND H
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q1
    &END KIND
    &KIND O
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

! Higher level calculation on subsys 2
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME BASIS_RI_cc-TZ
    POTENTIAL_FILE_NAME HF_POTENTIALS
    &MGRID
      CUTOFF 100
      REL_CUTOFF 20
    &END MGRID
    &POISSON
    &END POISSON
    &QS
      EPS_DEFAULT 1.0E-5
      EPS_PGF_ORB 1.0E-30
      HIGH_LEVEL_EMBED_SUBSYS
      METHOD GPW
    &END QS
    &SCF
      EPS_SCF 0.001
      SCF_GUESS ATOMIC
      &OT
        PRECONDITIONER FULL_ALL
      &END OT
    &END SCF
    &XC
      &WF_CORRELATION
        MEMORY 200.
        NUMBER_PROC 1
        &INTEGRALS
          &WFC_GPW
            CUTOFF 100
            REL_CUTOFF 20
          &END WFC_GPW
        &END INTEGRALS
        &RI_RPA
          MINIMAX
          RPA_NUM_QUAD_POINTS 8
          &HF
            FRACTION 1.0000000
            &SCREENING
              EPS_SCHWARZ 1.0E-8
              SCREEN_ON_INITIAL_P FALSE
            &END SCREENING
          &END HF
        &END RI_RPA
      &END WF_CORRELATION
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom] 5.000 5.000 5.000
    &END CELL
    &COORD
      H      1.75  2.75  0.0
      H      1.75  3.50 0.0
    &END COORD
    &KIND H
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q1
    &END KIND
    &KIND O
      BASIS_SET cc-TZ
      BASIS_SET RI_AUX RI_TZ
      POTENTIAL GTH-HF-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL
