LCOV - code coverage report
Current view: top level - hybrid - hybrid.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 49 0.0 %
Date: 2019-09-08 04:53:50 Functions: 0 1 0.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             : MODULE m_calc_hybrid
       8             : 
       9             :    USE m_judft
      10             : 
      11             : CONTAINS
      12             : 
      13           0 :    SUBROUTINE calc_hybrid(eig_id, hybrid, kpts, atoms, input, DIMENSION, mpi, noco, cell, oneD, &
      14             :                           enpara, results, sym, xcpot, v, iter, iterHF)
      15             : 
      16             :       USE m_types
      17             :       USE m_mixedbasis
      18             :       USE m_coulombmatrix
      19             :       USE m_hf_init
      20             :       USE m_hf_setup
      21             :       USE m_hsfock
      22             :       USE m_eig66_io
      23             :       USE m_io_hybrid
      24             : 
      25             :       IMPLICIT NONE
      26             : 
      27             :       TYPE(t_xcpot_inbuild), INTENT(IN)    :: xcpot
      28             :       TYPE(t_mpi), INTENT(IN)    :: mpi
      29             :       TYPE(t_dimension), INTENT(IN)    :: DIMENSION
      30             :       TYPE(t_oneD), INTENT(IN)    :: oneD
      31             :       TYPE(t_hybrid), INTENT(INOUT) :: hybrid
      32             :       TYPE(t_input), INTENT(IN)    :: input
      33             :       TYPE(t_noco), INTENT(IN)    :: noco
      34             :       TYPE(t_enpara), INTENT(IN)    :: enpara
      35             :       TYPE(t_results), INTENT(INOUT) :: results
      36             :       TYPE(t_sym), INTENT(IN)    :: sym
      37             :       TYPE(t_cell), INTENT(IN)    :: cell
      38             :       TYPE(t_kpts), INTENT(IN)    :: kpts
      39             :       TYPE(t_atoms), INTENT(IN)    :: atoms
      40             :       TYPE(t_potden), INTENT(IN)    :: v
      41             : 
      42             :       INTEGER, INTENT(IN)    :: iter
      43             :       INTEGER, INTENT(INOUT) :: iterHF
      44             :       INTEGER, INTENT(IN)    :: eig_id
      45             : 
      46             :       ! local variables
      47             :       INTEGER           :: jsp, nk, nred
      48           0 :       TYPE(t_hybdat)    :: hybdat
      49           0 :       type(t_lapw)      :: lapw
      50             :       LOGICAL           :: init_vex = .TRUE. !In first call we have to init v_nonlocal
      51             :       LOGICAL           :: l_restart = .FALSE.
      52             :       LOGICAL           :: l_zref
      53             : 
      54             :       REAL              :: bkpt(3)
      55           0 :       REAL, ALLOCATABLE :: eig_irr(:, :)
      56             : 
      57           0 :       CALL timestart("Hybrid code")
      58           0 :       INQUIRE (file="v_x.mat", exist=hybrid%l_addhf)
      59           0 :       CALL open_hybrid_io1(DIMENSION, sym%invs)
      60             : 
      61           0 :       IF (kpts%nkptf == 0) THEN
      62             :          CALL judft_error("kpoint-set of full BZ not available", &
      63           0 :                           hint="to generate kpts in the full BZ you should specify a k-mesh in inp.xml")
      64             :       END IF
      65             : 
      66             :       !Check if new non-local potential shall be generated
      67           0 :       hybrid%l_subvxc = hybrid%l_hybrid .AND. (.NOT. xcpot%is_name("exx"))
      68             :       !If this is the first iteration loop we can not calculate a new non-local potential
      69           0 :       hybrid%l_calhf = (results%last_distance >= 0.0) .AND. (results%last_distance < input%minDistance)
      70           0 :       IF (.NOT. hybrid%l_calhf) THEN
      71           0 :          hybrid%l_subvxc = hybrid%l_subvxc .AND. hybrid%l_addhf
      72           0 :          CALL timestop("Hybrid code")
      73           0 :          RETURN
      74             :       ENDIF
      75             : 
      76           0 :       results%te_hfex%core = 0
      77             : 
      78             :       !Check if we are converged well enough to calculate a new potential
      79           0 :       CALL open_hybrid_io1b(DIMENSION, sym%invs)
      80           0 :       hybrid%l_addhf = .TRUE.
      81             : 
      82             :       !In first iteration allocate some memory
      83           0 :       IF (init_vex) THEN
      84           0 :          ALLOCATE (hybrid%ne_eig(kpts%nkpt), hybrid%nbands(kpts%nkpt), hybrid%nobd(kpts%nkptf))
      85           0 :          ALLOCATE (hybrid%nbasm(kpts%nkptf))
      86           0 :          ALLOCATE (hybrid%div_vv(DIMENSION%neigd, kpts%nkpt, input%jspins))
      87           0 :          init_vex = .FALSE.
      88             :       END IF
      89             : 
      90           0 :       hybrid%l_subvxc = (hybrid%l_subvxc .AND. hybrid%l_addhf)
      91           0 :       IF (.NOT. ALLOCATED(results%w_iks)) ALLOCATE (results%w_iks(DIMENSION%neigd2, kpts%nkpt, input%jspins))
      92             : 
      93           0 :       IF (hybrid%l_calhf) THEN
      94           0 :          iterHF = iterHF + 1
      95             : 
      96             :          !Delete broyd files
      97           0 :          CALL system("rm -f broyd*")
      98             : 
      99             :          !check if z-reflection trick can be used
     100             : 
     101           0 :          l_zref = (sym%zrfs .AND. (SUM(ABS(kpts%bk(3, :kpts%nkpt))) < 1e-9) .AND. .NOT. noco%l_noco)
     102             : 
     103           0 :          CALL timestart("Preparation for Hybrid functionals")
     104             :          !    CALL juDFT_WARN ("Hybrid functionals not working in this version")
     105             : 
     106             :          !construct the mixed-basis
     107           0 :          CALL timestart("generation of mixed basis")
     108           0 :          CALL mixedbasis(atoms, kpts, dimension, input, cell, sym, xcpot, hybrid, enpara, mpi, v, l_restart)
     109           0 :          CALL timestop("generation of mixed basis")
     110             : 
     111           0 :          CALL open_hybrid_io2(hybrid, DIMENSION, atoms, sym%invs)
     112             : 
     113           0 :          CALL coulombmatrix(mpi, atoms, kpts, cell, sym, hybrid, xcpot, l_restart)
     114             : 
     115           0 :          CALL hf_init(hybrid, kpts, atoms, input, DIMENSION, hybdat, sym%invs)
     116           0 :          CALL timestop("Preparation for Hybrid functionals")
     117           0 :          CALL timestart("Calculation of non-local HF potential")
     118           0 :          DO jsp = 1, input%jspins
     119           0 :             call timestart("HF_setup")
     120             :             CALL HF_setup(hybrid, input, sym, kpts, dimension, atoms, mpi, noco, cell, oneD, results, jsp, enpara, eig_id, &
     121           0 :                           hybdat, iterHF, sym%invs, v%mt(:, 0, :, :), eig_irr)
     122           0 :             call timestop("HF_setup")
     123             : 
     124           0 :             DO nk = 1, kpts%nkpt
     125             :                !DO nk = mpi%n_start,kpts%nkpt,mpi%n_stride
     126           0 :                CALL lapw%init(input, noco, kpts, atoms, sym, nk, cell, l_zref)
     127             :                CALL hsfock(nk, atoms, hybrid, lapw, DIMENSION, kpts, jsp, input, hybdat, eig_irr, sym, cell, &
     128           0 :                            noco, results, iterHF, MAXVAL(hybrid%nobd), xcpot, mpi)
     129             :             END DO
     130             :          END DO
     131           0 :          CALL timestop("Calculation of non-local HF potential")
     132           0 :          CALL close_eig(eig_id)
     133             : 
     134             :       ENDIF
     135           0 :       CALL timestop("Hybrid code")
     136           0 :    END SUBROUTINE calc_hybrid
     137             : END MODULE m_calc_hybrid

Generated by: LCOV version 1.13