28 pw_c1d_gs_type, pw_r3d_rs_type
33 #include "../base/base_uses.f90"
40 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xc_util'
42 INTERFACE xc_pw_derive
43 MODULE PROCEDURE xc_pw_derive_r3d_rs, xc_pw_derive_c1d_gs
46 INTERFACE xc_pw_laplace
47 MODULE PROCEDURE xc_pw_laplace_r3d_rs, xc_pw_laplace_c1d_gs
58 INTEGER,
INTENT(IN) :: xc_deriv_id
73 TYPE(pw_r3d_rs_type),
INTENT(IN) :: pw_in
74 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: pw_out
75 INTEGER,
INTENT(IN) :: xc_smooth_id
77 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_smooth'
81 CALL timeset(routinen, handle)
83 SELECT CASE (xc_smooth_id)
85 CALL pw_copy(pw_in, pw_out)
107 cpabort(
"Unsupported smoothing")
110 CALL timestop(handle)
123 TYPE(pw_r3d_rs_type),
INTENT(IN) :: pw_r
124 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: pw_g, tmp_g
125 TYPE(pw_r3d_rs_type),
DIMENSION(3),
INTENT(INOUT) :: gradient
126 INTEGER,
INTENT(IN) :: xc_deriv_method_id
131 CALL pw_zero(gradient(idir))
132 CALL xc_pw_derive(pw_r, tmp_g, gradient(idir), idir, xc_deriv_method_id, pw_g=pw_g)
145 SUBROUTINE xc_pw_laplace_r3d_rs (pw, pw_pool, deriv_method_id, pw_out, tmp_g)
146 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: pw
147 TYPE(pw_pool_type),
INTENT(IN),
POINTER :: pw_pool
148 INTEGER,
INTENT(IN) :: deriv_method_id
149 TYPE(pw_r3d_rs_type),
INTENT(INOUT),
OPTIONAL :: pw_out
150 TYPE(pw_c1d_gs_type),
INTENT(IN),
OPTIONAL :: tmp_g
152 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_laplace'
155 LOGICAL :: owns_tmp_g
156 TYPE(pw_c1d_gs_type) :: my_tmp_g
158 CALL timeset(routinen, handle)
160 SELECT CASE (deriv_method_id)
163 IF (
PRESENT(tmp_g)) my_tmp_g = tmp_g
166 IF (.NOT.
ASSOCIATED(my_tmp_g%pw_grid))
THEN
167 CALL pw_pool%create_pw(my_tmp_g)
170 CALL pw_zero(my_tmp_g)
171 CALL pw_transfer(pw, my_tmp_g)
175 IF (
PRESENT(pw_out))
THEN
176 CALL pw_transfer(my_tmp_g, pw_out)
178 CALL pw_transfer(my_tmp_g, pw)
181 CALL pw_pool%give_back_pw(my_tmp_g)
184 cpabort(
"Unsupported derivative method")
187 CALL timestop(handle)
189 END SUBROUTINE xc_pw_laplace_r3d_rs
198 SUBROUTINE xc_pw_laplace_c1d_gs (pw, pw_pool, deriv_method_id, pw_out, tmp_g)
199 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: pw
200 TYPE(pw_pool_type),
INTENT(IN),
POINTER :: pw_pool
201 INTEGER,
INTENT(IN) :: deriv_method_id
202 TYPE(pw_r3d_rs_type),
INTENT(INOUT),
OPTIONAL :: pw_out
203 TYPE(pw_c1d_gs_type),
INTENT(IN),
OPTIONAL :: tmp_g
205 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_laplace'
208 LOGICAL :: owns_tmp_g
209 TYPE(pw_c1d_gs_type) :: my_tmp_g
211 CALL timeset(routinen, handle)
213 SELECT CASE (deriv_method_id)
216 IF (
PRESENT(tmp_g)) my_tmp_g = tmp_g
219 IF (.NOT.
ASSOCIATED(my_tmp_g%pw_grid))
THEN
220 CALL pw_pool%create_pw(my_tmp_g)
223 CALL pw_zero(my_tmp_g)
224 CALL pw_transfer(pw, my_tmp_g)
228 IF (
PRESENT(pw_out))
THEN
229 CALL pw_transfer(my_tmp_g, pw_out)
231 CALL pw_transfer(my_tmp_g, pw)
234 CALL pw_pool%give_back_pw(my_tmp_g)
237 cpabort(
"Unsupported derivative method")
240 CALL timestop(handle)
242 END SUBROUTINE xc_pw_laplace_c1d_gs
253 INTEGER,
INTENT(IN) :: xc_deriv_method_id
254 TYPE(pw_r3d_rs_type),
DIMENSION(3),
INTENT(INOUT) :: pw_to_deriv
255 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: tmp_g, vxc_g
256 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: vxc_r
258 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_divergence'
260 INTEGER :: handle, idir
262 CALL timeset(routinen, handle)
269 IF (
ASSOCIATED(vxc_g%pw_grid))
CALL pw_zero(vxc_g)
272 CALL xc_pw_derive(pw_to_deriv(idir), tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr=.false.)
273 IF (
ASSOCIATED(tmp_g%pw_grid) .AND.
ASSOCIATED(vxc_g%pw_grid))
CALL pw_axpy(tmp_g, vxc_g)
276 IF (
ASSOCIATED(vxc_g%pw_grid))
THEN
277 CALL pw_transfer(vxc_g, pw_to_deriv(1))
278 CALL pw_axpy(pw_to_deriv(1), vxc_r)
281 CALL timestop(handle)
295 SUBROUTINE xc_pw_derive_r3d_rs (pw, tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr, pw_g)
296 TYPE(pw_r3d_rs_type),
INTENT(IN) :: pw
297 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: tmp_g
298 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: vxc_r
299 INTEGER,
INTENT(IN) :: idir, xc_deriv_method_id
300 LOGICAL,
INTENT(IN),
OPTIONAL :: copy_to_vxcr
301 TYPE(pw_c1d_gs_type),
INTENT(IN),
OPTIONAL :: pw_g
303 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_derive'
304 INTEGER,
DIMENSION(3, 3),
PARAMETER :: nd = reshape((/1, 0, 0, 0, 1, 0, 0, 0, 1/), (/3, 3/))
307 LOGICAL :: my_copy_to_vxcr
309 CALL timeset(routinen, handle)
311 my_copy_to_vxcr = .true.
312 IF (
PRESENT(copy_to_vxcr)) my_copy_to_vxcr = copy_to_vxcr
316 IF (
PRESENT(pw_g))
THEN
317 IF (
ASSOCIATED(pw_g%pw_grid))
THEN
318 CALL pw_copy(pw_g, tmp_g)
320 CALL pw_transfer(pw, tmp_g)
323 CALL pw_transfer(pw, tmp_g)
326 SELECT CASE (xc_deriv_method_id)
336 cpabort(
"Unsupported deriv method")
339 IF (my_copy_to_vxcr)
CALL pw_transfer(tmp_g, vxc_r)
341 SELECT CASE (xc_deriv_method_id)
359 cpabort(
"Unsupported derivative method")
363 CALL timestop(handle)
365 END SUBROUTINE xc_pw_derive_r3d_rs
376 SUBROUTINE xc_pw_derive_c1d_gs (pw, tmp_g, vxc_r, idir, xc_deriv_method_id, copy_to_vxcr, pw_g)
377 TYPE(pw_c1d_gs_type),
INTENT(IN) :: pw
378 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: tmp_g
379 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: vxc_r
380 INTEGER,
INTENT(IN) :: idir, xc_deriv_method_id
381 LOGICAL,
INTENT(IN),
OPTIONAL :: copy_to_vxcr
382 TYPE(pw_c1d_gs_type),
INTENT(IN),
OPTIONAL :: pw_g
384 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_pw_derive'
385 INTEGER,
DIMENSION(3, 3),
PARAMETER :: nd = reshape((/1, 0, 0, 0, 1, 0, 0, 0, 1/), (/3, 3/))
388 LOGICAL :: my_copy_to_vxcr
389 TYPE(pw_r3d_rs_type) :: tmp_r
391 CALL timeset(routinen, handle)
393 my_copy_to_vxcr = .true.
394 IF (
PRESENT(copy_to_vxcr)) my_copy_to_vxcr = copy_to_vxcr
398 IF (
PRESENT(pw_g))
THEN
399 IF (
ASSOCIATED(pw_g%pw_grid))
THEN
400 CALL pw_copy(pw_g, tmp_g)
402 CALL pw_transfer(pw, tmp_g)
405 CALL pw_transfer(pw, tmp_g)
408 SELECT CASE (xc_deriv_method_id)
418 cpabort(
"Unsupported deriv method")
421 IF (my_copy_to_vxcr)
CALL pw_transfer(tmp_g, vxc_r)
423 CALL tmp_r%create(pw%pw_grid)
424 SELECT CASE (xc_deriv_method_id)
442 cpabort(
"Unsupported derivative method")
447 CALL timestop(handle)
449 END SUBROUTINE xc_pw_derive_c1d_gs
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)
...