85 LOGICAL,
INTENT(IN) :: do_gce
86 REAL(kind=
dp),
INTENT(INOUT) :: ref_esp
89 CHARACTER(LEN=*),
PARAMETER :: routinen =
'planar_averaged_v_hartree_3d'
91 INTEGER :: a, b, c, handle, x, y, z
92 REAL(kind=
dp) :: my_ref_esp, ngrids_in_plane
93 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: profile, profile_local
95 CALL timeset(routinen, handle)
100 CALL get_planar_axes(dft_control%pcc_control%surf_normal, a, b, c)
103 z = v_rspace%pw_grid%npts(a)*v_rspace%pw_grid%npts(b)
104 ngrids_in_plane = real(z,
dp)
110 DO y = v_rspace%pw_grid%bounds_local(1, b), v_rspace%pw_grid%bounds_local(2, b)
111 DO x = v_rspace%pw_grid%bounds_local(1, a), v_rspace%pw_grid%bounds_local(2, a)
112 DO z = v_rspace%pw_grid%bounds_local(1, c), v_rspace%pw_grid%bounds_local(2, c)
113 IF (z == v_rspace%pw_grid%bounds(2, c))
THEN
115 my_ref_esp = v_rspace%array(x, y, z) + my_ref_esp
116 ELSE IF (c == 2)
THEN
117 my_ref_esp = v_rspace%array(y, z, x) + my_ref_esp
119 my_ref_esp = v_rspace%array(z, x, y) + my_ref_esp
127 CALL para_env%sum(my_ref_esp)
128 my_ref_esp = my_ref_esp/ngrids_in_plane
133 IF (dft_control%do_paep)
THEN
135 CALL get_planar_axes(dft_control%paep_control%surf_normal, a, b, c)
137 z = v_rspace%pw_grid%npts(a)*v_rspace%pw_grid%npts(b)
138 ngrids_in_plane = real(z,
dp)
140 ALLOCATE (profile(v_rspace%pw_grid%bounds(1, c):v_rspace%pw_grid%bounds(2, c)))
148 ALLOCATE (profile_local(v_rspace%pw_grid%bounds(1, c):v_rspace%pw_grid%bounds(2, c)))
149 profile_local(:) = 0.0_dp
152 DO z = v_rspace%pw_grid%bounds_local(1, c), v_rspace%pw_grid%bounds_local(2, c)
153 DO y = v_rspace%pw_grid%bounds_local(1, b), v_rspace%pw_grid%bounds_local(2, b)
154 DO x = v_rspace%pw_grid%bounds_local(1, a), v_rspace%pw_grid%bounds_local(2, a)
155 IF (c == 3) profile_local(z) = profile_local(z) + v_rspace%array(x, y, z)
156 IF (c == 2) profile_local(z) = profile_local(z) + v_rspace%array(y, z, x)
157 IF (c == 1) profile_local(z) = profile_local(z) + v_rspace%array(z, x, y)
164 profile(:) = profile(:) + profile_local(:)
167 DEALLOCATE (profile_local)
171 CALL para_env%sum(profile(:))
172 profile(:) = profile(:)/ngrids_in_plane
178 CALL timestop(handle)
193 TYPE(
pw_pool_type),
INTENT(IN),
POINTER :: auxbas_pw_pool
195 CHARACTER(LEN=*),
PARAMETER :: routinen =
'planar_counter_charge'
197 INTEGER :: a, b, c, handle, lcenter, ucenter, x, y, &
199 REAL(kind=
dp) :: dz, gau_a, tot_charge, val
203 CALL timeset(routinen, handle)
206 CALL get_planar_axes(pcc_env%surf_normal, a, b, c)
208 CALL auxbas_pw_pool%create_pw(pcc_density_r)
209 CALL auxbas_pw_pool%create_pw(pcc_density_g)
215 dz = pcc_density_r%pw_grid%dr(c)
217 ucenter = pcc_density_r%pw_grid%bounds(2, c) - int(pcc_env%dist_edge/dz)
218 lcenter = pcc_density_r%pw_grid%bounds(1, c) + int(pcc_env%dist_edge/dz)
223 DO z = pcc_density_r%pw_grid%bounds_local(1, c), pcc_density_r%pw_grid%bounds_local(2, c)
224 val = gau_a*exp(-(dz*real(z - ucenter,
dp))**2.0_dp/(2.0_dp*pcc_env%gau_c**2.0_dp))
225 val = val + gau_a*exp(-(dz*real(z - lcenter,
dp))**2.0_dp/(2.0_dp*pcc_env%gau_c**2.0_dp))
226 IF (val < 1.0e-15_dp) val = 0.0_dp
227 DO y = pcc_density_r%pw_grid%bounds_local(1, b), pcc_density_r%pw_grid%bounds_local(2, b)
228 DO x = pcc_density_r%pw_grid%bounds_local(1, a), pcc_density_r%pw_grid%bounds_local(2, a)
229 IF (c == 3) pcc_density_r%array(x, y, z) = val
230 IF (c == 2) pcc_density_r%array(y, z, x) = val
231 IF (c == 1) pcc_density_r%array(z, x, y) = val
238 CALL pw_scale(pcc_density_r, tot_charge)
240 CALL pw_axpy(pcc_density_g, rho_tot_gspace)
245 CALL auxbas_pw_pool%give_back_pw(pcc_density_r)
246 CALL auxbas_pw_pool%give_back_pw(pcc_density_g)
248 CALL timestop(handle)