#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
  PROJECT  h2o_h2_pbe_rpa_restart
  PRINT_LEVEL HIGH
  RUN_TYPE ENERGY
  PREFERRED_DIAG_LIBRARY SL
&END GLOBAL
&MULTIPLE_FORCE_EVALS
   FORCE_EVAL_ORDER 2 3 4 5
   MULTIPLE_SUBSYS T
&END
&FORCE_EVAL
    METHOD EMBED
    &EMBED
       NGROUPS 1
       &MAPPING
          &FORCE_EVAL_EMBED
             &FRAGMENT 1
                1 3
             &END
             &FRAGMENT 2
                4 5
             &END
             &FRAGMENT 3
                1 5
             &END
          &END
          &FORCE_EVAL 1
             &FRAGMENT 1
                1 3
                MAP 1
              &END
          &END
          &FORCE_EVAL 2
             &FRAGMENT 1
                1 2
                MAP 2
             &END
          &END
          &FORCE_EVAL 3
             &FRAGMENT 1
                1 5
                MAP 3
              &END
          &END
          &FORCE_EVAL 4
             &FRAGMENT 1
                1 2
                MAP 2
             &END
          &END
       &END
    &END EMBED
  &SUBSYS
    &CELL
      ABC [angstrom]  5.000   5.000  5.000
    &END CELL
    &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
    &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
  &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
      METHOD GPW
      EPS_DEFAULT 1.0E-5
    &END QS
    &SCF
      &OT
       PRECONDITIONER FULL_ALL
      &END
      SCF_GUESS ATOMIC
      EPS_SCF 0.001
      &PRINT
        &RESTART OFF
        &END
      &END
    &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
    &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
    &COORD
  O      1.75  1.5  0.0
  H      1.0   1.0  0.0
  H      2.5   1.0  0.0
    &END
  &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.
      METHOD GPW
      EPS_DEFAULT 1.0E-5
    &END QS
    &SCF
      &OT
       PRECONDITIONER FULL_ALL
      &END
      EPS_SCF 0.001
      MAX_SCF 100
      &PRINT
        &RESTART OFF
        &END
      &END
    &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
    &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
    &COORD
  H      1.75  2.75  0.0
  H      1.75  3.50 0.0
    &END
  &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
    &PRINT
       &E_DENSITY_CUBE LOW
       &END
    &END
    &MGRID
      CUTOFF  100
      REL_CUTOFF  20
    &END MGRID
    &POISSON
    &END POISSON
    &QS
      REF_EMBED_SUBSYS .TRUE.
      METHOD GPW
      EPS_DEFAULT 1.0E-5
      &OPT_EMBED
         REG_LAMBDA 0.00001
         N_ITER 3
         DENS_CONV_INT 0.5
         DENS_CONV_MAX 0.025
         READ_EMBED_POT .TRUE.
         EMBED_RESTART_FILE_NAME h2o_h2_pbe_mp2-embed_pot_002-1_0.wfn
         OPTIMIZER QUASI_NEWTON
         GRID_OPT .FALSE.
      &END
    &END QS
    &SCF
      &OT
       PRECONDITIONER FULL_ALL
      &END
      SCF_GUESS ATOMIC
      EPS_SCF 0.001
      &PRINT
        &RESTART OFF
        &END
      &END
    &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
    &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
    &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
  &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
      HIGH_LEVEL_EMBED_SUBSYS
      METHOD GPW
      EPS_DEFAULT 1.0E-5
      EPS_PGF_ORB 1.0E-30
    &END QS
    &SCF
      &OT
       PRECONDITIONER FULL_ALL
      &END
      SCF_GUESS ATOMIC
      EPS_SCF 0.001
    &END
    &XC
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
      &WF_CORRELATION
        &INTEGRALS
          &WFC_GPW
            CUTOFF  100
            REL_CUTOFF 20
          &END WFC_GPW
        &END INTEGRALS
        &RI_RPA
          RPA_NUM_QUAD_POINTS 8
          MINIMAX
          &HF
            FRACTION 1.0000000
            &SCREENING
              EPS_SCHWARZ 1.0E-8
              SCREEN_ON_INITIAL_P FALSE
            &END SCREENING
          &END HF
        &END RI_RPA
        MEMORY  200.
        NUMBER_PROC  1
      &END
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC [angstrom]  5.000   5.000  5.000
    &END CELL
    &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
    &COORD
  H      1.75  2.75  0.0
  H      1.75  3.50 0.0
    &END
  &END SUBSYS
&END FORCE_EVAL

