alignSpinAxisMagn.f90 3.96 KB
Newer Older
1 2 3 4 5
!--------------------------------------------------------------------------------
! Copyright (c) 2018 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and avhttps://gcc.gnu.org/onlinedocs/gfortran/SQRT.htmlailable as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!------------------------------------------------------------------------------
6 7 8
!  This routine allows to rotate the cdn in a way that the direction of magnetization aligns with the direction of the spin quantization axis.
!  This routine also allows to reverse the rotation by using the angles stored in atoms (phi_mt_avg,theta_mt_avg) which are generated by the
!  routine magnMomFromDen.
9 10 11 12 13 14 15
!
! Robin Hilgers, Nov '19
MODULE m_alignSpinAxisMagn

USE m_magnMomFromDen
USE m_types
USE m_flipcdn
16
USE m_constants
17
USE m_polangle
18 19

CONTAINS
20 21
SUBROUTINE rotateMagnetToSpinAxis(vacuum,sphhar,stars&
,sym,oneD,cell,noco,input,atoms,den)
22 23
   TYPE(t_input), INTENT(IN)     :: input
   TYPE(t_atoms), INTENT(IN)     :: atoms
24
   TYPE(t_noco), INTENT(INOUT)   :: noco
25 26 27 28 29 30
   TYPE(t_stars),INTENT(IN)      :: stars
   TYPE(t_vacuum),INTENT(IN)     :: vacuum
   TYPE(t_sphhar),INTENT(IN)     :: sphhar
   TYPE(t_sym),INTENT(IN)        :: sym
   TYPE(t_oneD),INTENT(IN)       :: oneD
   TYPE(t_cell),INTENT(IN)       :: cell
31
   TYPE(t_potden), INTENT(INOUT) :: den
32

33
   REAL                          :: moments(3,atoms%ntype)
34 35
   REAL                          :: phiTemp(atoms%ntype),thetaTemp(atoms%ntype),pi
   INTEGER                       :: i
36
   pi=pimach()
37 38
!!TEMP
!   REAL :: x,y,z
39

40 41
   phiTemp=noco%alph
   thetaTemp=noco%beta
42
   CALL magnMomFromDen(input,atoms,noco,den,moments,thetaTemp,phiTemp)
43
  ! DO i=1, atoms%ntype
44
     ! IF (abs(atoms%theta_mt_avg(i)).LE. 0.001) THEN
45 46 47 48
     !    atoms%phi_mt_avg(i)=0.0
     !    atoms%theta_mt_avg(i)=0.0
     ! END IF
  ! END DO
49 50 51 52 53 54 55 56
   !write(*,*) "mx1"
   !write(*,*) moments(1,1)
   !write(*,*) "mz1"
   !write(*,*) moments(1,3)
   !write(*,*) "mx2"
   !write(*,*) moments(2,1)
   !write(*,*) "mz2"
   !write(*,*) moments(2,3)
57
   CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,-phiTemp,-thetaTemp,den)
58 59 60 61 62
  !write (*,*)"mx                my                     mz"
  !CALL sphericaltocart(SQRT(moments(1,1)**2+moments(1,2)**2+moments(1,3)**2),thetaTemp(1),phiTemp(1),x,y,z)
   !write(*,*) x,y,z
   !CALL sphericaltocart(SQRT(moments(2,1)**2+moments(2,2)**2+moments(2,3)**2),thetaTemp(2),phiTemp(2),x,y,z)
   !write(*,*) x,y,z
63 64 65 66
   !write(*,*) "atoms%phi_mt_avg"
   !!write(*,*) atoms%phi_mt_avg
   !write(*,*) "atoms%theta_mt_avg"
   !write(*,*) atoms%theta_mt_avg
67 68 69
   noco%alph=mod(noco%alph+phiTemp,2*pimach())
   noco%beta=mod(noco%alph+thetaTemp,2*pimach())

70 71 72
   DO i=1, atoms%ntype
      IF(noco%alph(i)<0) noco%alph(i)=noco%alph(i)+2*pi
      IF(noco%beta(i)<0) THEN
73 74
         noco%beta(i)=-noco%beta(i)
         noco%alph=noco%alph+pi
75
END IF
76
      IF(noco%beta(i)>pi) THEN
77 78 79 80 81
         noco%beta(i)=pi-mod(noco%beta(i),pi)
         noco%alph(i)=noco%alph(i)+pi
      END IF
      noco%alph=mod(noco%alph,2*pi)
   End Do
82 83 84 85
   write(*,*) "Noco Phi"
   write(*,*) noco%alph
   write(*,*) "Noco Theta"
   write(*,*) noco%beta
86 87 88 89
END SUBROUTINE rotateMagnetToSpinAxis


SUBROUTINE rotateMagnetFromSpinAxis(noco,vacuum,sphhar,stars&
90
,sym,oneD,cell,input,atoms,den,inDen)
91 92
   TYPE(t_input), INTENT(IN)  :: input
   TYPE(t_atoms), INTENT(IN)  :: atoms
93
   TYPE(t_noco), INTENT(INOUT)	 :: noco
94 95 96 97 98 99
   TYPE(t_stars),INTENT(IN)	 :: stars
   TYPE(t_vacuum),INTENT(IN)     :: vacuum
   TYPE(t_sphhar),INTENT(IN)     :: sphhar
   TYPE(t_sym),INTENT(IN)        :: sym
   TYPE(t_oneD),INTENT(IN)	 :: oneD
   TYPE(t_cell),INTENT(IN)	 :: cell
100
   TYPE(t_potden), INTENT(INOUT) :: den, inDen
101 102


103 104 105
   CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,noco%alph,noco%beta,den)
   CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,noco%alph,noco%beta,inDen)

106 107
   noco%alph=0
   noco%beta=0
108 109 110 111 112

END SUBROUTINE rotateMagnetFromSpinAxis


END MODULE m_alignSpinAxisMagn