34#include "../base/base_uses.f90"
42 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'xc_util'
45 MODULE PROCEDURE xc_pw_derive_r3d_rs, xc_pw_derive_c1d_gs
49 MODULE PROCEDURE xc_pw_laplace_r3d_rs, xc_pw_laplace_c1d_gs
60 INTEGER,
INTENT(IN) :: xc_deriv_id
77 INTEGER,
INTENT(IN) :: xc_smooth_id
79 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xc_pw_smooth'
83 CALL timeset(routinen, handle)
85 SELECT CASE (xc_smooth_id)
109 cpabort(
"Unsupported smoothing")
112 CALL timestop(handle)
128 INTEGER,
INTENT(IN) :: xc_deriv_method_id
134 IF (xc_deriv_method_id ==
xc_deriv_pw .AND.
ASSOCIATED(pw_g%pw_grid, tmp_g%pw_grid))
THEN
136 DO ig = 1,
SIZE(pw_g%array)
137 tmp_g%array(ig) =
gaussi*(pw_g%array(ig)*pw_g%pw_grid%g(idir, ig))
142 CALL xc_pw_derive(pw_r, tmp_g, gradient(idir), idir, xc_deriv_method_id, pw_g=pw_g)
156 SUBROUTINE xc_pw_laplace_r3d_rs(pw, pw_pool, deriv_method_id, pw_out, tmp_g)
159 INTEGER,
INTENT(IN) :: deriv_method_id
163 CHARACTER(LEN=*),
PARAMETER :: routineN =
'xc_pw_laplace'
166 LOGICAL :: owns_tmp_g
169 CALL timeset(routinen, handle)
171 SELECT CASE (deriv_method_id)
174 IF (
PRESENT(tmp_g)) my_tmp_g = tmp_g
177 IF (.NOT.
ASSOCIATED(my_tmp_g%pw_grid))
THEN
178 CALL pw_pool%create_pw(my_tmp_g)
186 IF (
PRESENT(pw_out))
THEN
192 CALL pw_pool%give_back_pw(my_tmp_g)
195 cpabort(
"Unsupported derivative method")
198 CALL timestop(handle)
200 END SUBROUTINE xc_pw_laplace_r3d_rs
209 SUBROUTINE xc_pw_laplace_c1d_gs(pw, pw_pool, deriv_method_id, pw_out, tmp_g)
212 INTEGER,
INTENT(IN) :: deriv_method_id
216 CHARACTER(LEN=*),
PARAMETER :: routineN =
'xc_pw_laplace'
219 LOGICAL :: owns_tmp_g
222 CALL timeset(routinen, handle)
224 SELECT CASE (deriv_method_id)
227 IF (
PRESENT(tmp_g)) my_tmp_g = tmp_g
230 IF (.NOT.
ASSOCIATED(my_tmp_g%pw_grid))
THEN
231 CALL pw_pool%create_pw(my_tmp_g)
239 IF (
PRESENT(pw_out))
THEN
245 CALL pw_pool%give_back_pw(my_tmp_g)
248 cpabort(
"Unsupported derivative method")
251 CALL timestop(handle)
253 END SUBROUTINE xc_pw_laplace_c1d_gs
264 INTEGER,
INTENT(IN) :: xc_deriv_method_id
269 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xc_pw_divergence'
271 INTEGER :: handle, idir, ig
273 CALL timeset(routinen, handle)
280 IF (
ASSOCIATED(vxc_g%pw_grid))
CALL pw_zero(vxc_g)
283 IF (xc_deriv_method_id ==
xc_deriv_pw .AND.
ASSOCIATED(tmp_g%pw_grid, vxc_g%pw_grid))
THEN
286 DO ig = 1,
SIZE(tmp_g%array)
287 tmp_g%array(ig) =
gaussi*(tmp_g%array(ig)*tmp_g%pw_grid%g(idir, ig))
288 vxc_g%array(ig) = vxc_g%array(ig) + tmp_g%array(ig)
292 CALL xc_pw_derive(pw_to_deriv(idir), tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr=.false.)
293 IF (
ASSOCIATED(tmp_g%pw_grid) .AND.
ASSOCIATED(vxc_g%pw_grid))
CALL pw_axpy(tmp_g, vxc_g)
297 IF (
ASSOCIATED(vxc_g%pw_grid))
THEN
299 CALL pw_axpy(pw_to_deriv(1), vxc_r)
302 CALL timestop(handle)
316 SUBROUTINE xc_pw_derive_r3d_rs(pw, tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr, pw_g)
320 INTEGER,
INTENT(IN) :: idir, xc_deriv_method_id
321 LOGICAL,
INTENT(IN),
OPTIONAL :: copy_to_vxcr
324 CHARACTER(LEN=*),
PARAMETER :: routineN =
'xc_pw_derive'
325 INTEGER,
DIMENSION(3, 3),
PARAMETER :: nd = reshape([1, 0, 0, 0, 1, 0, 0, 0, 1], [3, 3])
328 LOGICAL :: my_copy_to_vxcr
330 CALL timeset(routinen, handle)
332 my_copy_to_vxcr = .true.
333 IF (
PRESENT(copy_to_vxcr)) my_copy_to_vxcr = copy_to_vxcr
337 IF (
PRESENT(pw_g))
THEN
338 IF (
ASSOCIATED(pw_g%pw_grid))
THEN
347 SELECT CASE (xc_deriv_method_id)
357 cpabort(
"Unsupported deriv method")
360 IF (my_copy_to_vxcr)
CALL pw_transfer(tmp_g, vxc_r)
362 SELECT CASE (xc_deriv_method_id)
380 cpabort(
"Unsupported derivative method")
384 CALL timestop(handle)
386 END SUBROUTINE xc_pw_derive_r3d_rs
397 SUBROUTINE xc_pw_derive_c1d_gs(pw, tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr, pw_g)
401 INTEGER,
INTENT(IN) :: idir, xc_deriv_method_id
402 LOGICAL,
INTENT(IN),
OPTIONAL :: copy_to_vxcr
405 CHARACTER(LEN=*),
PARAMETER :: routineN =
'xc_pw_derive'
406 INTEGER,
DIMENSION(3, 3),
PARAMETER :: nd = reshape([1, 0, 0, 0, 1, 0, 0, 0, 1], [3, 3])
409 LOGICAL :: my_copy_to_vxcr
412 CALL timeset(routinen, handle)
414 my_copy_to_vxcr = .true.
415 IF (
PRESENT(copy_to_vxcr)) my_copy_to_vxcr = copy_to_vxcr
419 IF (
PRESENT(pw_g))
THEN
420 IF (
ASSOCIATED(pw_g%pw_grid))
THEN
429 SELECT CASE (xc_deriv_method_id)
439 cpabort(
"Unsupported deriv method")
442 IF (my_copy_to_vxcr)
CALL pw_transfer(tmp_g, vxc_r)
444 CALL tmp_r%create(pw%pw_grid)
445 SELECT CASE (xc_deriv_method_id)
463 cpabort(
"Unsupported derivative method")
468 CALL timestop(handle)
470 END SUBROUTINE xc_pw_derive_c1d_gs
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public gaussi
subroutine, public pw_laplace(pw)
Calculate the Laplacian of a plane wave vector.
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
different utils that are useful to manipulate splines on the regular grid of a pw
subroutine, public pw_nn_deriv_r(pw_in, pw_out, coeffs, idir)
calculates a nearest neighbor central derivative. for the x dir: pw_outarray(i,j,k)=( pw_in(i+1,...
subroutine, public pw_spline3_deriv_g(spline_g, idir)
calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the cubic spline
real(kind=dp), dimension(4), parameter, public spline2_coeffs
real(kind=dp), dimension(3), parameter, public spline3_deriv_coeffs
subroutine, public pw_spline_scale_deriv(deriv_vals_r, transpose, scale)
rescales the derivatives from gridspacing=1 to the real derivatives
real(kind=dp), dimension(3), parameter, public spline2_deriv_coeffs
subroutine, public pw_nn_smear_r(pw_in, pw_out, coeffs)
calculates the values of a nearest neighbor smearing
real(kind=dp), dimension(4), parameter, public spline3_coeffs
real(kind=dp), dimension(3), parameter, public nn50_deriv_coeffs
subroutine, public pw_spline3_interpolate_values_g(spline_g)
calculates the FFT of the coefficients of the2 cubic spline that interpolates the given values
subroutine, public pw_spline2_interpolate_values_g(spline_g)
calculates the FFT of the coefficients of the quadratic spline that interpolates the given values
real(kind=dp), dimension(3), parameter, public nn10_deriv_coeffs
subroutine, public pw_spline2_deriv_g(spline_g, idir)
calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the quadratic spline
real(kind=dp), dimension(4), parameter, public nn10_coeffs
real(kind=dp), dimension(4), parameter, public nn50_coeffs
contains utility functions for the xc package
subroutine, public xc_pw_divergence(xc_deriv_method_id, pw_to_deriv, tmp_g, vxc_g, vxc_r)
Calculates the divergence of pw_to_deriv.
subroutine, public xc_pw_smooth(pw_in, pw_out, xc_smooth_id)
...
elemental logical function, public xc_requires_tmp_g(xc_deriv_id)
...
subroutine, public xc_pw_gradient(pw_r, pw_g, tmp_g, gradient, xc_deriv_method_id)
...
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...