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

7 8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!     This module generates the cmt coefficients and eigenvectors z   !
Matthias Redies's avatar
Matthias Redies committed
9
!     at all kpoints nkpt from the irreducible kpoints kpts%nkpt          !
10 11 12
!     and writes them out in cmt and z, respectively.                 !
!                                                 M.Betzinger(09/07)  !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Matthias Redies's avatar
Matthias Redies committed
13

14
MODULE m_gen_wavf
15

16
CONTAINS
17

Matthias Redies's avatar
Matthias Redies committed
18
   SUBROUTINE gen_wavf(nkpti, kpts, sym, atoms, el_eig, ello_eig, cell, mpdata, hybinp, vr0, &
19
                       hybdat, noco,nococonv, oneD, fmpi, input, jsp)
20

Matthias Redies's avatar
Matthias Redies committed
21
      ! nkpt       ::     number of all k-points
22 23
      USE m_types
      USE m_constants
24 25 26
      USE m_radfun
      USE m_radflo
      USE m_abcof
27
      USE m_trafo!, ONLY: waveftrafo_genwavf
28
      USE m_olap
29
      USE m_hyb_abcrot
Matthias Redies's avatar
Matthias Redies committed
30
      USE m_io_hybinp
31

32
      IMPLICIT NONE
33

Matthias Redies's avatar
Matthias Redies committed
34
      TYPE(t_hybdat), INTENT(INOUT) :: hybdat
35
      TYPE(t_mpi), INTENT(IN)    :: fmpi
Matthias Redies's avatar
Matthias Redies committed
36
      TYPE(t_oneD), INTENT(IN)    :: oneD
37
      TYPE(t_mpdata), intent(in) :: mpdata
Matthias Redies's avatar
Matthias Redies committed
38
      TYPE(t_hybinp), INTENT(IN)    :: hybinp
Matthias Redies's avatar
Matthias Redies committed
39 40
      TYPE(t_input), INTENT(IN)    :: input
      TYPE(t_noco), INTENT(IN)    :: noco
41
      TYPE(t_nococonv), INTENT(IN)    :: nococonv
Matthias Redies's avatar
Matthias Redies committed
42 43 44 45 46
      TYPE(t_sym), INTENT(IN)    :: sym
      TYPE(t_cell), INTENT(IN)    :: cell
      TYPE(t_kpts), INTENT(IN)    :: kpts
      TYPE(t_atoms), INTENT(IN)    :: atoms

Matthias Redies's avatar
Matthias Redies committed
47
      INTEGER, INTENT(IN)    :: jsp, nkpti
Matthias Redies's avatar
Matthias Redies committed
48 49 50

      REAL, INTENT(IN)    :: vr0(:, :, :)!(jmtd,ntype,jspd)
      REAL, INTENT(IN)    :: el_eig(0:atoms%lmaxd, atoms%ntype)
51
      REAL, INTENT(IN)    :: ello_eig(:,:)
52 53

      ! local scalars
54
      INTEGER                 :: ilo, idum, m
55
      COMPLEX                 :: cdum
56
      INTEGER                 :: ikpt0, ikpt, itype, iop, ieq, indx, iatom
Matthias Redies's avatar
Matthias Redies committed
57
      INTEGER                 :: i, j, l, ll, lm, ng, ok
Matthias Redies's avatar
Matthias Redies committed
58
      COMPLEX, PARAMETER      :: img = (0.0, 1.0)
59

Matthias Redies's avatar
Matthias Redies committed
60
      INTEGER                 :: nodem, noded
61
      REAL                    :: wronk
62

63
      ! local arrays
Matthias Redies's avatar
Matthias Redies committed
64
      INTEGER                 :: rrot(3, 3, sym%nsym)
65
      INTEGER                 :: map_lo(atoms%nlod)
Matthias Redies's avatar
Matthias Redies committed
66 67 68
      INTEGER                 :: iarr(0:atoms%lmaxd, atoms%ntype)
      COMPLEX, ALLOCATABLE     :: acof(:, :, :), bcof(:, :, :), ccof(:, :, :, :)

69
      COMPLEX, ALLOCATABLE     :: cmt(:, :, :), cmthlp(:, :, :), c_phase(:)
Matthias Redies's avatar
Matthias Redies committed
70 71

      REAL                    :: vr(atoms%jmtd, atoms%ntype, input%jspins)
72
      REAL, ALLOCATABLE        :: u(:, :, :), du(:, :, :)
Matthias Redies's avatar
Matthias Redies committed
73 74 75 76 77

      REAL                    :: flo(atoms%jmtd, 2, atoms%nlod)
      REAL                    :: uuilon(atoms%nlod, atoms%ntype), duilon(atoms%nlod, atoms%ntype)
      REAL                    :: ulouilopn(atoms%nlod, atoms%nlod, atoms%ntype)

78
!     local arrays for abcof1
Matthias Redies's avatar
Matthias Redies committed
79
!      COMPLEX                 ::  a(nvd,0:lmd,natd,kpts%nkpt),b(nvd,0:lmd,natd,kpts%nkpt)
80

81
      TYPE(t_lapw)  :: lapw(kpts%nkptf)
82

Matthias Redies's avatar
Matthias Redies committed
83
      call timestart("gen_wavf")
84
      CALL hybdat%usdus%init(atoms, input%jspins)
Daniel Wortmann's avatar
Daniel Wortmann committed
85

86
      ! setup rotations in reciprocal space
87
      DO iop = 1, sym%nsym
Matthias Redies's avatar
Matthias Redies committed
88 89
         IF (iop <= sym%nop) THEN
            rrot(:, :, iop) = transpose(sym%mrot(:, :, sym%invtab(iop)))
90
         ELSE
Matthias Redies's avatar
Matthias Redies committed
91
            rrot(:, :, iop) = -rrot(:, :, iop - sym%nop)
92
         END IF
93 94 95 96
      END DO

      ! generate G-vectors, which fulfill |k+G|<rkmax
      ! for all k-points
97
      DO ikpt = 1, kpts%nkptf
98
         CALL lapw(ikpt)%init(input, noco,nococonv, kpts, atoms, sym, ikpt, cell, sym%zrfs)
99 100
      END DO

101
      ! set spherical component of the potential from the previous iteration vr
102
      vr = vr0
103 104 105 106 107 108

      ! calculate radial basis functions belonging to the
      ! potential vr stored in bas1 and bas2
      ! bas1 denotes the large component
      ! bas2    "     "  small component

109 110
      allocate(u(atoms%jmtd, 2, 0:atoms%lmaxd), &
                du(atoms%jmtd, 2, 0:atoms%lmaxd), &
Matthias Redies's avatar
Matthias Redies committed
111
                source=0.0)
Matthias Redies's avatar
Matthias Redies committed
112

113
      iarr = 2
114
      DO itype = 1, atoms%ntype
115
         IF (fmpi%irank == 0) WRITE (oUnit, FMT=8000) itype
116
         ng = atoms%jri(itype)
Matthias Redies's avatar
Matthias Redies committed
117
         DO l = 0, atoms%lmax(itype)
Matthias Redies's avatar
Matthias Redies committed
118
            CALL radfun(l, itype, jsp, el_eig(l, itype), vr(:, itype, jsp), &
119
                      atoms, u(:, :, l), du(:, :, l), hybdat%usdus, nodem, noded, wronk)
120
            IF (fmpi%irank == 0) WRITE (oUnit, FMT=8010) l, el_eig(l, itype), &
121 122 123
                               hybdat%usdus%us(l, itype, jsp), hybdat%usdus%dus(l, itype, jsp),&
                               nodem, hybdat%usdus%uds(l, itype, jsp), hybdat%usdus%duds(l, itype, jsp),&
                               noded, hybdat%usdus%ddn(l, itype, jsp), wronk
Matthias Redies's avatar
Matthias Redies committed
124

125 126 127 128
            hybdat%bas1(1:ng, 1, l, itype) = u(1:ng, 1, l)
            hybdat%bas2(1:ng, 1, l, itype) = u(1:ng, 2, l)
            hybdat%bas1(1:ng, 2, l, itype) = du(1:ng, 1, l)
            hybdat%bas2(1:ng, 2, l, itype) = du(1:ng, 2, l)
Matthias Redies's avatar
Matthias Redies committed
129

130 131 132 133
            hybdat%bas1_MT(1, l, itype) = hybdat%usdus%us(l, itype, jsp)
            hybdat%drbas1_MT(1, l, itype) = hybdat%usdus%dus(l, itype, jsp)
            hybdat%bas1_MT(2, l, itype) = hybdat%usdus%uds(l, itype, jsp)
            hybdat%drbas1_MT(2, l, itype) = hybdat%usdus%duds(l, itype, jsp)
134 135
         END DO

Matthias Redies's avatar
Matthias Redies committed
136
         IF (atoms%nlo(itype) >= 1) THEN
137
            CALL radflo(atoms, itype, jsp, ello_eig, vr(:, itype, jsp), u, du, fmpi, hybdat%usdus, uuilon, duilon, ulouilopn, flo)
138

Matthias Redies's avatar
Matthias Redies committed
139 140 141 142
            DO ilo = 1, atoms%nlo(itype)
               iarr(atoms%llo(ilo, itype), itype) = iarr(atoms%llo(ilo, itype), itype) + 1
               hybdat%bas1(1:ng, iarr(atoms%llo(ilo, itype), itype), atoms%llo(ilo, itype), itype) = flo(1:ng, 1, ilo)
               hybdat%bas2(1:ng, iarr(atoms%llo(ilo, itype), itype), atoms%llo(ilo, itype), itype) = flo(1:ng, 2, ilo)
143 144
               hybdat%bas1_MT(iarr(atoms%llo(ilo, itype), itype), atoms%llo(ilo, itype), itype) = hybdat%usdus%ulos(ilo, itype, jsp)
               hybdat%drbas1_MT(iarr(atoms%llo(ilo, itype), itype), atoms%llo(ilo, itype), itype) = hybdat%usdus%dulos(ilo, itype, jsp)
145 146
            END DO
         END IF
147
      END DO
Matthias Redies's avatar
Matthias Redies committed
148
      deallocate(u, du)
149

150
      ! consistency check
151
      IF (.not. all(iarr == mpdata%num_radfun_per_l)) call judft_error('gen_wavf: counting error')
152

153

Matthias Redies's avatar
Matthias Redies committed
154 155 156 157
8000  FORMAT(1x, /, /, ' wavefunction parameters for atom type', i3, ':', /, t32, 'radial function', t79, &
             'energy derivative', /, t3, 'l', t8, 'energy', t26, 'value', t39, 'derivative', t53, &
             'nodes', t68, 'value', t81, 'derivative', t95, 'nodes', t107, 'norm', t119, 'wronskian')
8010  FORMAT(i3, f10.5, 2(5x, 1p, 2e16.7, i5), 1p, 2e16.7)
158

Matthias Redies's avatar
Matthias Redies committed
159
      call timestop("gen_wavf")
160 161
   END SUBROUTINE gen_wavf
END MODULE m_gen_wavf