LCOV - code coverage report
Current view: top level - vgen - rotate_mt_den_tofrom_local.f90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 71 0.0 %
Date: 2019-09-08 04:53:50 Functions: 0 2 0.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_rotate_mt_den_tofrom_local
       8             :   USE m_juDFT
       9             :   USE m_types
      10             :   USE m_constants
      11             :   use m_mt_tofrom_grid
      12             :   IMPLICIT NONE
      13             : CONTAINS
      14           0 :   SUBROUTINE rotate_mt_den_to_local(atoms,sphhar,sym,den)
      15             :     TYPE(t_atoms),INTENT(IN)  :: atoms
      16             :     TYPE(t_sphhar),INTENT(IN) :: sphhar
      17             :     TYPE(t_sym),INTENT(IN)    :: sym
      18             :     TYPE(t_potden),INTENT(INOUT) :: den
      19             :     
      20             :     
      21           0 :     TYPE(t_xcpot_inbuild)    :: xcpot !local xcpot that is LDA to indicate we do not need gradients
      22           0 :     TYPE(t_gradients)        :: grad
      23             : 
      24             :     INTEGER :: n,nsp,imesh,i
      25             :     REAL    :: rho_11,rho_22,rho_21r,rho_21i,mx,my,mz,magmom
      26             :     REAL    :: rhotot,rho_up,rho_down,theta,phi
      27             :     REAL,ALLOCATABLE :: ch(:,:)
      28             :     REAL    :: eps=1E-10
      29           0 :     nsp=atoms%nsp()
      30             :     ALLOCATE(ch(nsp*atoms%jmtd,4),&
      31           0 :              den%theta_mt(nsp*atoms%jmtd,atoms%ntype),&
      32           0 :              den%phi_mt(nsp*atoms%jmtd,atoms%ntype))
      33           0 :     CALL xcpot%init("vwn",.FALSE.,1)
      34             : 
      35           0 :     CALL init_mt_grid(4,atoms,sphhar,xcpot,sym)
      36           0 :     DO n=1,atoms%ntype
      37           0 :        CALL mt_to_grid(xcpot,4,atoms,sphhar,den%mt(:,0:,n,:),n,grad,ch)
      38           0 :        DO imesh = 1,nsp*atoms%jri(n)
      39             :     
      40           0 :           rho_11  = ch(imesh,1)
      41           0 :           rho_22  = ch(imesh,2)
      42           0 :           rho_21r = ch(imesh,3)
      43           0 :           rho_21i = ch(imesh,4)
      44           0 :           mx      =  2*rho_21r
      45           0 :           my      = -2*rho_21i
      46           0 :           mz      = (rho_11-rho_22)
      47           0 :           magmom  = SQRT(mx**2 + my**2 + mz**2)
      48           0 :           rhotot  = rho_11 + rho_22
      49           0 :           rho_up  = (rhotot + magmom)/2
      50           0 :           rho_down= (rhotot - magmom)/2
      51             : 
      52           0 :           IF (ABS(mz) .LE. eps) THEN
      53             :              theta = pi_const/2
      54           0 :           ELSEIF (mz .GE. 0.0) THEN
      55           0 :              theta = ATAN(SQRT(mx**2 + my**2)/mz)
      56             :           ELSE
      57           0 :              theta = ATAN(SQRT(mx**2 + my**2)/mz) + pi_const
      58             :           ENDIF
      59             : 
      60           0 :           IF (ABS(mx) .LE. eps) THEN
      61           0 :              IF (ABS(my) .LE. eps) THEN
      62             :                 phi = 0.0
      63           0 :              ELSEIF (my .GE. 0.0) THEN
      64             :                 phi = pi_const/2
      65             :              ELSE
      66           0 :                 phi = -pi_const/2
      67             :              ENDIF
      68           0 :           ELSEIF (mx .GE. 0.0) THEN
      69           0 :              phi = ATAN(my/mx)
      70             :           ELSE
      71           0 :              IF (my .GE. 0.0) THEN
      72           0 :                 phi = ATAN(my/mx) + pi_const
      73             :              ELSE
      74           0 :                 phi = ATAN(my/mx) - pi_const
      75             :              ENDIF
      76             :           ENDIF
      77             :           
      78           0 :           ch(imesh,1) = rho_up
      79           0 :           ch(imesh,2) = rho_down
      80           0 :           den%theta_mt(imesh,n) = theta
      81           0 :           den%phi_mt(imesh,n) = phi
      82             :        ENDDO
      83           0 :        den%mt(:,0:,n,:)=0.0
      84           0 :        CALL mt_from_grid(atoms,sphhar,n,2,ch,den%mt(:,0:,n,:))
      85           0 :        DO i=1,atoms%jri(n)
      86           0 :           den%mt(i,:,n,:)=den%mt(i,:,n,:)*atoms%rmsh(i,n)**2
      87             :        ENDDO
      88             :     END DO
      89           0 :     CALL finish_mt_grid()
      90           0 :   END SUBROUTINE rotate_mt_den_to_local
      91             : 
      92           0 :   SUBROUTINE rotate_mt_den_from_local(atoms,sphhar,sym,den,vtot)
      93             :     TYPE(t_atoms),INTENT(IN)  :: atoms
      94             :     TYPE(t_sphhar),INTENT(IN) :: sphhar
      95             :     TYPE(t_sym),INTENT(IN)    :: sym
      96             :     TYPE(t_potden),INTENT(IN) :: den
      97             :     TYPE(t_potden),INTENT(INOUT) :: vtot
      98             :     
      99             :     
     100           0 :     TYPE(t_xcpot_inbuild)     :: xcpot !local xcpot that is LDA to indicate we do not need gradients
     101           0 :     TYPE(t_gradients) :: grad
     102             :     
     103             :     INTEGER :: n,nsp,imesh,i
     104             :     REAL    :: vup,vdown,veff,beff
     105             :     REAL    :: theta,phi
     106             :     REAL,ALLOCATABLE :: ch(:,:)
     107             :     
     108           0 :     nsp=atoms%nsp()
     109           0 :     ALLOCATE(ch(nsp*atoms%jmtd,4))
     110           0 :     CALL xcpot%init("vwn",.FALSE.,1)
     111             : 
     112           0 :     CALL init_mt_grid(4,atoms,sphhar,xcpot,sym)
     113           0 :     DO n=1,atoms%ntype
     114           0 :        CALL mt_to_grid(xcpot,4,atoms,sphhar,vtot%mt(:,0:,n,:),n,grad,ch)
     115           0 :        DO imesh = 1,nsp*atoms%jri(n)
     116           0 :           vup   = ch(imesh,1)
     117           0 :           vdown = ch(imesh,2)
     118           0 :           theta = den%theta_mt(imesh,n)
     119           0 :           phi   = den%phi_mt(imesh,n)
     120           0 :           veff  = (vup + vdown)/2.0
     121           0 :           beff  = (vup - vdown)/2.0
     122           0 :           ch(imesh,1) = veff + beff*COS(theta)
     123           0 :           ch(imesh,2) = veff - beff*COS(theta)
     124           0 :           ch(imesh,3) = beff*SIN(theta)*COS(phi)
     125           0 :           ch(imesh,4) = beff*SIN(theta)*SIN(phi)
     126             :        ENDDO
     127           0 :        vtot%mt(:,0:,n,:)=0.0
     128           0 :        CALL mt_from_grid(atoms,sphhar,n,4,ch,vtot%mt(:,0:,n,:))
     129           0 :        DO i=1,atoms%jri(n)
     130           0 :           vtot%mt(i,:,n,:)=vtot%mt(i,:,n,:)*atoms%rmsh(i,n)**2
     131             :        ENDDO
     132             :     END DO
     133           0 :     CALL finish_mt_grid()
     134           0 :   END SUBROUTINE rotate_mt_den_from_local
     135             : END MODULE m_rotate_mt_den_tofrom_local

Generated by: LCOV version 1.13