44 dbt_create, dbt_default_distvec, dbt_destroy, dbt_distribution_destroy, &
45 dbt_distribution_new, dbt_distribution_type, dbt_mp_dims_create, dbt_pgrid_create, &
46 dbt_pgrid_destroy, dbt_pgrid_type, dbt_type
93#include "./base/base_uses.f90"
115#define CACHE_SIZE 1024
116#define BITS_MAX_VAL 6
118 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'hfx_types'
123 REAL(kind=
dp),
DIMENSION(0:10), &
124 PARAMETER,
PUBLIC ::
mul_fact = [1.0_dp, &
143 REAL(
dp) :: omega = 0.0_dp
144 REAL(
dp) :: scale_coulomb = 0.0_dp
145 REAL(
dp) :: scale_longrange = 0.0_dp
146 REAL(
dp) :: scale_gaussian = 0.0_dp
147 REAL(
dp) :: cutoff_radius = 0.0_dp
148 CHARACTER(default_path_length) :: filename =
""
153 REAL(
dp) :: eps_schwarz = 0.0_dp
154 REAL(
dp) :: eps_schwarz_forces = 0.0_dp
155 LOGICAL :: do_p_screening_forces = .false.
156 LOGICAL :: do_initial_p_screening = .false.
161 INTEGER :: max_memory = 0
162 INTEGER(int_8) :: max_compression_counter = 0_int_8
163 INTEGER(int_8) :: final_comp_counter_energy = 0_int_8
164 LOGICAL :: do_all_on_the_fly = .false.
165 REAL(
dp) :: eps_storage_scaling = 0.0_dp
166 INTEGER :: cache_size = 0
167 INTEGER :: bits_max_val = 0
168 INTEGER :: actual_memory_usage = 0
169 INTEGER :: actual_memory_usage_disk = 0
170 INTEGER(int_8) :: max_compression_counter_disk = 0_int_8
171 LOGICAL :: do_disk_storage = .false.
172 CHARACTER(len=default_path_length) :: storage_location =
""
173 INTEGER(int_8) :: ram_counter = 0_int_8
174 INTEGER(int_8) :: ram_counter_forces = 0_int_8
175 INTEGER(int_8) :: size_p_screen = 0_int_8
176 LOGICAL :: treat_forces_in_core = .false.
177 LOGICAL :: recalc_forces = .false.
181 TYPE hfx_periodic_type
182 INTEGER :: number_of_shells = -1
183 LOGICAL :: do_periodic = .false.
184 INTEGER :: perd(3) = -1
186 REAL(
dp) :: r_max_stress = 0.0_dp
187 INTEGER :: number_of_shells_from_input = 0
188 END TYPE hfx_periodic_type
193 INTEGER :: block_size = 0
194 INTEGER :: nblocks = 0
195 LOGICAL :: rtp_redistribute = .false.
196 LOGICAL :: blocks_initialized = .false.
197 LOGICAL :: do_randomize = .false.
202 REAL(
dp) :: fraction = 0.0_dp
203 INTEGER :: hfx_library = 0
204 LOGICAL :: treat_lsd_in_core = .false.
209 REAL(
dp) :: cell(3) = 0.0_dp
210 REAL(
dp) :: cell_r(3) = 0.0_dp
215 INTEGER(int_8) :: istart = 0_int_8
216 INTEGER(int_8) :: number_of_atom_quartets = 0_int_8
217 INTEGER(int_8) :: cost = 0_int_8
218 REAL(kind=
dp) :: time_first_scf = 0.0_dp
219 REAL(kind=
dp) :: time_other_scf = 0.0_dp
220 REAL(kind=
dp) :: time_forces = 0.0_dp
221 INTEGER(int_8) :: ram_counter = 0_int_8
226 INTEGER,
DIMENSION(2) :: pair = 0
227 INTEGER,
DIMENSION(2) :: set_bounds = 0
228 INTEGER,
DIMENSION(2) :: kind_pair = 0
229 REAL(kind=
dp) :: r1(3) = 0.0_dp, r2(3) = 0.0_dp
230 REAL(kind=
dp) :: dist2 = 0.0_dp
235 INTEGER,
DIMENSION(2) :: pair = 0
241 INTEGER :: n_element = 0
246 INTEGER(int_8),
DIMENSION(CACHE_SIZE) :: data = 0_int_8
247 INTEGER :: element_counter = 0
251 TYPE hfx_container_node
252 TYPE(hfx_container_node),
POINTER :: next => null(), prev => null()
253 INTEGER(int_8),
DIMENSION(CACHE_SIZE) :: data = 0_int_8
254 END TYPE hfx_container_node
258 TYPE(hfx_container_node),
POINTER :: first => null(), current => null()
259 INTEGER :: element_counter = 0
260 INTEGER(int_8) :: file_counter = 0
261 CHARACTER(LEN=5) :: desc =
""
263 CHARACTER(default_path_length) :: filename =
""
268 INTEGER,
DIMENSION(:),
POINTER :: lmax => null()
269 INTEGER,
DIMENSION(:),
POINTER :: lmin => null()
270 INTEGER,
DIMENSION(:),
POINTER :: npgf => null()
272 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet => null()
273 INTEGER,
DIMENSION(:),
POINTER :: nsgf => null()
274 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf => null()
275 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi => null()
276 INTEGER :: nsgf_total = 0
277 INTEGER,
DIMENSION(:, :),
POINTER :: nl => null()
278 INTEGER,
DIMENSION(:, :),
POINTER :: nsgfl => null()
279 INTEGER,
DIMENSION(:),
POINTER :: nshell => null()
280 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER &
281 :: sphi_ext => null()
282 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: gcc => null()
283 REAL(
dp),
DIMENSION(:),
POINTER :: set_radius => null()
284 REAL(
dp),
DIMENSION(:, :),
POINTER :: pgf_radius => null()
285 REAL(
dp) :: kind_radius = 0.0_dp
290 INTEGER :: max_set = 0
291 INTEGER :: max_sgf = 0
292 INTEGER :: max_am = 0
297 REAL(
dp) :: x(2) = 0.0_dp
302 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: p_kind => null()
307 INTEGER,
DIMENSION(:),
POINTER :: iatom_list => null()
308 INTEGER,
DIMENSION(:),
POINTER :: jatom_list => null()
313 REAL(
dp) :: ra(3) = 0.0_dp, rb(3) = 0.0_dp
314 REAL(
dp) :: rab2 = 0.0_dp
315 REAL(
dp) :: s1234 = 0.0_dp
316 REAL(
dp) :: p(3) = 0.0_dp
317 REAL(
dp) :: r = 0.0_dp
318 REAL(
dp) :: pgf_max = 0.0_dp
319 REAL(
dp),
DIMENSION(3) :: bcell = 0.0_dp
320 END TYPE hfx_pgf_image
324 TYPE(hfx_pgf_image),
DIMENSION(:),
POINTER &
325 :: image_list => null()
326 INTEGER :: nimages = 0
327 REAL(
dp) :: zetapzetb = 0.0_dp
328 REAL(
dp) :: zetainv = 0.0_dp
329 REAL(
dp) :: zeta = 0.0_dp, zetb = 0.0_dp
330 INTEGER :: ipgf = 0, jpgf = 0
335 REAL(
dp) :: ra(3) = 0.0_dp, rb(3) = 0.0_dp, rc(3) = 0.0_dp, rd(3) = 0.0_dp
336 REAL(
dp) :: zetapetainv = 0.0_dp
337 REAL(
dp) :: rho = 0.0_dp, rhoinv = 0.0_dp
338 REAL(
dp) :: p(3) = 0.0_dp, q(3) = 0.0_dp, w(3) = 0.0_dp
339 REAL(
dp) :: ab(3) = 0.0_dp, cd(3) = 0.0_dp
345 INTEGER :: istart = 0, iend = 0
346 INTEGER(int_8) :: cost = 0_int_8
351 INTEGER :: thread_id = 0
352 INTEGER :: bin_id = 0
353 INTEGER(int_8) :: cost = 0_int_8
358 POINTER :: maxval_container => null()
360 POINTER :: maxval_cache => null()
362 POINTER :: integral_containers => null()
364 POINTER :: integral_caches => null()
369 DIMENSION(:) :: integral_containers_disk => null()
373 INTEGER,
DIMENSION(:, :),
ALLOCATABLE :: ind
378 REAL(kind=
dp) :: filter_eps = 0.0_dp, filter_eps_2c = 0.0_dp, filter_eps_storage = 0.0_dp, filter_eps_mo = 0.0_dp, &
379 eps_lanczos = 0.0_dp, eps_pgf_orb = 0.0_dp, eps_eigval = 0.0_dp, kp_ri_range = 0.0_dp, &
380 kp_image_range = 0.0_dp, kp_bump_rad = 0.0_dp
381 INTEGER :: t2c_sqrt_order = 0, max_iter_lanczos = 0, flavor = 0, unit_nr_dbcsr = -1, unit_nr = -1, &
382 min_bsize = 0, max_bsize_mo = 0, t2c_method = 0, nelectron_total = 0, input_flavor = 0, &
383 ncell_ri = 0, nimg = 0, kp_stack_size = 0, nimg_nze = 0, kp_ngroups = 1
384 LOGICAL :: check_2c_inv = .false., calc_condnum = .false.
390 REAL(kind=
dp) :: eps_schwarz = 0.0_dp
391 REAL(kind=
dp) :: eps_schwarz_forces = 0.0_dp
393 LOGICAL :: same_op = .false.
396 TYPE(dbt_pgrid_type),
POINTER :: pgrid => null()
397 TYPE(dbt_pgrid_type),
POINTER :: pgrid_2d => null()
401 TYPE(dbt_distribution_type) :: dist
404 INTEGER,
DIMENSION(:),
ALLOCATABLE :: bsizes_ri, bsizes_ao, bsizes_ri_split, bsizes_ao_split, &
405 bsizes_ri_fit, bsizes_ao_fit
408 INTEGER,
DIMENSION(:),
ALLOCATABLE :: img_to_ri_cell, present_images, idx_to_img, img_to_idx, &
412 REAL(
dp),
DIMENSION(:, :, :),
ALLOCATABLE :: kp_cost
418 TYPE(dbt_type),
DIMENSION(:),
ALLOCATABLE :: kp_t_3c_int
424 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: rho_ao_t, ks_t
427 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_inv
428 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_pot
431 TYPE(
dbcsr_type),
DIMENSION(:, :),
ALLOCATABLE :: kp_mat_2c_pot
434 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_int
437 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_1
439 TYPE(dbt_pgrid_type),
POINTER :: pgrid_1 => null()
442 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_2
443 TYPE(dbt_pgrid_type),
POINTER :: pgrid_2 => null()
446 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_3
449 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_int_mo
450 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ri
451 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ks
452 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ks_copy
460 CHARACTER(len=default_string_length) :: orb_basis_type =
"", ri_basis_type =
""
463 INTEGER :: n_mem_input = 0, n_mem = 0, n_mem_ri = 0, n_mem_flavor_switch = 0
466 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_mem_block, ends_array_mem_block
467 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_mem, ends_array_mem
469 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_ri_mem_block, ends_array_ri_mem_block
470 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_ri_mem, ends_array_ri_mem
472 INTEGER(int_8) :: dbcsr_nflop = 0_int_8
473 REAL(
dp) :: dbcsr_time = 0.0_dp
474 INTEGER :: num_pe = 0
518 TYPE(hfx_periodic_type) :: periodic_parameter = hfx_periodic_type()
526 POINTER :: neighbor_cells => null()
528 POINTER :: distribution_energy => null()
530 POINTER :: distribution_forces => null()
531 INTEGER,
DIMENSION(:, :),
POINTER :: is_assoc_atomic_block => null()
532 INTEGER :: number_of_p_entries = 0
534 POINTER :: basis_parameter => null()
535 INTEGER :: n_rep_hf = 0
536 LOGICAL :: b_first_load_balance_energy = .false., &
537 b_first_load_balance_forces = .false.
538 REAL(
dp),
DIMENSION(:, :),
POINTER :: full_ks_alpha => null()
539 REAL(
dp),
DIMENSION(:, :),
POINTER :: full_ks_beta => null()
543 DIMENSION(:, :, :, :, :, :),
POINTER :: screen_funct_coeffs_pgf => null(), &
544 pair_dist_radii_pgf => null()
546 DIMENSION(:, :, :, :),
POINTER :: screen_funct_coeffs_set => null()
548 DIMENSION(:, :),
POINTER :: screen_funct_coeffs_kind => null()
549 LOGICAL :: screen_funct_is_initialized = .false.
550 TYPE(
hfx_p_kind),
DIMENSION(:),
POINTER :: initial_p => null()
551 TYPE(
hfx_p_kind),
DIMENSION(:),
POINTER :: initial_p_forces => null()
552 INTEGER,
DIMENSION(:),
POINTER :: map_atom_to_kind_atom => null()
553 TYPE(
hfx_2d_map),
DIMENSION(:),
POINTER :: map_atoms_to_cpus => null()
554 INTEGER,
DIMENSION(:, :),
POINTER :: atomic_block_offset => null()
555 INTEGER,
DIMENSION(:, :, :, :),
POINTER :: set_offset => null()
556 INTEGER,
DIMENSION(:),
POINTER :: block_offset => null()
558 POINTER :: blocks => null()
560 POINTER :: task_list => null()
561 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmax_atom => null(), pmax_atom_forces => null()
563 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmax_block => null()
564 LOGICAL,
DIMENSION(:, :),
POINTER :: atomic_pair_list => null()
565 LOGICAL,
DIMENSION(:, :),
POINTER :: atomic_pair_list_forces => null()
566 LOGICAL :: do_hfx_ri = .false.
570 LOGICAL :: use_ace = .false.
571 INTEGER :: ace_rebuild_freq = 20
574 LOGICAL :: ace_is_built = .false.
575 INTEGER :: ace_build_counter = 0
604 SUBROUTINE hfx_create(x_data, para_env, hfx_section, atomic_kind_set, qs_kind_set, &
605 particle_set, dft_control, cell, orb_basis, ri_basis, &
606 nelectron_total, nkp_grid)
607 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
611 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
615 CHARACTER(LEN=*),
OPTIONAL :: orb_basis, ri_basis
616 INTEGER,
OPTIONAL :: nelectron_total
617 INTEGER,
DIMENSION(3),
OPTIONAL :: nkp_grid
619 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_create'
621 CHARACTER(LEN=512) :: error_msg
622 CHARACTER(LEN=default_path_length) :: char_val
623 CHARACTER(LEN=default_string_length) :: orb_basis_type, ri_basis_type
624 INTEGER :: handle, i, i_thread, iatom, ikind, int_val, irep, jkind, max_set, n_rep_hf, &
625 n_threads, natom, natom_a, natom_b, nkind, nseta, nsetb, pbc_shells, storage_id
626 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom2kind, kind_of
627 LOGICAL :: do_ri, explicit, logic_val
629 TYPE(
hfx_type),
POINTER :: actual_x_data
633 CALL timeset(routinen, handle)
638 natom =
SIZE(particle_set)
646 IF (do_ri) n_threads = 1
648 IF (
PRESENT(orb_basis))
THEN
649 orb_basis_type = orb_basis
651 orb_basis_type =
"ORB"
653 IF (
PRESENT(ri_basis))
THEN
654 ri_basis_type = ri_basis
656 ri_basis_type =
"RI_HFX"
659 ALLOCATE (x_data(n_rep_hf, n_threads))
660 DO i_thread = 1, n_threads
661 DO irep = 1, n_rep_hf
662 actual_x_data => x_data(irep, i_thread)
667 actual_x_data%general_parameter%fraction = real_val
668 actual_x_data%n_rep_hf = n_rep_hf
670 NULLIFY (actual_x_data%map_atoms_to_cpus)
672 CALL section_vals_val_get(hfx_section,
"TREAT_LSD_IN_CORE", l_val=logic_val, i_rep_section=irep)
673 actual_x_data%general_parameter%treat_lsd_in_core = logic_val
676 actual_x_data%general_parameter%hfx_library = int_val
679 CALL section_vals_val_get(hfx_ri_section,
"_SECTION_PARAMETERS_", l_val=actual_x_data%do_hfx_ri)
683 CALL parse_memory_section(actual_x_data%memory_parameter, hf_sub_section, storage_id, i_thread, &
684 n_threads, para_env, irep, skip_disk=.false., skip_in_core_forces=.false.)
689 actual_x_data%periodic_parameter%number_of_shells = int_val
690 actual_x_data%periodic_parameter%mode = int_val
691 CALL get_cell(cell=cell, periodic=actual_x_data%periodic_parameter%perd)
692 IF (sum(actual_x_data%periodic_parameter%perd) == 0)
THEN
693 actual_x_data%periodic_parameter%do_periodic = .false.
695 actual_x_data%periodic_parameter%do_periodic = .true.
701 actual_x_data%screening_parameter%eps_schwarz = real_val
702 CALL section_vals_val_get(hf_sub_section,
"EPS_SCHWARZ_FORCES", r_val=real_val, explicit=explicit)
704 actual_x_data%screening_parameter%eps_schwarz_forces = real_val
706 actual_x_data%screening_parameter%eps_schwarz_forces = &
707 100._dp*actual_x_data%screening_parameter%eps_schwarz
710 actual_x_data%screening_parameter%do_p_screening_forces = logic_val
712 actual_x_data%screening_parameter%do_initial_p_screening = logic_val
713 actual_x_data%screen_funct_is_initialized = .false.
718 actual_x_data%potential_parameter%potential_type = int_val
720 actual_x_data%potential_parameter%omega = real_val
722 actual_x_data%potential_parameter%scale_coulomb = real_val
724 actual_x_data%potential_parameter%scale_longrange = real_val
726 actual_x_data%potential_parameter%scale_gaussian = real_val
730 actual_x_data%potential_parameter%cutoff_radius = real_val
735 WRITE (error_msg,
'(A,A,A)')
"Truncated hfx calculation requested. The file containing "// &
736 "the data could not be found at ", trim(char_val),
" Please check T_C_G_DATA "// &
737 "in the INTERACTION_POTENTIAL section"
740 actual_x_data%potential_parameter%filename = char_val
744 CALL erfc_cutoff(actual_x_data%screening_parameter%eps_schwarz, &
745 actual_x_data%potential_parameter%omega, &
746 actual_x_data%potential_parameter%cutoff_radius)
750 IF (real_val < actual_x_data%potential_parameter%cutoff_radius .AND. &
751 i_thread == 1 .AND. irep == 1)
THEN
752 WRITE (error_msg,
'(A,F6.3,A,ES8.1,A,F6.3,A,F6.3,A)') &
753 "Periodic Hartree Fock calculation requested with the use "// &
754 "of a shortrange potential erfc(omega*r)/r. Given omega = ", &
755 actual_x_data%potential_parameter%omega,
" and EPS_SCHWARZ = ", &
756 actual_x_data%screening_parameter%eps_schwarz,
", the requested "// &
757 "cutoff radius ", real_val*
a_bohr*1e+10_dp,
" A is smaller than "// &
758 "what is necessary to satisfy erfc(omega*r)/r = EPS_SCHWARZ at r = ", &
759 actual_x_data%potential_parameter%cutoff_radius*
a_bohr*1e+10_dp, &
760 " A. Increase input value (or omit keyword to use program default) "// &
761 "to ensure accuracy."
764 actual_x_data%potential_parameter%cutoff_radius = real_val
767 IF (actual_x_data%potential_parameter%potential_type ==
do_potential_id)
THEN
768 actual_x_data%potential_parameter%cutoff_radius = 0.0_dp
774 actual_x_data%load_balance_parameter%nbins = max(1, int_val)
775 actual_x_data%load_balance_parameter%blocks_initialized = .false.
778 actual_x_data%load_balance_parameter%do_randomize = logic_val
780 actual_x_data%load_balance_parameter%rtp_redistribute = .false.
781 IF (
ASSOCIATED(dft_control%rtp_control))
THEN
782 actual_x_data%load_balance_parameter%rtp_redistribute = dft_control%rtp_control%hfx_redistribute
787 IF (int_val <= 0)
THEN
789 int_val = ceiling(0.1_dp*natom/ &
790 REAL(actual_x_data%load_balance_parameter%nbins*n_threads*para_env%num_pe, kind=
dp)**(0.25_dp))
793 actual_x_data%load_balance_parameter%block_size = min(
max_atom_block, max(1, int_val))
895 IF (actual_x_data%periodic_parameter%do_periodic)
THEN
898 actual_x_data%periodic_parameter%number_of_shells_from_input = pbc_shells
899 ALLOCATE (actual_x_data%neighbor_cells(1))
902 ALLOCATE (actual_x_data%neighbor_cells(1))
904 actual_x_data%periodic_parameter%R_max_stress = 1.0_dp
907 nkind =
SIZE(qs_kind_set, 1)
908 max_set = actual_x_data%basis_info%max_set
911 IF (i_thread == 1)
THEN
912 ALLOCATE (actual_x_data%is_assoc_atomic_block(natom, natom))
913 ALLOCATE (actual_x_data%atomic_block_offset(natom, natom))
914 ALLOCATE (actual_x_data%set_offset(max_set, max_set, nkind, nkind))
915 ALLOCATE (actual_x_data%block_offset(para_env%num_pe + 1))
918 ALLOCATE (actual_x_data%distribution_forces(1))
919 ALLOCATE (actual_x_data%distribution_energy(1))
921 actual_x_data%memory_parameter%size_p_screen = 0_int_8
922 IF (i_thread == 1)
THEN
923 ALLOCATE (actual_x_data%atomic_pair_list(natom, natom))
924 ALLOCATE (actual_x_data%atomic_pair_list_forces(natom, natom))
927 IF (actual_x_data%screening_parameter%do_initial_p_screening .OR. &
928 actual_x_data%screening_parameter%do_p_screening_forces)
THEN
930 IF (i_thread == 1)
THEN
931 ALLOCATE (actual_x_data%pmax_atom(natom, natom))
932 ALLOCATE (actual_x_data%initial_p(nkind*(nkind + 1)/2))
936 nseta = actual_x_data%basis_parameter(ikind)%nset
937 DO jkind = ikind, nkind
939 nsetb = actual_x_data%basis_parameter(jkind)%nset
940 ALLOCATE (actual_x_data%initial_p(i)%p_kind(nseta, nsetb, natom_a, natom_b))
941 actual_x_data%memory_parameter%size_p_screen = &
942 actual_x_data%memory_parameter%size_p_screen + nseta*nsetb*natom_a*natom_b
947 ALLOCATE (actual_x_data%pmax_atom_forces(natom, natom))
948 ALLOCATE (actual_x_data%initial_p_forces(nkind*(nkind + 1)/2))
952 nseta = actual_x_data%basis_parameter(ikind)%nset
953 DO jkind = ikind, nkind
955 nsetb = actual_x_data%basis_parameter(jkind)%nset
956 ALLOCATE (actual_x_data%initial_p_forces(i)%p_kind(nseta, nsetb, natom_a, natom_b))
957 actual_x_data%memory_parameter%size_p_screen = &
958 actual_x_data%memory_parameter%size_p_screen + nseta*nsetb*natom_a*natom_b
963 ALLOCATE (actual_x_data%map_atom_to_kind_atom(natom))
966 ALLOCATE (atom2kind(nkind))
969 ikind = kind_of(iatom)
970 atom2kind(ikind) = atom2kind(ikind) + 1
971 actual_x_data%map_atom_to_kind_atom(iatom) = atom2kind(ikind)
973 DEALLOCATE (kind_of, atom2kind)
986 actual_x_data%store_ints%maxval_cache_disk%element_counter = 1
987 ALLOCATE (actual_x_data%store_ints%maxval_container_disk)
988 ALLOCATE (actual_x_data%store_ints%maxval_container_disk%first)
989 actual_x_data%store_ints%maxval_container_disk%first%prev => null()
990 actual_x_data%store_ints%maxval_container_disk%first%next => null()
991 actual_x_data%store_ints%maxval_container_disk%current => actual_x_data%store_ints%maxval_container_disk%first
992 actual_x_data%store_ints%maxval_container_disk%current%data = 0
993 actual_x_data%store_ints%maxval_container_disk%element_counter = 1
994 actual_x_data%store_ints%maxval_container_disk%file_counter = 1
995 actual_x_data%store_ints%maxval_container_disk%desc =
'Max_'
996 actual_x_data%store_ints%maxval_container_disk%unit = -1
997 WRITE (actual_x_data%store_ints%maxval_container_disk%filename,
'(A,I0,A,A,A)') &
998 trim(actual_x_data%memory_parameter%storage_location), &
999 storage_id,
"_", actual_x_data%store_ints%maxval_container_disk%desc,
"6"
1000 CALL compress(actual_x_data%store_ints%maxval_container_disk%filename, .true.)
1001 ALLOCATE (actual_x_data%store_ints%integral_containers_disk(64))
1003 actual_x_data%store_ints%integral_caches_disk(i)%element_counter = 1
1004 actual_x_data%store_ints%integral_caches_disk(i)%data = 0
1005 ALLOCATE (actual_x_data%store_ints%integral_containers_disk(i)%first)
1006 actual_x_data%store_ints%integral_containers_disk(i)%first%prev => null()
1007 actual_x_data%store_ints%integral_containers_disk(i)%first%next => null()
1008 actual_x_data%store_ints%integral_containers_disk(i)%current => &
1009 actual_x_data%store_ints%integral_containers_disk(i)%first
1010 actual_x_data%store_ints%integral_containers_disk(i)%current%data = 0
1011 actual_x_data%store_ints%integral_containers_disk(i)%element_counter = 1
1012 actual_x_data%store_ints%integral_containers_disk(i)%file_counter = 1
1013 actual_x_data%store_ints%integral_containers_disk(i)%desc =
'Int_'
1014 actual_x_data%store_ints%integral_containers_disk(i)%unit = -1
1015 WRITE (actual_x_data%store_ints%integral_containers_disk(i)%filename,
'(A,I0,A,A,I0)') &
1016 trim(actual_x_data%memory_parameter%storage_location), &
1017 storage_id,
"_", actual_x_data%store_ints%integral_containers_disk(i)%desc, i
1018 CALL compress(actual_x_data%store_ints%integral_containers_disk(i)%filename, .true.)
1021 actual_x_data%b_first_load_balance_energy = .true.
1022 actual_x_data%b_first_load_balance_forces = .true.
1025 IF (actual_x_data%do_hfx_ri)
THEN
1026 cpassert(
PRESENT(nelectron_total))
1027 ALLOCATE (actual_x_data%ri_data)
1028 CALL hfx_ri_init_read_input_from_hfx(actual_x_data%ri_data, actual_x_data, hfx_section, &
1029 hf_sub_section, qs_kind_set, &
1030 particle_set, atomic_kind_set, dft_control, para_env, irep, &
1031 nelectron_total, orb_basis_type, ri_basis_type)
1035 IF (i_thread == 1)
THEN
1041 l_val=actual_x_data%use_ace)
1043 i_val=actual_x_data%ace_rebuild_freq)
1046 IF (actual_x_data%use_ace)
THEN
1048 IF (actual_x_data%general_parameter%fraction <= 0.0_dp)
THEN
1049 cpabort(
"ACE requires FRACTION > 0.")
1052 IF (actual_x_data%ace_rebuild_freq < 1)
THEN
1053 cpabort(
"ACE: REBUILD_FREQUENCY must be >= 1")
1060 DO irep = 1, n_rep_hf
1061 actual_x_data => x_data(irep, 1)
1062 CALL hfx_print_info(actual_x_data, hfx_section, irep)
1065 CALL timestop(handle)
1085 SUBROUTINE hfx_ri_init_read_input_from_hfx(ri_data, x_data, hfx_section, ri_section, qs_kind_set, &
1086 particle_set, atomic_kind_set, dft_control, para_env, irep, &
1087 nelectron_total, orb_basis_type, ri_basis_type)
1089 TYPE(
hfx_type),
INTENT(INOUT) :: x_data
1091 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1096 INTEGER,
INTENT(IN) :: irep, nelectron_total
1097 CHARACTER(LEN=*) :: orb_basis_type, ri_basis_type
1099 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init_read_input_from_hfx'
1101 CHARACTER(LEN=512) :: error_msg
1102 CHARACTER(LEN=default_path_length) :: char_val, t_c_filename
1103 INTEGER :: handle, unit_nr, unit_nr_dbcsr
1107 CALL timeset(routinen, handle)
1109 NULLIFY (hf_sub_section)
1111 associate(hfx_pot => ri_data%hfx_pot)
1112 hfx_pot%potential_type = x_data%potential_parameter%potential_type
1113 hfx_pot%omega = x_data%potential_parameter%omega
1114 hfx_pot%cutoff_radius = x_data%potential_parameter%cutoff_radius
1115 hfx_pot%scale_coulomb = x_data%potential_parameter%scale_coulomb
1116 hfx_pot%scale_longrange = x_data%potential_parameter%scale_longrange
1118 ri_data%ri_section => ri_section
1119 ri_data%hfx_section => hfx_section
1120 ri_data%eps_schwarz = x_data%screening_parameter%eps_schwarz
1121 ri_data%eps_schwarz_forces = x_data%screening_parameter%eps_schwarz_forces
1125 extension=
".dbcsrLog")
1128 extension=
".scfLog")
1135 WRITE (error_msg,
'(A,A,A)')
"File not found. Please check T_C_G_DATA "// &
1136 "in the INTERACTION_POTENTIAL section"
1139 t_c_filename = char_val
1142 CALL hfx_ri_init_read_input(ri_data, ri_section, qs_kind_set, particle_set, atomic_kind_set, &
1143 orb_basis_type, ri_basis_type, para_env, unit_nr, unit_nr_dbcsr, &
1144 nelectron_total, t_c_filename=t_c_filename)
1146 IF (dft_control%smear .AND. ri_data%flavor ==
ri_mo)
THEN
1147 cpabort(
"RI_FLAVOR MO is not consistent with smearing. Please use RI_FLAVOR RHO.")
1150 CALL timestop(handle)
1152 END SUBROUTINE hfx_ri_init_read_input_from_hfx
1169 SUBROUTINE hfx_ri_init_read_input(ri_data, ri_section, qs_kind_set, &
1170 particle_set, atomic_kind_set, orb_basis_type, ri_basis_type, para_env, &
1171 unit_nr, unit_nr_dbcsr, nelectron_total, t_c_filename)
1173 TYPE(section_vals_type),
POINTER :: ri_section
1174 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1175 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1176 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1177 CHARACTER(LEN=*),
INTENT(IN) :: orb_basis_type, ri_basis_type
1178 TYPE(mp_para_env_type) :: para_env
1179 INTEGER,
INTENT(IN) :: unit_nr, unit_nr_dbcsr, nelectron_total
1180 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: t_c_filename
1182 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init_read_input'
1186 REAL(dp) :: eps_storage_scaling
1188 CALL timeset(routinen, handle)
1190 CALL section_vals_val_get(ri_section,
"EPS_FILTER", r_val=ri_data%filter_eps)
1191 CALL section_vals_val_get(ri_section,
"EPS_FILTER_2C", r_val=ri_data%filter_eps_2c)
1192 CALL section_vals_val_get(ri_section,
"EPS_STORAGE_SCALING", r_val=eps_storage_scaling)
1193 ri_data%filter_eps_storage = ri_data%filter_eps*eps_storage_scaling
1194 CALL section_vals_val_get(ri_section,
"EPS_FILTER_MO", r_val=ri_data%filter_eps_mo)
1196 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
1197 CALL section_vals_val_get(ri_section,
"RI_METRIC", i_val=ri_metric%potential_type, explicit=explicit)
1198 IF (.NOT. explicit .OR. ri_metric%potential_type == 0)
THEN
1199 ri_metric%potential_type = hfx_pot%potential_type
1202 CALL section_vals_val_get(ri_section,
"OMEGA", r_val=ri_metric%omega, explicit=explicit)
1203 IF (.NOT. explicit)
THEN
1204 ri_metric%omega = hfx_pot%omega
1207 CALL section_vals_val_get(ri_section,
"CUTOFF_RADIUS", r_val=ri_metric%cutoff_radius, explicit=explicit)
1208 IF (.NOT. explicit)
THEN
1209 ri_metric%cutoff_radius = hfx_pot%cutoff_radius
1212 CALL section_vals_val_get(ri_section,
"SCALE_COULOMB", r_val=ri_metric%scale_coulomb, explicit=explicit)
1213 IF (.NOT. explicit)
THEN
1214 ri_metric%scale_coulomb = hfx_pot%scale_coulomb
1217 CALL section_vals_val_get(ri_section,
"SCALE_LONGRANGE", r_val=ri_metric%scale_longrange, explicit=explicit)
1218 IF (.NOT. explicit)
THEN
1219 ri_metric%scale_longrange = hfx_pot%scale_longrange
1222 IF (ri_metric%potential_type == do_potential_short)
THEN
1223 CALL erfc_cutoff(ri_data%eps_schwarz, ri_metric%omega, ri_metric%cutoff_radius)
1225 IF (ri_metric%potential_type == do_potential_id) ri_metric%cutoff_radius = 0.0_dp
1228 CALL section_vals_val_get(ri_section,
"2C_MATRIX_FUNCTIONS", i_val=ri_data%t2c_method)
1229 CALL section_vals_val_get(ri_section,
"EPS_EIGVAL", r_val=ri_data%eps_eigval)
1230 CALL section_vals_val_get(ri_section,
"CHECK_2C_MATRIX", l_val=ri_data%check_2c_inv)
1231 CALL section_vals_val_get(ri_section,
"CALC_COND_NUM", l_val=ri_data%calc_condnum)
1232 CALL section_vals_val_get(ri_section,
"SQRT_ORDER", i_val=ri_data%t2c_sqrt_order)
1233 CALL section_vals_val_get(ri_section,
"EPS_LANCZOS", r_val=ri_data%eps_lanczos)
1234 CALL section_vals_val_get(ri_section,
"MAX_ITER_LANCZOS", i_val=ri_data%max_iter_lanczos)
1235 CALL section_vals_val_get(ri_section,
"RI_FLAVOR", i_val=ri_data%flavor)
1236 CALL section_vals_val_get(ri_section,
"EPS_PGF_ORB", r_val=ri_data%eps_pgf_orb)
1237 CALL section_vals_val_get(ri_section,
"MIN_BLOCK_SIZE", i_val=ri_data%min_bsize)
1238 CALL section_vals_val_get(ri_section,
"MAX_BLOCK_SIZE_MO", i_val=ri_data%max_bsize_MO)
1239 CALL section_vals_val_get(ri_section,
"MEMORY_CUT", i_val=ri_data%n_mem_input)
1240 CALL section_vals_val_get(ri_section,
"FLAVOR_SWITCH_MEMORY_CUT", i_val=ri_data%n_mem_flavor_switch)
1242 ri_data%orb_basis_type = orb_basis_type
1243 ri_data%ri_basis_type = ri_basis_type
1244 ri_data%nelectron_total = nelectron_total
1245 ri_data%input_flavor = ri_data%flavor
1247 IF (
PRESENT(t_c_filename))
THEN
1248 ri_data%ri_metric%filename = t_c_filename
1249 ri_data%hfx_pot%filename = t_c_filename
1252 ri_data%unit_nr_dbcsr = unit_nr_dbcsr
1253 ri_data%unit_nr = unit_nr
1254 ri_data%dbcsr_nflop = 0
1255 ri_data%dbcsr_time = 0.0_dp
1257 CALL hfx_ri_init(ri_data, qs_kind_set, particle_set, atomic_kind_set, para_env)
1259 CALL timestop(handle)
1261 END SUBROUTINE hfx_ri_init_read_input
1271 SUBROUTINE hfx_ri_init(ri_data, qs_kind_set, particle_set, atomic_kind_set, para_env)
1273 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1274 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1275 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1276 TYPE(mp_para_env_type) :: para_env
1278 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init'
1280 INTEGER :: handle, i_mem, j_mem, mo_dim, natom, &
1282 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bsizes_ao_store, bsizes_ri_store, dist1, &
1283 dist2, dist3, dist_ao_1, dist_ao_2, &
1285 INTEGER,
DIMENSION(2) :: pdims_2d
1286 INTEGER,
DIMENSION(3) :: pdims
1288 TYPE(distribution_3d_type) :: dist_3d
1289 TYPE(gto_basis_set_p_type),
ALLOCATABLE, &
1290 DIMENSION(:) :: basis_set_ao, basis_set_ri
1291 TYPE(mp_cart_type) :: mp_comm_3d
1293 CALL cite_reference(bussy2023)
1295 CALL timeset(routinen, handle)
1298 CALL cp_libint_static_init()
1300 natom =
SIZE(particle_set)
1301 nkind =
SIZE(qs_kind_set, 1)
1302 nproc = para_env%num_pe
1304 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
1305 IF (ri_metric%potential_type == do_potential_short)
THEN
1306 CALL erfc_cutoff(ri_data%eps_schwarz, ri_metric%omega, ri_metric%cutoff_radius)
1309 IF (hfx_pot%potential_type == do_potential_short)
THEN
1312 CALL erfc_cutoff(ri_data%filter_eps_2c, hfx_pot%omega, hfx_pot%cutoff_radius)
1315 same_op = compare_potential_types(ri_metric, hfx_pot)
1318 ri_data%same_op = same_op
1321 CALL mp_comm_3d%create(para_env, 3, pdims)
1323 ALLOCATE (ri_data%bsizes_RI(natom))
1324 ALLOCATE (ri_data%bsizes_AO(natom))
1325 ALLOCATE (basis_set_ri(nkind), basis_set_ao(nkind))
1326 CALL basis_set_list_setup(basis_set_ri, ri_data%ri_basis_type, qs_kind_set)
1327 CALL get_particle_set(particle_set, qs_kind_set, nsgf=ri_data%bsizes_RI, basis=basis_set_ri)
1328 CALL basis_set_list_setup(basis_set_ao, ri_data%orb_basis_type, qs_kind_set)
1329 CALL get_particle_set(particle_set, qs_kind_set, nsgf=ri_data%bsizes_AO, basis=basis_set_ao)
1331 ALLOCATE (dist_ri(natom))
1332 ALLOCATE (dist_ao_1(natom))
1333 ALLOCATE (dist_ao_2(natom))
1334 CALL dbt_default_distvec(natom, pdims(1), ri_data%bsizes_RI, dist_ri)
1335 CALL dbt_default_distvec(natom, pdims(2), ri_data%bsizes_AO, dist_ao_1)
1336 CALL dbt_default_distvec(natom, pdims(3), ri_data%bsizes_AO, dist_ao_2)
1337 CALL distribution_3d_create(dist_3d, dist_ri, dist_ao_1, dist_ao_2, nkind, particle_set, &
1338 mp_comm_3d, own_comm=.true.)
1340 ALLOCATE (ri_data%pgrid)
1341 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid)
1343 ALLOCATE (ri_data%pgrid_2d)
1345 CALL dbt_pgrid_create(para_env, pdims_2d, ri_data%pgrid_2d)
1347 ri_data%dist_3d = dist_3d
1349 CALL dbt_distribution_new(ri_data%dist, ri_data%pgrid, &
1350 dist_ri, dist_ao_1, dist_ao_2)
1352 DEALLOCATE (dist_ao_1, dist_ao_2, dist_ri)
1354 ri_data%num_pe = para_env%num_pe
1357 CALL pgf_block_sizes(atomic_kind_set, basis_set_ao, ri_data%min_bsize, ri_data%bsizes_AO_split)
1358 CALL pgf_block_sizes(atomic_kind_set, basis_set_ri, ri_data%min_bsize, ri_data%bsizes_RI_split)
1360 CALL pgf_block_sizes(atomic_kind_set, basis_set_ao, 1, bsizes_ao_store)
1361 CALL pgf_block_sizes(atomic_kind_set, basis_set_ri, 1, bsizes_ri_store)
1363 CALL split_block_sizes([sum(ri_data%bsizes_AO)], ri_data%bsizes_AO_fit, default_block_size)
1364 CALL split_block_sizes([sum(ri_data%bsizes_RI)], ri_data%bsizes_RI_fit, default_block_size)
1366 IF (ri_data%flavor == ri_pmat)
THEN
1369 ri_data%n_mem = ri_data%n_mem_input
1370 ri_data%n_mem_RI = ri_data%n_mem_input
1372 CALL create_tensor_batches(ri_data%bsizes_AO_split, ri_data%n_mem, ri_data%starts_array_mem, &
1373 ri_data%ends_array_mem, ri_data%starts_array_mem_block, &
1374 ri_data%ends_array_mem_block)
1376 CALL create_tensor_batches(ri_data%bsizes_RI_split, ri_data%n_mem_RI, &
1377 ri_data%starts_array_RI_mem, ri_data%ends_array_RI_mem, &
1378 ri_data%starts_array_RI_mem_block, ri_data%ends_array_RI_mem_block)
1380 ALLOCATE (ri_data%pgrid_1)
1381 ALLOCATE (ri_data%pgrid_2)
1384 CALL dbt_mp_dims_create(nproc, pdims, [
SIZE(ri_data%bsizes_AO_split),
SIZE(ri_data%bsizes_RI_split), &
1385 SIZE(ri_data%bsizes_AO_split)])
1387 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_1)
1389 pdims = pdims([2, 1, 3])
1390 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_2)
1392 ALLOCATE (ri_data%t_3c_int_ctr_1(1, 1))
1393 CALL create_3c_tensor(ri_data%t_3c_int_ctr_1(1, 1), dist1, dist2, dist3, &
1394 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, &
1395 ri_data%bsizes_AO_split, [1, 2], [3], name=
"(AO RI | AO)")
1396 DEALLOCATE (dist1, dist2, dist3)
1398 ALLOCATE (ri_data%blk_indices(ri_data%n_mem, ri_data%n_mem_RI))
1399 ALLOCATE (ri_data%store_3c(ri_data%n_mem, ri_data%n_mem_RI))
1400 DO i_mem = 1, ri_data%n_mem
1401 DO j_mem = 1, ri_data%n_mem_RI
1406 ALLOCATE (ri_data%t_3c_int_ctr_2(1, 1))
1407 CALL create_3c_tensor(ri_data%t_3c_int_ctr_2(1, 1), dist1, dist2, dist3, &
1408 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, &
1409 ri_data%bsizes_AO_split, [1, 2], [3], name=
"(AO RI | AO)")
1410 DEALLOCATE (dist1, dist2, dist3)
1412 ALLOCATE (ri_data%t_3c_int_ctr_3(1, 1))
1413 CALL create_3c_tensor(ri_data%t_3c_int_ctr_3(1, 1), dist1, dist2, dist3, &
1414 ri_data%pgrid_2, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1415 ri_data%bsizes_AO_split, [1], [2, 3], name=
"(RI | AO AO)")
1416 DEALLOCATE (dist1, dist2, dist3)
1418 ALLOCATE (ri_data%t_2c_int(1, 1))
1419 CALL create_2c_tensor(ri_data%t_2c_int(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1420 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1422 DEALLOCATE (dist1, dist2)
1425 ALLOCATE (ri_data%rho_ao_t(2, 1))
1426 CALL create_2c_tensor(ri_data%rho_ao_t(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1427 ri_data%bsizes_AO_split, ri_data%bsizes_AO_split, &
1429 DEALLOCATE (dist1, dist2)
1430 CALL dbt_create(ri_data%rho_ao_t(1, 1), ri_data%rho_ao_t(2, 1))
1432 ALLOCATE (ri_data%ks_t(2, 1))
1433 CALL create_2c_tensor(ri_data%ks_t(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1434 ri_data%bsizes_AO_split, ri_data%bsizes_AO_split, &
1436 DEALLOCATE (dist1, dist2)
1437 CALL dbt_create(ri_data%ks_t(1, 1), ri_data%ks_t(2, 1))
1439 ELSE IF (ri_data%flavor == ri_mo)
THEN
1440 ALLOCATE (ri_data%t_2c_int(2, 1))
1442 CALL create_2c_tensor(ri_data%t_2c_int(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1443 ri_data%bsizes_RI_fit, ri_data%bsizes_RI_fit, &
1445 CALL dbt_create(ri_data%t_2c_int(1, 1), ri_data%t_2c_int(2, 1))
1447 DEALLOCATE (dist1, dist2)
1449 ALLOCATE (ri_data%t_3c_int_ctr_1(1, 1))
1451 ALLOCATE (ri_data%pgrid_1)
1452 ALLOCATE (ri_data%pgrid_2)
1455 ri_data%n_mem = ri_data%n_mem_input**2
1456 IF (ri_data%n_mem > ri_data%nelectron_total/2) ri_data%n_mem = max(ri_data%nelectron_total/2, 1)
1461 mo_dim = max((ri_data%nelectron_total/2 - 1)/ri_data%n_mem + 1, 1)
1462 mo_dim = (mo_dim - 1)/ri_data%max_bsize_MO + 1
1465 CALL dbt_mp_dims_create(nproc, pdims, [
SIZE(ri_data%bsizes_AO_split),
SIZE(ri_data%bsizes_RI_split), mo_dim])
1467 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_1)
1469 pdims = pdims([3, 2, 1])
1470 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_2)
1472 CALL create_3c_tensor(ri_data%t_3c_int_ctr_1(1, 1), dist1, dist2, dist3, &
1473 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1474 [1, 2], [3], name=
"(AO RI | AO)")
1475 DEALLOCATE (dist1, dist2, dist3)
1477 ALLOCATE (ri_data%t_3c_int_ctr_2(1, 1))
1478 CALL create_3c_tensor(ri_data%t_3c_int_ctr_2(1, 1), dist1, dist2, dist3, &
1479 ri_data%pgrid_2, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1480 [1], [2, 3], name=
"(AO | RI AO)")
1481 DEALLOCATE (dist1, dist2, dist3)
1486 ALLOCATE (ri_data%t_2c_inv(1, 1))
1487 CALL create_2c_tensor(ri_data%t_2c_inv(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1488 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1490 DEALLOCATE (dist1, dist2)
1492 ALLOCATE (ri_data%t_2c_pot(1, 1))
1493 CALL create_2c_tensor(ri_data%t_2c_pot(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1494 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1496 DEALLOCATE (dist1, dist2)
1498 CALL timestop(handle)
1506 SUBROUTINE hfx_ri_write_stats(ri_data)
1509 REAL(dp) :: my_flop_rate
1511 associate(unit_nr => ri_data%unit_nr, dbcsr_nflop => ri_data%dbcsr_nflop, &
1512 dbcsr_time => ri_data%dbcsr_time, num_pe => ri_data%num_pe)
1513 my_flop_rate = real(dbcsr_nflop, dp)/(1.0e09_dp*ri_data%dbcsr_time)
1514 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(/T2,A,T73,ES8.2)") &
1515 "RI-HFX PERFORMANCE| DBT total number of flops:", real(dbcsr_nflop*num_pe, dp)
1516 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(T2,A,T66,F15.2)") &
1517 "RI-HFX PERFORMANCE| DBT total execution time:", dbcsr_time
1518 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(T2,A,T66,F15.2)") &
1519 "RI-HFX PERFORMANCE| DBT flop rate (Gflops / MPI rank):", my_flop_rate
1521 END SUBROUTINE hfx_ri_write_stats
1530 LOGICAL,
OPTIONAL :: write_stats
1532 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_release'
1534 INTEGER :: handle, i, i_mem, ispin, j, j_mem, unused
1535 LOGICAL :: my_write_stats
1537 CALL timeset(routinen, handle)
1540 CALL cp_libint_static_cleanup()
1542 my_write_stats = .true.
1543 IF (
PRESENT(write_stats)) my_write_stats = write_stats
1544 IF (my_write_stats)
CALL hfx_ri_write_stats(ri_data)
1546 IF (
ASSOCIATED(ri_data%pgrid))
THEN
1547 CALL dbt_pgrid_destroy(ri_data%pgrid)
1548 DEALLOCATE (ri_data%pgrid)
1550 IF (
ASSOCIATED(ri_data%pgrid_1))
THEN
1551 CALL dbt_pgrid_destroy(ri_data%pgrid_1)
1552 DEALLOCATE (ri_data%pgrid_1)
1554 IF (
ASSOCIATED(ri_data%pgrid_2))
THEN
1555 CALL dbt_pgrid_destroy(ri_data%pgrid_2)
1556 DEALLOCATE (ri_data%pgrid_2)
1558 IF (
ASSOCIATED(ri_data%pgrid_2d))
THEN
1559 CALL dbt_pgrid_destroy(ri_data%pgrid_2d)
1560 DEALLOCATE (ri_data%pgrid_2d)
1563 CALL distribution_3d_destroy(ri_data%dist_3d)
1564 CALL dbt_distribution_destroy(ri_data%dist)
1566 DEALLOCATE (ri_data%bsizes_RI)
1567 DEALLOCATE (ri_data%bsizes_AO)
1568 DEALLOCATE (ri_data%bsizes_AO_split)
1569 DEALLOCATE (ri_data%bsizes_RI_split)
1570 DEALLOCATE (ri_data%bsizes_AO_fit)
1571 DEALLOCATE (ri_data%bsizes_RI_fit)
1573 IF (ri_data%flavor == ri_pmat)
THEN
1574 DO i_mem = 1, ri_data%n_mem
1575 DO j_mem = 1, ri_data%n_mem_RI
1580 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_1, 2)
1581 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_1, 1)
1582 CALL dbt_destroy(ri_data%t_3c_int_ctr_1(i, j))
1585 DEALLOCATE (ri_data%t_3c_int_ctr_1)
1587 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_2, 2)
1588 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_2, 1)
1589 CALL dbt_destroy(ri_data%t_3c_int_ctr_2(i, j))
1592 DEALLOCATE (ri_data%t_3c_int_ctr_2)
1594 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_3, 2)
1595 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_3, 1)
1596 CALL dbt_destroy(ri_data%t_3c_int_ctr_3(i, j))
1599 DEALLOCATE (ri_data%t_3c_int_ctr_3)
1601 DO j = 1,
SIZE(ri_data%t_2c_int, 2)
1602 DO i = 1,
SIZE(ri_data%t_2c_int, 1)
1603 CALL dbt_destroy(ri_data%t_2c_int(i, j))
1606 DEALLOCATE (ri_data%t_2c_int)
1608 DO j = 1,
SIZE(ri_data%rho_ao_t, 2)
1609 DO i = 1,
SIZE(ri_data%rho_ao_t, 1)
1610 CALL dbt_destroy(ri_data%rho_ao_t(i, j))
1613 DEALLOCATE (ri_data%rho_ao_t)
1615 DO j = 1,
SIZE(ri_data%ks_t, 2)
1616 DO i = 1,
SIZE(ri_data%ks_t, 1)
1617 CALL dbt_destroy(ri_data%ks_t(i, j))
1620 DEALLOCATE (ri_data%ks_t)
1622 DEALLOCATE (ri_data%starts_array_mem_block, ri_data%ends_array_mem_block, &
1623 ri_data%starts_array_mem, ri_data%ends_array_mem)
1624 DEALLOCATE (ri_data%starts_array_RI_mem_block, ri_data%ends_array_RI_mem_block, &
1625 ri_data%starts_array_RI_mem, ri_data%ends_array_RI_mem)
1627 DEALLOCATE (ri_data%blk_indices)
1628 DEALLOCATE (ri_data%store_3c)
1629 ELSE IF (ri_data%flavor == ri_mo)
THEN
1630 CALL dbt_destroy(ri_data%t_3c_int_ctr_1(1, 1))
1631 CALL dbt_destroy(ri_data%t_3c_int_ctr_2(1, 1))
1632 DEALLOCATE (ri_data%t_3c_int_ctr_1)
1633 DEALLOCATE (ri_data%t_3c_int_ctr_2)
1635 DO ispin = 1,
SIZE(ri_data%t_3c_int_mo, 1)
1636 CALL dbt_destroy(ri_data%t_3c_int_mo(ispin, 1, 1))
1637 CALL dbt_destroy(ri_data%t_3c_ctr_RI(ispin, 1, 1))
1638 CALL dbt_destroy(ri_data%t_3c_ctr_KS(ispin, 1, 1))
1639 CALL dbt_destroy(ri_data%t_3c_ctr_KS_copy(ispin, 1, 1))
1642 CALL dbt_destroy(ri_data%t_2c_int(ispin, 1))
1644 DEALLOCATE (ri_data%t_2c_int)
1645 DEALLOCATE (ri_data%t_3c_int_mo)
1646 DEALLOCATE (ri_data%t_3c_ctr_RI)
1647 DEALLOCATE (ri_data%t_3c_ctr_KS)
1648 DEALLOCATE (ri_data%t_3c_ctr_KS_copy)
1651 DO j = 1,
SIZE(ri_data%t_2c_inv, 2)
1652 DO i = 1,
SIZE(ri_data%t_2c_inv, 1)
1653 CALL dbt_destroy(ri_data%t_2c_inv(i, j))
1656 DEALLOCATE (ri_data%t_2c_inv)
1658 DO j = 1,
SIZE(ri_data%t_2c_pot, 2)
1659 DO i = 1,
SIZE(ri_data%t_2c_pot, 1)
1660 CALL dbt_destroy(ri_data%t_2c_pot(i, j))
1663 DEALLOCATE (ri_data%t_2c_pot)
1665 IF (
ALLOCATED(ri_data%kp_mat_2c_pot))
THEN
1666 DO j = 1,
SIZE(ri_data%kp_mat_2c_pot, 2)
1667 DO i = 1,
SIZE(ri_data%kp_mat_2c_pot, 1)
1668 CALL dbcsr_release(ri_data%kp_mat_2c_pot(i, j))
1671 DEALLOCATE (ri_data%kp_mat_2c_pot)
1674 IF (
ALLOCATED(ri_data%kp_t_3c_int))
THEN
1675 DO i = 1,
SIZE(ri_data%kp_t_3c_int)
1676 CALL dbt_destroy(ri_data%kp_t_3c_int(i))
1678 DEALLOCATE (ri_data%kp_t_3c_int)
1681 IF (
ALLOCATED(ri_data%rho_ao_t))
THEN
1682 DO j = 1,
SIZE(ri_data%rho_ao_t, 2)
1683 DO i = 1,
SIZE(ri_data%rho_ao_t, 1)
1684 CALL dbt_destroy(ri_data%rho_ao_t(i, j))
1687 DEALLOCATE (ri_data%rho_ao_t)
1690 IF (
ALLOCATED(ri_data%ks_t))
THEN
1691 DO j = 1,
SIZE(ri_data%ks_t, 2)
1692 DO i = 1,
SIZE(ri_data%ks_t, 1)
1693 CALL dbt_destroy(ri_data%ks_t(i, j))
1696 DEALLOCATE (ri_data%ks_t)
1699 IF (
ALLOCATED(ri_data%iatom_to_subgroup))
THEN
1700 DO i = 1,
SIZE(ri_data%iatom_to_subgroup)
1701 DEALLOCATE (ri_data%iatom_to_subgroup(i)%array)
1703 DEALLOCATE (ri_data%iatom_to_subgroup)
1706 CALL timestop(handle)
1722 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1723 CHARACTER(LEN=*) :: basis_type
1725 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_create_basis_types'
1727 INTEGER :: co_counter, handle, i, ikind, ipgf, iset, j, k, la, max_am_kind, max_coeff, &
1728 max_nsgfl, max_pgf, max_pgf_kind, max_set, nkind, nl_count, nset, nseta, offset_a, &
1729 offset_a1, s_offset_nl_a, sgfa, so_counter
1730 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nshell
1731 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, nl_a
1732 REAL(dp),
DIMENSION(:, :),
POINTER :: sphi_a
1733 TYPE(gto_basis_set_type),
POINTER :: orb_basis_a
1735 CALL timeset(routinen, handle)
1738 nkind =
SIZE(qs_kind_set, 1)
1740 ALLOCATE (basis_parameter(nkind))
1743 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_a, basis_type=basis_type)
1744 CALL get_qs_kind_set(qs_kind_set, &
1745 maxsgf=basis_info%max_sgf, &
1746 maxnset=basis_info%max_set, &
1747 maxlgto=basis_info%max_am, &
1748 basis_type=basis_type)
1749 IF (basis_info%max_set < max_set) cpabort(
"UNEXPECTED MAX_SET")
1750 max_set = max(max_set, basis_info%max_set)
1751 CALL get_gto_basis_set(gto_basis_set=orb_basis_a, &
1752 lmax=basis_parameter(ikind)%lmax, &
1753 lmin=basis_parameter(ikind)%lmin, &
1754 npgf=basis_parameter(ikind)%npgf, &
1755 nset=basis_parameter(ikind)%nset, &
1756 zet=basis_parameter(ikind)%zet, &
1757 nsgf_set=basis_parameter(ikind)%nsgf, &
1758 first_sgf=basis_parameter(ikind)%first_sgf, &
1759 sphi=basis_parameter(ikind)%sphi, &
1760 gcc=basis_parameter(ikind)%gcc, &
1761 nsgf=basis_parameter(ikind)%nsgf_total, &
1762 l=basis_parameter(ikind)%nl, &
1763 nshell=basis_parameter(ikind)%nshell, &
1764 set_radius=basis_parameter(ikind)%set_radius, &
1765 pgf_radius=basis_parameter(ikind)%pgf_radius, &
1766 kind_radius=basis_parameter(ikind)%kind_radius)
1769 ALLOCATE (basis_parameter(ikind)%nsgfl(0:basis_info%max_am, max_set))
1770 basis_parameter(ikind)%nsgfl = 0
1771 nset = basis_parameter(ikind)%nset
1772 nshell => basis_parameter(ikind)%nshell
1774 DO i = 0, basis_info%max_am
1776 DO j = 1, nshell(iset)
1777 IF (basis_parameter(ikind)%nl(j, iset) == i) nl_count = nl_count + 1
1779 basis_parameter(ikind)%nsgfl(i, iset) = nl_count
1790 npgfa => basis_parameter(ikind)%npgf
1791 nseta = basis_parameter(ikind)%nset
1792 nl_a => basis_parameter(ikind)%nsgfl
1793 la_max => basis_parameter(ikind)%lmax
1794 la_min => basis_parameter(ikind)%lmin
1796 max_pgf_kind = max(max_pgf_kind, npgfa(iset))
1797 max_pgf = max(max_pgf, npgfa(iset))
1798 DO la = la_min(iset), la_max(iset)
1799 max_nsgfl = max(max_nsgfl, nl_a(la, iset))
1800 max_coeff = max(max_coeff, nso(la)*nl_a(la, iset)*nco(la))
1801 max_am_kind = max(max_am_kind, la)
1804 ALLOCATE (basis_parameter(ikind)%sphi_ext(max_coeff, 0:max_am_kind, max_pgf_kind, nseta))
1805 basis_parameter(ikind)%sphi_ext = 0.0_dp
1809 sphi_a => basis_parameter(ikind)%sphi
1810 nseta = basis_parameter(ikind)%nset
1811 la_max => basis_parameter(ikind)%lmax
1812 la_min => basis_parameter(ikind)%lmin
1813 npgfa => basis_parameter(ikind)%npgf
1814 first_sgfa => basis_parameter(ikind)%first_sgf
1815 nl_a => basis_parameter(ikind)%nsgfl
1817 sgfa = first_sgfa(1, iset)
1818 DO ipgf = 1, npgfa(iset)
1819 offset_a1 = (ipgf - 1)*
ncoset(la_max(iset))
1821 DO la = la_min(iset), la_max(iset)
1822 offset_a = offset_a1 +
ncoset(la - 1)
1824 co_counter = co_counter + 1
1826 DO k = sgfa + s_offset_nl_a, sgfa + s_offset_nl_a + nso(la)*nl_a(la, iset) - 1
1827 DO i = offset_a + 1, offset_a + nco(la)
1828 so_counter = so_counter + 1
1829 basis_parameter(ikind)%sphi_ext(so_counter, la, ipgf, iset) = sphi_a(i, k)
1832 s_offset_nl_a = s_offset_nl_a + nso(la)*(nl_a(la, iset))
1838 CALL timestop(handle)
1849 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_release_basis_types'
1851 INTEGER :: handle, i
1853 CALL timeset(routinen, handle)
1856 DO i = 1,
SIZE(basis_parameter)
1857 DEALLOCATE (basis_parameter(i)%nsgfl)
1858 DEALLOCATE (basis_parameter(i)%sphi_ext)
1860 DEALLOCATE (basis_parameter)
1861 CALL timestop(handle)
1878 i_thread, n_threads, para_env, irep, skip_disk, skip_in_core_forces)
1880 TYPE(section_vals_type),
POINTER :: hf_sub_section
1881 INTEGER,
INTENT(OUT),
OPTIONAL :: storage_id
1882 INTEGER,
INTENT(IN),
OPTIONAL :: i_thread, n_threads
1883 TYPE(mp_para_env_type),
OPTIONAL :: para_env
1884 INTEGER,
INTENT(IN),
OPTIONAL :: irep
1885 LOGICAL,
INTENT(IN) :: skip_disk, skip_in_core_forces
1887 CHARACTER(LEN=512) :: error_msg
1888 CHARACTER(LEN=default_path_length) :: char_val, filename, orig_wd
1889 INTEGER :: int_val, stat
1890 LOGICAL :: check, logic_val
1891 REAL(dp) :: real_val
1893 check = (
PRESENT(storage_id) .EQV.
PRESENT(i_thread)) .AND. &
1894 (
PRESENT(storage_id) .EQV.
PRESENT(n_threads)) .AND. &
1895 (
PRESENT(storage_id) .EQV.
PRESENT(para_env)) .AND. &
1896 (
PRESENT(storage_id) .EQV.
PRESENT(irep))
1900 CALL section_vals_val_get(hf_sub_section,
"MAX_MEMORY", i_val=int_val)
1901 memory_parameter%max_memory = int_val
1902 memory_parameter%max_compression_counter = int_val*1024_int_8*128_int_8
1903 CALL section_vals_val_get(hf_sub_section,
"EPS_STORAGE", r_val=real_val)
1904 memory_parameter%eps_storage_scaling = real_val
1905 IF (int_val == 0)
THEN
1906 memory_parameter%do_all_on_the_fly = .true.
1908 memory_parameter%do_all_on_the_fly = .false.
1910 memory_parameter%cache_size = cache_size
1911 memory_parameter%bits_max_val = bits_max_val
1912 memory_parameter%actual_memory_usage = 1
1913 IF (.NOT. skip_in_core_forces)
THEN
1914 CALL section_vals_val_get(hf_sub_section,
"TREAT_FORCES_IN_CORE", l_val=logic_val)
1915 memory_parameter%treat_forces_in_core = logic_val
1919 IF (memory_parameter%do_all_on_the_fly) memory_parameter%treat_forces_in_core = .false.
1922 IF (.NOT. skip_disk)
THEN
1923 memory_parameter%actual_memory_usage_disk = 1
1924 CALL section_vals_val_get(hf_sub_section,
"MAX_DISK_SPACE", i_val=int_val)
1925 memory_parameter%max_compression_counter_disk = int_val*1024_int_8*128_int_8
1926 IF (int_val == 0)
THEN
1927 memory_parameter%do_disk_storage = .false.
1929 memory_parameter%do_disk_storage = .true.
1931 CALL section_vals_val_get(hf_sub_section,
"STORAGE_LOCATION", c_val=char_val)
1932 CALL compress(char_val, .true.)
1935 IF (scan(char_val,
"/", .true.) /= len_trim(char_val))
THEN
1936 WRITE (filename,
'(A,A)') trim(char_val),
"/"
1937 CALL compress(filename)
1939 filename = trim(char_val)
1941 CALL compress(filename, .true.)
1944 CALL m_getcwd(orig_wd)
1945 CALL m_chdir(trim(filename), stat)
1947 WRITE (error_msg,
'(A,A,A)')
"Request for disk storage failed due to unknown error while writing to ", &
1948 trim(filename),
". Please check STORAGE_LOCATION"
1951 CALL m_chdir(orig_wd, stat)
1953 memory_parameter%storage_location = filename
1954 CALL compress(memory_parameter%storage_location, .true.)
1956 memory_parameter%do_disk_storage = .false.
1958 IF (
PRESENT(storage_id))
THEN
1959 storage_id = (irep - 1)*para_env%num_pe*n_threads + para_env%mepos*n_threads + i_thread - 1
1971 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
1973 INTEGER :: i, i_thread, irep, n_rep_hf, n_threads
1974 TYPE(cp_logger_type),
POINTER :: logger
1975 TYPE(
hfx_type),
POINTER :: actual_x_data
1979 n_rep_hf = x_data(1, 1)%n_rep_hf
1980 n_threads =
SIZE(x_data, 2)
1982 IF (x_data(1, 1)%potential_parameter%potential_type == do_potential_truncated .OR. &
1983 x_data(1, 1)%potential_parameter%potential_type == do_potential_mix_cl_trunc)
THEN
1987 DO i_thread = 1, n_threads
1988 DO irep = 1, n_rep_hf
1989 actual_x_data => x_data(irep, i_thread)
1990 DEALLOCATE (actual_x_data%neighbor_cells)
1991 DEALLOCATE (actual_x_data%distribution_energy)
1992 DEALLOCATE (actual_x_data%distribution_forces)
1994 IF (actual_x_data%load_balance_parameter%blocks_initialized)
THEN
1995 DEALLOCATE (actual_x_data%blocks)
1996 IF (i_thread == 1)
THEN
1997 DEALLOCATE (actual_x_data%pmax_block)
2001 IF (i_thread == 1)
THEN
2002 DEALLOCATE (actual_x_data%atomic_pair_list)
2003 DEALLOCATE (actual_x_data%atomic_pair_list_forces)
2006 IF (actual_x_data%screening_parameter%do_initial_p_screening .OR. &
2007 actual_x_data%screening_parameter%do_p_screening_forces)
THEN
2008 IF (i_thread == 1)
THEN
2009 DEALLOCATE (actual_x_data%pmax_atom)
2010 DO i = 1,
SIZE(actual_x_data%initial_p)
2011 DEALLOCATE (actual_x_data%initial_p(i)%p_kind)
2013 DEALLOCATE (actual_x_data%initial_p)
2015 DEALLOCATE (actual_x_data%pmax_atom_forces)
2016 DO i = 1,
SIZE(actual_x_data%initial_p_forces)
2017 DEALLOCATE (actual_x_data%initial_p_forces(i)%p_kind)
2019 DEALLOCATE (actual_x_data%initial_p_forces)
2021 DEALLOCATE (actual_x_data%map_atom_to_kind_atom)
2023 IF (i_thread == 1)
THEN
2024 DEALLOCATE (actual_x_data%is_assoc_atomic_block)
2025 DEALLOCATE (actual_x_data%atomic_block_offset)
2026 DEALLOCATE (actual_x_data%set_offset)
2027 DEALLOCATE (actual_x_data%block_offset)
2034 CALL cp_libint_cleanup_eri(actual_x_data%lib)
2035 CALL cp_libint_cleanup_eri1(actual_x_data%lib_deriv)
2036 CALL cp_libint_static_cleanup()
2039 CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
2040 CALL dealloc_containers(actual_x_data%store_forces, actual_x_data%memory_parameter%actual_memory_usage)
2044 actual_x_data%memory_parameter%actual_memory_usage_disk, &
2046 IF (actual_x_data%memory_parameter%do_disk_storage)
THEN
2047 CALL close_file(unit_number=actual_x_data%store_ints%maxval_container_disk%unit, file_status=
"DELETE")
2049 DEALLOCATE (actual_x_data%store_ints%maxval_container_disk%first)
2050 DEALLOCATE (actual_x_data%store_ints%maxval_container_disk)
2054 actual_x_data%memory_parameter%actual_memory_usage_disk, &
2056 IF (actual_x_data%memory_parameter%do_disk_storage)
THEN
2057 CALL close_file(unit_number=actual_x_data%store_ints%integral_containers_disk(i)%unit, file_status=
"DELETE")
2059 DEALLOCATE (actual_x_data%store_ints%integral_containers_disk(i)%first)
2061 DEALLOCATE (actual_x_data%store_ints%integral_containers_disk)
2064 IF (actual_x_data%screen_funct_is_initialized)
THEN
2065 DEALLOCATE (actual_x_data%screen_funct_coeffs_set)
2066 DEALLOCATE (actual_x_data%screen_funct_coeffs_kind)
2067 DEALLOCATE (actual_x_data%pair_dist_radii_pgf)
2068 DEALLOCATE (actual_x_data%screen_funct_coeffs_pgf)
2069 actual_x_data%screen_funct_is_initialized = .false.
2073 IF (
ASSOCIATED(actual_x_data%map_atoms_to_cpus))
THEN
2074 DO i = 1,
SIZE(actual_x_data%map_atoms_to_cpus)
2075 DEALLOCATE (actual_x_data%map_atoms_to_cpus(i)%iatom_list)
2076 DEALLOCATE (actual_x_data%map_atoms_to_cpus(i)%jatom_list)
2078 DEALLOCATE (actual_x_data%map_atoms_to_cpus)
2081 IF (actual_x_data%do_hfx_ri)
THEN
2083 IF (
ASSOCIATED(actual_x_data%ri_data%ri_section))
THEN
2084 logger => cp_get_default_logger()
2085 CALL cp_print_key_finished_output(actual_x_data%ri_data%unit_nr_dbcsr, logger, actual_x_data%ri_data%ri_section, &
2088 IF (
ASSOCIATED(actual_x_data%ri_data%hfx_section))
THEN
2089 logger => cp_get_default_logger()
2090 CALL cp_print_key_finished_output(actual_x_data%ri_data%unit_nr, logger, actual_x_data%ri_data%hfx_section, &
2093 DEALLOCATE (actual_x_data%ri_data)
2097 actual_x_data%use_ace = .false.
2098 actual_x_data%ace_is_built = .false.
2099 actual_x_data%ace_build_counter = 0
2121 INTEGER,
INTENT(INOUT) :: pbc_shells
2122 TYPE(cell_type),
POINTER :: cell
2123 INTEGER,
INTENT(IN) :: i_thread
2124 INTEGER,
DIMENSION(3),
OPTIONAL :: nkp_grid
2126 CHARACTER(LEN=512) :: error_msg
2127 CHARACTER(LEN=64) :: char_nshells
2128 INTEGER :: i,
idx, ikind, ipgf, iset, ishell, j, jkind, jpgf, jset, jshell, k, kshell, l, &
2129 m(3), max_shell, nkp(3), nseta, nsetb, perd(3), total_number_of_cells, ub, ub_max
2130 INTEGER,
DIMENSION(:),
POINTER :: la_max, lb_max, npgfa, npgfb
2131 LOGICAL :: do_kpoints, image_cell_found, &
2133 REAL(dp) :: cross_product(3), dist_min, distance(14), l_min, normal(3, 6), p(3, 14), &
2134 plane_vector(3, 2), point_in_plane(3), r(3), r1, r_max, r_max_stress, s(3), x, y, z, zeta1
2135 REAL(dp),
DIMENSION(:, :),
POINTER :: zeta, zetb
2136 TYPE(
hfx_cell_type),
ALLOCATABLE,
DIMENSION(:) :: tmp_neighbor_cells
2138 total_number_of_cells = 0
2141 IF (
PRESENT(nkp_grid)) nkp = nkp_grid
2142 do_kpoints = any(nkp > 1)
2145 IF (i_thread == 1)
THEN
2146 IF (x_data%potential_parameter%potential_type /= do_potential_truncated .AND. &
2147 x_data%potential_parameter%potential_type /= do_potential_short .AND. &
2148 x_data%potential_parameter%potential_type /= do_potential_mix_cl_trunc .AND. &
2149 x_data%potential_parameter%potential_type /= do_potential_id)
THEN
2150 CALL cp_warn(__location__, &
2151 "Periodic Hartree Fock calculation requested without use "// &
2152 "of a truncated or shortrange potential. This may lead to unphysical total energies. "// &
2153 "Use a truncated potential to avoid possible problems.")
2154 ELSE IF (x_data%potential_parameter%potential_type /= do_potential_id)
THEN
2156 l_min = min(real(nkp(1), dp)*plane_distance(1, 0, 0, cell), &
2157 REAL(nkp(2), dp)*plane_distance(0, 1, 0, cell), &
2158 REAL(nkp(3), dp)*plane_distance(0, 0, 1, cell))
2159 l_min = 0.5_dp*l_min
2160 IF (x_data%potential_parameter%cutoff_radius >= l_min)
THEN
2161 IF (.NOT. do_kpoints)
THEN
2162 WRITE (error_msg,
"(A,F6.3,A,F6.3,A)") &
2163 "Periodic Hartree Fock calculation requested with the use "// &
2164 "of a truncated or shortrange potential. "// &
2165 "The cutoff radius (", x_data%potential_parameter%cutoff_radius*a_bohr*1e+10_dp, &
2166 " A) is larger than half the minimal cell dimension (", &
2167 l_min*a_bohr*1e+10_dp,
" A). This may lead to unphysical "// &
2168 "total energies. Reduce the cutoff radius in order to avoid "// &
2169 "possible problems."
2171 WRITE (error_msg,
"(A,F6.3,A,F6.3,A)") &
2172 "K-point Hartree-Fock calculation requested with the use of a "// &
2173 "truncated or shortrange potential. The cutoff radius (", &
2174 x_data%potential_parameter%cutoff_radius*a_bohr*1e+10_dp, &
2175 " A) is larger than half the minimal Born-von Karman supercell dimension (", &
2176 l_min*a_bohr*1e+10_dp,
" A). This may lead "// &
2177 "to unphysical total energies. Reduce the cutoff radius or increase "// &
2178 "the number of K-points in order to avoid possible problems."
2180 CALL cp_warn(__location__, error_msg)
2185 SELECT CASE (x_data%potential_parameter%potential_type)
2186 CASE (do_potential_truncated, do_potential_mix_cl_trunc, do_potential_short)
2188 DO ikind = 1,
SIZE(x_data%basis_parameter)
2189 la_max => x_data%basis_parameter(ikind)%lmax
2190 zeta => x_data%basis_parameter(ikind)%zet
2191 nseta = x_data%basis_parameter(ikind)%nset
2192 npgfa => x_data%basis_parameter(ikind)%npgf
2193 DO jkind = 1,
SIZE(x_data%basis_parameter)
2194 lb_max => x_data%basis_parameter(jkind)%lmax
2195 zetb => x_data%basis_parameter(jkind)%zet
2196 nsetb = x_data%basis_parameter(jkind)%nset
2197 npgfb => x_data%basis_parameter(jkind)%npgf
2200 DO ipgf = 1, npgfa(iset)
2201 DO jpgf = 1, npgfb(jset)
2202 zeta1 = zeta(ipgf, iset) + zetb(jpgf, jset)
2203 r1 = 1.0_dp/sqrt(zeta1)*
mul_fact(la_max(iset) + lb_max(jset))* &
2204 sqrt(-log(x_data%screening_parameter%eps_schwarz))
2205 r_max = max(r1, r_max)
2213 r_max = 2.0_dp*r_max + x_data%potential_parameter%cutoff_radius
2214 nothing_more_to_add = .false.
2216 total_number_of_cells = 0
2218 DEALLOCATE (x_data%neighbor_cells)
2219 ALLOCATE (x_data%neighbor_cells(1))
2220 x_data%neighbor_cells(1)%cell = 0.0_dp
2221 x_data%neighbor_cells(1)%cell_r = 0.0_dp
2258 DO WHILE (.NOT. nothing_more_to_add)
2260 image_cell_found = .false.
2261 ALLOCATE (tmp_neighbor_cells(1:ub))
2263 tmp_neighbor_cells(i) = x_data%neighbor_cells(i)
2265 ub_max = (2*max_shell + 1)**3
2266 DEALLOCATE (x_data%neighbor_cells)
2267 ALLOCATE (x_data%neighbor_cells(1:ub_max))
2269 x_data%neighbor_cells(i) = tmp_neighbor_cells(i)
2272 x_data%neighbor_cells(i)%cell = 0.0_dp
2273 x_data%neighbor_cells(i)%cell_r = 0.0_dp
2276 DEALLOCATE (tmp_neighbor_cells)
2278 perd(1:3) = x_data%periodic_parameter%perd(1:3)
2280 DO ishell = -max_shell*perd(1), max_shell*perd(1)
2281 DO jshell = -max_shell*perd(2), max_shell*perd(2)
2282 DO kshell = -max_shell*perd(3), max_shell*perd(3)
2283 IF (max(abs(ishell), abs(jshell), abs(kshell)) /= max_shell) cycle
2286 x = -1.0_dp/2.0_dp + j*1.0_dp
2288 y = -1.0_dp/2.0_dp + k*1.0_dp
2290 z = -1.0_dp/2.0_dp + l*1.0_dp
2292 p(1,
idx) = x + ishell
2293 p(2,
idx) = y + jshell
2294 p(3,
idx) = z + kshell
2295 CALL scaled_to_real(r, p(:,
idx), cell)
2296 distance(
idx) = sqrt(sum(r**2))
2305 plane_vector(:, 1) = p(:, 3) - p(:, 1)
2306 plane_vector(:, 2) = p(:, 2) - p(:, 1)
2307 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2308 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2309 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2310 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2311 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2313 IF (point_is_in_quadrilateral(p(:, 1), p(:, 3), p(:, 4), p(:, 2), point_in_plane))
THEN
2314 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2316 distance(
idx) = huge(distance(
idx))
2321 plane_vector(:, 1) = p(:, 2) - p(:, 1)
2322 plane_vector(:, 2) = p(:, 5) - p(:, 1)
2323 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2324 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2325 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2326 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2327 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2329 IF (point_is_in_quadrilateral(p(:, 1), p(:, 5), p(:, 6), p(:, 2), point_in_plane))
THEN
2330 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2332 distance(
idx) = huge(distance(
idx))
2337 plane_vector(:, 1) = p(:, 7) - p(:, 5)
2338 plane_vector(:, 2) = p(:, 6) - p(:, 5)
2339 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2340 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2341 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2342 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2343 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 5) + normal(2, 1)*p(2, 5) + normal(3, 1)*p(3, 5))
2345 IF (point_is_in_quadrilateral(p(:, 5), p(:, 7), p(:, 8), p(:, 6), point_in_plane))
THEN
2346 distance(
idx) = abs(normal(1, 1)*p(1, 5) + normal(2, 1)*p(2, 5) + normal(3, 1)*p(3, 5))
2348 distance(
idx) = huge(distance(
idx))
2353 plane_vector(:, 1) = p(:, 7) - p(:, 3)
2354 plane_vector(:, 2) = p(:, 4) - p(:, 3)
2355 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2356 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2357 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2358 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2359 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 3) + normal(2, 1)*p(2, 3) + normal(3, 1)*p(3, 3))
2361 IF (point_is_in_quadrilateral(p(:, 3), p(:, 7), p(:, 8), p(:, 4), point_in_plane))
THEN
2362 distance(
idx) = abs(normal(1, 1)*p(1, 3) + normal(2, 1)*p(2, 3) + normal(3, 1)*p(3, 3))
2364 distance(
idx) = huge(distance(
idx))
2369 plane_vector(:, 1) = p(:, 6) - p(:, 2)
2370 plane_vector(:, 2) = p(:, 4) - p(:, 2)
2371 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2372 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2373 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2374 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2375 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 2) + normal(2, 1)*p(2, 2) + normal(3, 1)*p(3, 2))
2377 IF (point_is_in_quadrilateral(p(:, 2), p(:, 6), p(:, 8), p(:, 4), point_in_plane))
THEN
2378 distance(
idx) = abs(normal(1, 1)*p(1, 2) + normal(2, 1)*p(2, 2) + normal(3, 1)*p(3, 2))
2380 distance(
idx) = huge(distance(
idx))
2385 plane_vector(:, 1) = p(:, 5) - p(:, 1)
2386 plane_vector(:, 2) = p(:, 3) - p(:, 1)
2387 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2388 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2389 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2390 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2391 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2393 IF (point_is_in_quadrilateral(p(:, 1), p(:, 5), p(:, 7), p(:, 3), point_in_plane))
THEN
2394 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2396 distance(
idx) = huge(distance(
idx))
2399 dist_min = minval(distance)
2400 IF (max_shell == 0)
THEN
2401 image_cell_found = .true.
2403 IF (dist_min < r_max)
THEN
2404 total_number_of_cells = total_number_of_cells + 1
2405 x_data%neighbor_cells(ub)%cell = real([ishell, jshell, kshell], dp)
2407 image_cell_found = .true.
2413 IF (image_cell_found)
THEN
2414 max_shell = max_shell + 1
2416 nothing_more_to_add = .true.
2420 ALLOCATE (tmp_neighbor_cells(total_number_of_cells))
2422 tmp_neighbor_cells(i) = x_data%neighbor_cells(i)
2424 DEALLOCATE (x_data%neighbor_cells)
2426 IF (total_number_of_cells == 0)
THEN
2427 total_number_of_cells = 1
2428 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2429 DO i = 1, total_number_of_cells
2430 x_data%neighbor_cells(i)%cell = 0.0_dp
2431 x_data%neighbor_cells(i)%cell_r = 0.0_dp
2434 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2435 DO i = 1, total_number_of_cells
2436 x_data%neighbor_cells(i) = tmp_neighbor_cells(i)
2439 DEALLOCATE (tmp_neighbor_cells)
2441 IF (x_data%periodic_parameter%number_of_shells == do_hfx_auto_shells)
THEN
2444 total_number_of_cells = 0
2445 DO i = 0, x_data%periodic_parameter%number_of_shells
2446 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2448 IF (total_number_of_cells <
SIZE(x_data%neighbor_cells))
THEN
2449 IF (i_thread == 1)
THEN
2450 WRITE (char_nshells,
'(I3)')
SIZE(x_data%neighbor_cells)
2451 WRITE (error_msg,
'(A,A,A)')
"Periodic Hartree Fock calculation requested with use "// &
2452 "of a truncated potential. The number of shells to be considered "// &
2453 "might be too small. CP2K conservatively estimates to need "//trim(char_nshells)//
" periodic images "// &
2454 "Please carefully check if you get converged results."
2458 total_number_of_cells = 0
2459 DO i = 0, x_data%periodic_parameter%number_of_shells
2460 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2462 DEALLOCATE (x_data%neighbor_cells)
2464 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2467 DO WHILE (sum(m**2) <= x_data%periodic_parameter%number_of_shells)
2468 x_data%neighbor_cells(i)%cell = real(m, dp)
2469 CALL next_image_cell_perd(m, x_data%periodic_parameter%perd)
2474 total_number_of_cells = 0
2475 IF (pbc_shells == -1) pbc_shells = 0
2476 DO i = 0, pbc_shells
2477 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2479 DEALLOCATE (x_data%neighbor_cells)
2481 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2485 DO WHILE (sum(m**2) <= pbc_shells)
2486 x_data%neighbor_cells(i)%cell = real(m, dp)
2487 CALL next_image_cell_perd(m, x_data%periodic_parameter%perd)
2493 DO i = 1,
SIZE(x_data%neighbor_cells)
2495 x_data%neighbor_cells(i)%cell_r(:) = 0.0_dp
2496 s = x_data%neighbor_cells(i)%cell(:)
2497 CALL scaled_to_real(x_data%neighbor_cells(i)%cell_r, s, cell)
2499 x_data%periodic_parameter%number_of_shells = pbc_shells
2501 r_max_stress = 0.0_dp
2502 DO i = 1,
SIZE(x_data%neighbor_cells)
2503 r_max_stress = max(r_max_stress, maxval(abs(x_data%neighbor_cells(i)%cell_r(:))))
2505 r_max_stress = r_max_stress + abs(maxval(cell%hmat(:, :)))
2506 x_data%periodic_parameter%R_max_stress = r_max_stress
2520 FUNCTION point_is_in_quadrilateral(A, B, C, D, P)
2521 REAL(dp) :: a(3), b(3), c(3), d(3), p(3)
2522 LOGICAL :: point_is_in_quadrilateral
2524 REAL(dp),
PARAMETER :: fuzzy = 1000.0_dp*epsilon(1.0_dp)
2526 REAL(dp) :: dot00, dot01, dot02, dot11, dot12, &
2527 invdenom, u, v, v0(3), v1(3), v2(3)
2529 point_is_in_quadrilateral = .false.
2548 dot00 = dot_product(v0, v0)
2549 dot01 = dot_product(v0, v1)
2550 dot02 = dot_product(v0, v2)
2551 dot11 = dot_product(v1, v1)
2552 dot12 = dot_product(v1, v2)
2555 invdenom = 1/(dot00*dot11 - dot01*dot01)
2556 u = (dot11*dot02 - dot01*dot12)*invdenom
2557 v = (dot00*dot12 - dot01*dot02)*invdenom
2559 IF ((u >= 0 - fuzzy) .AND. (v >= 0 - fuzzy) .AND. (u + v <= 1 + fuzzy))
THEN
2560 point_is_in_quadrilateral = .true.
2568 dot00 = dot_product(v0, v0)
2569 dot01 = dot_product(v0, v1)
2570 dot02 = dot_product(v0, v2)
2571 dot11 = dot_product(v1, v1)
2572 dot12 = dot_product(v1, v2)
2575 invdenom = 1/(dot00*dot11 - dot01*dot01)
2576 u = (dot11*dot02 - dot01*dot12)*invdenom
2577 v = (dot00*dot12 - dot01*dot02)*invdenom
2580 IF ((u >= 0 - fuzzy) .AND. (v >= 0 - fuzzy) .AND. (u + v <= 1 + fuzzy))
THEN
2581 point_is_in_quadrilateral = .true.
2585 END FUNCTION point_is_in_quadrilateral
2599 INTEGER :: memory_usage
2600 LOGICAL :: do_disk_storage
2602 TYPE(hfx_container_node),
POINTER :: current, next
2606 current => container%first
2607 DO WHILE (
ASSOCIATED(current))
2608 next => current%next
2609 DEALLOCATE (current)
2614 ALLOCATE (container%first)
2615 container%first%prev => null()
2616 container%first%next => null()
2617 container%current => container%first
2618 container%current%data = 0
2619 container%element_counter = 1
2622 IF (do_disk_storage)
THEN
2624 IF (container%unit /= -1)
THEN
2625 CALL close_file(unit_number=container%unit)
2627 CALL open_file(file_name=trim(container%filename), file_status=
"UNKNOWN", file_form=
"UNFORMATTED", file_action=
"WRITE", &
2628 unit_number=container%unit)
2646 DEALLOCATE (x_data%distribution_energy)
2648 ALLOCATE (x_data%distribution_energy(
SIZE(ptr_to_distr)))
2649 x_data%distribution_energy = ptr_to_distr
2666 DEALLOCATE (x_data%distribution_forces)
2668 ALLOCATE (x_data%distribution_forces(
SIZE(ptr_to_distr)))
2669 x_data%distribution_forces = ptr_to_distr
2686 INTEGER(int_8),
INTENT(IN) :: subtr_size_mb
2688 INTEGER(int_8) :: max_memory
2690 max_memory = memory_parameter%max_memory
2691 max_memory = max_memory - subtr_size_mb
2692 IF (max_memory <= 0)
THEN
2693 memory_parameter%do_all_on_the_fly = .true.
2694 memory_parameter%max_compression_counter = 0
2696 memory_parameter%do_all_on_the_fly = .false.
2697 memory_parameter%max_compression_counter = max_memory*1024_int_8*128_int_8
2709 SUBROUTINE hfx_print_std_info(x_data, hfx_section)
2711 TYPE(section_vals_type),
POINTER :: hfx_section
2714 TYPE(cp_logger_type),
POINTER :: logger
2717 logger => cp_get_default_logger()
2719 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2720 extension=
".scfLog")
2723 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2724 "HFX_INFO| EPS_SCHWARZ: ", x_data%screening_parameter%eps_schwarz
2725 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2726 "HFX_INFO| EPS_SCHWARZ_FORCES ", x_data%screening_parameter%eps_schwarz_forces
2727 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2728 "HFX_INFO| EPS_STORAGE_SCALING: ", x_data%memory_parameter%eps_storage_scaling
2729 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2730 "HFX_INFO| NBINS: ", x_data%load_balance_parameter%nbins
2731 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2732 "HFX_INFO| BLOCK_SIZE: ", x_data%load_balance_parameter%block_size
2733 IF (x_data%periodic_parameter%do_periodic)
THEN
2734 IF (x_data%periodic_parameter%mode == -1)
THEN
2735 WRITE (unit=iw, fmt=
"((T3,A,T77,A))") &
2736 "HFX_INFO| NUMBER_OF_SHELLS: ",
"AUTO"
2738 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2739 "HFX_INFO| NUMBER_OF_SHELLS: ", x_data%periodic_parameter%mode
2741 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2742 "HFX_INFO| Number of periodic shells considered: ", x_data%periodic_parameter%number_of_shells
2743 WRITE (unit=iw, fmt=
"((T3,A,T61,I20),/)") &
2744 "HFX_INFO| Number of periodic cells considered: ",
SIZE(x_data%neighbor_cells)
2746 WRITE (unit=iw, fmt=
"((T3,A,T77,A))") &
2747 "HFX_INFO| Number of periodic shells considered: ",
"NONE"
2748 WRITE (unit=iw, fmt=
"((T3,A,T77,A),/)") &
2749 "HFX_INFO| Number of periodic cells considered: ",
"NONE"
2752 END SUBROUTINE hfx_print_std_info
2759 SUBROUTINE hfx_print_ri_info(ri_data, hfx_section)
2761 TYPE(section_vals_type),
POINTER :: hfx_section
2765 TYPE(cp_logger_type),
POINTER :: logger
2766 TYPE(section_vals_type),
POINTER :: ri_section
2768 NULLIFY (logger, ri_section)
2769 logger => cp_get_default_logger()
2771 ri_section => ri_data%ri_section
2773 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2774 extension=
".scfLog")
2778 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
2779 SELECT CASE (ri_metric%potential_type)
2780 CASE (do_potential_coulomb)
2781 WRITE (unit=iw, fmt=
"(/T3,A,T74,A)") &
2782 "HFX_RI_INFO| RI metric: ",
"COULOMB"
2783 CASE (do_potential_short)
2784 WRITE (unit=iw, fmt=
"(T3,A,T71,A)") &
2785 "HFX_RI_INFO| RI metric: ",
"SHORTRANGE"
2786 WRITE (iw,
'(T3,A,T61,F20.10)') &
2787 "HFX_RI_INFO| Omega: ", ri_metric%omega
2788 rc_ang = cp_unit_from_cp2k(ri_metric%cutoff_radius,
"angstrom")
2789 WRITE (iw,
'(T3,A,T61,F20.10)') &
2790 "HFX_RI_INFO| Cutoff Radius [angstrom]: ", rc_ang
2791 CASE (do_potential_long)
2792 WRITE (unit=iw, fmt=
"(T3,A,T72,A)") &
2793 "HFX_RI_INFO| RI metric: ",
"LONGRANGE"
2794 WRITE (iw,
'(T3,A,T61,F20.10)') &
2795 "HFX_RI_INFO| Omega: ", ri_metric%omega
2796 CASE (do_potential_id)
2797 WRITE (unit=iw, fmt=
"(T3,A,T74,A)") &
2798 "HFX_RI_INFO| RI metric: ",
"OVERLAP"
2799 CASE (do_potential_truncated)
2800 WRITE (unit=iw, fmt=
"(T3,A,T64,A)") &
2801 "HFX_RI_INFO| RI metric: ",
"TRUNCATED COULOMB"
2802 rc_ang = cp_unit_from_cp2k(ri_metric%cutoff_radius,
"angstrom")
2803 WRITE (iw,
'(T3,A,T61,F20.10)') &
2804 "HFX_RI_INFO| Cutoff Radius [angstrom]: ", rc_ang
2808 SELECT CASE (ri_data%flavor)
2810 WRITE (unit=iw, fmt=
"(T3, A, T79, A)") &
2811 "HFX_RI_INFO| RI flavor: ",
"MO"
2813 WRITE (unit=iw, fmt=
"(T3, A, T78, A)") &
2814 "HFX_RI_INFO| RI flavor: ",
"RHO"
2816 SELECT CASE (ri_data%t2c_method)
2817 CASE (hfx_ri_do_2c_iter)
2818 WRITE (unit=iw, fmt=
"(T3, A, T69, A)") &
2819 "HFX_RI_INFO| Matrix SQRT/INV",
"DBCSR / iter"
2820 CASE (hfx_ri_do_2c_diag)
2821 WRITE (unit=iw, fmt=
"(T3, A, T65, A)") &
2822 "HFX_RI_INFO| Matrix SQRT/INV",
"Dense / diag"
2824 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2825 "HFX_RI_INFO| EPS_FILTER", ri_data%filter_eps
2826 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2827 "HFX_RI_INFO| EPS_FILTER 2-center", ri_data%filter_eps_2c
2828 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2829 "HFX_RI_INFO| EPS_FILTER storage", ri_data%filter_eps_storage
2830 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2831 "HFX_RI_INFO| EPS_FILTER MO", ri_data%filter_eps_mo
2832 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2833 "HFX_RI_INFO| EPS_PGF_ORB", ri_data%eps_pgf_orb
2834 WRITE (unit=iw, fmt=
"((T3, A, T73, ES8.1))") &
2835 "HFX_RI_INFO| EPS_SCHWARZ: ", ri_data%eps_schwarz
2836 WRITE (unit=iw, fmt=
"((T3, A, T73, ES8.1))") &
2837 "HFX_RI_INFO| EPS_SCHWARZ_FORCES: ", ri_data%eps_schwarz_forces
2838 WRITE (unit=iw, fmt=
"(T3, A, T78, I3)") &
2839 "HFX_RI_INFO| Minimum block size", ri_data%min_bsize
2840 WRITE (unit=iw, fmt=
"(T3, A, T78, I3)") &
2841 "HFX_RI_INFO| MO block size", ri_data%max_bsize_MO
2842 WRITE (unit=iw, fmt=
"(T3, A, T79, I2)") &
2843 "HFX_RI_INFO| Memory reduction factor", ri_data%n_mem_input
2846 END SUBROUTINE hfx_print_ri_info
2854 SUBROUTINE hfx_print_info(x_data, hfx_section, i_rep)
2856 TYPE(section_vals_type),
POINTER :: hfx_section
2857 INTEGER,
INTENT(IN) :: i_rep
2861 TYPE(cp_logger_type),
POINTER :: logger
2864 logger => cp_get_default_logger()
2866 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2867 extension=
".scfLog")
2870 WRITE (unit=iw, fmt=
"(/,(T3,A,T61,I20))") &
2871 "HFX_INFO| Replica ID: ", i_rep
2873 WRITE (iw,
'(T3,A,T61,F20.10)') &
2874 "HFX_INFO| FRACTION: ", x_data%general_parameter%fraction
2875 SELECT CASE (x_data%potential_parameter%potential_type)
2876 CASE (do_potential_coulomb)
2877 WRITE (unit=iw, fmt=
"((T3,A,T74,A))") &
2878 "HFX_INFO| Interaction Potential: ",
"COULOMB"
2879 CASE (do_potential_short)
2880 WRITE (unit=iw, fmt=
"((T3,A,T71,A))") &
2881 "HFX_INFO| Interaction Potential: ",
"SHORTRANGE"
2882 WRITE (iw,
'(T3,A,T61,F20.10)') &
2883 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2884 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2885 WRITE (iw,
'(T3,A,T61,F20.10)') &
2886 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2887 CASE (do_potential_long)
2888 WRITE (unit=iw, fmt=
"((T3,A,T72,A))") &
2889 "HFX_INFO| Interaction Potential: ",
"LONGRANGE"
2890 WRITE (iw,
'(T3,A,T61,F20.10)') &
2891 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2892 CASE (do_potential_mix_cl)
2893 WRITE (unit=iw, fmt=
"((T3,A,T75,A))") &
2894 "HFX_INFO| Interaction Potential: ",
"MIX_CL"
2895 WRITE (iw,
'(T3,A,T61,F20.10)') &
2896 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2897 WRITE (iw,
'(T3,A,T61,F20.10)') &
2898 "HFX_INFO| SCALE_COULOMB: ", x_data%potential_parameter%scale_coulomb
2899 WRITE (iw,
'(T3,A,T61,F20.10)') &
2900 "HFX_INFO| SCALE_LONGRANGE: ", x_data%potential_parameter%scale_longrange
2901 CASE (do_potential_gaussian)
2902 WRITE (unit=iw, fmt=
"((T3,A,T73,A))") &
2903 "HFX_INFO| Interaction Potential: ",
"GAUSSIAN"
2904 WRITE (iw,
'(T3,A,T61,F20.10)') &
2905 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2906 CASE (do_potential_mix_lg)
2907 WRITE (unit=iw, fmt=
"((T3,A,T75,A))") &
2908 "HFX_INFO| Interaction Potential: ",
"MIX_LG"
2909 WRITE (iw,
'(T3,A,T61,F20.10)') &
2910 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2911 WRITE (iw,
'(T3,A,T61,F20.10)') &
2912 "HFX_INFO| SCALE_LONGRANGE: ", x_data%potential_parameter%scale_longrange
2913 WRITE (iw,
'(T3,A,T61,F20.10)') &
2914 "HFX_INFO| SCALE_GAUSSIAN: ", x_data%potential_parameter%scale_gaussian
2915 CASE (do_potential_id)
2916 WRITE (unit=iw, fmt=
"((T3,A,T73,A))") &
2917 "HFX_INFO| Interaction Potential: ",
"IDENTITY"
2918 CASE (do_potential_truncated)
2919 WRITE (unit=iw, fmt=
"((T3,A,T72,A))") &
2920 "HFX_INFO| Interaction Potential: ",
"TRUNCATED"
2921 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2922 WRITE (iw,
'(T3,A,T61,F20.10)') &
2923 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2924 CASE (do_potential_mix_cl_trunc)
2925 WRITE (unit=iw, fmt=
"((T3,A,T65,A))") &
2926 "HFX_INFO| Interaction Potential: ",
"TRUNCATED MIX_CL"
2927 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2928 WRITE (iw,
'(T3,A,T61,F20.10)') &
2929 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2933 IF (x_data%do_hfx_ri)
THEN
2934 CALL hfx_print_ri_info(x_data%ri_data, hfx_section)
2936 CALL hfx_print_std_info(x_data, hfx_section)
2940 IF (x_data%use_ace .AND. iw > 0)
THEN
2941 WRITE (unit=iw, fmt=
"(/,T3,A)") &
2942 "HFX_INFO| ACE (Adaptively Compressed Exchange): ACTIVE"
2943 WRITE (unit=iw, fmt=
"(T3,A,T61,I20)") &
2944 "HFX_INFO| ACE rebuild frequency: ", x_data%ace_rebuild_freq
2947 CALL cp_print_key_finished_output(iw, logger, hfx_section, &
2949 END SUBROUTINE hfx_print_info
2958 INTEGER :: memory_usage
2962 DO bin = 1,
SIZE(data%maxval_container)
2965 DEALLOCATE (data%maxval_container(bin)%first)
2967 DEALLOCATE (data%maxval_container)
2968 DEALLOCATE (data%maxval_cache)
2970 DO bin = 1,
SIZE(data%integral_containers, 2)
2974 DEALLOCATE (data%integral_containers(i, bin)%first)
2977 DEALLOCATE (data%integral_containers)
2979 DEALLOCATE (data%integral_caches)
2990 INTEGER,
INTENT(IN) :: bin_size
2994 ALLOCATE (data%maxval_cache(bin_size))
2995 DO bin = 1, bin_size
2996 data%maxval_cache(bin)%element_counter = 1
2998 ALLOCATE (data%maxval_container(bin_size))
2999 DO bin = 1, bin_size
3000 ALLOCATE (data%maxval_container(bin)%first)
3001 data%maxval_container(bin)%first%prev => null()
3002 data%maxval_container(bin)%first%next => null()
3003 data%maxval_container(bin)%current => data%maxval_container(bin)%first
3004 data%maxval_container(bin)%current%data = 0
3005 data%maxval_container(bin)%element_counter = 1
3008 ALLOCATE (data%integral_containers(64, bin_size))
3009 ALLOCATE (data%integral_caches(64, bin_size))
3011 DO bin = 1, bin_size
3013 data%integral_caches(i, bin)%element_counter = 1
3014 data%integral_caches(i, bin)%data = 0
3015 ALLOCATE (data%integral_containers(i, bin)%first)
3016 data%integral_containers(i, bin)%first%prev => null()
3017 data%integral_containers(i, bin)%first%next => null()
3018 data%integral_containers(i, bin)%current => data%integral_containers(i, bin)%first
3019 data%integral_containers(i, bin)%current%data = 0
3020 data%integral_containers(i, bin)%element_counter = 1
3037 TYPE(section_vals_type),
POINTER :: hfx_section1, hfx_section2
3038 LOGICAL,
INTENT(OUT) :: is_identical
3039 LOGICAL,
INTENT(OUT),
OPTIONAL :: same_except_frac
3041 CHARACTER(LEN=default_path_length) :: cval1, cval2
3042 INTEGER :: irep, ival1, ival2, n_rep_hf1, n_rep_hf2
3043 LOGICAL :: lval1, lval2
3044 REAL(dp) :: rval1, rval2
3045 TYPE(section_vals_type),
POINTER :: hfx_sub_section1, hfx_sub_section2
3047 is_identical = .true.
3048 IF (
PRESENT(same_except_frac)) same_except_frac = .false.
3050 CALL section_vals_get(hfx_section1, n_repetition=n_rep_hf1)
3051 CALL section_vals_get(hfx_section2, n_repetition=n_rep_hf2)
3052 is_identical = n_rep_hf1 == n_rep_hf2
3053 IF (.NOT. is_identical)
RETURN
3055 DO irep = 1, n_rep_hf1
3056 CALL section_vals_val_get(hfx_section1,
"PW_HFX", l_val=lval1, i_rep_section=irep)
3057 CALL section_vals_val_get(hfx_section2,
"PW_HFX", l_val=lval2, i_rep_section=irep)
3058 IF (lval1 .NEQV. lval2) is_identical = .false.
3060 CALL section_vals_val_get(hfx_section1,
"PW_HFX_BLOCKSIZE", i_val=ival1, i_rep_section=irep)
3061 CALL section_vals_val_get(hfx_section2,
"PW_HFX_BLOCKSIZE", i_val=ival2, i_rep_section=irep)
3062 IF (ival1 /= ival2) is_identical = .false.
3064 CALL section_vals_val_get(hfx_section1,
"TREAT_LSD_IN_CORE", l_val=lval1, i_rep_section=irep)
3065 CALL section_vals_val_get(hfx_section2,
"TREAT_LSD_IN_CORE", l_val=lval2, i_rep_section=irep)
3066 IF (lval1 .NEQV. lval2) is_identical = .false.
3068 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"INTERACTION_POTENTIAL", i_rep_section=irep)
3069 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"INTERACTION_POTENTIAL", i_rep_section=irep)
3071 CALL section_vals_val_get(hfx_sub_section1,
"OMEGA", r_val=rval1, i_rep_section=irep)
3072 CALL section_vals_val_get(hfx_sub_section2,
"OMEGA", r_val=rval2, i_rep_section=irep)
3073 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3075 CALL section_vals_val_get(hfx_sub_section1,
"POTENTIAL_TYPE", i_val=ival1, i_rep_section=irep)
3076 CALL section_vals_val_get(hfx_sub_section2,
"POTENTIAL_TYPE", i_val=ival2, i_rep_section=irep)
3077 IF (ival1 /= ival2) is_identical = .false.
3078 IF (.NOT. is_identical)
RETURN
3080 IF (ival1 == do_potential_truncated .OR. ival1 == do_potential_mix_cl_trunc)
THEN
3081 CALL section_vals_val_get(hfx_sub_section1,
"CUTOFF_RADIUS", r_val=rval1, i_rep_section=irep)
3082 CALL section_vals_val_get(hfx_sub_section2,
"CUTOFF_RADIUS", r_val=rval2, i_rep_section=irep)
3083 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3085 CALL section_vals_val_get(hfx_sub_section1,
"T_C_G_DATA", c_val=cval1, i_rep_section=irep)
3086 CALL section_vals_val_get(hfx_sub_section2,
"T_C_G_DATA", c_val=cval2, i_rep_section=irep)
3087 IF (cval1 /= cval2) is_identical = .false.
3090 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_COULOMB", r_val=rval1, i_rep_section=irep)
3091 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_COULOMB", r_val=rval2, i_rep_section=irep)
3092 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3094 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_GAUSSIAN", r_val=rval1, i_rep_section=irep)
3095 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_GAUSSIAN", r_val=rval2, i_rep_section=irep)
3096 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3098 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_LONGRANGE", r_val=rval1, i_rep_section=irep)
3099 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_LONGRANGE", r_val=rval2, i_rep_section=irep)
3100 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3102 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"PERIODIC", i_rep_section=irep)
3103 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"PERIODIC", i_rep_section=irep)
3105 CALL section_vals_val_get(hfx_sub_section1,
"NUMBER_OF_SHELLS", i_val=ival1, i_rep_section=irep)
3106 CALL section_vals_val_get(hfx_sub_section2,
"NUMBER_OF_SHELLS", i_val=ival2, i_rep_section=irep)
3107 IF (ival1 /= ival2) is_identical = .false.
3109 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"RI", i_rep_section=irep)
3110 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"RI", i_rep_section=irep)
3112 CALL section_vals_val_get(hfx_sub_section1,
"_SECTION_PARAMETERS_", l_val=lval1, i_rep_section=irep)
3113 CALL section_vals_val_get(hfx_sub_section2,
"_SECTION_PARAMETERS_", l_val=lval2, i_rep_section=irep)
3114 IF (lval1 .NEQV. lval2) is_identical = .false.
3116 CALL section_vals_val_get(hfx_sub_section1,
"CUTOFF_RADIUS", r_val=rval1, i_rep_section=irep)
3117 CALL section_vals_val_get(hfx_sub_section2,
"CUTOFF_RADIUS", r_val=rval2, i_rep_section=irep)
3118 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3120 CALL section_vals_val_get(hfx_sub_section1,
"EPS_EIGVAL", r_val=rval1, i_rep_section=irep)
3121 CALL section_vals_val_get(hfx_sub_section2,
"EPS_EIGVAL", r_val=rval2, i_rep_section=irep)
3122 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3124 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER", r_val=rval1, i_rep_section=irep)
3125 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER", r_val=rval2, i_rep_section=irep)
3126 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3128 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER_2C", r_val=rval1, i_rep_section=irep)
3129 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER_2C", r_val=rval2, i_rep_section=irep)
3130 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3132 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER_MO", r_val=rval1, i_rep_section=irep)
3133 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER_MO", r_val=rval2, i_rep_section=irep)
3134 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3136 CALL section_vals_val_get(hfx_sub_section1,
"EPS_PGF_ORB", r_val=rval1, i_rep_section=irep)
3137 CALL section_vals_val_get(hfx_sub_section2,
"EPS_PGF_ORB", r_val=rval2, i_rep_section=irep)
3138 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3140 CALL section_vals_val_get(hfx_sub_section1,
"MAX_BLOCK_SIZE_MO", i_val=ival1, i_rep_section=irep)
3141 CALL section_vals_val_get(hfx_sub_section2,
"MAX_BLOCK_SIZE_MO", i_val=ival2, i_rep_section=irep)
3142 IF (ival1 /= ival2) is_identical = .false.
3144 CALL section_vals_val_get(hfx_sub_section1,
"MIN_BLOCK_SIZE", i_val=ival1, i_rep_section=irep)
3145 CALL section_vals_val_get(hfx_sub_section2,
"MIN_BLOCK_SIZE", i_val=ival2, i_rep_section=irep)
3146 IF (ival1 /= ival2) is_identical = .false.
3148 CALL section_vals_val_get(hfx_sub_section1,
"OMEGA", r_val=rval1, i_rep_section=irep)
3149 CALL section_vals_val_get(hfx_sub_section2,
"OMEGA", r_val=rval2, i_rep_section=irep)
3150 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3152 CALL section_vals_val_get(hfx_sub_section1,
"RI_FLAVOR", i_val=ival1, i_rep_section=irep)
3153 CALL section_vals_val_get(hfx_sub_section2,
"RI_FLAVOR", i_val=ival2, i_rep_section=irep)
3154 IF (ival1 /= ival2) is_identical = .false.
3156 CALL section_vals_val_get(hfx_sub_section1,
"RI_METRIC", i_val=ival1, i_rep_section=irep)
3157 CALL section_vals_val_get(hfx_sub_section2,
"RI_METRIC", i_val=ival2, i_rep_section=irep)
3158 IF (ival1 /= ival2) is_identical = .false.
3160 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"SCREENING", i_rep_section=irep)
3161 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"SCREENING", i_rep_section=irep)
3163 CALL section_vals_val_get(hfx_sub_section1,
"EPS_SCHWARZ", r_val=rval1, i_rep_section=irep)
3164 CALL section_vals_val_get(hfx_sub_section2,
"EPS_SCHWARZ", r_val=rval2, i_rep_section=irep)
3165 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3167 CALL section_vals_val_get(hfx_sub_section1,
"EPS_SCHWARZ_FORCES", r_val=rval1, i_rep_section=irep)
3168 CALL section_vals_val_get(hfx_sub_section2,
"EPS_SCHWARZ_FORCES", r_val=rval2, i_rep_section=irep)
3169 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3171 CALL section_vals_val_get(hfx_sub_section1,
"P_SCREEN_CORRECTION_FACTOR", r_val=rval1, i_rep_section=irep)
3172 CALL section_vals_val_get(hfx_sub_section2,
"P_SCREEN_CORRECTION_FACTOR", r_val=rval2, i_rep_section=irep)
3173 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3175 CALL section_vals_val_get(hfx_sub_section1,
"SCREEN_ON_INITIAL_P", l_val=lval1, i_rep_section=irep)
3176 CALL section_vals_val_get(hfx_sub_section2,
"SCREEN_ON_INITIAL_P", l_val=lval2, i_rep_section=irep)
3177 IF (lval1 .NEQV. lval2) is_identical = .false.
3179 CALL section_vals_val_get(hfx_sub_section1,
"SCREEN_P_FORCES", l_val=lval1, i_rep_section=irep)
3180 CALL section_vals_val_get(hfx_sub_section2,
"SCREEN_P_FORCES", l_val=lval2, i_rep_section=irep)
3181 IF (lval1 .NEQV. lval2) is_identical = .false.
3186 IF (is_identical)
THEN
3187 DO irep = 1, n_rep_hf1
3188 CALL section_vals_val_get(hfx_section1,
"FRACTION", r_val=rval1, i_rep_section=irep)
3189 CALL section_vals_val_get(hfx_section2,
"FRACTION", r_val=rval2, i_rep_section=irep)
3190 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3193 IF (
PRESENT(same_except_frac))
THEN
3194 IF (.NOT. is_identical) same_except_frac = .true.
static GRID_HOST_DEVICE int ncoset(const int l)
Number of Cartesian orbitals up to given angular momentum quantum.
static GRID_HOST_DEVICE int idx(const orbital a)
Return coset index of given orbital angular momentum.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
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)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public guidon2008
integer, save, public guidon2009
integer, save, public bussy2023
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
real(kind=dp) function, public plane_distance(h, k, l, cell)
Calculate the distance between two lattice planes as defined by a triple of Miller indices (hkl).
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_release(matrix)
...
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
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,...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
This is the start of a dbt_api, all publically needed functions are exported here....
Some auxiliary functions and subroutines needed for HFX calculations.
integer function, public count_cells_perd(shell, perd)
Auxiliary function for creating periodic neighbor cells
subroutine, public next_image_cell_perd(m, perd)
Auxiliary function for creating periodic neighbor cells
Types and set/get functions for HFX.
subroutine, public hfx_create(x_data, para_env, hfx_section, atomic_kind_set, qs_kind_set, particle_set, dft_control, cell, orb_basis, ri_basis, nelectron_total, nkp_grid)
This routine allocates and initializes all types in hfx_data
subroutine, public hfx_init_container(container, memory_usage, do_disk_storage)
This routine deletes all list entries in a container in order to deallocate the memory.
subroutine, public hfx_set_distr_energy(ptr_to_distr, x_data)
This routine stores the data obtained from the load balance routine for the energy
subroutine, public hfx_set_distr_forces(ptr_to_distr, x_data)
This routine stores the data obtained from the load balance routine for the forces
integer, parameter, public max_atom_block
subroutine, public parse_memory_section(memory_parameter, hf_sub_section, storage_id, i_thread, n_threads, para_env, irep, skip_disk, skip_in_core_forces)
Parses the memory section
subroutine, public hfx_release_basis_types(basis_parameter)
...
integer, save, public init_t_c_g0_lmax
real(dp), parameter, public log_zero
integer, parameter, public max_images
subroutine, public hfx_release(x_data)
This routine deallocates all data structures
subroutine, public alloc_containers(data, bin_size)
...
subroutine, public hfx_create_neighbor_cells(x_data, pbc_shells, cell, i_thread, nkp_grid)
This routine computes the neighbor cells that are taken into account in periodic runs
subroutine, public dealloc_containers(data, memory_usage)
...
subroutine, public hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, basis_type)
This routine allocates and initializes the basis_info and basis_parameter types
subroutine, public hfx_ri_init(ri_data, qs_kind_set, particle_set, atomic_kind_set, para_env)
...
subroutine, public compare_hfx_sections(hfx_section1, hfx_section2, is_identical, same_except_frac)
Compares the non-technical parts of two HFX input section and check whether they are the same Ignore ...
real(kind=dp), dimension(0:10), parameter, public mul_fact
real(dp), parameter, public powell_min_log
subroutine, public hfx_reset_memory_usage_counter(memory_parameter, subtr_size_mb)
resets the maximum memory usage for a HFX calculation subtracting all relevant buffers from the input...
subroutine, public hfx_ri_release(ri_data, write_stats)
...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
pure logical function, public compare_potential_types(potential1, potential2)
Helper function to compare libint_potential_types.
Interface to the Libint-Library or a c++ wrapper.
subroutine, public cp_libint_init_eri1(lib, max_am)
integer, parameter, public prim_data_f_size
subroutine, public cp_libint_cleanup_eri1(lib)
subroutine, public cp_libint_static_cleanup()
subroutine, public cp_libint_init_eri(lib, max_am)
subroutine, public cp_libint_static_init()
subroutine, public cp_libint_cleanup_eri(lib)
subroutine, public cp_libint_set_contrdepth(lib, contrdepth)
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_getcwd(curdir)
...
subroutine, public m_chdir(dir, ierror)
...
Collection of simple mathematical functions and subroutines.
subroutine, public erfc_cutoff(eps, omg, r_cutoff)
compute a truncation radius for the shortrange operator
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public ncoset
integer, dimension(:), allocatable, public nso
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public a_bohr
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
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_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Utility methods to build 3-center integral tensors of various types.
subroutine, public distribution_3d_create(dist_3d, dist1, dist2, dist3, nkind, particle_set, mp_comm_3d, own_comm)
Create a 3d distribution.
integer, parameter, public default_block_size
subroutine, public create_2c_tensor(t2c, dist_1, dist_2, pgrid, sizes_1, sizes_2, order, name)
...
subroutine, public split_block_sizes(blk_sizes, blk_sizes_split, max_size)
...
subroutine, public pgf_block_sizes(atomic_kind_set, basis, min_blk_size, pgf_blk_sizes)
...
subroutine, public distribution_3d_destroy(dist)
Destroy a 3d distribution.
subroutine, public create_tensor_batches(sizes, nbatches, starts_array, ends_array, starts_array_block, ends_array_block)
...
subroutine, public create_3c_tensor(t3c, dist_1, dist_2, dist_3, pgrid, sizes_1, sizes_2, sizes_3, map1, map2, name)
...
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
This module computes the basic integrals for the truncated coulomb operator.
subroutine, public free_c0()
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a pointer to a 1d array
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores some data used in construction of Kohn-Sham matrix
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.