lhglptg.f90 3.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
MODULE m_lhglptg
  !.....------------------------------------------------------------------
  !     calculates lattice harmonics and their gradients on the
  !       gauss-legendre angular mesh - r.p. and t.a.
  !     for gradient. t.a. 1996.
  !.....------------------------------------------------------------------
CONTAINS
  SUBROUTINE lhglptg(&
       &                   sphhar,atoms,&
       &                   rx,nsp,xcpot,sym,&
       &                   ylh,thet,ylht1,ylht2,ylhf1,ylhf2,ylhtf)
    !
    USE m_polangle
    USE m_ylm
    USE m_dylm
    USE m_types
    IMPLICIT NONE

19
    CLASS(t_xcpot),INTENT(IN)   :: xcpot
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    TYPE(t_sym),INTENT(IN)      :: sym
    TYPE(t_sphhar),INTENT(IN)   :: sphhar
    TYPE(t_atoms),INTENT(IN)    :: atoms
    !     ..
    !     .. Scalar Arguments ..
    INTEGER, INTENT (IN) :: nsp  
    !     ..
    !     .. Array Arguments ..
    REAL,    INTENT (IN) :: rx(:,:)!(3,dimension%nspd)
    REAL,    INTENT (OUT):: thet(:) !nspd
    REAL,    INTENT (OUT):: ylh(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd),thet(nspd)
    REAL,    INTENT (OUT):: ylht1(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd)
    REAL,    INTENT (OUT):: ylht2(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd)
    REAL,    INTENT (OUT):: ylhtf(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd)
    REAL,    INTENT (OUT):: ylhf1(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd)
    REAL,    INTENT (OUT):: ylhf2(:,0:,:)!(dimension%nspd,0:sphhar%nlhd,sphhar%ntypsd)
    !     ..
    !     .. Local Scalars ..
    REAL s,st1,st2,sf1,sf2,stf,phi
    INTEGER k,lh,mem,nd,lm,ll1
    !     ..
    !     .. Local Arrays ..
    COMPLEX ylm( (atoms%lmaxd+1)**2 )
    COMPLEX dylmt1( (atoms%lmaxd+1)**2 ), dylmt2( (atoms%lmaxd+1)**2 )
    COMPLEX dylmf1( (atoms%lmaxd+1)**2 ), dylmf2( (atoms%lmaxd+1)**2 )
    COMPLEX dylmtf( (atoms%lmaxd+1)**2 )
    !     ..

    !.....------------------------------------------------------------------
    !     ..
    DO  nd = 1,sym%nsymt

       DO  k = 1,nsp

          CALL ylm4(&
               &                   atoms%lmaxd,rx(:,k),&
               &                   ylm)
          CALL pol_angle(&
               &                       rx(1,k),rx(2,k),rx(3,k),&
               &                       thet(k),phi)

61
          IF (xcpot%needs_grad()) THEN
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
             CALL dylm3(&
                  &                     atoms%lmaxd,atoms%lmaxd,rx(:,k),ylm,&
                  &                     dylmt1,dylmt2,dylmf1,dylmf2,dylmtf)
          ENDIF

          DO  lh = 0,sphhar%nlh(nd)
             s   = 0
             st1 = 0
             st2 = 0
             sf1 = 0
             sf2 = 0
             stf = 0
             ll1 = sphhar%llh(lh,nd) * ( sphhar%llh(lh,nd) + 1 ) + 1

             DO mem = 1,sphhar%nmem(lh,nd)
                lm = ll1 + sphhar%mlh(mem,lh,nd)
                s = s + REAL( sphhar%clnu(mem,lh,nd) * ylm(lm) )
             ENDDO

             ylh(k,lh,nd) = s

83
             IF (xcpot%needs_grad()) THEN
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

                DO mem = 1,sphhar%nmem(lh,nd)
                   lm = ll1 + sphhar%mlh(mem,lh,nd)
                   s   = s   + REAL( sphhar%clnu(mem,lh,nd)* ylm(lm) )
                   st1 = st1 + REAL( sphhar%clnu(mem,lh,nd)*dylmt1(lm) )
                   st2 = st2 + REAL( sphhar%clnu(mem,lh,nd)*dylmt2(lm) )
                   sf1 = sf1 + REAL( sphhar%clnu(mem,lh,nd)*dylmf1(lm) )
                   sf2 = sf2 + REAL( sphhar%clnu(mem,lh,nd)*dylmf2(lm) )
                   stf = stf + REAL( sphhar%clnu(mem,lh,nd)*dylmtf(lm) )
                ENDDO

                ylht1(k,lh,nd) = st1
                ylht2(k,lh,nd) = st2
                ylhf1(k,lh,nd) = sf1
                ylhf2(k,lh,nd) = sf2
                ylhtf(k,lh,nd) = stf

             ENDIF

          ENDDO
       ENDDO
    ENDDO

    RETURN
  END SUBROUTINE lhglptg
END MODULE m_lhglptg