LCOV - code coverage report
Current view: top level - vgen - vmatgen.f90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 27 69 39.1 %
Date: 2019-09-08 04:53:50 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_vmatgen
       8             :   USE m_juDFT
       9             :   !**********************************************************************
      10             :   !     This subroutine prepares the spin dependent 2x2 matrix potential
      11             :   !     for the Hamiltonian setup. This is done in 4 steps.
      12             :   !
      13             :   !    i) The spin up and down potential and the direction of the
      14             :   !     magentic field, theta and phi, are reloaded from files nrp,
      15             :   !     dirofmag.
      16             :   !    ii) The spin up and down potential is Fouriertransformed to real
      17             :   !     space (theta and phi are stored in real space).
      18             :   !    iii) The four components of the matrix potential are calculated on
      19             :   !     the real space mesh.
      20             :   !    iv) The matrix potential is Fouriertransformed, stored in terms of
      21             :   !     stars and written to file potmat.
      22             :   !
      23             :   !     Philipp Kurz 99/11/01
      24             :   !**********************************************************************
      25             : CONTAINS
      26         248 :   SUBROUTINE vmatgen(stars,atoms,vacuum,sym,input,den,vTot)
      27             : 
      28             :     !******** ABBREVIATIONS ***********************************************
      29             :     !     ifft3    : size of the 3d real space mesh
      30             :     !     ifft2    : size of the 2d real space mesh
      31             :     !     vpw      : first interstitial spin up and down potential
      32             :     !                later four components of matrix potential
      33             :     !                all stored in terms of 3d-stars
      34             :     !     vis      : first interstitial spin up and down potential and
      35             :     !                direction of magnetic field (theta and phi)
      36             :     !                later four components of matrix potential
      37             :     !                all stored on real space mesh
      38             :     !**********************************************************************
      39             : 
      40             :     USE m_fft2d
      41             :     USE m_fft3d
      42             :     USE m_types
      43             :     IMPLICIT NONE
      44             : !    TYPE(t_oneD),INTENT(IN)   :: oneD
      45             :     TYPE(t_input),INTENT(IN)  :: input
      46             :     TYPE(t_vacuum),INTENT(IN) :: vacuum
      47             :     TYPE(t_sym),INTENT(IN)    :: sym
      48             :     TYPE(t_stars),INTENT(IN)  :: stars
      49             :     TYPE(t_atoms),INTENT(IN)  :: atoms
      50             :     TYPE(t_potden),INTENT(IN) :: den
      51             :     TYPE(t_potden),INTENT(INOUT):: vTot
      52             : 
      53             :  
      54             :     !     ..
      55             :     !     .. Local Scalars ..
      56             :     INTEGER imeshpt,ipot,jspin,ig2 ,ig3,ivac,ifft2,ifft3,imz,iter
      57             :     REAL    vup,vdown,veff,beff,vziw,theta,phi
      58             :     !     ..
      59             :     !     .. Local Arrays ..
      60         248 :     REAL,    ALLOCATABLE :: vvacxy(:,:,:,:),vis(:,:),fftwork(:)
      61             : 
      62         248 :     ifft3 = 27*stars%mx1*stars%mx2*stars%mx3
      63         248 :     IF (ifft3.NE.SIZE(den%theta_pw)) CALL judft_error("Wrong size of angles")
      64         248 :     ifft2 = SIZE(den%phi_vacxy,1) 
      65             :     
      66             :     
      67         248 :     ALLOCATE ( vis(ifft3,4),fftwork(ifft3))
      68             :       
      69             :     
      70             :     !---> fouriertransform the spin up and down potential
      71             :     !---> in the interstitial, vpw, to real space (vis)
      72         744 :     DO jspin = 1,input%jspins
      73         744 :        CALL fft3d(vis(:,jspin),fftwork, vTot%pw(:,jspin), stars,+1)
      74             :     ENDDO
      75             : 
      76             :     !---> calculate the four components of the matrix potential on
      77             :     !---> real space mesh
      78     6795176 :     DO imeshpt = 1,ifft3
      79     3397464 :        vup   = vis(imeshpt,1)
      80     3397464 :        vdown = vis(imeshpt,2)
      81     3397464 :        theta = den%theta_pw(imeshpt)
      82     3397464 :        phi   = den%phi_pw(imeshpt)
      83             :        !--->    at first determine the effective potential and magnetic field
      84     3397464 :        veff  = (vup + vdown)/2.0
      85     3397464 :        beff  = (vup - vdown)/2.0
      86             :        !--->    now calculate the matrix potential, which is hermitian.
      87             :        !--->    thus calculate the diagonal elements:
      88             :        !--->    V_11
      89     3397464 :        vis(imeshpt,1) = veff + beff*COS(theta)
      90             :        !--->    V_22
      91     3397464 :        vis(imeshpt,2) = veff - beff*COS(theta)
      92             :        !--->    the real part of V_21
      93     3397464 :        vis(imeshpt,3) = beff*SIN(theta)*COS(phi)
      94             :        !--->    and the imaginary part of V_21
      95     3397464 :        vis(imeshpt,4) = beff*SIN(theta)*SIN(phi)
      96             : 
      97    16987568 :        DO ipot = 1,4
      98    16987320 :           vis(imeshpt,ipot) =  vis(imeshpt,ipot) * stars%ufft(imeshpt-1)
      99             :        ENDDO
     100             :     ENDDO
     101             : 
     102             :     !---> Fouriertransform the matrix potential back to reciprocal space
     103        1240 :     DO ipot = 1,2
     104     6795424 :        fftwork=0.0
     105         744 :        CALL fft3d(vis(:,ipot),fftwork, vTot%pw_w(1,ipot), stars,-1)
     106             :     ENDDO
     107         248 :     CALL fft3d(vis(:,3),vis(:,4), vTot%pw_w(1,3), stars,-1)
     108             : 
     109         248 :     IF (.NOT. input%film) RETURN
     110             : 
     111             :     !Now the vacuum part starts
     112             : 
     113             :  
     114           0 :     ALLOCATE(vvacxy(ifft2,vacuum%nmzxyd,2,4))
     115             : 
     116             :     
     117             :        !--->    fouriertransform the spin up and down potential
     118             :        !--->    in the vacuum, vz & vxy, to real space (vvacxy)
     119           0 :        DO jspin = 1,input%jspins
     120           0 :           DO ivac = 1,vacuum%nvac
     121           0 :              DO imz = 1,vacuum%nmzxyd
     122           0 :                 vziw = 0.0
     123             :                 !IF (oneD%odi%d1) THEN
     124           0 :                 IF (.FALSE.) THEN
     125             :                    CALL judft_error("oneD not implemented",calledby="vmatgen")
     126             :                    !                  CALL fft2d(&
     127             :                    !     &                 oneD%k3,odi%M,odi%n2d,&
     128             :                    !     &                 vvacxy(0,imz,ivac,jspin),fftwork,&
     129             :                    !     &                 vz(imz,ivac,jspin),vziw,vxy(imz,1,ivac,jspin),&
     130             :                    !     &                 vacuum,odi%nq2,odi%kimax2,1,&
     131             :                    !     &                  %igf,odl%pgf,odi%nst2)
     132             :                 ELSE
     133             :                    CALL fft2d(stars, vvacxy(:,imz,ivac,jspin),fftwork,&
     134           0 :                         vTot%vacz(imz,ivac,jspin),vziw,vTot%vacxy(imz,1,ivac,jspin), vacuum%nmzxyd,1)
     135             :                 ENDIF
     136             :              ENDDO
     137             :           ENDDO
     138             :        ENDDO
     139             : 
     140             :        !--->    calculate the four components of the matrix potential on
     141             :        !--->    real space mesh
     142           0 :        DO ivac = 1,vacuum%nvac
     143           0 :           DO imz = 1,vacuum%nmzxyd
     144           0 :              DO imeshpt = 1,ifft2
     145           0 :                 vup   = vvacxy(imeshpt,imz,ivac,1)
     146           0 :                 vdown = vvacxy(imeshpt,imz,ivac,2)
     147           0 :                 theta = den%theta_vacxy(imeshpt,imz,ivac)
     148           0 :                 phi   = den%phi_vacxy(imeshpt,imz,ivac)
     149           0 :                 veff  = (vup + vdown)/2.0
     150           0 :                 beff  = (vup - vdown)/2.0
     151           0 :                 vvacxy(imeshpt,imz,ivac,1) = veff + beff*COS(theta)
     152           0 :                 vvacxy(imeshpt,imz,ivac,2) = veff - beff*COS(theta)
     153           0 :                 vvacxy(imeshpt,imz,ivac,3) = beff*SIN(theta)*COS(phi)
     154           0 :                 vvacxy(imeshpt,imz,ivac,4) = beff*SIN(theta)*SIN(phi)
     155             :              ENDDO
     156             :           ENDDO
     157           0 :           DO imz = vacuum%nmzxyd+1,vacuum%nmzd
     158           0 :              vup   = vTot%vacz(imz,ivac,1)
     159           0 :              vdown = vTot%vacz(imz,ivac,2)
     160           0 :              theta = den%theta_vacz(imz,ivac)
     161           0 :              phi   = den%phi_vacz(imz,ivac)
     162           0 :              veff  = (vup + vdown)/2.0
     163           0 :              beff  = (vup - vdown)/2.0
     164           0 :              vTot%vacz(imz,ivac,1) = veff + beff*COS(theta)
     165           0 :              vTot%vacz(imz,ivac,2) = veff - beff*COS(theta)
     166           0 :              vTot%vacz(imz,ivac,3) = beff*SIN(theta)*COS(phi)
     167           0 :              vTot%vacz(imz,ivac,4) = beff*SIN(theta)*SIN(phi)
     168             :           ENDDO
     169             :        ENDDO
     170             : 
     171             :        !--->    Fouriertransform the matrix potential back to reciprocal space
     172           0 :        DO ipot = 1,2
     173           0 :           DO ivac = 1,vacuum%nvac
     174           0 :              DO imz = 1,vacuum%nmzxyd
     175           0 :                 fftwork=0.0
     176             :                 !IF (oneD%odi%d1) THEN
     177           0 :                 IF (.FALSE.) THEN
     178             :                    CALL judft_error("oneD not implemented",calledby="vmatgen")
     179             :                    !                CALL fft2d(&
     180             :                    !     &                 oneD%k3,odi%M,odi%n2d,&
     181             :                    !     &                 vvacxy(0,imz,ivac,ipot),fftwork,&
     182             :                    !     &                 vz(imz,ivac,ipot),vziw,vxy(imz,1,ivac,ipot),&
     183             :                    !     &                 vacuum,odi%nq2,odi%kimax2,-1,&
     184             :                    !     &                  %igf,odl%pgf,odi%nst2)
     185             :                 ELSE
     186             :                    CALL fft2d(stars, vvacxy(:,imz,ivac,ipot),fftwork,&
     187           0 :                         vTot%vacz(imz,ivac,ipot),vziw,vTot%vacxy(imz,1,ivac,ipot), vacuum%nmzxyd,-1)
     188             :                 END IF
     189             :              ENDDO
     190             :           ENDDO
     191             :        ENDDO
     192             : 
     193           0 :        DO ivac = 1,vacuum%nvac
     194           0 :           DO imz = 1,vacuum%nmzxyd
     195           0 :              fftwork=0.0
     196             :              !IF (oneD%odi%d1) THEN
     197           0 :              IF (.FALSE.) THEN
     198             :              CALL judft_error("oneD not implemented",calledby="vmatgen")
     199             :                 !              CALL fft2d(&
     200             :                 !   &              oneD%k3,odi%M,odi%n2d,&
     201             :                 !   &              vvacxy(0,imz,ivac,3),vvacxy(0,imz,ivac,4),&
     202             :                 !   &              vz(imz,ivac,3),vz(imz,ivac,4),vxy(imz,1,ivac,3),&
     203             :                 !   &              vacuum,odi%nq2,odi%kimax2,-1,&
     204             :                 !   &               %igf,odl%pgf,odi%nst2)
     205             :              ELSE
     206             :                 CALL fft2d(stars, vvacxy(:,imz,ivac,3),vvacxy(:,imz,ivac,4),&
     207           0 :                      vTot%vacz(imz,ivac,3),vTot%vacz(imz,ivac,4),vTot%vacxy(imz,1,ivac,3), vacuum%nmzxyd,-1)
     208             :              END IF
     209             :           ENDDO
     210             :        ENDDO
     211             : 
     212             :     RETURN
     213         248 :   END SUBROUTINE vmatgen
     214             : END MODULE m_vmatgen

Generated by: LCOV version 1.13