types_xcpot.F90 4.31 KB
Newer Older
1 2 3 4 5
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------
Daniel Wortmann's avatar
Daniel Wortmann committed
6 7 8 9 10 11 12 13
!> This module defines two data-types used in the calculation of xc-potentials
!! a) the abstract t_xcpot which should be overwritten for actual implementations
!! b) the t_gradients that collects the gradients needed in GGAs
!!
!! Currently t_xcpot_inbuild implements the XC-pots directly build into FLEUR
!! and t_xcpot_libxc provides and interface to libxc.
!! In addition to overloading the t_xcpot datatype also mpi_bc_xcpot must be adjusted
!! for additional implementations.
Daniel Wortmann's avatar
Daniel Wortmann committed
14 15 16
MODULE m_types_xcpot
  IMPLICIT NONE
  PRIVATE
17
  PUBLIC :: t_xcpot,t_gradients
Daniel Wortmann's avatar
Daniel Wortmann committed
18
       
19 20
  TYPE,ABSTRACT :: t_xcpot
     REAL :: gmaxxc
Daniel Wortmann's avatar
Daniel Wortmann committed
21 22
   CONTAINS
     PROCEDURE        :: is_gga=>xcpot_is_gga
23 24
     PROCEDURE        :: is_MetaGGA=>xcpot_is_MetaGGA
     PROCEDURE        :: needs_grad=>xcpot_needs_grad
25
     PROCEDURE        :: is_hybrid=>xcpot_is_hybrid
Daniel Wortmann's avatar
Daniel Wortmann committed
26
     PROCEDURE        :: get_exchange_weight=>xcpot_get_exchange_weight
27 28 29
     PROCEDURE        :: get_vxc=>xcpot_get_vxc
     PROCEDURE        :: get_exc=>xcpot_get_exc
     PROCEDURE,NOPASS :: alloc_gradients=>xcpot_alloc_gradients
Daniel Wortmann's avatar
Daniel Wortmann committed
30 31
  END TYPE t_xcpot

32 33 34 35 36 37 38 39 40 41 42 43
  TYPE t_gradients
     !Naming convention:
     !t,u,d as last letter for total,up,down
     !agr for absolute value of gradient
     !g2r for laplacien of gradient
     !+??
     REAL,ALLOCATABLE :: agrt(:),agru(:),agrd(:) 
     REAL,ALLOCATABLE :: g2ru(:),g2rd(:),gggrt(:)
     REAL,ALLOCATABLE :: gggru(:),gzgr(:),g2rt(:)
     REAL,ALLOCATABLE :: gggrd(:),grgru(:),grgrd(:)
     !These are the contracted Gradients used in libxc
     REAL,ALLOCATABLE :: sigma(:,:)
44
     REAL,ALLOCATABLE :: vsigma(:,:)
45
     REAL,ALLOCATABLE :: gr(:,:,:)
46
     REAL,ALLOCATABLE :: laplace(:,:)
47
  END TYPE t_gradients
Daniel Wortmann's avatar
Daniel Wortmann committed
48

49
CONTAINS
Daniel Wortmann's avatar
Daniel Wortmann committed
50
  
51
  LOGICAL FUNCTION xcpot_is_gga(xcpot)
Daniel Wortmann's avatar
Daniel Wortmann committed
52 53
    IMPLICIT NONE
    CLASS(t_xcpot),INTENT(IN):: xcpot
54
    xcpot_is_gga=.false.
Daniel Wortmann's avatar
Daniel Wortmann committed
55 56
  END FUNCTION xcpot_is_gga

Matthias Redies's avatar
Matthias Redies committed
57 58 59 60 61 62
  LOGICAL FUNCTION xcpot_is_MetaGGA(xcpot)
    IMPLICIT NONE
    CLASS(t_xcpot),INTENT(IN):: xcpot
    xcpot_is_MetaGGA=.false.
  END FUNCTION xcpot_is_MetaGGA

63 64 65 66 67 68 69 70
  LOGICAL FUNCTION xcpot_needs_grad(xcpot)
    IMPLICIT NONE
    CLASS(t_xcpot),INTENT(IN):: xcpot

    xcpot_needs_grad= xcpot%is_gga() .or. xcpot%is_MetaGGA()
  END FUNCTION xcpot_needs_grad


71
  LOGICAL FUNCTION xcpot_is_hybrid(xcpot)
Daniel Wortmann's avatar
Daniel Wortmann committed
72 73
    IMPLICIT NONE
    CLASS(t_xcpot),INTENT(IN):: xcpot
74
    xcpot_is_hybrid=.FALSE.
Daniel Wortmann's avatar
Daniel Wortmann committed
75
  END FUNCTION xcpot_is_hybrid
76
  
Daniel Wortmann's avatar
Daniel Wortmann committed
77 78 79 80 81 82 83
  FUNCTION xcpot_get_exchange_weight(xcpot) RESULT(a_ex)
    USE m_judft
    IMPLICIT NONE
    CLASS(t_xcpot),INTENT(IN):: xcpot
    REAL:: a_ex
    a_ex=-1
  END FUNCTION xcpot_get_exchange_weight
84

85
  SUBROUTINE xcpot_get_vxc(xcpot,jspins,rh,vxc,vx,grad)
86 87 88 89 90 91
    CLASS(t_xcpot),INTENT(IN) :: xcpot
    INTEGER, INTENT (IN)     :: jspins
    !--> charge density
    REAL,INTENT (IN)         :: rh(:,:)
    !---> xc potential
    REAL, INTENT (OUT)       :: vxc (:,:),vx(:,:)
92
    TYPE(t_gradients),OPTIONAL,INTENT(INOUT)::grad
93 94 95 96 97 98 99 100 101 102 103 104 105 106
  END SUBROUTINE xcpot_get_vxc

  SUBROUTINE xcpot_get_exc(xcpot,jspins,rh,exc,grad)
    CLASS(t_xcpot),INTENT(IN) :: xcpot
    INTEGER, INTENT (IN)     :: jspins
    !--> charge density
    REAL,INTENT (IN)         :: rh(:,:)
    !---> xc energy density
    REAL, INTENT (OUT)       :: exc (:)
    TYPE(t_gradients),OPTIONAL,INTENT(IN)::grad
  END SUBROUTINE xcpot_get_exc

  SUBROUTINE xcpot_alloc_gradients(ngrid,jspins,grad)
    INTEGER, INTENT (IN)         :: jspins,ngrid
107
    TYPE(t_gradients),INTENT(INOUT):: grad
108

109 110 111 112 113 114
    IF (allocated(grad%agrt)) THEN
       DEALLOCATE(grad%agrt,grad%agru,grad%agrd)
       DEALLOCATE(grad%g2ru,grad%g2rd,grad%gggrt)
       DEALLOCATE(grad%gggru,grad%gzgr,grad%g2rt)
       DEALLOCATE(grad%gggrd,grad%grgru,grad%grgrd)
    ENDIF
115 116 117 118 119 120 121
    !For the in-build xc-pots
    ALLOCATE(grad%agrt(ngrid),grad%agru(ngrid),grad%agrd(ngrid))
    ALLOCATE(grad%g2ru(ngrid),grad%g2rd(ngrid),grad%gggrt(ngrid))
    ALLOCATE(grad%gggru(ngrid),grad%gzgr(ngrid),grad%g2rt(ngrid))
    ALLOCATE(grad%gggrd(ngrid),grad%grgru(ngrid),grad%grgrd(ngrid))
  END SUBROUTINE xcpot_alloc_gradients
  
Daniel Wortmann's avatar
Daniel Wortmann committed
122
END MODULE m_types_xcpot