@SET Project        H28_k
@SET V_bias_volt    0.0
@SET Temperature    10.0
# The following two parameters are computed automatically during the NEGF run.
# You can use keywords 'FERMI_LEVEL' to give this value and skip calculation
# or 'FERMI_LEVEL'+'REFINE_FERMI_LEVEL' to compute starting from this value.
# If 'FERMI_LEVEL' is not given, it is calculated automatically.
# 'V_SHIFT' is used to give initial value.
@SET Fermi_level   -0.22306350 #-0.23822635 #-0.22306350 #
@SET V_shift        0.00011009 # 0.00010984 # 0.00011009 #
@SET basis_set_path BASIS_SET
! BASIS_MOLOPT BASIS_SET
@SET potential_path GTH_POTENTIALS
@SET xc_functional  pade
!PBE pade
@SET cutoff         100
@SET added_mos      -1
@SET max_scf        100
@SET eps_scf        1e-9
@SET lx             6.0
@SET ly             6.0
!--------------------------------------------------------------------------------------------------!
&GLOBAL
  EXTENDED_FFT_LENGTHS .true.
  PREFERRED_DIAG_LIBRARY SL
  PRINT_LEVEL LOW  #SILENT #LOW #MEDIUM #HIGH #DEBUG
  PROJECT ${Project}
  RUN_TYPE NEGF
&END GLOBAL

&MULTIPLE_FORCE_EVALS
  # Order in which the input file parser internally stores different force environments.
  #
  # 'FORCE_EVAL_ORDER 1 2 3' means that the 1st force environment --
  # which holds the entire system -- will have the internal index '0',
  # while the 2nd and 3rd force environments -- which correspond to the
  # 1st and 2nd semi-infinite electrodes respectively -- will have
  # the internal indices '1' and '2'. Note that internal indices start from 0.
  #
  FORCE_EVAL_ORDER 1 2 3
  # Different force environments contain non-identical molecular structures.
  # By default, the input parser ignores 'subsys' sections from all but the force
  # environment with the internal index '0'.
  MULTIPLE_SUBSYS .true.
&END MULTIPLE_FORCE_EVALS

&NEGF
  # Integration lower bound (in Hartree)
  ENERGY_LBOUND -2.0
  !clenshaw-curtis simpson
  # Maximum error in each matrix element of the density matrix
  EPS_DENSITY 1e-5
  EPS_GREEN 1e-5
  EPS_SCF 1e-5
  ETA 1e-5
  # 'simpson' is slower, but works without FFTW3 library
  # clenshaw-curtis is faster, but requires FFTW3 library
  INTEGRATION_METHOD simpson
  MAX_SCF 100
  # Number of parallel processes per energy point.
  # 'NPROC_POINT 1' means that if you run this job using 8 MPI processes,
  # than Green's functions at up to 8 (8 / NPROC_POINT) energy points
  # will be computed simultaneously.
  #
  NPROC_POINT 1
  # Boundary conditions define solution of the Poisson equation up to
  # an additive constant, which affects Hamiltonian matrix elements within
  # the NEGF procedure. The following parameters control evaluation of
  # the correct shift in Hartree potential:
  #   * V_SHIFT           -- initial guess for the shift
  #   * V_SHIFT_MAX_ITERS -- maximal number of iterations
  V_SHIFT ${V_shift}
  V_SHIFT_MAX_ITERS 100
  &CONTACT
    #  REFINE_FERMI_LEVEL
    ELECTRIC_POTENTIAL [eV] ${V_bias_volt}/2
    FERMI_LEVEL ${Fermi_level}
    # the force environment with the internal index '1' should be used
    # to compute 'bulk' properties of this (1st) semi-infinite electrode.
    FORCE_EVAL_SECTION 1
    TEMPERATURE [K] ${Temperature}
    &BULK_REGION
      # This section is used to map matrix elements between the primary
      # (with index 0) and the 'electrode' (with index 1) force environments.
      #
      # Atomic indices (and/or names of molecular fragments) are relative
      # to the primary force environment.
      MOLNAME L1 L2
      !LIST 1..8
      &CELL
        MOLNAME L1
        !LIST 5..8
      &END CELL
      &CELL
        MOLNAME L2
        !LIST 1..4
      &END CELL
    &END BULK_REGION
    &SCREENING_REGION
      MOLNAME L0
      !LIST 9..12
    &END SCREENING_REGION
  &END CONTACT
  &CONTACT
    #  REFINE_FERMI_LEVEL
    ELECTRIC_POTENTIAL [eV] -${V_bias_volt}/2
    FERMI_LEVEL ${Fermi_level}
    # the second semi-infinite electrode
    FORCE_EVAL_SECTION 2
    TEMPERATURE [K] ${Temperature}
    &BULK_REGION
      MOLNAME R1 R2
      &CELL
        MOLNAME R1
      &END CELL
      &CELL
        MOLNAME R2
      &END CELL
    &END BULK_REGION
    &SCREENING_REGION
      MOLNAME R0
    &END SCREENING_REGION
  &END CONTACT
  # Density mixing is not needed in zero-bias case, as NEGF self-consistent
  # procedure will converge in one iteration. However, when an external bias
  # is applied, a density mixing scheme in inverse space is typically
  # much stable then the default direct mixing of new and old density matrices.
  &MIXING
    ALPHA 0.2
    METHOD broyden_mixing
    NBUFFER 8
  &END MIXING
  &PRINT
    &DOS
      FILENAME device
      FROM_ENERGY [eV] -15
      N_GRIDPOINTS 401
      TILL_ENERGY [eV] 15
    &END DOS
    &PROGRAM_RUN_INFO low
      PRINT_LEVEL debug
      ! high debug
    &END PROGRAM_RUN_INFO
    &TRANSMISSION
      FILENAME transm
      FROM_ENERGY [eV] -15
      N_GRIDPOINTS 401
      TILL_ENERGY [eV] 15
    &END TRANSMISSION
  &END PRINT
  &SCATTERING_REGION
    MOLNAME S
    !LIST 13..16
  &END SCATTERING_REGION
  #DISABLE_CACHE
&END NEGF

# *** Primary force environment ***
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME ${basis_set_path}
    POTENTIAL_FILE_NAME ${potential_path}
    &MGRID
      CUTOFF ${cutoff}
    &END MGRID
    &POISSON
      PERIODIC xyz
    &END POISSON
    &SCF
      !atomic restart
      ADDED_MOS ${added_mos}
      EPS_SCF ${eps_scf}
      MAX_SCF ${max_scf}
      SCF_GUESS restart
      &MIXING
        ALPHA 0.3
        METHOD broyden_mixing
        NBUFFER 8
      &END MIXING
      &PRINT
        &RESTART
          FILENAME RESTART_0
        &END RESTART
        #&PROGRAM_RUN_INFO silent
        #&END
        #&DETAILED_ENERGY silent
        #&END
      &END PRINT
      &SMEAR
        ELECTRONIC_TEMPERATURE [K] ${Temperature}
        METHOD fermi_dirac
      &END SMEAR
    &END SCF
    &XC
      &XC_FUNCTIONAL ${xc_functional}
      &END XC_FUNCTIONAL
    &END XC
  &END DFT
  &SUBSYS
    &CELL
      ABC ${lx} ${ly} 42.
      PERIODIC xyz
    &END CELL
    &COORD
      #     H        0.00000000       0.00000000      10.50000000 L1
      #     H        0.00000000       0.00000000       9.00000000 L1
      #     H        0.00000000       0.00000000       7.50000000 L1
      #     H        0.00000000       0.00000000       6.00000000 L1
      #     H        0.00000000       0.00000000       4.50000000 L2
      #     H        0.00000000       0.00000000       3.00000000 L2
      #     H        0.00000000       0.00000000       1.50000000 L2
      #     H        0.00000000       0.00000000       0.00000000 L2
      #     H        0.00000000       0.00000000      16.50000000 L0
      #     H        0.00000000       0.00000000      15.00000000 L0
      #     H        0.00000000       0.00000000      13.50000000 L0
      #     H        0.00000000       0.00000000      12.00000000 L0
      H        0.00000000       0.00000000       0.00000000 L2
      H        0.00000000       0.00000000       1.50000000 L2
      H        0.00000000       0.00000000       3.00000000 L2
      H        0.00000000       0.00000000       4.50000000 L2
      H        0.00000000       0.00000000       6.00000000 L1
      H        0.00000000       0.00000000       7.50000000 L1
      H        0.00000000       0.00000000       9.00000000 L1
      H        0.00000000       0.00000000      10.50000000 L1
      H        0.00000000       0.00000000      12.00000000 L0
      H        0.00000000       0.00000000      13.50000000 L0
      H        0.00000000       0.00000000      15.00000000 L0
      H        0.00000000       0.00000000      16.50000000 L0
      H        0.00000000       0.00000000      18.00000000 S
      H        0.00000000       0.00000000      19.50000000 S
      H        0.00000000       0.00000000      21.00000000 S
      H        0.00000000       0.00000000      22.50000000 S
      H        0.00000000       0.00000000      24.00000000 R0
      H        0.00000000       0.00000000      25.50000000 R0
      H        0.00000000       0.00000000      27.00000000 R0
      H        0.00000000       0.00000000      28.50000000 R0
      H        0.00000000       0.00000000      30.00000000 R1
      H        0.00000000       0.00000000      31.50000000 R1
      H        0.00000000       0.00000000      33.00000000 R1
      H        0.00000000       0.00000000      34.50000000 R1
      H        0.00000000       0.00000000      36.00000000 R2
      H        0.00000000       0.00000000      37.50000000 R2
      H        0.00000000       0.00000000      39.00000000 R2
      H        0.00000000       0.00000000      40.50000000 R2
      #  H        0.00000000       0.00000000      42.00000000 R3
      #  H        0.00000000       0.00000000      43.50000000 R3
      #  H        0.00000000       0.00000000      45.00000000 R3
      #  H        0.00000000       0.00000000      46.50000000 R3
      #  H        0.00000000       0.00000000      48.00000000 R4
      #  H        0.00000000       0.00000000      49.50000000 R4
      #  H        0.00000000       0.00000000      51.00000000 R4
      #  H        0.00000000       0.00000000      52.50000000 R4
    &END COORD
    &KIND H
      BASIS_SET SZV-GTH-PADE
      ! SZV-GTH-PADE DZV-ALL-PADE DZVP-ALL-PADE SZV-MOLOPT-GTH
      POTENTIAL GTH-PADE-q1
      !GTH-PADE-q1 GTH-PBE-q1
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

# *** The 1st (left) semi-infinite electrode ***
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME ${basis_set_path}
    POTENTIAL_FILE_NAME ${potential_path}
    &KPOINTS
      SCHEME MONKHORST-PACK 1 1 14
    &END KPOINTS
    &MGRID
      CUTOFF ${cutoff}
    &END MGRID
    &POISSON
      PERIODIC xyz
    &END POISSON
    &SCF
      !atomic restart
      ADDED_MOS ${added_mos}
      EPS_SCF ${eps_scf}
      MAX_SCF ${max_scf}
      SCF_GUESS restart
      &MIXING
        ALPHA 0.2
        METHOD broyden_mixing
        NBUFFER 8
      &END MIXING
      &PRINT
        &RESTART
          FILENAME RESTART_1
        &END RESTART
      &END PRINT
      &SMEAR
        ELECTRONIC_TEMPERATURE [K] ${Temperature}
        METHOD fermi_dirac
      &END SMEAR
    &END SCF
    &XC
      &XC_FUNCTIONAL ${xc_functional}
      &END XC_FUNCTIONAL
    &END XC
    #   &PRINT
    #     &S_CSR_WRITE
    #       REAL_SPACE
    #       FILENAME=L
    #     &END
    #     &KS_CSR_WRITE
    #       REAL_SPACE
    #     &END
    #   &END PRINT
  &END DFT
  &SUBSYS
    # a primary unit cell of the 1st semi-infinite electrode
    &CELL
      ABC ${lx} ${ly} 6.00000000
      PERIODIC xyz
    &END CELL
    &COORD
      #    H        0.00000000       0.00000000      10.50000000 L1
      #    H        0.00000000       0.00000000       9.00000000 L1
      #    H        0.00000000       0.00000000       7.50000000 L1
      #    H        0.00000000       0.00000000       6.00000000 L1
      H        0.00000000       0.00000000       6.00000000 L1
      H        0.00000000       0.00000000       7.50000000 L1
      H        0.00000000       0.00000000       9.00000000 L1
      H        0.00000000       0.00000000      10.50000000 L1
    &END COORD
    &KIND H
      BASIS_SET SZV-GTH-PADE
      ! SZV-GTH-PADE DZV-ALL-PADE DZVP-ALL-PADE SZV-MOLOPT-GTH
      POTENTIAL GTH-PADE-q1
      !GTH-PADE-q1 GTH-PBE-q1
    &END KIND
    &TOPOLOGY
      ! COORD_FILE_FORMAT XYZ
      ! COORD_FILE_NAME ${COORD_FILE_NAME}.xyz
      ! &CENTER_COORDINATES
      !   CENTER_POINT 0. 0. 0.
      ! &END
    &END TOPOLOGY
  &END SUBSYS
&END FORCE_EVAL

# *** The 2nd (right) semi-infinite electrode ***
&FORCE_EVAL
  METHOD Quickstep
  &DFT
    BASIS_SET_FILE_NAME ${basis_set_path}
    POTENTIAL_FILE_NAME ${potential_path}
    &KPOINTS
      SCHEME MONKHORST-PACK 1 1 14
    &END KPOINTS
    &MGRID
      CUTOFF ${cutoff}
    &END MGRID
    &POISSON
      PERIODIC xyz
    &END POISSON
    &SCF
      !atomic
      ADDED_MOS ${added_mos}
      EPS_SCF ${eps_scf}
      MAX_SCF ${max_scf}
      SCF_GUESS restart
      &MIXING
        ALPHA 0.2
        METHOD broyden_mixing
        NBUFFER 8
      &END MIXING
      &PRINT
        &RESTART
          FILENAME RESTART_2
        &END RESTART
      &END PRINT
      &SMEAR
        ELECTRONIC_TEMPERATURE [K] ${Temperature}
        METHOD fermi_dirac
      &END SMEAR
    &END SCF
    &XC
      &XC_FUNCTIONAL ${xc_functional}
      &END XC_FUNCTIONAL
    &END XC
    #  &PRINT
    #    &S_CSR_WRITE
    #      REAL_SPACE
    #      FILENAME=R
    #    &END
    #    &KS_CSR_WRITE
    #      REAL_SPACE
    #    &END
    #  &END PRINT
  &END DFT
  &SUBSYS
    # a primary unit cell of the 2st semi-infinite electrode
    &CELL
      ABC ${lx} ${ly} 6.00000000
      PERIODIC xyz
    &END CELL
    &COORD
      #    H        0.00000000       0.00000000      34.50000000 R1
      #    H        0.00000000       0.00000000      33.00000000 R1
      #    H        0.00000000       0.00000000      31.50000000 R1
      #    H        0.00000000       0.00000000      30.00000000 R1
      H        0.00000000       0.00000000      30.00000000 R1
      H        0.00000000       0.00000000      31.50000000 R1
      H        0.00000000       0.00000000      33.00000000 R1
      H        0.00000000       0.00000000      34.50000000 R1
      #    H        0.00000000       0.00000000      36.00000000 R2
      #    H        0.00000000       0.00000000      37.50000000 R2
      #    H        0.00000000       0.00000000      39.00000000 R2
      #    H        0.00000000       0.00000000      40.50000000 R2
      #    H        0.00000000       0.00000000      42.00000000 R3
      #    H        0.00000000       0.00000000      43.50000000 R3
      #    H        0.00000000       0.00000000      45.00000000 R3
      #    H        0.00000000       0.00000000      46.50000000 R3
    &END COORD
    &KIND H
      BASIS_SET SZV-GTH-PADE
      ! SZV-GTH-PADE DZV-ALL-PADE DZVP-ALL-PADE SZV-MOLOPT-GTH
      POTENTIAL GTH-PADE-q1
      !GTH-PADE-q1 GTH-PBE-q1
    &END KIND
  &END SUBSYS
&END FORCE_EVAL
