LCOV - code coverage report
Current view: top level - cdn_mt - magnMomFromDen.f90 (source / functions) Hit Total Coverage
Test: FLEUR test coverage Lines: 29 30 96.7 %
Date: 2024-04-28 04:28:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2018 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and avhttps://gcc.gnu.org/onlinedocs/gfortran/SQRT.htmlailable as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !------------------------------------------------------------------------------
       6             : ! This routine calculates the magnetic moments and the corresponding directions
       7             : ! (angles) according to the Atoms in the system.
       8             : !
       9             : !
      10             : ! Robin Hilgers, Nov '19
      11             : ! Modified for usability with the potential matrix; A. Neukirchen, Dec '19
      12             : 
      13             : MODULE m_magnMomFromDen
      14             : 
      15             : IMPLICIT NONE
      16             : 
      17             : CONTAINS
      18           3 : SUBROUTINE magnMomFromDen(input,atoms,noco,den,moments,theta_mt_avg,phi_mt_avg)
      19             :    USE m_constants
      20             :    USE m_types
      21             :    USE m_types_fleurinput
      22             :    USE m_intgr
      23             :    USE m_juDFT
      24             :    USE m_polangle
      25             :    USE m_constants
      26             : 
      27             :    TYPE(t_input), INTENT(IN)     ::  input
      28             :    TYPE(t_atoms), INTENT(IN)     ::  atoms
      29             :    TYPE(t_noco), INTENT(IN)      ::  noco
      30             :    TYPE(t_potden),INTENT(IN)     ::  den
      31             :    REAL, INTENT(OUT)             ::  moments(3,atoms%ntype)
      32             :    REAL,INTENT(OUT)              :: theta_mt_avg(atoms%ntype)
      33             :    REAL,INTENT(OUT)              :: phi_mt_avg(atoms%ntype)
      34             : 
      35             :    INTEGER                       ::  jsp,i,j,ir
      36             :    REAL                          ::  mx,my,mz
      37             : 
      38           3 :    TYPE(t_potden)                ::  denloc
      39           3 :    REAL, ALLOCATABLE             ::  dummyResults(:,:)
      40             : 
      41             : 
      42          12 :   ALLOCATE(dummyResults(SIZE(den%mt,3),SIZE(den%mt,4)))
      43             : 
      44           3 :   IF(any(noco%l_unrestrictMT)) THEN
      45             :      jsp=4
      46             :   ELSE
      47           0 :      jsp=input%jspins
      48             :   END IF
      49             : !!Loop over Spins and Atoms
      50           9 :    DO i=1, atoms%ntype
      51          33 :       DO j=1, jsp
      52             : !!Integration over r
      53          24 :            IF (den%potdenType<=1000) THEN
      54          16 :               CALL denloc%copyPotDen(den)
      55       12128 :               DO ir=1, atoms%jri(i)
      56      993200 :                  denloc%mt(ir,:,i,j)=den%mt(ir,:,i,j)*atoms%rmsh(ir,i)**2
      57             :               END DO
      58             :            ELSE
      59           8 :               CALL denloc%copyPotDen(den)
      60             :            END IF
      61          24 :            CALL intgr3(denloc%mt(:,0,i,j), atoms%rmsh(:,i),atoms%dx(i),atoms%jri(i),dummyResults(i,j))
      62             : !!Considering Lattice harmonics integral (Only L=0 component does not vanish and has a factor of sqrt(4*Pi))
      63          30 :           dummyResults(i,j)=dummyResults(i,j)*sfp_const
      64             :       END DO
      65             :    END DO
      66             : !!Assign results
      67           9 :    DO i=1 , atoms%ntype
      68           6 :    IF (any(noco%l_unrestrictMT)) THEN
      69          18 :       moments(1:2,i)=2*dummyResults(i,3:4)
      70             :    END IF
      71           9 :       moments(3,i)=dummyResults(i,1)-dummyResults(i,2)
      72             :    END DO
      73             : 
      74             : 
      75             : 
      76           3 : DEALLOCATE(dummyResults)
      77             : 
      78           3 : IF (den%potdenType<=1000) THEN
      79          18 :    moments=moments/2
      80             : ELSE
      81           3 :    moments(2,:)=-moments(2,:)
      82             : END IF
      83             : 
      84             : !!Calculation of Angles
      85           9 :    DO i=1 , atoms%ntype
      86           6 :       mx=moments(1,i)
      87           6 :       my=moments(2,i)
      88           6 :       mz=moments(3,i)
      89           9 :       IF (den%potdenType>1000) THEN
      90           2 :          CALL pol_angle(mx,my,mz,theta_mt_avg(i),phi_mt_avg(i),.true.)
      91             :       END IF
      92             :    ENDDO
      93             : 
      94           3 : END SUBROUTINE magnMomFromDen
      95             : END MODULE m_magnMomFromDen

Generated by: LCOV version 1.14