LCOV - code coverage report
Current view: top level - cdn - rot_den_mat.f (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 9 0.0 %
Date: 2019-09-08 04:53:50 Functions: 0 1 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_rotdenmat
       8             :       use m_juDFT
       9             :       CONTAINS
      10           0 :       SUBROUTINE rot_den_mat(
      11             :      >                       alph,beta,
      12             :      X                       rho11,rho22,rho21)
      13             : c***********************************************************************
      14             : c This subroutine rotates the direction of the magnetization of the 
      15             : c density matrix by multiplying with the unitary 2x2 spin rotation
      16             : c matrix. --> U*rho*U^dagger
      17             : c Philipp Kurz 2000-02-03
      18             : c new method for improved stability (l_new=t) gb'19
      19             : c***********************************************************************
      20             : 
      21             :       use m_constants
      22             :       IMPLICIT NONE
      23             : 
      24             : C     .. Scalar Arguments ..
      25             :       REAL, INTENT    (IN) :: alph,beta
      26             :       REAL, INTENT    (INOUT) :: rho11
      27             :       REAL, INTENT    (INOUT) :: rho22
      28             :       COMPLEX, INTENT (INOUT) :: rho21
      29             : C     ..
      30             : C     .. Local Scalars ..
      31             :       INTEGER ispin
      32             :       REAL eps,r11n,r22n
      33             :       COMPLEX r21n
      34             :       LOGICAL l_new
      35             : C     ..
      36             : C     .. Local Arrays ..
      37             :       COMPLEX u2(2,2),rho(2,2),rhoh(2,2)
      38             : C     ..
      39           0 :       l_new = .true.
      40             : 
      41             :       IF (l_new) THEN
      42             : 
      43             :       r11n = 0.5*(1.0+cos(beta))*rho11 - sin(beta)*real(rho21) +
      44           0 :      +       0.5*(1.0-cos(beta))*rho22
      45             :       r22n = 0.5*(1.0-cos(beta))*rho11 + sin(beta)*real(rho21) +
      46           0 :      +       0.5*(1.0+cos(beta))*rho22
      47             :       r21n = CMPLX(cos(alph),-sin(alph))*(sin(beta)*(rho11-rho22) +
      48           0 :      +       2.0*(cos(beta)*real(rho21)-cmplx(0.0,aimag(rho21))))*0.5
      49             : 
      50           0 :       rho11 = r11n
      51           0 :       rho22 = r22n
      52           0 :       rho21 = r21n
      53             : 
      54             :       ELSE
      55             :       
      56             :       eps = 1.0e-10
      57             : 
      58             : c---> set up the unitary 2x2 spin rotation matrix U^(2)
      59             :       u2(1,1) =  exp(-ImagUnit*alph/2)*cos(beta/2)
      60             :       u2(1,2) = -exp(-ImagUnit*alph/2)*sin(beta/2)
      61             :       u2(2,1) =  exp( ImagUnit*alph/2)*sin(beta/2)
      62             :       u2(2,2) =  exp( ImagUnit*alph/2)*cos(beta/2)
      63             :       
      64             :       rho(1,1) = cmplx(rho11,0.0)
      65             :       rho(2,2) = cmplx(rho22,0.0)
      66             :       rho(2,1) =       rho21
      67             :       rho(1,2) = conjg(rho21)
      68             : 
      69             : c---> first calculate U*rho
      70             :       rhoh(1,1) = u2(1,1)*rho(1,1) + u2(1,2)*rho(2,1)
      71             :       rhoh(1,2) = u2(1,1)*rho(1,2) + u2(1,2)*rho(2,2)
      72             :       rhoh(2,1) = u2(2,1)*rho(1,1) + u2(2,2)*rho(2,1)
      73             :       rhoh(2,2) = u2(2,1)*rho(1,2) + u2(2,2)*rho(2,2)
      74             : c---> now calculate (U*rho)*U^dagger
      75             :       rho(1,1) = rhoh(1,1)*conjg(u2(1,1))
      76             :      +         + rhoh(1,2)*conjg(u2(1,2))
      77             :       rho(1,2) = rhoh(1,1)*conjg(u2(2,1))
      78             :      +         + rhoh(1,2)*conjg(u2(2,2))
      79             :       rho(2,1) = rhoh(2,1)*conjg(u2(1,1))
      80             :      +         + rhoh(2,2)*conjg(u2(1,2))
      81             :       rho(2,2) = rhoh(2,1)*conjg(u2(2,1))
      82             :      +         + rhoh(2,2)*conjg(u2(2,2))
      83             : 
      84             : c---> check wether the diagonal elements of the rotated density
      85             : c---> are real.
      86             :       DO ispin = 1,2
      87             :          IF (aimag(rho(ispin,ispin)).GT.eps) THEN
      88             :             CALL juDFT_error("rotation of mag. failed",calledby
      89             :      +           ="rot_den_mat",hint=
      90             :      +        'After the rotation of the density matrix in the '//
      91             :      +       'muffin-tin sphere one diagonal element of the '//
      92             :      +       '(hermitian) density matrix is not real. That means '//
      93             :      +       'that the density matrix was probably damaged.')
      94             :          ENDIF
      95             :       ENDDO
      96             :  
      97             :       rho11 = real(rho(1,1))
      98             :       rho22 = real(rho(2,2))
      99             :       rho21 =      rho(2,1)
     100             : 
     101             :       ENDIF
     102             :       
     103           0 :       END SUBROUTINE rot_den_mat
     104             :       END MODULE m_rotdenmat
     105             : 

Generated by: LCOV version 1.13