LCOV - code coverage report
Current view: top level - vgen - vis_xc.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 24 25 96.0 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.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             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       8             : ! This file is part of FLEUR and available as free software under the conditions
       9             : ! of the MIT license as expressed in the LICENSE file in more detail.
      10             : !--------------------------------------------------------------------------------
      11             : MODULE m_vis_xc
      12             :    USE m_juDFT
      13             :    use m_convol
      14             :    !     ******************************************************
      15             :    !     subroutine generates the exchange-correlation potential
      16             :    !     in the interstitial region    c.l.fu
      17             :    !     including gradient corrections. t.a. 1996.
      18             :    !     ******************************************************
      19             : CONTAINS
      20         170 :    SUBROUTINE vis_xc(stars,sym,cell,den,xcpot,input,noco,EnergyDen,vTot,vx,exc)
      21             : 
      22             :       !     ******************************************************
      23             :       !     instead of visxcor.f: the different exchange-correlation
      24             :       !     potentials defined through the key icorr are called through
      25             :       !     the driver subroutine vxcallg.f,for the energy density - excallg
      26             :       !     subroutines vectorized
      27             :       !     ** r.pentcheva 22.01.96
      28             :       !     *********************************************************
      29             :       !     in case of total = .true. calculates the ex-corr. energy
      30             :       !     density
      31             :       !     ** r.pentcheva 08.05.96
      32             :       !     ******************************************************************
      33             :       USE m_pw_tofrom_grid
      34             :       USE m_types
      35             :       USE m_types_xcpot_libxc
      36             :       USE m_libxc_postprocess_gga
      37             :       USE m_metagga
      38             :       IMPLICIT NONE
      39             : 
      40             :       CLASS(t_xcpot),INTENT(INOUT)  :: xcpot
      41             :       TYPE(t_input),INTENT(IN)      :: input
      42             :       TYPE(t_noco),INTENT(IN)       :: noco
      43             :       TYPE(t_sym),INTENT(IN)        :: sym
      44             :       TYPE(t_stars),INTENT(IN)      :: stars
      45             :       TYPE(t_cell),INTENT(IN)       :: cell
      46             :       TYPE(t_potden),INTENT(IN)  :: den, EnergyDen
      47             :       TYPE(t_potden),INTENT(INOUT)  :: vTot,vx,exc
      48             : 
      49         170 :       TYPE(t_gradients) :: grad, tmp_grad
      50         170 :       REAL, ALLOCATABLE :: rho(:,:), ED_rs(:,:), vTot_rs(:,:)
      51             :       REAL, ALLOCATABLE :: rho_conv(:,:), ED_conv(:,:), vTot_conv(:,:)
      52         340 :       REAL, ALLOCATABLE :: v_x(:,:),v_xc(:,:),e_xc(:,:)
      53             :       INTEGER           :: jspin, i, js
      54             :       LOGICAL           :: perform_MetaGGA
      55             : 
      56             :       perform_MetaGGA = ALLOCATED(EnergyDen%mt) &
      57         170 :                       .AND. (xcpot%exc_is_MetaGGA() .or. xcpot%vx_is_MetaGGA())
      58         170 :       CALL init_pw_grid(xcpot,stars,sym,cell)
      59             : 
      60             :       !Put the charge on the grid, in GGA case also calculate gradients
      61         170 :       CALL pw_to_grid(xcpot,input%jspins,noco%l_noco,stars,cell,den%pw,grad,rho)
      62             : 
      63         170 :       ALLOCATE(v_xc,mold=rho)
      64         170 :       ALLOCATE(v_x,mold=rho)
      65             : 
      66         170 :       if(perform_MetaGGA .and. xcpot%kinED%set) then
      67           0 :          CALL xcpot%get_vxc(input%jspins,rho,v_xc, v_x,grad, kinED_KS=xcpot%kinED%is)
      68             :       else
      69         170 :          CALL xcpot%get_vxc(input%jspins,rho,v_xc,v_x,grad)
      70             :       endif
      71             : 
      72         170 :       IF (xcpot%needs_grad()) THEN
      73             :          SELECT TYPE(xcpot)
      74             :          TYPE IS (t_xcpot_libxc)
      75          20 :             CALL libxc_postprocess_gga_pw(xcpot,stars,cell,v_xc,grad)
      76             :          END SELECT
      77             :       ENDIF
      78             :       !Put the potentials in rez. space.
      79         170 :       CALL  pw_from_grid(xcpot,stars,input%total,v_xc,vTot%pw,vTot%pw_w)
      80         170 :       CALL  pw_from_grid(xcpot,stars,input%total,v_x,vx%pw,vx%pw_w)
      81             : 
      82             :       !calculate the ex.-cor energy density
      83         170 :       IF (ALLOCATED(exc%pw_w)) THEN
      84         170 :          ALLOCATE ( e_xc(SIZE(rho,1),1) ); e_xc=0.0
      85             : 
      86         170 :          IF(xcpot%kinED%set) THEN
      87          49 :             CALL xcpot%get_exc(input%jspins,rho,e_xc(:,1),grad, xcpot%kinED%is, mt_call=.False.)
      88             :          ELSE
      89         121 :             CALL xcpot%get_exc(input%jspins,rho,e_xc(:,1),grad, mt_call=.False.)
      90             :          ENDIF
      91         170 :          CALL pw_from_grid(xcpot,stars,.TRUE.,e_xc,exc%pw,exc%pw_w)
      92             :       ENDIF
      93             : 
      94         170 :       CALL finish_pw_grid()
      95         340 :    END SUBROUTINE vis_xc
      96         181 : END MODULE m_vis_xc

Generated by: LCOV version 1.13