vgen.F90 4.62 KB
Newer Older
1 2 3 4 5
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------
6
MODULE m_vgen
7

Matthias Redies's avatar
Matthias Redies committed
8
   USE m_juDFT
9

10
CONTAINS
Matthias Redies's avatar
Matthias Redies committed
11 12 13 14 15 16 17 18 19 20 21
   !> FLAPW potential generator
   !! The full potential is generated by the following main steps:
   !! * generation of Coulomb potential
   !! * copy of VCoul to both spins
   !! * generation of XC potential
   !! In addition, the rotation of the density in the noco case and some scaling is done
   !! In results we store:
   !!     TE_VCOUL  :   charge density-coulomb potential integral
   !!     TE_VEFF:   charge density-effective potential integral
   !!     TE_EXC :   charge density-ex-corr.energy density integral

22
   SUBROUTINE vgen(hybdat,field,input,xcpot,atoms,sphhar,stars,vacuum,sym,&
23
                   cell,oneD,sliceplot,mpi,results,noco,EnergyDen,den,vTot,vx,vCoul)
Matthias Redies's avatar
Matthias Redies committed
24 25 26 27 28 29 30

      USE m_types
      USE m_rotate_int_den_to_local
      USE m_bfield
      USE m_vgen_coulomb
      USE m_vgen_xcpot
      USE m_vgen_finalize
31
      USE m_rotate_mt_den_tofrom_local
32
#ifdef CPP_MPI
Matthias Redies's avatar
Matthias Redies committed
33
      USE m_mpi_bc_potden
34
#endif
Matthias Redies's avatar
Matthias Redies committed
35 36 37
      IMPLICIT NONE

      TYPE(t_results),   INTENT(INOUT)  :: results
38
      CLASS(t_xcpot),    INTENT(IN)     :: xcpot
39
      TYPE(t_hybdat),    INTENT(IN)     :: hybdat
Matthias Redies's avatar
Matthias Redies committed
40
      TYPE(t_mpi),       INTENT(IN)     :: mpi
41

Matthias Redies's avatar
Matthias Redies committed
42 43 44 45 46
      TYPE(t_oneD),      INTENT(IN)     :: oneD
      TYPE(t_sliceplot), INTENT(IN)     :: sliceplot
      TYPE(t_input),     INTENT(IN)     :: input
      TYPE(t_field),     INTENT(INOUT)  :: field  !efield can be modified
      TYPE(t_vacuum),    INTENT(IN)     :: vacuum
47
      TYPE(t_noco),      INTENT(INOUT)  :: noco
Matthias Redies's avatar
Matthias Redies committed
48 49 50 51 52 53 54 55 56 57 58
      TYPE(t_sym),       INTENT(IN)     :: sym
      TYPE(t_stars),     INTENT(IN)     :: stars
      TYPE(t_cell),      INTENT(IN)     :: cell
      TYPE(t_sphhar),    INTENT(IN)     :: sphhar
      TYPE(t_atoms),     INTENT(IN)     :: atoms
      TYPE(t_potden),    INTENT(IN)     :: EnergyDen
      TYPE(t_potden),    INTENT(INOUT)  :: den
      TYPE(t_potden),    INTENT(INOUT)  :: vTot,vx,vCoul

      TYPE(t_potden)                    :: workden,denRot

59
      INTEGER :: i
Henning Janssen's avatar
Henning Janssen committed
60
      COMPLEX :: mmpmat(-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const,MAX(1,atoms%n_u+atoms%n_hia),MERGE(3,input%jspins,noco%l_mperp))
61

Matthias Redies's avatar
Matthias Redies committed
62 63
      if (mpi%irank==0) WRITE (6,FMT=8000)
8000  FORMAT (/,/,t10,' p o t e n t i a l   g e n e r a t o r',/)
Henning Janssen's avatar
Henning Janssen committed
64

65 66 67 68
      IF(atoms%n_u+atoms%n_hia>0.AND.input%ldaUAdjEnpara) THEN
         !In this case we need the last mmpmat after vgen
         mmpmat = vTot%mmpmat
      ENDIF
Matthias Redies's avatar
Matthias Redies committed
69 70 71
      CALL vTot%resetPotDen()
      CALL vCoul%resetPotDen()
      CALL vx%resetPotDen()
72 73 74 75
      IF(atoms%n_u+atoms%n_hia>0.AND.input%ldaUAdjEnpara) THEN
         !In this case we need the last mmpmat after vgen
         vTot%mmpmat = mmpmat
      ENDIF
Matthias Redies's avatar
Matthias Redies committed
76
      ALLOCATE(vx%pw_w,mold=vTot%pw)
Matthias Redies's avatar
Matthias Redies committed
77
      vx%pw_w = 0.0
78

79
#ifndef CPP_OLDINTEL
Matthias Redies's avatar
Matthias Redies committed
80
      ALLOCATE(vTot%pw_w,mold=vTot%pw)
81
#else
82
      ALLOCATE( vTot%pw_w(size(vTot%pw,1),size(vTot%pw,2)))
83
#endif
84 85
      ALLOCATE(vCoul%pw_w(SIZE(vCoul%pw,1),size(vCoul%pw,2)))
      vCoul%pw_w = CMPLX(0.0,0.0)
86

87
      CALL workDen%init(stars,atoms,sphhar,vacuum,noco,input%jspins,0)
88

Matthias Redies's avatar
Matthias Redies committed
89 90
      !sum up both spins in den into workden
      CALL den%sum_both_spin(workden)
91

92
      CALL vgen_coulomb(1,mpi,oneD,input,field,vacuum,sym,stars,cell,sphhar,atoms,.FALSE.,workden,vCoul,results)
93

Matthias Redies's avatar
Matthias Redies committed
94 95
      CALL vCoul%copy_both_spin(vTot)
      vCoul%mt(:,:,:,input%jspins)=vCoul%mt(:,:,:,1)
96

Matthias Redies's avatar
Matthias Redies committed
97
      IF (noco%l_noco) THEN
98
         CALL denRot%init(stars,atoms,sphhar,vacuum,noco,input%jspins,0)
Matthias Redies's avatar
Matthias Redies committed
99
         denRot=den
100
         CALL rotate_int_den_to_local(sym,stars,atoms,sphhar,vacuum,cell,input,noco,oneD,denRot)
101
         IF (noco%l_mtnocoPot) CALL rotate_mt_den_to_local(atoms,sphhar,sym,noco,denrot)
Matthias Redies's avatar
Matthias Redies committed
102
      ENDIF
103

104
      CALL vgen_xcpot(hybdat,input,xcpot,atoms,sphhar,stars,vacuum,sym,&
105
                      cell,oneD,sliceplot,mpi,noco,den,denRot,EnergyDen,vTot,vx,results)
106

Matthias Redies's avatar
Matthias Redies committed
107
      !ToDo, check if this is needed for more potentials as well...
108
      CALL vgen_finalize(mpi,oneD,field,cell,atoms,stars,vacuum,sym,noco,input,xcpot,sphhar,vTot,vCoul,denRot)
109
      !DEALLOCATE(vcoul%pw_w)
110

Matthias Redies's avatar
Matthias Redies committed
111
      CALL bfield(input,noco,atoms,field,vTot)
112

113
#ifdef CPP_MPI
Matthias Redies's avatar
Matthias Redies committed
114 115 116
      CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,vTot)
      CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,vCoul)
      CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,vx)
117
#endif
Matthias Redies's avatar
Matthias Redies committed
118
   END SUBROUTINE vgen
119
END MODULE m_vgen