111#include "./base/base_uses.f90"
116 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
117 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pw_env_methods'
135 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_env_create'
139 CALL timeset(routinen, handle)
141 cpassert(.NOT.
ASSOCIATED(pw_env))
143 NULLIFY (pw_env%pw_pools, pw_env%gridlevel_info, pw_env%poisson_env, &
144 pw_env%cube_info, pw_env%rs_descs, pw_env%rs_grids, &
145 pw_env%xc_pw_pool, pw_env%vdw_pw_pool, &
146 pw_env%interp_section)
147 pw_env%auxbas_grid = -1
150 CALL timestop(handle)
167 TARGET :: external_para_env
169 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_env_rebuild'
171 CHARACTER(LEN=3) :: string
172 INTEGER :: blocked_id, blocked_id_input, boundary_condition, grid_span, handle, i, &
173 igrid_level, iounit, ncommensurate, ngrid_level, xc_deriv_method_id, xc_smooth_method_id
174 INTEGER,
DIMENSION(2) :: distribution_layout
175 INTEGER,
DIMENSION(3) :: higher_grid_layout
176 LOGICAL :: do_io, efg_present, linres_present, odd, set_vdw_pool, should_output, &
177 smooth_required, spherical, uf_grid, use_ref_cell
178 REAL(kind=
dp) :: cutilev, fine_grid_factor, rel_cutoff
179 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: radius
180 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cutoff
181 TYPE(
cell_type),
POINTER :: cell, cell_ref, my_cell
185 TYPE(
pw_grid_type),
POINTER :: dct_pw_grid, mt_super_ref_grid, old_pw_grid, pw_grid, &
186 super_ref_grid, vdw_grid, vdw_ref_grid, xc_super_ref_grid
190 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
196 poisson_section, print_section, &
197 rs_grid_section, xc_section
205 CALL timeset(routinen, handle)
212 NULLIFY (cutoff, cell, pw_grid, old_pw_grid, dft_control, qs_kind_set, &
213 pw_pools, rs_descs, para_env, cell_ref, vdw_ref_grid, &
214 mt_super_ref_grid, input, poisson_section, xc_super_ref_grid, &
215 dct_pw_grid, vdw_grid, super_ref_grid, my_cell, rs_grids, dispersion_env)
218 dft_control=dft_control, &
219 qs_kind_set=qs_kind_set, &
224 dispersion_env=dispersion_env)
226 cpassert(
ASSOCIATED(pw_env))
227 cpassert(pw_env%ref_count > 0)
231 IF (
ASSOCIATED(pw_env%rs_descs))
THEN
232 DO i = 1,
SIZE(pw_env%rs_descs)
235 DEALLOCATE (pw_env%rs_descs)
237 IF (
ASSOCIATED(pw_env%rs_grids))
THEN
238 DO i = 1,
SIZE(pw_env%rs_grids)
241 DEALLOCATE (pw_env%rs_grids)
243 IF (
ASSOCIATED(pw_env%gridlevel_info))
THEN
246 ALLOCATE (pw_env%gridlevel_info)
249 IF (
ASSOCIATED(pw_env%cube_info))
THEN
250 DO igrid_level = 1,
SIZE(pw_env%cube_info)
253 DEALLOCATE (pw_env%cube_info)
255 NULLIFY (pw_env%pw_pools, pw_env%cube_info)
267 IF (
PRESENT(external_para_env))
THEN
268 para_env => external_para_env
269 cpassert(
ASSOCIATED(para_env))
275 CALL get_qs_env(qs_env, use_ref_cell=use_ref_cell)
276 IF (use_ref_cell)
THEN
281 rel_cutoff = dft_control%qs_control%relative_cutoff
282 cutoff => dft_control%qs_control%e_cutoff
285 IF (uf_grid .AND. fine_grid_factor <= 1.0_dp)
THEN
286 cpabort(
"FINE_GRID_FACTOR must be larger than one when USE_FINER_GRID is enabled")
288 ngrid_level =
SIZE(cutoff)
294 "PRINT%GRID_INFORMATION")
296 ngrid_levels=ngrid_level, cutoff=cutoff, rel_cutoff=rel_cutoff, &
297 print_section=print_section)
299 ALLOCATE (pw_pools(ngrid_level))
301 IF (dft_control%qs_control%commensurate_mgrids)
THEN
302 ncommensurate = ngrid_level
310 IF (dft_control%qs_control%pw_grid_opt%spherical)
THEN
313 ELSE IF (dft_control%qs_control%pw_grid_opt%fullspace)
THEN
322 CALL setup_super_ref_grid(super_ref_grid, mt_super_ref_grid, &
323 xc_super_ref_grid, cutilev, grid_span, spherical, my_cell, para_env, &
324 poisson_section, ncommensurate, uf_grid=uf_grid, &
325 fine_grid_factor=fine_grid_factor, &
326 print_section=print_section)
327 old_pw_grid => super_ref_grid
328 IF (.NOT.
ASSOCIATED(mt_super_ref_grid)) vdw_ref_grid => super_ref_grid
340 IF (dft_control%qs_control%pw_grid_opt%spherical)
THEN
344 ELSE IF (dft_control%qs_control%pw_grid_opt%fullspace)
THEN
355 blocked_id_input = dft_control%qs_control%pw_grid_opt%blocked
362 smooth_required = .false.
363 SELECT CASE (xc_deriv_method_id)
365 smooth_required = smooth_required .OR. .false.
368 smooth_required = smooth_required .OR. .true.
372 SELECT CASE (xc_smooth_method_id)
374 smooth_required = smooth_required .OR. .false.
376 smooth_required = smooth_required .OR. .true.
383 subsection_name=
"PROPERTIES%LINRES")
385 IF (linres_present)
THEN
386 smooth_required = smooth_required .OR. .true.
390 subsection_name=
"DFT%PRINT%ELECTRIC_FIELD_GRADIENT")
392 IF (efg_present)
THEN
393 smooth_required = smooth_required .OR. .true.
396 DO igrid_level = 1, ngrid_level
397 cutilev = cutoff(igrid_level)
401 blocked_id = blocked_id_input
403 distribution_layout = dft_control%qs_control%pw_grid_opt%distribution_layout
407 IF (qs_env%qmmm)
THEN
408 distribution_layout = [para_env%num_pe, 1]
413 IF (smooth_required)
THEN
414 distribution_layout = [para_env%num_pe, 1]
417 IF (igrid_level == 1)
THEN
418 IF (
ASSOCIATED(old_pw_grid))
THEN
419 CALL pw_grid_create(pw_grid, para_env, my_cell%hmat, grid_span=grid_span, &
421 spherical=spherical, odd=odd, fft_usage=.true., &
422 ncommensurate=ncommensurate, icommensurate=igrid_level, &
424 ref_grid=old_pw_grid, &
425 rs_dims=distribution_layout, &
427 old_pw_grid => pw_grid
429 CALL pw_grid_create(pw_grid, para_env, my_cell%hmat, grid_span=grid_span, &
431 spherical=spherical, odd=odd, fft_usage=.true., &
432 ncommensurate=ncommensurate, icommensurate=igrid_level, &
433 blocked=blocked_id, &
434 rs_dims=distribution_layout, &
436 old_pw_grid => pw_grid
439 CALL pw_grid_create(pw_grid, para_env, my_cell%hmat, grid_span=grid_span, &
441 spherical=spherical, odd=odd, fft_usage=.true., &
442 ncommensurate=ncommensurate, icommensurate=igrid_level, &
444 ref_grid=old_pw_grid, &
445 rs_dims=distribution_layout, &
450 NULLIFY (pw_pools(igrid_level)%pool)
457 pw_env%pw_pools => pw_pools
460 DO i = 1, ngrid_level
461 IF (cutoff(i) == dft_control%qs_control%cutoff) pw_env%auxbas_grid = i
465 IF (
ASSOCIATED(xc_super_ref_grid))
THEN
467 pw_grid=xc_super_ref_grid)
470 pw_env%xc_pw_pool => pw_pools(pw_env%auxbas_grid)%pool
471 CALL pw_env%xc_pw_pool%retain()
475 set_vdw_pool = .false.
476 IF (
ASSOCIATED(dispersion_env))
THEN
478 IF (dispersion_env%pw_cutoff > 0._dp) set_vdw_pool = .true.
481 IF (set_vdw_pool)
THEN
482 cpassert(
ASSOCIATED(old_pw_grid))
483 IF (.NOT.
ASSOCIATED(vdw_ref_grid)) vdw_ref_grid => old_pw_grid
484 IF (iounit > 0)
WRITE (iounit,
"(/,T2,A)")
"PW_GRID| Grid for non-local vdW functional"
485 CALL pw_grid_create(vdw_grid, para_env, my_cell%hmat, grid_span=grid_span, &
486 cutoff=dispersion_env%pw_cutoff, &
487 spherical=spherical, odd=odd, fft_usage=.true., &
488 ncommensurate=0, icommensurate=0, &
490 ref_grid=vdw_ref_grid, &
491 rs_dims=distribution_layout, &
496 pw_env%vdw_pw_pool => pw_pools(pw_env%auxbas_grid)%pool
497 CALL pw_env%vdw_pw_pool%retain()
503 IF (.NOT.
ASSOCIATED(pw_env%poisson_env))
THEN
504 ALLOCATE (pw_env%poisson_env)
505 CALL pw_env%poisson_env%create()
510 CALL pw_poisson_set(pw_env%poisson_env, cell_hmat=my_cell%hmat, pw_pools=pw_env%pw_pools, &
511 parameters=poisson_params, mt_super_ref_pw_grid=mt_super_ref_grid, &
512 dct_pw_grid=dct_pw_grid, use_level=pw_env%auxbas_grid)
519 IF (use_ref_cell)
THEN
520 DO igrid_level = 1,
SIZE(pw_pools)
521 CALL pw_grid_change(cell%hmat, pw_pools(igrid_level)%pool%pw_grid)
523 IF (set_vdw_pool)
CALL pw_grid_change(cell%hmat, pw_env%vdw_pw_pool%pw_grid)
525 CALL pw_poisson_set(pw_env%poisson_env, cell_hmat=cell%hmat, pw_pools=pw_env%pw_pools, &
526 parameters=poisson_params, mt_super_ref_pw_grid=mt_super_ref_grid, &
527 dct_pw_grid=dct_pw_grid, use_level=pw_env%auxbas_grid)
530 IF ((poisson_params%ps_implicit_params%boundary_condition ==
mixed_periodic_bc) .OR. &
531 (poisson_params%ps_implicit_params%boundary_condition ==
mixed_bc))
THEN
532 pw_env%poisson_env%parameters%dbc_params%do_dbc_cube = &
534 "DFT%PRINT%IMPLICIT_PSOLVER%DIRICHLET_BC_CUBE"),
cp_p_file)
537 IF ((poisson_params%ps_implicit_params%boundary_condition ==
neumann_bc) .OR. &
538 (poisson_params%ps_implicit_params%boundary_condition ==
mixed_bc))
THEN
539 CALL setup_dct_pw_grids(pw_env%poisson_env%pw_pools(pw_env%poisson_env%pw_level)%pool%pw_grid, &
540 my_cell%hmat, poisson_params%ps_implicit_params%neumann_directions, &
541 pw_env%poisson_env%dct_pw_grid)
544 IF (poisson_params%has_dielectric .AND. &
545 ((poisson_params%dielectric_params%derivative_method ==
derivative_cd3) .OR. &
546 (poisson_params%dielectric_params%derivative_method ==
derivative_cd5) .OR. &
547 (poisson_params%dielectric_params%derivative_method ==
derivative_cd7)))
THEN
549 SELECT CASE (poisson_params%ps_implicit_params%boundary_condition)
551 CALL setup_diel_rs_grid(pw_env%poisson_env%diel_rs_grid, &
552 poisson_params%dielectric_params%derivative_method, input, &
553 pw_env%poisson_env%dct_pw_grid)
555 CALL setup_diel_rs_grid(pw_env%poisson_env%diel_rs_grid, &
556 poisson_params%dielectric_params%derivative_method, input, &
557 pw_env%poisson_env%pw_pools(pw_env%poisson_env%pw_level)%pool%pw_grid)
569 ALLOCATE (radius(ngrid_level))
571 CALL compute_max_radius(radius, pw_env, qs_env)
578 ALLOCATE (rs_descs(ngrid_level))
580 ALLOCATE (rs_grids(ngrid_level))
582 ALLOCATE (pw_env%cube_info(ngrid_level))
583 higher_grid_layout = [-1, -1, -1]
585 DO igrid_level = 1, ngrid_level
586 pw_grid => pw_pools(igrid_level)%pool%pw_grid
590 pw_grid%dr(:), pw_grid%dh(:, :), pw_grid%dh_inv(:, :), pw_grid%orthorhombic, &
596 rs_grid_section=rs_grid_section, ilevel=igrid_level, &
597 higher_grid_layout=higher_grid_layout)
599 NULLIFY (rs_descs(igrid_level)%rs_desc)
602 IF (rs_descs(igrid_level)%rs_desc%distributed) higher_grid_layout = rs_descs(igrid_level)%rs_desc%group_dim
604 CALL rs_grid_create(rs_grids(igrid_level), rs_descs(igrid_level)%rs_desc)
606 pw_env%rs_descs => rs_descs
607 pw_env%rs_grids => rs_grids
618 SELECT CASE (poisson_params%solver)
620 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
621 "POISSON| Solver",
"PERIODIC"
623 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
624 "POISSON| Solver",
"ANALYTIC"
626 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
627 "POISSON| Solver", adjustr(
"Martyna-Tuckerman (MT)")
628 WRITE (unit=iounit, fmt=
"(T2,A,T71,F10.3,/,T2,A,T71,F10.1)") &
629 "POISSON| MT| Alpha", poisson_params%mt_alpha, &
630 "POISSON| MT| Relative cutoff", poisson_params%mt_rel_cutoff
632 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
633 "POISSON| Solver",
"MULTIPOLE (Bloechl)"
635 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
636 "POISSON| Solver",
"WAVELET"
637 WRITE (unit=iounit, fmt=
"(T2,A,T71,I10)") &
638 "POISSON| Wavelet| Scaling function", poisson_params%wavelet_scf_type
639 SELECT CASE (poisson_params%wavelet_method)
641 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
642 "POISSON| Periodicity",
"NONE"
645 IF (poisson_params%periodic(1) == 1) string = trim(string)//
"X"
646 IF (poisson_params%periodic(2) == 1) string = trim(string)//
"Y"
647 IF (poisson_params%periodic(3) == 1) string = trim(string)//
"Z"
648 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
649 "POISSON| Periodicity", adjustr(string)
651 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
652 "POISSON| Periodicity",
"XYZ"
654 cpabort(
"Invalid periodicity for wavelet solver selected")
657 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
658 "POISSON| Solver",
"IMPLICIT (GENERALIZED)"
659 boundary_condition = poisson_params%ps_implicit_params%boundary_condition
660 SELECT CASE (boundary_condition)
662 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
663 "POISSON| Boundary Condition",
"PERIODIC"
666 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
667 "POISSON| Boundary Condition",
"NEUMANN"
669 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
670 "POISSON| Boundary Condition",
"MIXED"
672 SELECT CASE (poisson_params%ps_implicit_params%neumann_directions)
674 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"X, Y, Z"
675 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"NONE"
677 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"X, Y"
678 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"Z"
680 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"X, Z"
681 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"Y"
683 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"Y, Z"
684 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"X"
686 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"X"
687 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"Y, Z"
689 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"Y"
690 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"X, Z"
692 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| homogeneous Neumann directions",
"Z"
693 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)")
"POISSON| periodic directions",
"X, Y"
695 cpabort(
"Invalid combination of Neumann and periodic conditions.")
698 WRITE (unit=iounit, fmt=
"(T2,A,T51,A30)") &
699 "POISSON| Boundary Condition",
"PERIODIC & DIRICHLET"
701 cpabort(
"Invalid boundary conditions for the implicit (generalized) poisson solver.")
703 WRITE (unit=iounit, fmt=
"(T2,A,T71,I10)") &
704 "POISSON| Maximum number of iterations", poisson_params%ps_implicit_params%max_iter
705 WRITE (unit=iounit, fmt=
"(T2,A,T51,ES30.2)") &
706 "POISSON| Convergence threshold", poisson_params%ps_implicit_params%tol
707 IF (poisson_params%dielectric_params%dielec_functiontype ==
rho_dependent)
THEN
708 WRITE (unit=iounit, fmt=
"(T2,A,T51,F30.2)") &
709 "POISSON| Dielectric Constant", poisson_params%dielectric_params%eps0
711 WRITE (unit=iounit, fmt=
"(T2,A,T31,F9.2)", advance=
'NO') &
712 "POISSON| Dielectric Constants", poisson_params%dielectric_params%eps0
713 DO i = 1, poisson_params%dielectric_params%n_aa_cuboidal
714 WRITE (unit=iounit, fmt=
"(F9.2)", advance=
'NO') &
715 poisson_params%dielectric_params%aa_cuboidal_eps(i)
717 DO i = 1, poisson_params%dielectric_params%n_xaa_annular
718 WRITE (unit=iounit, fmt=
"(F9.2)", advance=
'NO') &
719 poisson_params%dielectric_params%xaa_annular_eps(i)
721 WRITE (unit=iounit, fmt=
'(A1,/)')
723 WRITE (unit=iounit, fmt=
"(T2,A,T51,ES30.2)") &
724 "POISSON| Relaxation parameter", poisson_params%ps_implicit_params%omega
726 WRITE (unit=iounit, fmt=
"(/,T2,A,T51,A30)") &
727 "POISSON| Solver",
"NONE"
729 cpabort(
"Invalid Poisson solver selected")
733 IF (sum(poisson_params%periodic(1:3)) == 0)
THEN
734 WRITE (unit=iounit, fmt=
"(T2,A,T77,A4)") &
735 "POISSON| Periodicity",
"NONE"
738 IF (poisson_params%periodic(1) == 1) string = trim(string)//
"X"
739 IF (poisson_params%periodic(2) == 1) string = trim(string)//
"Y"
740 IF (poisson_params%periodic(3) == 1) string = trim(string)//
"Z"
741 WRITE (unit=iounit, fmt=
"(T2,A,T78,A3)") &
742 "POISSON| Periodicity", adjustr(string)
747 IF ((dft_control%qs_control%method_id ==
do_method_gpw) .OR. &
754 IF (any(my_cell%perd(1:3) /= poisson_params%periodic(1:3)))
THEN
755 CALL cp_warn(__location__, &
756 "The selected periodicities in the sections &CELL and &POISSON do not match")
764 IF (should_output)
THEN
765 DO igrid_level = 1, ngrid_level
772 CALL timestop(handle)
786 SUBROUTINE compute_max_radius(radius, pw_env, qs_env)
787 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: radius
791 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_max_radius'
792 CHARACTER(LEN=8),
DIMENSION(10),
PARAMETER :: sbas = [
"ORB ",
"AUX ",
"RI_AUX ", &
793 "MAO ",
"HARRIS ",
"RI_HXC ",
"RI_K ",
"LRI_AUX ",
"RHOIN ",
"NUC "]
794 CHARACTER(LEN=8),
DIMENSION(5),
PARAMETER :: &
795 pbas = [
"ORB ",
"AUX_FIT ",
"MAO ",
"HARRIS ",
"NUC "]
796 REAL(kind=
dp),
PARAMETER :: safety_factor = 1.015_dp
798 INTEGER :: handle, ibasis_set_type, igrid_level, igrid_zet0_s, ikind, ipgf, iset, ishell, &
799 jkind, jpgf, jset, jshell, la, lb, lgrid_level, ngrid_level, nkind, nseta, nsetb
800 INTEGER,
DIMENSION(:),
POINTER :: npgfa, npgfb, nshella, nshellb
801 INTEGER,
DIMENSION(:, :),
POINTER :: lshella, lshellb
802 REAL(kind=
dp) :: alpha, core_charge, eps_gvg, eps_rho, &
803 max_rpgf0_s, maxradius, zet0_h, zetp
804 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zeta, zetb
808 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
817 CALL timeset(routinen, handle)
818 NULLIFY (dft_control, qs_kind_set, rho0_mpole)
820 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
822 eps_rho = dft_control%qs_control%eps_rho_rspace
823 eps_gvg = dft_control%qs_control%eps_gvg_rspace
825 IF (dft_control%qs_control%gapw)
THEN
826 CALL get_qs_env(qs_env=qs_env, rho0_mpole=rho0_mpole)
827 cpassert(
ASSOCIATED(rho0_mpole))
829 CALL get_rho0_mpole(rho0_mpole=rho0_mpole, max_rpgf0_s=max_rpgf0_s, zet0_h=zet0_h)
831 rho0_mpole%igrid_zet0_s = igrid_zet0_s
834 ngrid_level =
SIZE(radius)
835 nkind =
SIZE(qs_kind_set)
840 DO igrid_level = 1, ngrid_level
844 IF (dft_control%qs_control%gapw)
THEN
845 IF (igrid_zet0_s == igrid_level) maxradius = max(maxradius, max_rpgf0_s)
853 NULLIFY (cneo_potential)
854 CALL get_qs_kind(qs_kind_set(ikind), cneo_potential=cneo_potential)
855 IF (
ASSOCIATED(cneo_potential)) cycle
857 alpha_core_charge=alpha, ccore_charge=core_charge)
858 IF (alpha > 0.0_dp .AND. core_charge /= 0.0_dp)
THEN
859 maxradius = max(maxradius,
exp_radius(0, alpha, eps_rho, core_charge, rlow=maxradius))
861 maxradius = max(maxradius,
exp_radius(1, alpha, eps_rho, core_charge, rlow=maxradius))
867 DO ibasis_set_type = 1,
SIZE(sbas)
869 qs_kind => qs_kind_set(ikind)
870 NULLIFY (orb_basis_set)
872 basis_set=orb_basis_set, basis_type=sbas(ibasis_set_type))
873 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
875 npgf=npgfa, nset=nseta, zet=zeta, l=lshella, nshell=nshella)
877 DO ipgf = 1, npgfa(iset)
878 DO ishell = 1, nshella(iset)
879 zetp = zeta(ipgf, iset)
880 la = lshella(ishell, iset)
882 IF (lgrid_level == igrid_level)
THEN
883 maxradius = max(maxradius,
exp_radius(la, zetp, eps_rho, 1.0_dp, rlow=maxradius))
891 DO ibasis_set_type = 1,
SIZE(pbas)
893 qs_kind => qs_kind_set(ikind)
894 NULLIFY (orb_basis_set)
896 basis_set=orb_basis_set, basis_type=pbas(ibasis_set_type))
897 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
899 npgf=npgfa, nset=nseta, zet=zeta, l=lshella, nshell=nshella)
902 qs_kind => qs_kind_set(jkind)
904 basis_set=orb_basis_set, basis_type=pbas(ibasis_set_type))
905 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
907 npgf=npgfb, nset=nsetb, zet=zetb, l=lshellb, nshell=nshellb)
909 DO ipgf = 1, npgfa(iset)
910 DO ishell = 1, nshella(iset)
911 la = lshella(ishell, iset)
913 DO jpgf = 1, npgfb(jset)
914 DO jshell = 1, nshellb(jset)
915 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
916 lb = lshellb(jshell, jset) + la
918 IF (lgrid_level == igrid_level)
THEN
920 maxradius = max(maxradius,
exp_radius(lb, zetp, eps_rho, 2.0_dp, rlow=maxradius))
922 maxradius = max(maxradius,
exp_radius(lb + 1, zetp, eps_rho, 2.0_dp, rlow=maxradius))
924 maxradius = max(maxradius,
exp_radius(lb, zetp, eps_gvg, 2.0_dp, rlow=maxradius))
926 maxradius = max(maxradius,
exp_radius(lb + 1, zetp, eps_gvg, 2.0_dp, rlow=maxradius))
939 maxradius = maxradius*safety_factor
940 radius(igrid_level) = maxradius
943 CALL timestop(handle)
945 END SUBROUTINE compute_max_radius
966 SUBROUTINE setup_super_ref_grid(super_ref_pw_grid, mt_super_ref_pw_grid, &
967 xc_super_ref_pw_grid, cutilev, grid_span, spherical, &
968 cell_ref, para_env, poisson_section, my_ncommensurate, uf_grid, &
969 fine_grid_factor, print_section)
970 TYPE(
pw_grid_type),
POINTER :: super_ref_pw_grid, mt_super_ref_pw_grid, &
972 REAL(kind=
dp),
INTENT(IN) :: cutilev
973 INTEGER,
INTENT(IN) :: grid_span
974 LOGICAL,
INTENT(in) :: spherical
978 INTEGER,
INTENT(IN) :: my_ncommensurate
979 LOGICAL,
INTENT(in) :: uf_grid
980 REAL(kind=
dp),
INTENT(IN) :: fine_grid_factor
983 INTEGER :: iounit, my_val, nn(3), no(3)
985 REAL(kind=
dp) :: mt_rel_cutoff, my_cutilev
988 cpassert(.NOT.
ASSOCIATED(mt_super_ref_pw_grid))
989 cpassert(.NOT.
ASSOCIATED(xc_super_ref_pw_grid))
990 cpassert(.NOT.
ASSOCIATED(super_ref_pw_grid))
999 IF (mt_rel_cutoff > 1._dp) mt_s_grid = .true.
1007 my_cutilev = fine_grid_factor*cutilev
1008 IF (mt_s_grid) my_cutilev = max(my_cutilev, cutilev*mt_rel_cutoff)
1009 CALL pw_grid_create(xc_super_ref_pw_grid, para_env, cell_ref%hmat, grid_span=grid_span, &
1010 cutoff=my_cutilev, spherical=spherical, odd=.false., fft_usage=.true., &
1011 ncommensurate=my_ncommensurate, icommensurate=1, &
1014 super_ref_pw_grid => xc_super_ref_pw_grid
1017 my_cutilev = cutilev*mt_rel_cutoff
1018 IF (
ASSOCIATED(xc_super_ref_pw_grid)) my_cutilev = max(my_cutilev, fine_grid_factor*cutilev)
1021 odd=.false., fft_usage=.true., ncommensurate=0, icommensurate=1)
1023 odd=.false., fft_usage=.true., ncommensurate=0, icommensurate=1)
1026 cpassert(all(nn > no))
1027 IF (
ASSOCIATED(xc_super_ref_pw_grid))
THEN
1028 mt_super_ref_pw_grid => xc_super_ref_pw_grid
1031 CALL pw_grid_create(mt_super_ref_pw_grid, para_env, cell_ref%hmat, &
1032 cutoff=my_cutilev, spherical=spherical, fft_usage=.true., &
1035 super_ref_pw_grid => mt_super_ref_pw_grid
1040 END SUBROUTINE setup_super_ref_grid
1053 SUBROUTINE setup_diel_rs_grid(diel_rs_grid, method, input, pw_grid)
1056 INTEGER,
INTENT(IN) :: method
1060 CHARACTER(LEN=*),
PARAMETER :: routinen =
'setup_diel_rs_grid'
1062 INTEGER :: border_points, handle
1067 CALL timeset(routinen, handle)
1071 SELECT CASE (method)
1079 CALL init_input_type(input_settings, 2*border_points + 1, rs_grid_section, &
1082 border_points=border_points)
1083 ALLOCATE (diel_rs_grid)
1087 CALL timestop(handle)
1089 END SUBROUTINE setup_diel_rs_grid
All kind of helpful little routines.
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
subroutine, public init_input_type(input_settings, nsmax, rs_grid_section, ilevel, higher_grid_layout)
parses an input section to assign the proper values to the input type
for a given dr()/dh(r) this will provide the bounds to be used if one wants to go over a sphere-subre...
integer function, public return_cube_max_iradius(info)
...
subroutine, public destroy_cube_info(info)
...
subroutine, public init_cube_info(info, dr, dh, dh_inv, ortho, max_radius)
...
Routines to efficiently handle dense polynomial in 3 variables up to a given degree....
subroutine, public init_d3_poly_module()
initialization of the cache, is called by functions in this module that use cached values
the type I Discrete Cosine Transform (DCT-I)
integer, parameter, public neumannx
integer, parameter, public neumannxy
integer, parameter, public neumannxz
integer, parameter, public neumannxyz
integer, parameter, public neumannz
integer, parameter, public neumannyz
subroutine, public setup_dct_pw_grids(pw_grid, cell_hmat, neumann_directions, dct_pw_grid)
sets up an extended pw_grid for Discrete Cosine Transform (DCT) calculations
integer, parameter, public neumanny
dielectric constant data type
integer, parameter, public derivative_cd5
integer, parameter, public derivative_cd3
integer, parameter, public rho_dependent
integer, parameter, public derivative_cd7
integer function, public gaussian_gridlevel(gridlevel_info, exponent)
...
subroutine, public destroy_gaussian_gridlevel(gridlevel_info, para_env)
...
subroutine, public init_gaussian_gridlevel(gridlevel_info, ngrid_levels, cutoff, rel_cutoff, print_section)
...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Types containing essential information for running implicit (iterative) Poisson solver.
integer, parameter, public neumann_bc
integer, parameter, public mixed_bc
integer, parameter, public mixed_periodic_bc
integer, parameter, public periodic_bc
Definition and initialisation of the ps_wavelet data type.
integer, parameter, public wavelet3d
integer, parameter, public wavelet0d
integer, parameter, public wavelet2d
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_rebuild(pw_env, qs_env, external_para_env)
rebuilds the pw_env data (necessary if cell or cutoffs change)
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
This module returns additional info on PW grids.
integer function, dimension(3), public pw_grid_init_setup(hmat, cutoff, spherical, odd, fft_usage, ncommensurate, icommensurate, ref_grid, n_orig)
...
integer, parameter, public halfspace
integer, parameter, public fullspace
This module defines the grid data type and some basic operations on it.
integer, parameter, public do_pw_grid_blocked_false
subroutine, public pw_grid_release(pw_grid)
releases the given pw grid
subroutine, public pw_grid_retain(pw_grid)
retains the given pw grid
subroutine, public pw_grid_change(cell_hmat, pw_grid)
Recalculate the g-vectors after a change of the box.
subroutine, public pw_poisson_set(poisson_env, cell_hmat, parameters, pw_pools, use_level, mt_super_ref_pw_grid, dct_pw_grid, force_rebuild)
sets cell, grids and parameters used by the poisson solver You should call this at least once (and se...
functions related to the poisson solver on regular grids
integer, parameter, public pw_poisson_wavelet
integer, parameter, public pw_poisson_periodic
integer, parameter, public pw_poisson_none
integer, parameter, public pw_poisson_mt
integer, parameter, public pw_poisson_implicit
integer, parameter, public pw_poisson_analytic
integer, parameter, public pw_poisson_multipole
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public pw_pools_dealloc(pools)
deallocates the given pools (releasing each of the underlying pools)
subroutine, public pw_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
subroutine, public pw_pool_create(pool, pw_grid, max_cache)
creates a pool for pw
Types used by CNEO-DFT (see J. Chem. Theory Comput. 2025, 21, 16, 7865–7877)
Definition of disperson types for DFT calculations.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, mp_gau_ikind, mp_rho, norm_g0l_h, qlm_gg, qlm_car, qlm_tot, zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, max_rpgf0_s, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs)
...
subroutine, public rs_grid_print(rs, iounit)
Print information on grids to output.
subroutine, public rs_grid_create(rs, desc)
...
subroutine, public rs_grid_create_descriptor(desc, pw_grid, input_settings, border_points)
Determine the setup of real space grids - this is divided up into the creation of a descriptor and th...
subroutine, public rs_grid_release_descriptor(rs_desc)
releases the given rs grid descriptor (see doc/ReferenceCounting.html)
subroutine, public rs_grid_release(rs_grid)
releases the given rs grid (see doc/ReferenceCounting.html)
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
contained for different pw related things
parameters for the poisson solver independet of input_section
to create arrays of pools
Provides all information about a quickstep kind.