31 pw_pools_give_back_pws
38 #include "../base/base_uses.f90"
44 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rs_pw_interface'
66 TYPE(pw_env_type),
INTENT(IN) :: pw_env
67 TYPE(realspace_grid_type),
DIMENSION(:), &
69 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: rho
70 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: rho_gspace
72 CHARACTER(LEN=*),
PARAMETER :: routinen =
'density_rs2pw'
74 INTEGER :: handle, igrid_level, interp_kind
75 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
76 TYPE(pw_c1d_gs_type),
ALLOCATABLE,
DIMENSION(:) :: mgrid_gspace
77 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
78 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:) :: mgrid_rspace
79 TYPE(realspace_grid_desc_p_type),
DIMENSION(:), &
82 CALL timeset(routinen, handle)
83 NULLIFY (gridlevel_info, rs_descs, pw_pools)
84 CALL pw_env_get(pw_env, rs_descs=rs_descs, pw_pools=pw_pools)
86 gridlevel_info => pw_env%gridlevel_info
90 CALL pw_pools_create_pws(pw_pools, mgrid_rspace)
92 CALL pw_pools_create_pws(pw_pools, mgrid_gspace)
94 IF (gridlevel_info%ngrid_levels == 1)
THEN
96 CALL pw_transfer(rho, rho_gspace)
97 IF (rho%pw_grid%spherical)
THEN
98 CALL pw_transfer(rho_gspace, rho)
101 DO igrid_level = 1, gridlevel_info%ngrid_levels
103 mgrid_rspace(igrid_level))
107 SELECT CASE (interp_kind)
109 CALL pw_zero(rho_gspace)
110 DO igrid_level = 1, gridlevel_info%ngrid_levels
111 CALL pw_transfer(mgrid_rspace(igrid_level), &
112 mgrid_gspace(igrid_level))
113 CALL pw_axpy(mgrid_gspace(igrid_level), rho_gspace)
115 CALL pw_transfer(rho_gspace, rho)
117 DO igrid_level = gridlevel_info%ngrid_levels, 2, -1
119 mgrid_rspace(igrid_level - 1), pw_pools(igrid_level)%pool, &
120 pw_env%interp_section)
122 CALL pw_copy(mgrid_rspace(1), rho)
123 CALL pw_transfer(rho, rho_gspace)
125 CALL cp_abort(__location__, &
127 cp_to_string(interp_kind))
132 CALL pw_pools_give_back_pws(pw_pools, mgrid_gspace)
133 CALL pw_pools_give_back_pws(pw_pools, mgrid_rspace)
134 CALL timestop(handle)
153 TYPE(realspace_grid_type),
DIMENSION(:), &
155 TYPE(pw_r3d_rs_type),
INTENT(IN) :: v_rspace
156 TYPE(pw_env_type),
INTENT(IN) :: pw_env
158 CHARACTER(len=*),
PARAMETER :: routinen =
'potential_pw2rs'
160 INTEGER :: auxbas_grid, handle, igrid_level, &
162 REAL(kind=
dp) :: scale
163 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
164 TYPE(pw_c1d_gs_type),
ALLOCATABLE,
DIMENSION(:) :: mgrid_gspace
165 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
166 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:) :: mgrid_rspace
168 CALL timeset(routinen, handle)
171 CALL pw_env_get(pw_env, pw_pools=pw_pools, gridlevel_info=gridlevel_info, &
172 auxbas_grid=auxbas_grid)
174 CALL pw_pools_create_pws(pw_pools, mgrid_rspace)
178 SELECT CASE (interp_kind)
180 CALL pw_pools_create_pws(pw_pools, mgrid_gspace)
181 CALL pw_transfer(v_rspace, mgrid_gspace(auxbas_grid))
182 DO igrid_level = 1, gridlevel_info%ngrid_levels
183 IF (igrid_level /= auxbas_grid)
THEN
184 CALL pw_copy(mgrid_gspace(auxbas_grid), mgrid_gspace(igrid_level))
185 CALL pw_transfer(mgrid_gspace(igrid_level), mgrid_rspace(igrid_level))
187 IF (mgrid_gspace(auxbas_grid)%pw_grid%spherical)
THEN
188 CALL pw_transfer(mgrid_gspace(auxbas_grid), mgrid_rspace(auxbas_grid))
190 CALL pw_copy(v_rspace, mgrid_rspace(auxbas_grid))
194 IF (igrid_level /= auxbas_grid)
THEN
195 scale = mgrid_rspace(igrid_level)%pw_grid%dvol/ &
196 mgrid_rspace(auxbas_grid)%pw_grid%dvol
197 mgrid_rspace(igrid_level)%array = &
198 scale*mgrid_rspace(igrid_level)%array
201 CALL pw_pools_give_back_pws(pw_pools, mgrid_gspace)
203 CALL pw_copy(v_rspace, mgrid_rspace(1))
204 DO igrid_level = 1, gridlevel_info%ngrid_levels - 1
205 CALL pw_zero(mgrid_rspace(igrid_level + 1))
207 mgrid_rspace(igrid_level + 1), pw_pools(igrid_level + 1)%pool, &
208 pw_env%interp_section)
210 mgrid_rspace(igrid_level + 1)%array = &
211 mgrid_rspace(igrid_level + 1)%array*8._dp
214 CALL cp_abort(__location__, &
215 "interpolation not supported "// &
216 cp_to_string(interp_kind))
219 DO igrid_level = 1, gridlevel_info%ngrid_levels
221 mgrid_rspace(igrid_level))
224 CALL pw_pools_give_back_pws(pw_pools, mgrid_rspace)
226 CALL timestop(handle)
various routines to log and control the output. The idea is that decisions about where to log should ...
utils to manipulate splines on the regular grid of a pw
integer, parameter, public pw_interp
subroutine, public pw_prolongate_s3(pw_coarse_in, pw_fine_out, coarse_pool, param_section)
prolongates a function from a coarse grid into a fine one
integer, parameter, public spline3_pbc_interp
subroutine, public pw_restrict_s3(pw_fine_in, pw_coarse_out, coarse_pool, param_section)
restricts the function from a fine grid to a coarse one
Defines the basic variable types.
integer, parameter, public dp
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public transfer_pw2rs(rs, pw)
...
subroutine, public transfer_rs2pw(rs, pw)
...
Transfers densities from PW to RS grids and potentials from PW to RS.
subroutine, public density_rs2pw(pw_env, rs_rho, rho, rho_gspace)
given partial densities on the realspace multigrids, computes the full density on the plane wave grid...
subroutine, public potential_pw2rs(rs_v, v_rspace, pw_env)
transfers a potential from a pw_grid to a vector of realspace multigrids