LCOV - code coverage report
Current view: top level - eigen - hsmt.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 38 40 95.0 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.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             : MODULE m_hsmt
       7             :   USE m_juDFT
       8             :   IMPLICIT NONE
       9             : CONTAINS
      10             :   !> Setup of MT-part of the Hamiltonian and the overlap matrix
      11             :   !!
      12             :   !! Here the MT-components are added to the matrices.
      13             :   !! 1. The spherical part in hsmt_sph()
      14             :   !! 2. The non-spherical part in hsmt_nonsph()
      15             :   !! 3. The lo-part in hsmt_lo()
      16             :   !!
      17             :   !! - In the case of a noco-calculation (but not spin-spiral), first a temporary matrix is set-up
      18             :   !! for each atom in its local spin-frame and this matrix is the rotated into the global frame and added to the full matrix
      19             :   !! - In the spin-spiral case, a loop over the global spin is performed and the four parts of the matrix are calculated one-by-one
      20             :   !! @todo
      21             :   !! The off-diagonal contribution in first-variation soc and constraint calculations is still missing
      22             :   
      23        1852 :   SUBROUTINE hsmt(atoms,sym,enpara,&
      24        1852 :        ispin,input,mpi,noco,cell,lapw,usdus,td,smat,hmat)
      25             :     USE m_types
      26             :     USE m_hsmt_nonsph
      27             :     USE m_hsmt_sph
      28             :     use m_hsmt_lo
      29             :     USE m_hsmt_distspins
      30             :     USE m_hsmt_fjgj
      31             :     USE m_hsmt_spinor
      32             :     USE m_hsmt_soc_offdiag
      33             :     USE m_hsmt_mtNocoPot_offdiag
      34             :     USE m_hsmt_offdiag
      35             :     IMPLICIT NONE
      36             :     TYPE(t_mpi),INTENT(IN)        :: mpi
      37             :     TYPE(t_input),INTENT(IN)      :: input
      38             :     TYPE(t_noco),INTENT(IN)       :: noco
      39             :     TYPE(t_sym),INTENT(IN)        :: sym
      40             :     TYPE(t_cell),INTENT(IN)       :: cell
      41             :     TYPE(t_atoms),INTENT(IN)      :: atoms
      42             :     TYPE(t_enpara),INTENT(IN)     :: enpara
      43             :     TYPE(t_lapw),INTENT(IN)       :: lapw 
      44             :     TYPE(t_tlmplm),INTENT(IN)     :: td
      45             :     TYPE(t_usdus),INTENT(IN)      :: usdus
      46             :     CLASS(t_mat),INTENT(INOUT)    :: smat(:,:),hmat(:,:)
      47             :     !     ..
      48             :     !     .. Scalar Arguments ..
      49             :     INTEGER, INTENT (IN) :: ispin  
      50             :     
      51             :     !locals
      52             : #ifdef CPP_GPU
      53             :     REAL, ALLOCATABLE,MANAGED    :: fj(:,:,:,:),gj(:,:,:,:)
      54             : #else
      55        1852 :     REAL, ALLOCATABLE    :: fj(:,:,:,:),gj(:,:,:,:)
      56             : #endif
      57             : 
      58             :     INTEGER :: iintsp,jintsp,n
      59             :     COMPLEX :: chi(2,2),chi_one
      60             : 
      61        1852 :     TYPE(t_mat)::smat_tmp,hmat_tmp
      62             : 
      63             :     !
      64        1852 :     IF (noco%l_noco.AND..NOT.noco%l_ss) THEN
      65        1248 :        CALL smat_tmp%alloc(smat(1,1)%l_real,smat(1,1)%matsize1,smat(1,1)%matsize2)
      66        1248 :        CALL hmat_tmp%alloc(smat(1,1)%l_real,smat(1,1)%matsize1,smat(1,1)%matsize2)
      67             :     ENDIF
      68             :     
      69        1852 :     ALLOCATE(fj(MAXVAL(lapw%nv),0:atoms%lmaxd,input%jspins,MERGE(2,1,noco%l_noco)))
      70        1852 :     ALLOCATE(gj(MAXVAL(lapw%nv),0:atoms%lmaxd,input%jspins,MERGE(2,1,noco%l_noco)))
      71             : 
      72        1852 :     iintsp=1;jintsp=1;chi_one=1.0 !Defaults in non-noco case
      73        6008 :        DO n=1,atoms%ntype
      74        4156 :           CALL timestart("fjgj coefficients")
      75        4156 :           CALL hsmt_fjgj(input,atoms,cell,lapw,noco,usdus,n,ispin,fj,gj)
      76        4156 :           CALL timestop("fjgj coefficients")
      77        6008 :           IF (.NOT.noco%l_noco) THEN
      78             :              !This is for collinear calculations: the (1,1) element of the matrices is all
      79             :              !that is needed and allocated
      80             :              CALL hsmt_sph(n,atoms,mpi,ispin,input,noco,1,1,chi_one,lapw,enpara%el0,&
      81        1580 :                            td%e_shift(n,ispin),usdus,fj(:,0:,ispin,:),gj(:,0:,ispin,:),smat(1,1),hmat(1,1))
      82             :              CALL hsmt_nonsph(n,mpi,sym,atoms,ispin,1,1,chi_one,noco,cell,lapw,td,&
      83        1580 :                               fj(:,0:,ispin,:),gj(:,0:,ispin,:),hmat(1,1))
      84             :              CALL hsmt_lo(input,atoms,sym,cell,mpi,noco,lapw,usdus,td,fj(:,0:,ispin,:),gj(:,0:,ispin,:),&
      85        1580 :                           n,chi_one,ispin,iintsp,jintsp,hmat(1,1),smat(1,1))
      86        2576 :           ELSEIF(noco%l_noco.AND..NOT.noco%l_ss) THEN
      87             :              !The NOCO but non-spinspiral setup follows:
      88             :              !The Matrix-elements are first calculated in the local frame of the atom and
      89             :              !stored in tmp-variables. Then these are distributed (rotated) into the 2x2
      90             :              !global spin-matrices.
      91        2496 :              CALL hmat_tmp%clear();CALL smat_tmp%clear()
      92             :              CALL hsmt_sph(n,atoms,mpi,ispin,input,noco,1,1,chi_one,lapw,enpara%el0,td%e_shift(n,ispin),&
      93        2496 :                   usdus,fj(:,0:,ispin,:),gj(:,0:,ispin,:),smat_tmp,hmat_tmp)
      94             :              CALL hsmt_nonsph(n,mpi,sym,atoms,ispin,1,1,chi_one,noco,cell,lapw,td,&
      95        2496 :                   fj(:,0:,ispin,:),gj(:,0:,ispin,:),hmat_tmp)
      96             :              CALL hsmt_lo(input,atoms,sym,cell,mpi,noco,lapw,usdus,td,fj(:,0:,ispin,:),gj(:,0:,ispin,:),&
      97        2496 :                   n,chi_one,ispin,iintsp,jintsp,hmat_tmp,smat_tmp)
      98        2496 :              CALL hsmt_spinor(ispin,n,noco,chi)
      99        2496 :              CALL hsmt_distspins(chi,smat_tmp,smat)
     100        2496 :              CALL hsmt_distspins(chi,hmat_tmp,hmat)
     101             :              !Add off-diagonal contributions to Hamiltonian if needed
     102        2496 :              IF (ispin==1.AND.noco%l_mtNocoPot) THEN
     103           0 :                 CALL hsmt_mtNocoPot_offdiag(n,mpi,sym,atoms,noco,cell,lapw,td,fj,gj,hmat_tmp,hmat)
     104             :              ENDIF
     105        2496 :              IF (ispin==1.and.noco%l_soc) &
     106         480 :                   CALL hsmt_soc_offdiag(n,atoms,mpi,noco,lapw,usdus,td,fj(:,0:,:,iintsp),gj(:,0:,:,iintsp),hmat)
     107        2496 :              IF (noco%l_constr) &
     108           0 :                   CALL hsmt_offdiag(n,atoms,mpi,ispin,noco,lapw,td,usdus,fj(:,0:,ispin,:),gj(:,0:,ispin,:),hmat)
     109             :           ELSE
     110             :              !In the spin-spiral case the loop over the interstitial=global spin has to
     111             :              !be performed explicitely
     112          80 :              CALL hsmt_spinor(ispin,n,noco,chi)
     113         480 :              DO iintsp=1,2
     114         560 :                 DO jintsp=1,2
     115             :                    CALL hsmt_sph(n,atoms,mpi,ispin,input,noco,iintsp,jintsp,chi(iintsp,jintsp),&
     116             :                                  lapw,enpara%el0,td%e_shift(n,ispin),usdus,fj(:,0:,ispin,:),gj(:,0:,ispin,:),&
     117         320 :                                  smat(iintsp,jintsp),hmat(iintsp,jintsp))
     118             :                    CALL hsmt_nonsph(n,mpi,sym,atoms,ispin,iintsp,jintsp,chi(iintsp,jintsp),noco,cell,&
     119         320 :                                     lapw,td,fj(:,0:,ispin,:),gj(:,0:,ispin,:),hmat(iintsp,jintsp))
     120             :                    CALL hsmt_lo(input,atoms,sym,cell,mpi,noco,lapw,usdus,td,fj(:,0:,ispin,:),gj(:,0:,ispin,:),&
     121         480 :                           n,chi(iintsp,jintsp),ispin,iintsp,jintsp,hmat(iintsp,jintsp),smat(iintsp,jintsp))
     122             :                 ENDDO
     123             :              ENDDO
     124             :           ENDIF
     125             :           
     126             :     END DO
     127             : 
     128             :     
     129        1852 :     RETURN
     130        1852 :   END SUBROUTINE hsmt
     131             : END MODULE m_hsmt

Generated by: LCOV version 1.13