Line data Source code
1 : MODULE m_vvac_xc
2 : use m_juDFT
3 : private
4 : !These used to be inputs for testing...
5 : INTEGER,PARAMETER:: fixed_ndvgrd=6
6 : REAL,PARAMETER :: fixed_chng=-0.1e-11
7 :
8 : public vvac_xc
9 : !-----------------------------------------------------------------------
10 : ! calculates 2-d star function coefficients of exchange-correlation*
11 : ! potential in the vacuum regions and adds them to the corresponding
12 : ! coeffs of the coulomb potential c.l.fu, r.podloucky *
13 : ! for the gradient contribution. t.a. 1996
14 : !-----------------------------------------------------------------------
15 : CONTAINS
16 44 : SUBROUTINE vvac_xc(ifftd2,stars,vacuum,noco ,cell,xcpot,input,den, vxc,exc)
17 :
18 : !-----------------------------------------------------------------------
19 : ! instead of vvacxcor.f: the different exchange-correlation
20 : ! potentials defined through the key icorr are called through
21 : ! the driver subroutine vxcallg.f, subroutines vectorized
22 : ! in case of total = .true. calculates the ex-corr. energy
23 : ! density through the driver subroutine excallg.f
24 : ! ** r.pentcheva 08.05.96
25 : !-----------------------------------------------------------------------
26 :
27 : USE m_types
28 : USE m_types_xcpot_libxc
29 : use m_constants
30 : USE m_grdrsvac
31 : USE m_grdchlh
32 : USE m_mkgz
33 : USE m_mkgxyz3
34 : !
35 : !
36 : USE m_fft2d
37 : use m_vac_tofrom_grid
38 : USE m_libxc_postprocess_gga
39 : IMPLICIT NONE
40 :
41 : CLASS(t_xcpot),INTENT(IN) :: xcpot
42 :
43 : TYPE(t_input),INTENT(IN) :: input
44 : TYPE(t_vacuum),INTENT(IN) :: vacuum
45 : TYPE(t_noco),INTENT(IN) :: noco
46 : TYPE(t_stars),INTENT(IN) :: stars
47 : TYPE(t_cell),INTENT(IN) :: cell
48 : TYPE(t_potden),INTENT(IN) :: den
49 : TYPE(t_potden),INTENT(INOUT) :: vxc
50 : TYPE(t_potden),INTENT(INOUT) :: exc
51 : ! ..
52 : ! .. Scalar Arguments ..
53 : INTEGER, INTENT (IN) :: ifftd2
54 :
55 : ! ..
56 : ! .. Local Scalars ..
57 : INTEGER :: js,nt,i,iq,irec2,nmz0,nmzdiff,ivac,ip,ngrid
58 : REAL :: rhti,zro,fgz,rhmnv,d_15,bmat1(3,3),rd
59 : LOGICAL :: l_libxc
60 : ! ..
61 : ! .. Local Arrays ..
62 44 : REAL, ALLOCATABLE :: rho(:,:),v_xc(:,:),v_x(:,:),e_xc(:,:)
63 :
64 44 : TYPE(t_gradients)::grad
65 :
66 : ! .. unused input (needed for other noco GGA-implementations) ..
67 :
68 44 : l_libxc=.FALSE.
69 :
70 : !SELECT TYPE(xcpot)
71 : !TYPE IS (t_xcpot_libxc)
72 : ! IF (xcpot%needs_grad()) THEN
73 : ! CALL judft_error("libxc GGA functionals not implemented in film setups")
74 : ! END IF
75 : !END SELECT
76 :
77 44 : ngrid=vacuum%nvac*(vacuum%nmzxy*ifftd2+vacuum%nmz)
78 :
79 44 : if (xcpot%needs_grad()) CALL xcpot%alloc_gradients(ngrid,input%jspins,grad)
80 352 : allocate(rho(ngrid,input%jspins),v_xc(ngrid,input%jspins),v_x(ngrid,input%jspins))
81 13870602 : rho=0.0
82 44 : call vac_to_grid(xcpot%needs_grad(),ifftd2,input%jspins,vacuum,noco%l_noco,cell,den%vac,stars,rho,grad)
83 :
84 : ! calculate the exchange-correlation potential in real space
85 : !
86 44 : CALL xcpot%get_vxc(input%jspins,rho,v_xc,v_x,grad)
87 :
88 : SELECT TYPE(xcpot)
89 : TYPE IS (t_xcpot_libxc)
90 0 : l_libxc=.TRUE.
91 0 : IF (xcpot%needs_grad()) THEN
92 0 : CALL libxc_postprocess_gga_vac(xcpot,input,cell,stars,vacuum ,v_xc,grad)
93 0 : CALL libxc_postprocess_gga_vac(xcpot,input,cell,stars,vacuum ,v_x,grad)
94 : END IF
95 : END SELECT
96 :
97 44 : call vac_from_grid(stars,vacuum,v_xc,ifftd2,vxc%vac)
98 :
99 : !IF (l_libxc.AND.xcpot%needs_grad()) THEN
100 : ! CALL save_npy('vxc_gga_vac_libxc.npy',v_xc)
101 : !ELSE IF (l_libxc.AND.(.NOT.xcpot%needs_grad())) THEN
102 : ! CALL save_npy('vxc_lda_vac_libxc.npy',v_xc)
103 : !ELSE IF ((.NOT.l_libxc).AND.xcpot%needs_grad()) THEN
104 : ! CALL save_npy('vxc_gga_vac_inbuild.npy',v_xc)
105 : !ELSE
106 : ! CALL save_npy('vxc_lda_vac_inbuild.npy',v_xc)
107 : !END IF
108 :
109 44 : IF (ALLOCATED(exc%vac)) THEN
110 11398676 : ALLOCATE ( e_xc(ngrid,1) ); e_xc=0.0
111 44 : CALL xcpot%get_exc(input%jspins,rho,e_xc(:,1),grad, mt_call=.False.)
112 44 : CALL vac_from_grid(stars,vacuum,e_xc,ifftd2,exc%vac)
113 : ENDIF
114 :
115 :
116 44 : END SUBROUTINE vvac_xc
117 44 : END MODULE m_vvac_xc
|