LCOV - code coverage report
Current view: top level - types - types_xcpot.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 33 67 49.3 %
Date: 2019-09-08 04:53:50 Functions: 7 20 35.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             : !> This module defines two data-types used in the calculation of xc-potentials
       7             : !! a) the abstract t_xcpot which should be overwritten for actual implementations
       8             : !! b) the t_gradients that collects the gradients needed in GGAs
       9             : !!
      10             : !! Currently t_xcpot_inbuild implements the XC-pots directly build into FLEUR
      11             : !! and t_xcpot_libxc provides and interface to libxc.
      12             : !! In addition to overloading the t_xcpot datatype also mpi_bc_xcpot must be adjusted
      13             : !! for additional implementations.
      14             : MODULE m_types_xcpot
      15             :    use m_types_potden
      16             :    IMPLICIT NONE
      17             :    PRIVATE
      18             :    PUBLIC           :: t_xcpot,t_gradients
      19             : 
      20             :    TYPE t_kinED
      21             :       logical             :: set
      22             :       real, allocatable   :: is(:,:)   ! (nsp*jmtd, jspins)
      23             :       real, allocatable   :: mt(:,:,:) ! (nsp*jmtd, jspins, local num of types)
      24             :    contains
      25             :       procedure           :: alloc_mt => kED_alloc_mt
      26             :    END TYPE t_kinED
      27             : 
      28             :    TYPE,ABSTRACT :: t_xcpot
      29             :       REAL :: gmaxxc
      30             :       TYPE(t_kinED)    :: kinED
      31             :    CONTAINS
      32             :       PROCEDURE        :: vxc_is_LDA => xcpot_vxc_is_LDA
      33             :       PROCEDURE        :: vxc_is_GGA => xcpot_vxc_is_GGA
      34             : 
      35             :       PROCEDURE        :: vx_is_LDA     => xcpot_vx_is_LDA
      36             :       PROCEDURE        :: vx_is_GGA     => xcpot_vx_is_GGA
      37             :       PROCEDURE        :: vx_is_MetaGGA => xcpot_vx_is_MetaGGA
      38             : 
      39             :       PROCEDURE        :: vc_is_LDA => xcpot_vc_is_LDA
      40             :       PROCEDURE        :: vc_is_GGA => xcpot_vc_is_GGA
      41             : 
      42             :       PROCEDURE        :: exc_is_LDA     => xcpot_exc_is_LDA
      43             :       PROCEDURE        :: exc_is_GGA     => xcpot_exc_is_GGA
      44             :       PROCEDURE        :: exc_is_MetaGGA => xcpot_exc_is_MetaGGA
      45             : 
      46             :       PROCEDURE        :: needs_grad => xcpot_needs_grad
      47             :       PROCEDURE        :: is_hybrid  => xcpot_is_hybrid
      48             : 
      49             :       PROCEDURE        :: get_exchange_weight => xcpot_get_exchange_weight
      50             :       PROCEDURE        :: get_vxc             => xcpot_get_vxc
      51             :       PROCEDURE        :: get_exc             => xcpot_get_exc
      52             :       PROCEDURE,NOPASS :: alloc_gradients     => xcpot_alloc_gradients
      53             :    END TYPE t_xcpot
      54             : 
      55             :    TYPE t_gradients
      56             :       !Naming convention:
      57             :       !t,u,d as last letter for total,up,down
      58             :       !agr for absolute value of gradient
      59             :       !g2r for laplacien of gradient
      60             :       !+??
      61             :       REAL,ALLOCATABLE :: agrt(:),agru(:),agrd(:)
      62             :       REAL,ALLOCATABLE :: g2ru(:),g2rd(:),gggrt(:)
      63             :       REAL,ALLOCATABLE :: gggru(:),gzgr(:),g2rt(:)
      64             :       REAL,ALLOCATABLE :: gggrd(:),grgru(:),grgrd(:)
      65             :       !These are the contracted Gradients used in libxc
      66             :       REAL,ALLOCATABLE :: sigma(:,:)
      67             :       REAL,ALLOCATABLE :: vsigma(:,:)
      68             :       REAL,ALLOCATABLE :: gr(:,:,:)
      69             :       REAL,ALLOCATABLE :: laplace(:,:)
      70             :    END TYPE t_gradients
      71             : CONTAINS
      72         340 :    subroutine kED_alloc_mt(kED,nsp_x_jmtd, jspins, n_start, n_types, n_stride)
      73             :       implicit none
      74             :       class(t_kinED), intent(inout)   :: kED
      75             :       integer, intent(in)            :: nsp_x_jmtd, jspins, n_start, n_types, n_stride
      76             :       integer                        :: cnt, n
      77             :       
      78         340 :       if(.not. allocated(kED%mt)) then
      79          66 :          cnt = 0
      80         139 :          do n = n_start,n_types,n_stride
      81          66 :             cnt = cnt + 1
      82             :          enddo
      83          66 :          allocate(kED%mt(nsp_x_jmtd, jspins, cnt), source=0.0)
      84             :       endif
      85         340 :    end subroutine kED_alloc_mt
      86             : 
      87             :    ! LDA
      88           0 :    LOGICAL FUNCTION xcpot_vc_is_LDA(xcpot)
      89             :       IMPLICIT NONE
      90             :       CLASS(t_xcpot),INTENT(IN):: xcpot
      91           0 :       xcpot_vc_is_LDA=.false.
      92           0 :    END FUNCTION xcpot_vc_is_LDA
      93             : 
      94           0 :    LOGICAL FUNCTION xcpot_vx_is_LDA(xcpot)
      95             :       IMPLICIT NONE
      96             :       CLASS(t_xcpot),INTENT(IN):: xcpot
      97           0 :       xcpot_vx_is_LDA=.false.
      98           0 :    END FUNCTION xcpot_vx_is_LDA
      99             :    
     100          24 :    LOGICAL FUNCTION xcpot_vxc_is_LDA(xcpot)
     101             :       IMPLICIT NONE
     102             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     103          24 :       xcpot_vxc_is_LDA = xcpot%vx_is_LDA() .and. xcpot%vc_is_LDA()
     104          24 :    END FUNCTION xcpot_vxc_is_LDA
     105             : 
     106           0 :    LOGICAL FUNCTION xcpot_exc_is_LDA(xcpot)
     107             :       IMPLICIT NONE
     108             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     109           0 :       xcpot_exc_is_LDA=.false.
     110           0 :    END FUNCTION xcpot_exc_is_LDA
     111             : 
     112             :    ! GGA
     113           0 :    LOGICAL FUNCTION xcpot_vc_is_GGA(xcpot)
     114             :       IMPLICIT NONE
     115             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     116           0 :       xcpot_vc_is_GGA=.false.
     117           0 :    END FUNCTION xcpot_vc_is_GGA
     118             : 
     119           0 :    LOGICAL FUNCTION xcpot_vx_is_GGA(xcpot)
     120             :       IMPLICIT NONE
     121             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     122           0 :       xcpot_vx_is_GGA=.false.
     123           0 :    END FUNCTION xcpot_vx_is_GGA
     124             :    
     125         986 :    LOGICAL FUNCTION xcpot_vxc_is_gga(xcpot)
     126             :       IMPLICIT NONE
     127             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     128         986 :       xcpot_vxc_is_gga= xcpot%vx_is_GGA() .and. xcpot%vc_is_GGA()
     129         986 :    END FUNCTION xcpot_vxc_is_gga
     130             : 
     131           0 :    LOGICAL FUNCTION xcpot_exc_is_gga(xcpot)
     132             :       IMPLICIT NONE
     133             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     134           0 :       xcpot_exc_is_gga=.false.
     135           0 :    END FUNCTION xcpot_exc_is_gga
     136             : 
     137       18836 :    LOGICAL FUNCTION xcpot_vx_is_MetaGGA(xcpot)
     138             :       IMPLICIT NONE
     139             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     140       18836 :       xcpot_vx_is_MetaGGA=.false.
     141       18836 :    END FUNCTION xcpot_vx_is_MetaGGA
     142             : 
     143        1235 :    LOGICAL FUNCTION xcpot_exc_is_MetaGGA(xcpot)
     144             :       IMPLICIT NONE
     145             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     146        1235 :       xcpot_exc_is_MetaGGA=.false.
     147        1235 :    END FUNCTION xcpot_exc_is_MetaGGA
     148             : 
     149     1660200 :    LOGICAL FUNCTION xcpot_needs_grad(xcpot)
     150             :       IMPLICIT NONE
     151             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     152             : 
     153     1660200 :       xcpot_needs_grad= xcpot%vc_is_gga() .or. xcpot%vx_is_MetaGGA()
     154     1660200 :    END FUNCTION xcpot_needs_grad
     155             : 
     156           0 :    LOGICAL FUNCTION xcpot_is_hybrid(xcpot)
     157             :       IMPLICIT NONE
     158             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     159           0 :       xcpot_is_hybrid=.FALSE.
     160           0 :    END FUNCTION xcpot_is_hybrid
     161             : 
     162           0 :    FUNCTION xcpot_get_exchange_weight(xcpot) RESULT(a_ex)
     163             :       USE m_judft
     164             :       IMPLICIT NONE
     165             :       CLASS(t_xcpot),INTENT(IN):: xcpot
     166             :       REAL:: a_ex
     167           0 :       a_ex=-1
     168           0 :    END FUNCTION xcpot_get_exchange_weight
     169             : 
     170           0 :    SUBROUTINE xcpot_get_vxc(xcpot,jspins,rh,vxc,vx,grad, kinED_KS)
     171             :       USE m_judft
     172             :       IMPLICIT NONE
     173             : 
     174             :       CLASS(t_xcpot),INTENT(IN) :: xcpot
     175             :       INTEGER, INTENT (IN)     :: jspins
     176             :       !--> charge density
     177             :       REAL,INTENT (IN)         :: rh(:,:)
     178             :       !---> xc potential
     179             :       REAL, INTENT (OUT)       :: vxc (:,:),vx(:,:)
     180             :       TYPE(t_gradients),OPTIONAL,INTENT(INOUT)::grad
     181             :       REAL, INTENT(IN),OPTIONAL:: kinED_KS(:,:)
     182             : 
     183           0 :       vxc = 0.0
     184           0 :       vx  = 0.0
     185           0 :       call juDFT_error("Can't use XC-parrent class")
     186           0 :    END SUBROUTINE xcpot_get_vxc
     187             : 
     188           0 :    SUBROUTINE xcpot_get_exc(xcpot,jspins,rh,exc,grad,kinED_KS, mt_call)
     189             :       USE m_types_misc
     190             :       USE m_judft
     191             :       USE, INTRINSIC :: IEEE_ARITHMETIC
     192             :       IMPLICIT NONE
     193             : 
     194             :       CLASS(t_xcpot),INTENT(IN)             :: xcpot
     195             :       INTEGER, INTENT (IN)                  :: jspins
     196             :       !--> charge density
     197             :       REAL,INTENT (IN)                      :: rh(:,:)
     198             :       !--> kinetic energy density
     199             :       !---> xc energy density
     200             :       REAL, INTENT (OUT)                    :: exc (:)
     201             :       TYPE(t_gradients),OPTIONAL,INTENT(IN) :: grad
     202             :       LOGICAL, OPTIONAL, INTENT(IN)         :: mt_call    
     203             :       REAL, INTENT(IN), OPTIONAL            :: kinED_KS(:,:)
     204             : 
     205           0 :       exc = 0.0
     206           0 :       call juDFT_error("Can't use XC-parrent class")
     207           0 :    END SUBROUTINE xcpot_get_exc
     208             : 
     209        1112 :    SUBROUTINE xcpot_alloc_gradients(ngrid,jspins,grad)
     210             :       IMPLICIT NONE
     211             : 
     212             :       INTEGER, INTENT (IN)         :: jspins,ngrid
     213             :       TYPE(t_gradients),INTENT(INOUT):: grad
     214             : 
     215        1112 :       IF (allocated(grad%agrt)) THEN
     216           5 :          DEALLOCATE(grad%agrt,grad%agru,grad%agrd)
     217           5 :          DEALLOCATE(grad%g2ru,grad%g2rd,grad%gggrt)
     218           5 :          DEALLOCATE(grad%gggru,grad%gzgr,grad%g2rt)
     219           5 :          DEALLOCATE(grad%gggrd,grad%grgru,grad%grgrd)
     220             :       ENDIF
     221             :       !For the in-build xc-pots
     222        1112 :       ALLOCATE(grad%agrt(ngrid),grad%agru(ngrid),grad%agrd(ngrid))
     223        1112 :       ALLOCATE(grad%g2ru(ngrid),grad%g2rd(ngrid),grad%gggrt(ngrid))
     224        1112 :       ALLOCATE(grad%gggru(ngrid),grad%gzgr(ngrid),grad%g2rt(ngrid))
     225        1112 :       ALLOCATE(grad%gggrd(ngrid),grad%grgru(ngrid),grad%grgrd(ngrid))
     226        1112 :   END SUBROUTINE xcpot_alloc_gradients
     227             : 
     228           0 : END MODULE m_types_xcpot

Generated by: LCOV version 1.13