vgen.F90 3.72 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 7 8
MODULE m_vgen
  USE m_juDFT
CONTAINS
9 10 11 12 13 14 15 16 17 18
  !> 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
19
  SUBROUTINE vgen(hybrid,field,input,xcpot,DIMENSION, atoms,sphhar,stars,&
20 21
       vacuum,sym,obsolete,cell,oneD,sliceplot,mpi, results,noco,den,vTot,vx,vCoul)
    USE m_rotate_int_den_to_local
22 23 24 25
    USE m_bfield
    USE m_vgen_coulomb
    USE m_vgen_xcpot
    USE m_vgen_finalize
26
    USE m_types
27 28 29
#ifdef CPP_MPI
    USE m_mpi_bc_potden
#endif
30 31
    IMPLICIT NONE
    TYPE(t_results),INTENT(INOUT)   :: results
32
    CLASS(t_xcpot),INTENT(IN)       :: xcpot
33
    TYPE(t_hybrid),INTENT(IN)       :: hybrid
34 35 36 37 38
    TYPE(t_mpi),INTENT(IN)          :: mpi
    TYPE(t_dimension),INTENT(IN)    :: dimension
    TYPE(t_oneD),INTENT(IN)         :: oneD
    TYPE(t_obsolete),INTENT(IN)     :: obsolete
    TYPE(t_sliceplot),INTENT(IN)    :: sliceplot
39 40
    TYPE(t_input),INTENT(IN)        :: input
    TYPE(t_field),INTENT(INOUT)     :: field  !efield can be modified
41 42 43 44 45 46
    TYPE(t_vacuum),INTENT(IN)       :: vacuum
    TYPE(t_noco),INTENT(IN)         :: noco
    TYPE(t_sym),INTENT(IN)          :: sym
    TYPE(t_stars),INTENT(IN)        :: stars
    TYPE(t_cell),INTENT(IN)         :: cell
    TYPE(t_sphhar),INTENT(IN)       :: sphhar
47
    TYPE(t_atoms),INTENT(IN)        :: atoms 
48
    TYPE(t_potden), INTENT(INOUT)   :: den
49
    TYPE(t_potden),INTENT(INOUT)    :: vTot,vx,vCoul
50
    !     ..
51

52
    TYPE(t_potden) :: workden,denRot
53

54 55 56 57
    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',/)

    
58 59 60
    CALL vTot%resetPotDen()
    CALL vCoul%resetPotDen()
    CALL vx%resetPotDen()
Daniel Wortmann's avatar
Daniel Wortmann committed
61 62
    ALLOCATE(vx%pw_w,vTot%pw_w,mold=vTot%pw)
    ALLOCATE(vCoul%pw_w(SIZE(den%pw,1),1))
63

64
    CALL workDen%init(stars,atoms,sphhar,vacuum,input%jspins,noco%l_noco,0)
65

66 67 68
    !sum up both spins in den into workden
    CALL den%sum_both_spin(workden)
    
69
    CALL vgen_coulomb(1,mpi,DIMENSION,oneD,input,field,vacuum,sym,stars,cell,sphhar,atoms,workden,vCoul,results)
70

71
    CALL vCoul%copy_both_spin(vTot)
72 73 74 75 76 77 78 79

    IF (noco%l_noco) THEN
       CALL denRot%init(stars,atoms,sphhar,vacuum,input%jspins,noco%l_noco,0)
       denRot=den
       CALL rotate_int_den_to_local(DIMENSION,sym,stars,atoms,sphhar,vacuum,cell,input,&
            noco,oneD,denRot)
    ENDIF

80 81
    call vgen_xcpot(hybrid,input,xcpot,DIMENSION, atoms,sphhar,stars,&
       vacuum,sym, obsolete,cell,oneD,sliceplot,mpi,noco,den,denRot,vTot,vx,results)
82

83
    !ToDo, check if this is needed for more potentials as well...
84
    CALL vgen_finalize(atoms,stars,vacuum,sym,noco,input,vTot,denRot)
Daniel Wortmann's avatar
Daniel Wortmann committed
85
    DEALLOCATE(vcoul%pw_w,vx%pw_w)
86

Daniel Wortmann's avatar
Daniel Wortmann committed
87
    
88 89 90
    CALL bfield(input,noco,atoms,field,vTot)
    
    ! broadcast potentials
91
#ifdef CPP_MPI
92 93 94
    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)
95
#endif
96

97 98
  END SUBROUTINE vgen
END MODULE m_vgen