LCOV - code coverage report
Current view: top level - ldaX - u_setup.f90 (source / functions) Hit Total Coverage
Test: FLEUR test coverage Lines: 31 32 96.9 %
Date: 2024-05-15 04:28:08 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             : 
       7             : MODULE m_usetup
       8             :    !-------------------------------------------------------------------+
       9             :    ! Sets up the quantities needed for the LDA+U subroutines:          |                                         |
      10             :    !     potential matrix: vs_mmp                                      |
      11             :    !     total energy contribution: e_ldau                             |
      12             :    !                                                  G.B. Oct. 2000   |
      13             :    !                                                                   |
      14             :    !     Extension to multiple U per atom type  G.M. 2017              |
      15             :    !-------------------------------------------------------------------+
      16             :    USE m_juDFT
      17             :    USE m_rotMMPmat
      18             :    USE m_dftUPotential
      19             :    USE m_types
      20             :    USE m_constants
      21             : 
      22             :    IMPLICIT NONE
      23             : 
      24             :    CONTAINS
      25             : 
      26          64 :    SUBROUTINE u_setup(atoms,input,noco,mpi,hub1data,inDen,pot,results)
      27             : 
      28             :       TYPE(t_mpi),      INTENT(IN)    :: mpi
      29             :       TYPE(t_input),    INTENT(IN)    :: input
      30             :       TYPE(t_atoms),    INTENT(IN)    :: atoms
      31             :       TYPE(t_noco),     INTENT(IN)    :: noco
      32             :       TYPE(t_hub1data), INTENT(IN)    :: hub1data
      33             :       TYPE(t_potden),   INTENT(IN)    :: inDen
      34             :       TYPE(t_potden),   INTENT(INOUT) :: pot
      35             :       TYPE(t_results),  INTENT(INOUT) :: results
      36             : 
      37             : 
      38             :       INTEGER :: itype,ispin,l,m,mp,i_u,n_u
      39             :       CHARACTER(len=2) :: l_type
      40             :       CHARACTER(len=9) :: l_form
      41             : 
      42          64 :       COMPLEX, ALLOCATABLE :: n_mmp(:,:,:,:)
      43             : 
      44             :       ! look, whether density matrix exists already:
      45        1648 :       IF (ANY(ABS(inDen%mmpMat).GT.1e-12)) THEN
      46             : 
      47          60 :          n_u = atoms%n_u+atoms%n_hia
      48             : 
      49             :          !Rotate the density matrix if specified with phi or theta angles
      50         360 :          ALLOCATE(n_mmp,mold=inDen%mmpmat)
      51         220 :          DO i_u = 1, n_u
      52             :             n_mmp(:,:,i_u,:) = rotMMPmat(inDen%mmpmat(:,:,i_u,:),atoms%lda_u(i_u)%phi,&
      53       12532 :                                          atoms%lda_u(i_u)%theta,0.0,atoms%lda_u(i_u)%l)
      54             :          ENDDO
      55             : 
      56          60 :          results%e_ldau = 0.0
      57         220 :          DO i_u = 1, n_u
      58             :             CALL dftUPotential(n_mmp(:,:,i_u,:), atoms%lda_u(i_u), input%jspins,&
      59             :                                atoms%neq(atoms%lda_u(i_u)%atomType),&
      60             :                                any(noco%l_unrestrictMT).OR.input%ldauSpinoffd, &
      61             :                                pot%mmpMat(:,:,i_u,:), results%e_ldau, &
      62         776 :                                spinavg_dc=hub1data%l_performSpinavg.and.i_u>atoms%n_u)
      63             :          ENDDO
      64             : 
      65          60 :          IF (mpi%irank.EQ.0) THEN
      66          77 :             DO ispin = 1,SIZE(pot%mmpMat,4)
      67          47 :                WRITE (oUnit,'(a7,i3)') 'spin #',ispin
      68         185 :                DO i_u = 1, n_u
      69         108 :                   itype = atoms%lda_u(i_u)%atomType
      70         108 :                   l     = atoms%lda_u(i_u)%l
      71             : 
      72         108 :                   WRITE (l_type,'(i2)') 2*(2*l+1)
      73         108 :                   l_form = '('//l_type//'f12.7)'
      74         108 :                   WRITE (oUnit,'(a20,i3)') 'n-matrix for atom # ',itype
      75         108 :                   IF(i_u > atoms%n_u) WRITE(oUnit,'(A)') 'n-matrix calculated with DFT+Hubbard-1'
      76         108 :                   WRITE (oUnit,l_form) ((n_mmp(m,mp,i_u,ispin),m=-l,l),mp=-l,l)
      77         108 :                   WRITE (oUnit,'(a20,i3)') 'V-matrix for atom # ',itype
      78         108 :                   IF (atoms%lda_u(i_u)%l_amf) THEN
      79           0 :                      WRITE (oUnit,*) 'using the around-mean-field limit'
      80             :                   ELSE
      81         108 :                      WRITE (oUnit,*) 'using the atomic limit of LDA+U'
      82             :                   ENDIF
      83        3239 :                   WRITE (oUnit,l_form) ((pot%mmpMat(m,mp,i_u,ispin),m=-l,l),mp=-l,l)
      84             :                END DO
      85             :             END DO
      86          30 :             WRITE (oUnit,*) results%e_ldau
      87             :          ENDIF
      88             :       ELSE
      89           4 :          IF (mpi%irank.EQ.0) THEN
      90           2 :             WRITE (*,*) 'no density matrix found ... skipping LDA+U'
      91             :          ENDIF
      92         922 :          pot%mmpMat = cmplx_0
      93           4 :          results%e_ldau = 0.0
      94             :       ENDIF
      95             : 
      96          64 :    END SUBROUTINE u_setup
      97             : END MODULE m_usetup

Generated by: LCOV version 1.14