types_misc.F90 7.09 KB
Newer Older
1 2 3 4 5 6 7
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------

MODULE m_types_misc
8

Matthias Redies's avatar
Matthias Redies committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
   IMPLICIT NONE

   !*************************************************************
   !     This module contains definitions for all kind of types
   !*************************************************************

   ! Type for the HF total energy
   TYPE t_energy_hf
      REAL :: valence
      REAL :: core
   END TYPE t_energy_hf

   TYPE prodtype
      INTEGER :: l1,l2,n1,n2
   END TYPE prodtype

   TYPE t_hybdat
      INTEGER              :: lmaxcd,maxindxc
      REAL,  ALLOCATABLE   ::  gridf(:,:)                                    !alloc in util.F
      INTEGER , ALLOCATABLE::  nindxc(:,:)                                   !alloc in eigen_HF_init
      INTEGER,ALLOCATABLE  :: lmaxc(:)                                       !alloc in eigen_HF_init
      REAL,    ALLOCATABLE ::  core1(:,:,:,:),core2(:,:,:,:)                 !alloc in eigen_HF_init
      REAL,    ALLOCATABLE ::  eig_c(:,:,:)                                  !alloc in eigen_HF_init
      INTEGER , ALLOCATABLE::  kveclo_eig(:,:)                               !alloc in eigen_HF_setup
      INTEGER              ::  maxfac
      REAL,    ALLOCATABLE ::  sfac(:),fac(:)                                !alloc in eigen_HF_init
      REAL,    ALLOCATABLE ::  gauntarr(:,:,:,:,:,:)                         !alloc in eigen_HF_init
      REAL,    ALLOCATABLE ::  bas1(:,:,:,:),bas2(:,:,:,:)                   !alloc in eigen_HF_init
      REAL ,   ALLOCATABLE ::  bas1_MT(:,:,:),drbas1_MT(:,:,:)               !alloc in eigen_HF_init
      REAL, ALLOCATABLE    ::  prodm(:,:,:,:)                                !alloc in eigen_HF_setup
      TYPE(PRODTYPE),ALLOCATABLE :: prod(:,:,:)                              !alloc in eigen_HF_setup
      INTEGER, ALLOCATABLE :: pntgptd(:)                                     !alloc in eigen_HF_setup
      INTEGER, ALLOCATABLE :: pntgpt(:,:,:,:)                                !alloc in eigen_HF_setup
      INTEGER,ALLOCATABLE   ::  nindxp1(:,:)
43 44
      REAL, ALLOCATABLE   ::  stepfunc_r(:,:,:)
      COMPLEX,ALLOCATABLE ::  stepfunc_c(:,:,:)
Matthias Redies's avatar
Matthias Redies committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
   END TYPE t_hybdat

   TYPE t_results
      REAL, ALLOCATABLE    :: force(:,:,:)   !< Forces calculated on all atoms (for each spin)
      REAL, ALLOCATABLE    :: force_old(:,:) !< Forces on all atoms from last iteration
      REAL                 :: ef        !<Fermie energy
      REAL                 :: seigc     !<sum of the core eigenvalues
      REAL                 :: seigsc    !<weighted sum of the semi-core eigenvalues
      REAL                 :: seigv     !<weighted sum of the occupied valence eigenvalues
      REAL                 :: seigscv   !<sum of seigv and seigsc
      REAL                 :: ts        !<entropy contribution to the free energy
      REAL                 :: te_vcoul  !<charge density-coulomb potential integral
      REAL                 :: te_veff   !<charge density-effective potential integral
      REAL                 :: te_exc    !<charge density-ex-corr.energy density integral
      REAL                 :: e_ldau    !<total energy contribution of LDA+U
      REAL                 :: tote
      REAL                 :: last_distance
      REAL                 :: bandgap
63
      COMPLEX, ALLOCATABLE    :: unfolding_weights(:,:,:) !weights for unfolding a supercell bandstructure
Matthias Redies's avatar
Matthias Redies committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
      TYPE(t_energy_hf)    ::  te_hfex
      REAL                 ::  te_hfex_loc(2)
      REAL, ALLOCATABLE    :: w_iks(:,:,:)
      REAL, ALLOCATABLE    :: eig(:,:,:)
      INTEGER, ALLOCATABLE :: neig(:,:) ! neig(nkpts,jspins) number of calculated eigenvalues for each k point, spin

   CONTAINS
      PROCEDURE,PASS :: init => results_init
   END TYPE t_results

   TYPE t_zMat
      LOGICAL              :: l_real
      INTEGER              :: nbasfcn
      INTEGER              :: nbands
      REAL,    ALLOCATABLE :: z_r(:,:) ! z_r(nbasfcn,nbands)
      COMPLEX, ALLOCATABLE :: z_c(:,:) ! z_c(nbasfcn,nbands)

   CONTAINS
      PROCEDURE,PASS :: init => zMat_init
   END TYPE t_zMat

   TYPE t_hamOvlp
      LOGICAL              :: l_real
      INTEGER              :: matsize
      REAL,    ALLOCATABLE :: a_r(:), b_r(:)
      COMPLEX, ALLOCATABLE :: a_c(:), b_c(:)
   END TYPE t_hamOvlp
91 92 93

CONTAINS

Matthias Redies's avatar
Matthias Redies committed
94
   SUBROUTINE zMat_init(thisZMat,l_real,nbasfcn,nbands)
95

Matthias Redies's avatar
Matthias Redies committed
96
      IMPLICIT NONE
97

Matthias Redies's avatar
Matthias Redies committed
98 99 100
      CLASS(t_zMat),      INTENT(INOUT) :: thisZMat
      LOGICAL,            INTENT(IN)    :: l_real
      INTEGER,            INTENT(IN)    :: nbasfcn,nbands
101

Matthias Redies's avatar
Matthias Redies committed
102 103 104
      thisZMat%l_real = l_real
      thisZMat%nbasfcn = nbasfcn
      thisZMat%nbands = nbands
105

Matthias Redies's avatar
Matthias Redies committed
106 107 108 109 110 111 112 113 114
      IF (ALLOCATED(thisZMat%z_r)) DEALLOCATE(thisZMat%z_r)
      IF (ALLOCATED(thisZMat%z_c)) DEALLOCATE(thisZMat%z_c)
      IF (l_real) THEN
         ALLOCATE(thisZMat%z_r(nbasfcn,nbands))
         thisZMat%z_r = 0.0
      ELSE
         ALLOCATE(thisZMat%z_c(nbasfcn,nbands))
         thisZMat%z_c = CMPLX(0.0,0.0)
      END IF
115

Matthias Redies's avatar
Matthias Redies committed
116
   END SUBROUTINE zMat_init
117

Matthias Redies's avatar
Matthias Redies committed
118
   SUBROUTINE results_init(thisResults,dimension,input,atoms,kpts,noco)
119

Matthias Redies's avatar
Matthias Redies committed
120 121
      USE m_types_setup
      USE m_types_kpts
122

Matthias Redies's avatar
Matthias Redies committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
      IMPLICIT NONE

      CLASS(t_results),      INTENT(INOUT) :: thisResults
      TYPE(t_dimension),     INTENT(IN)    :: dimension
      TYPE(t_input),         INTENT(IN)    :: input
      TYPE(t_atoms),         INTENT(IN)    :: atoms
      TYPE(t_kpts),          INTENT(IN)    :: kpts
      TYPE(t_noco),          INTENT(IN)    :: noco

      INTEGER                              :: neigd2

      thisResults%seigc           = 0.0
      thisResults%seigsc          = 0.0
      thisResults%seigv           = 0.0
      thisResults%seigscv         = 0.0
      thisResults%e_ldau          = 0.0
      thisResults%ts              = 0.0
140

Matthias Redies's avatar
Matthias Redies committed
141 142 143 144 145 146 147 148 149 150 151 152 153
      thisResults%te_vcoul        = 0.0
      thisResults%te_veff         = 0.0
      thisResults%te_exc          = 0.0
      thisResults%te_hfex%valence = 0.0
      thisResults%te_hfex%core    = 0.0
      thisResults%te_hfex_loc     = 0.0

      thisResults%tote            = 0.0
      thisResults%last_distance   = -1.0
      thisResults%bandgap         = 0.0
      thisResults%ef              = 0.0

      neigd2 = MIN(dimension%neigd,dimension%nbasfcn)
154
!   neigd2 = dimension%neigd
Matthias Redies's avatar
Matthias Redies committed
155 156
      IF (noco%l_soc.AND.(.NOT.noco%l_noco)) neigd2 = 2*neigd2

157 158
      ALLOCATE (thisResults%force(3,atoms%ntype,input%jspins));thisResults%force=0.0
      ALLOCATE (thisResults%force_old(3,atoms%ntype));thisResults%force_old=0.0
Matthias Redies's avatar
Matthias Redies committed
159 160 161
      ALLOCATE (thisResults%w_iks(neigd2,kpts%nkpt,input%jspins))
      ALLOCATE (thisResults%neig(kpts%nkpt,input%jspins))
      ALLOCATE (thisResults%eig(neigd2,kpts%nkpt,input%jspins))
162
      ALLOCATE (thisResults%unfolding_weights(neigd2,kpts%nkpt,input%jspins))
Matthias Redies's avatar
Matthias Redies committed
163 164 165 166 167 168 169 170 171

      thisResults%force = 0.0
      thisResults%force_old = 0.0
      thisResults%w_iks = 0.0
      thisResults%neig = 0
      thisResults%eig = 0.0

   END SUBROUTINE results_init

172
END MODULE m_types_misc