43 dbt_create, dbt_default_distvec, dbt_destroy, dbt_distribution_destroy, &
44 dbt_distribution_new, dbt_distribution_type, dbt_mp_dims_create, dbt_pgrid_create, &
45 dbt_pgrid_destroy, dbt_pgrid_type, dbt_type
92#include "./base/base_uses.f90"
114#define CACHE_SIZE 1024
115#define BITS_MAX_VAL 6
117 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'hfx_types'
122 REAL(kind=
dp),
DIMENSION(0:10), &
123 PARAMETER,
PUBLIC ::
mul_fact = [1.0_dp, &
142 REAL(
dp) :: omega = 0.0_dp
143 REAL(
dp) :: scale_coulomb = 0.0_dp
144 REAL(
dp) :: scale_longrange = 0.0_dp
145 REAL(
dp) :: scale_gaussian = 0.0_dp
146 REAL(
dp) :: cutoff_radius = 0.0_dp
147 CHARACTER(default_path_length) :: filename =
""
152 REAL(
dp) :: eps_schwarz = 0.0_dp
153 REAL(
dp) :: eps_schwarz_forces = 0.0_dp
154 LOGICAL :: do_p_screening_forces = .false.
155 LOGICAL :: do_initial_p_screening = .false.
160 INTEGER :: max_memory = 0
161 INTEGER(int_8) :: max_compression_counter = 0_int_8
162 INTEGER(int_8) :: final_comp_counter_energy = 0_int_8
163 LOGICAL :: do_all_on_the_fly = .false.
164 REAL(
dp) :: eps_storage_scaling = 0.0_dp
165 INTEGER :: cache_size = 0
166 INTEGER :: bits_max_val = 0
167 INTEGER :: actual_memory_usage = 0
168 INTEGER :: actual_memory_usage_disk = 0
169 INTEGER(int_8) :: max_compression_counter_disk = 0_int_8
170 LOGICAL :: do_disk_storage = .false.
171 CHARACTER(len=default_path_length) :: storage_location =
""
172 INTEGER(int_8) :: ram_counter = 0_int_8
173 INTEGER(int_8) :: ram_counter_forces = 0_int_8
174 INTEGER(int_8) :: size_p_screen = 0_int_8
175 LOGICAL :: treat_forces_in_core = .false.
176 LOGICAL :: recalc_forces = .false.
180 TYPE hfx_periodic_type
181 INTEGER :: number_of_shells = -1
182 LOGICAL :: do_periodic = .false.
183 INTEGER :: perd(3) = -1
185 REAL(
dp) :: r_max_stress = 0.0_dp
186 INTEGER :: number_of_shells_from_input = 0
187 END TYPE hfx_periodic_type
192 INTEGER :: block_size = 0
193 INTEGER :: nblocks = 0
194 LOGICAL :: rtp_redistribute = .false.
195 LOGICAL :: blocks_initialized = .false.
196 LOGICAL :: do_randomize = .false.
201 REAL(
dp) :: fraction = 0.0_dp
202 LOGICAL :: treat_lsd_in_core = .false.
207 REAL(
dp) :: cell(3) = 0.0_dp
208 REAL(
dp) :: cell_r(3) = 0.0_dp
213 INTEGER(int_8) :: istart = 0_int_8
214 INTEGER(int_8) :: number_of_atom_quartets = 0_int_8
215 INTEGER(int_8) :: cost = 0_int_8
216 REAL(kind=
dp) :: time_first_scf = 0.0_dp
217 REAL(kind=
dp) :: time_other_scf = 0.0_dp
218 REAL(kind=
dp) :: time_forces = 0.0_dp
219 INTEGER(int_8) :: ram_counter = 0_int_8
224 INTEGER,
DIMENSION(2) :: pair = 0
225 INTEGER,
DIMENSION(2) :: set_bounds = 0
226 INTEGER,
DIMENSION(2) :: kind_pair = 0
227 REAL(kind=
dp) :: r1(3) = 0.0_dp, r2(3) = 0.0_dp
228 REAL(kind=
dp) :: dist2 = 0.0_dp
233 INTEGER,
DIMENSION(2) :: pair = 0
239 INTEGER :: n_element = 0
244 INTEGER(int_8),
DIMENSION(CACHE_SIZE) :: data = 0_int_8
245 INTEGER :: element_counter = 0
249 TYPE hfx_container_node
250 TYPE(hfx_container_node),
POINTER :: next => null(), prev => null()
251 INTEGER(int_8),
DIMENSION(CACHE_SIZE) :: data = 0_int_8
252 END TYPE hfx_container_node
256 TYPE(hfx_container_node),
POINTER :: first => null(), current => null()
257 INTEGER :: element_counter = 0
258 INTEGER(int_8) :: file_counter = 0
259 CHARACTER(LEN=5) :: desc =
""
261 CHARACTER(default_path_length) :: filename =
""
266 INTEGER,
DIMENSION(:),
POINTER :: lmax => null()
267 INTEGER,
DIMENSION(:),
POINTER :: lmin => null()
268 INTEGER,
DIMENSION(:),
POINTER :: npgf => null()
270 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet => null()
271 INTEGER,
DIMENSION(:),
POINTER :: nsgf => null()
272 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf => null()
273 REAL(
dp),
DIMENSION(:, :),
POINTER :: sphi => null()
274 INTEGER :: nsgf_total = 0
275 INTEGER,
DIMENSION(:, :),
POINTER :: nl => null()
276 INTEGER,
DIMENSION(:, :),
POINTER :: nsgfl => null()
277 INTEGER,
DIMENSION(:),
POINTER :: nshell => null()
278 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER &
279 :: sphi_ext => null()
280 REAL(
dp),
DIMENSION(:),
POINTER :: set_radius => null()
281 REAL(
dp),
DIMENSION(:, :),
POINTER :: pgf_radius => null()
282 REAL(
dp) :: kind_radius = 0.0_dp
287 INTEGER :: max_set = 0
288 INTEGER :: max_sgf = 0
289 INTEGER :: max_am = 0
294 REAL(
dp) :: x(2) = 0.0_dp
299 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: p_kind => null()
304 INTEGER,
DIMENSION(:),
POINTER :: iatom_list => null()
305 INTEGER,
DIMENSION(:),
POINTER :: jatom_list => null()
310 REAL(
dp) :: ra(3) = 0.0_dp, rb(3) = 0.0_dp
311 REAL(
dp) :: rab2 = 0.0_dp
312 REAL(
dp) :: s1234 = 0.0_dp
313 REAL(
dp) :: p(3) = 0.0_dp
314 REAL(
dp) :: r = 0.0_dp
315 REAL(
dp) :: pgf_max = 0.0_dp
316 REAL(
dp),
DIMENSION(3) :: bcell = 0.0_dp
317 END TYPE hfx_pgf_image
321 TYPE(hfx_pgf_image),
DIMENSION(:),
POINTER &
322 :: image_list => null()
323 INTEGER :: nimages = 0
324 REAL(
dp) :: zetapzetb = 0.0_dp
325 REAL(
dp) :: zetainv = 0.0_dp
326 REAL(
dp) :: zeta = 0.0_dp, zetb = 0.0_dp
327 INTEGER :: ipgf = 0, jpgf = 0
332 REAL(
dp) :: ra(3) = 0.0_dp, rb(3) = 0.0_dp, rc(3) = 0.0_dp, rd(3) = 0.0_dp
333 REAL(
dp) :: zetapetainv = 0.0_dp
334 REAL(
dp) :: rho = 0.0_dp, rhoinv = 0.0_dp
335 REAL(
dp) :: p(3) = 0.0_dp, q(3) = 0.0_dp, w(3) = 0.0_dp
336 REAL(
dp) :: ab(3) = 0.0_dp, cd(3) = 0.0_dp
342 INTEGER :: istart = 0, iend = 0
343 INTEGER(int_8) :: cost = 0_int_8
348 INTEGER :: thread_id = 0
349 INTEGER :: bin_id = 0
350 INTEGER(int_8) :: cost = 0_int_8
355 POINTER :: maxval_container => null()
357 POINTER :: maxval_cache => null()
359 POINTER :: integral_containers => null()
361 POINTER :: integral_caches => null()
366 DIMENSION(:) :: integral_containers_disk => null()
370 INTEGER,
DIMENSION(:, :),
ALLOCATABLE :: ind
375 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, &
376 eps_lanczos = 0.0_dp, eps_pgf_orb = 0.0_dp, eps_eigval = 0.0_dp, kp_ri_range = 0.0_dp, &
377 kp_image_range = 0.0_dp, kp_bump_rad = 0.0_dp
378 INTEGER :: t2c_sqrt_order = 0, max_iter_lanczos = 0, flavor = 0, unit_nr_dbcsr = -1, unit_nr = -1, &
379 min_bsize = 0, max_bsize_mo = 0, t2c_method = 0, nelectron_total = 0, input_flavor = 0, &
380 ncell_ri = 0, nimg = 0, kp_stack_size = 0, nimg_nze = 0, kp_ngroups = 1
381 LOGICAL :: check_2c_inv = .false., calc_condnum = .false.
387 REAL(kind=
dp) :: eps_schwarz = 0.0_dp
388 REAL(kind=
dp) :: eps_schwarz_forces = 0.0_dp
390 LOGICAL :: same_op = .false.
393 TYPE(dbt_pgrid_type),
POINTER :: pgrid => null()
394 TYPE(dbt_pgrid_type),
POINTER :: pgrid_2d => null()
398 TYPE(dbt_distribution_type) :: dist
401 INTEGER,
DIMENSION(:),
ALLOCATABLE :: bsizes_ri, bsizes_ao, bsizes_ri_split, bsizes_ao_split, &
402 bsizes_ri_fit, bsizes_ao_fit
405 INTEGER,
DIMENSION(:),
ALLOCATABLE :: img_to_ri_cell, present_images, idx_to_img, img_to_idx, &
409 REAL(
dp),
DIMENSION(:, :, :),
ALLOCATABLE :: kp_cost
415 TYPE(dbt_type),
DIMENSION(:),
ALLOCATABLE :: kp_t_3c_int
421 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: rho_ao_t, ks_t
424 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_inv
425 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_pot
428 TYPE(
dbcsr_type),
DIMENSION(:, :),
ALLOCATABLE :: kp_mat_2c_pot
431 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_2c_int
434 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_1
436 TYPE(dbt_pgrid_type),
POINTER :: pgrid_1 => null()
439 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_2
440 TYPE(dbt_pgrid_type),
POINTER :: pgrid_2 => null()
443 TYPE(dbt_type),
DIMENSION(:, :),
ALLOCATABLE :: t_3c_int_ctr_3
446 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_int_mo
447 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ri
448 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ks
449 TYPE(dbt_type),
DIMENSION(:, :, :),
ALLOCATABLE :: t_3c_ctr_ks_copy
457 CHARACTER(len=default_string_length) :: orb_basis_type =
"", ri_basis_type =
""
460 INTEGER :: n_mem_input = 0, n_mem = 0, n_mem_ri = 0, n_mem_flavor_switch = 0
463 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_mem_block, ends_array_mem_block
464 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_mem, ends_array_mem
466 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_ri_mem_block, ends_array_ri_mem_block
467 INTEGER,
DIMENSION(:),
ALLOCATABLE :: starts_array_ri_mem, ends_array_ri_mem
469 INTEGER(int_8) :: dbcsr_nflop = 0_int_8
470 REAL(
dp) :: dbcsr_time = 0.0_dp
471 INTEGER :: num_pe = 0
515 TYPE(hfx_periodic_type) :: periodic_parameter = hfx_periodic_type()
523 POINTER :: neighbor_cells => null()
525 POINTER :: distribution_energy => null()
527 POINTER :: distribution_forces => null()
528 INTEGER,
DIMENSION(:, :),
POINTER :: is_assoc_atomic_block => null()
529 INTEGER :: number_of_p_entries = 0
531 POINTER :: basis_parameter => null()
532 INTEGER :: n_rep_hf = 0
533 LOGICAL :: b_first_load_balance_energy = .false., &
534 b_first_load_balance_forces = .false.
535 REAL(
dp),
DIMENSION(:, :),
POINTER :: full_ks_alpha => null()
536 REAL(
dp),
DIMENSION(:, :),
POINTER :: full_ks_beta => null()
540 DIMENSION(:, :, :, :, :, :),
POINTER :: screen_funct_coeffs_pgf => null(), &
541 pair_dist_radii_pgf => null()
543 DIMENSION(:, :, :, :),
POINTER :: screen_funct_coeffs_set => null()
545 DIMENSION(:, :),
POINTER :: screen_funct_coeffs_kind => null()
546 LOGICAL :: screen_funct_is_initialized = .false.
547 TYPE(
hfx_p_kind),
DIMENSION(:),
POINTER :: initial_p => null()
548 TYPE(
hfx_p_kind),
DIMENSION(:),
POINTER :: initial_p_forces => null()
549 INTEGER,
DIMENSION(:),
POINTER :: map_atom_to_kind_atom => null()
550 TYPE(
hfx_2d_map),
DIMENSION(:),
POINTER :: map_atoms_to_cpus => null()
551 INTEGER,
DIMENSION(:, :),
POINTER :: atomic_block_offset => null()
552 INTEGER,
DIMENSION(:, :, :, :),
POINTER :: set_offset => null()
553 INTEGER,
DIMENSION(:),
POINTER :: block_offset => null()
555 POINTER :: blocks => null()
557 POINTER :: task_list => null()
558 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmax_atom => null(), pmax_atom_forces => null()
560 REAL(
dp),
DIMENSION(:, :),
POINTER :: pmax_block => null()
561 LOGICAL,
DIMENSION(:, :),
POINTER :: atomic_pair_list => null()
562 LOGICAL,
DIMENSION(:, :),
POINTER :: atomic_pair_list_forces => null()
563 LOGICAL :: do_hfx_ri = .false.
593 SUBROUTINE hfx_create(x_data, para_env, hfx_section, atomic_kind_set, qs_kind_set, &
594 particle_set, dft_control, cell, orb_basis, ri_basis, &
595 nelectron_total, nkp_grid)
596 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
600 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
604 CHARACTER(LEN=*),
OPTIONAL :: orb_basis, ri_basis
605 INTEGER,
OPTIONAL :: nelectron_total
606 INTEGER,
DIMENSION(3),
OPTIONAL :: nkp_grid
608 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_create'
610 CHARACTER(LEN=512) :: error_msg
611 CHARACTER(LEN=default_path_length) :: char_val
612 CHARACTER(LEN=default_string_length) :: orb_basis_type, ri_basis_type
613 INTEGER :: handle, i, i_thread, iatom, ikind, int_val, irep, jkind, max_set, n_rep_hf, &
614 n_threads, natom, natom_a, natom_b, nkind, nseta, nsetb, pbc_shells, storage_id
615 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom2kind, kind_of
616 LOGICAL :: do_ri, explicit, logic_val
618 TYPE(
hfx_type),
POINTER :: actual_x_data
622 CALL timeset(routinen, handle)
627 natom =
SIZE(particle_set)
635 IF (do_ri) n_threads = 1
637 IF (
PRESENT(orb_basis))
THEN
638 orb_basis_type = orb_basis
640 orb_basis_type =
"ORB"
642 IF (
PRESENT(ri_basis))
THEN
643 ri_basis_type = ri_basis
645 ri_basis_type =
"RI_HFX"
648 ALLOCATE (x_data(n_rep_hf, n_threads))
649 DO i_thread = 1, n_threads
650 DO irep = 1, n_rep_hf
651 actual_x_data => x_data(irep, i_thread)
656 actual_x_data%general_parameter%fraction = real_val
657 actual_x_data%n_rep_hf = n_rep_hf
659 NULLIFY (actual_x_data%map_atoms_to_cpus)
661 CALL section_vals_val_get(hfx_section,
"TREAT_LSD_IN_CORE", l_val=logic_val, i_rep_section=irep)
662 actual_x_data%general_parameter%treat_lsd_in_core = logic_val
665 CALL section_vals_val_get(hfx_ri_section,
"_SECTION_PARAMETERS_", l_val=actual_x_data%do_hfx_ri)
669 CALL parse_memory_section(actual_x_data%memory_parameter, hf_sub_section, storage_id, i_thread, &
670 n_threads, para_env, irep, skip_disk=.false., skip_in_core_forces=.false.)
675 actual_x_data%periodic_parameter%number_of_shells = int_val
676 actual_x_data%periodic_parameter%mode = int_val
677 CALL get_cell(cell=cell, periodic=actual_x_data%periodic_parameter%perd)
678 IF (sum(actual_x_data%periodic_parameter%perd) == 0)
THEN
679 actual_x_data%periodic_parameter%do_periodic = .false.
681 actual_x_data%periodic_parameter%do_periodic = .true.
687 actual_x_data%screening_parameter%eps_schwarz = real_val
688 CALL section_vals_val_get(hf_sub_section,
"EPS_SCHWARZ_FORCES", r_val=real_val, explicit=explicit)
690 actual_x_data%screening_parameter%eps_schwarz_forces = real_val
692 actual_x_data%screening_parameter%eps_schwarz_forces = &
693 100._dp*actual_x_data%screening_parameter%eps_schwarz
696 actual_x_data%screening_parameter%do_p_screening_forces = logic_val
698 actual_x_data%screening_parameter%do_initial_p_screening = logic_val
699 actual_x_data%screen_funct_is_initialized = .false.
704 actual_x_data%potential_parameter%potential_type = int_val
706 actual_x_data%potential_parameter%omega = real_val
708 actual_x_data%potential_parameter%scale_coulomb = real_val
710 actual_x_data%potential_parameter%scale_longrange = real_val
712 actual_x_data%potential_parameter%scale_gaussian = real_val
716 actual_x_data%potential_parameter%cutoff_radius = real_val
721 WRITE (error_msg,
'(A,A,A)')
"Truncated hfx calculation requested. The file containing "// &
722 "the data could not be found at ", trim(char_val),
" Please check T_C_G_DATA "// &
723 "in the INTERACTION_POTENTIAL section"
726 actual_x_data%potential_parameter%filename = char_val
730 CALL erfc_cutoff(actual_x_data%screening_parameter%eps_schwarz, &
731 actual_x_data%potential_parameter%omega, &
732 actual_x_data%potential_parameter%cutoff_radius)
736 IF (real_val < actual_x_data%potential_parameter%cutoff_radius .AND. &
737 i_thread == 1 .AND. irep == 1)
THEN
738 WRITE (error_msg,
'(A,F6.3,A,ES8.1,A,F6.3,A,F6.3,A)') &
739 "Periodic Hartree Fock calculation requested with the use "// &
740 "of a shortrange potential erfc(omega*r)/r. Given omega = ", &
741 actual_x_data%potential_parameter%omega,
" and EPS_SCHWARZ = ", &
742 actual_x_data%screening_parameter%eps_schwarz,
", the requested "// &
743 "cutoff radius ", real_val*
a_bohr*1e+10_dp,
" A is smaller than "// &
744 "what is necessary to satisfy erfc(omega*r)/r = EPS_SCHWARZ at r = ", &
745 actual_x_data%potential_parameter%cutoff_radius*
a_bohr*1e+10_dp, &
746 " A. Increase input value (or omit keyword to use program default) "// &
747 "to ensure accuracy."
750 actual_x_data%potential_parameter%cutoff_radius = real_val
753 IF (actual_x_data%potential_parameter%potential_type ==
do_potential_id)
THEN
754 actual_x_data%potential_parameter%cutoff_radius = 0.0_dp
760 actual_x_data%load_balance_parameter%nbins = max(1, int_val)
761 actual_x_data%load_balance_parameter%blocks_initialized = .false.
764 actual_x_data%load_balance_parameter%do_randomize = logic_val
766 actual_x_data%load_balance_parameter%rtp_redistribute = .false.
767 IF (
ASSOCIATED(dft_control%rtp_control)) &
768 actual_x_data%load_balance_parameter%rtp_redistribute = dft_control%rtp_control%hfx_redistribute
772 IF (int_val <= 0)
THEN
774 int_val = ceiling(0.1_dp*natom/ &
775 REAL(actual_x_data%load_balance_parameter%nbins*n_threads*para_env%num_pe, kind=
dp)**(0.25_dp))
778 actual_x_data%load_balance_parameter%block_size = min(
max_atom_block, max(1, int_val))
880 IF (actual_x_data%periodic_parameter%do_periodic)
THEN
883 actual_x_data%periodic_parameter%number_of_shells_from_input = pbc_shells
884 ALLOCATE (actual_x_data%neighbor_cells(1))
887 ALLOCATE (actual_x_data%neighbor_cells(1))
889 actual_x_data%periodic_parameter%R_max_stress = 1.0_dp
892 nkind =
SIZE(qs_kind_set, 1)
893 max_set = actual_x_data%basis_info%max_set
896 IF (i_thread == 1)
THEN
897 ALLOCATE (actual_x_data%is_assoc_atomic_block(natom, natom))
898 ALLOCATE (actual_x_data%atomic_block_offset(natom, natom))
899 ALLOCATE (actual_x_data%set_offset(max_set, max_set, nkind, nkind))
900 ALLOCATE (actual_x_data%block_offset(para_env%num_pe + 1))
903 ALLOCATE (actual_x_data%distribution_forces(1))
904 ALLOCATE (actual_x_data%distribution_energy(1))
906 actual_x_data%memory_parameter%size_p_screen = 0_int_8
907 IF (i_thread == 1)
THEN
908 ALLOCATE (actual_x_data%atomic_pair_list(natom, natom))
909 ALLOCATE (actual_x_data%atomic_pair_list_forces(natom, natom))
912 IF (actual_x_data%screening_parameter%do_initial_p_screening .OR. &
913 actual_x_data%screening_parameter%do_p_screening_forces)
THEN
915 IF (i_thread == 1)
THEN
916 ALLOCATE (actual_x_data%pmax_atom(natom, natom))
917 ALLOCATE (actual_x_data%initial_p(nkind*(nkind + 1)/2))
921 nseta = actual_x_data%basis_parameter(ikind)%nset
922 DO jkind = ikind, nkind
924 nsetb = actual_x_data%basis_parameter(jkind)%nset
925 ALLOCATE (actual_x_data%initial_p(i)%p_kind(nseta, nsetb, natom_a, natom_b))
926 actual_x_data%memory_parameter%size_p_screen = &
927 actual_x_data%memory_parameter%size_p_screen + nseta*nsetb*natom_a*natom_b
932 ALLOCATE (actual_x_data%pmax_atom_forces(natom, natom))
933 ALLOCATE (actual_x_data%initial_p_forces(nkind*(nkind + 1)/2))
937 nseta = actual_x_data%basis_parameter(ikind)%nset
938 DO jkind = ikind, nkind
940 nsetb = actual_x_data%basis_parameter(jkind)%nset
941 ALLOCATE (actual_x_data%initial_p_forces(i)%p_kind(nseta, nsetb, natom_a, natom_b))
942 actual_x_data%memory_parameter%size_p_screen = &
943 actual_x_data%memory_parameter%size_p_screen + nseta*nsetb*natom_a*natom_b
948 ALLOCATE (actual_x_data%map_atom_to_kind_atom(natom))
951 ALLOCATE (atom2kind(nkind))
954 ikind = kind_of(iatom)
955 atom2kind(ikind) = atom2kind(ikind) + 1
956 actual_x_data%map_atom_to_kind_atom(iatom) = atom2kind(ikind)
958 DEALLOCATE (kind_of, atom2kind)
971 actual_x_data%store_ints%maxval_cache_disk%element_counter = 1
972 ALLOCATE (actual_x_data%store_ints%maxval_container_disk)
973 ALLOCATE (actual_x_data%store_ints%maxval_container_disk%first)
974 actual_x_data%store_ints%maxval_container_disk%first%prev => null()
975 actual_x_data%store_ints%maxval_container_disk%first%next => null()
976 actual_x_data%store_ints%maxval_container_disk%current => actual_x_data%store_ints%maxval_container_disk%first
977 actual_x_data%store_ints%maxval_container_disk%current%data = 0
978 actual_x_data%store_ints%maxval_container_disk%element_counter = 1
979 actual_x_data%store_ints%maxval_container_disk%file_counter = 1
980 actual_x_data%store_ints%maxval_container_disk%desc =
'Max_'
981 actual_x_data%store_ints%maxval_container_disk%unit = -1
982 WRITE (actual_x_data%store_ints%maxval_container_disk%filename,
'(A,I0,A,A,A)') &
983 trim(actual_x_data%memory_parameter%storage_location), &
984 storage_id,
"_", actual_x_data%store_ints%maxval_container_disk%desc,
"6"
985 CALL compress(actual_x_data%store_ints%maxval_container_disk%filename, .true.)
986 ALLOCATE (actual_x_data%store_ints%integral_containers_disk(64))
988 actual_x_data%store_ints%integral_caches_disk(i)%element_counter = 1
989 actual_x_data%store_ints%integral_caches_disk(i)%data = 0
990 ALLOCATE (actual_x_data%store_ints%integral_containers_disk(i)%first)
991 actual_x_data%store_ints%integral_containers_disk(i)%first%prev => null()
992 actual_x_data%store_ints%integral_containers_disk(i)%first%next => null()
993 actual_x_data%store_ints%integral_containers_disk(i)%current => &
994 actual_x_data%store_ints%integral_containers_disk(i)%first
995 actual_x_data%store_ints%integral_containers_disk(i)%current%data = 0
996 actual_x_data%store_ints%integral_containers_disk(i)%element_counter = 1
997 actual_x_data%store_ints%integral_containers_disk(i)%file_counter = 1
998 actual_x_data%store_ints%integral_containers_disk(i)%desc =
'Int_'
999 actual_x_data%store_ints%integral_containers_disk(i)%unit = -1
1000 WRITE (actual_x_data%store_ints%integral_containers_disk(i)%filename,
'(A,I0,A,A,I0)') &
1001 trim(actual_x_data%memory_parameter%storage_location), &
1002 storage_id,
"_", actual_x_data%store_ints%integral_containers_disk(i)%desc, i
1003 CALL compress(actual_x_data%store_ints%integral_containers_disk(i)%filename, .true.)
1006 actual_x_data%b_first_load_balance_energy = .true.
1007 actual_x_data%b_first_load_balance_forces = .true.
1010 IF (actual_x_data%do_hfx_ri)
THEN
1011 cpassert(
PRESENT(nelectron_total))
1012 ALLOCATE (actual_x_data%ri_data)
1013 CALL hfx_ri_init_read_input_from_hfx(actual_x_data%ri_data, actual_x_data, hfx_section, &
1014 hf_sub_section, qs_kind_set, &
1015 particle_set, atomic_kind_set, dft_control, para_env, irep, &
1016 nelectron_total, orb_basis_type, ri_basis_type)
1021 DO irep = 1, n_rep_hf
1022 actual_x_data => x_data(irep, 1)
1023 CALL hfx_print_info(actual_x_data, hfx_section, irep)
1026 CALL timestop(handle)
1046 SUBROUTINE hfx_ri_init_read_input_from_hfx(ri_data, x_data, hfx_section, ri_section, qs_kind_set, &
1047 particle_set, atomic_kind_set, dft_control, para_env, irep, &
1048 nelectron_total, orb_basis_type, ri_basis_type)
1050 TYPE(
hfx_type),
INTENT(INOUT) :: x_data
1052 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1057 INTEGER,
INTENT(IN) :: irep, nelectron_total
1058 CHARACTER(LEN=*) :: orb_basis_type, ri_basis_type
1060 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init_read_input_from_hfx'
1062 CHARACTER(LEN=512) :: error_msg
1063 CHARACTER(LEN=default_path_length) :: char_val, t_c_filename
1064 INTEGER :: handle, unit_nr, unit_nr_dbcsr
1068 CALL timeset(routinen, handle)
1070 NULLIFY (hf_sub_section)
1072 associate(hfx_pot => ri_data%hfx_pot)
1073 hfx_pot%potential_type = x_data%potential_parameter%potential_type
1074 hfx_pot%omega = x_data%potential_parameter%omega
1075 hfx_pot%cutoff_radius = x_data%potential_parameter%cutoff_radius
1076 hfx_pot%scale_coulomb = x_data%potential_parameter%scale_coulomb
1077 hfx_pot%scale_longrange = x_data%potential_parameter%scale_longrange
1079 ri_data%ri_section => ri_section
1080 ri_data%hfx_section => hfx_section
1081 ri_data%eps_schwarz = x_data%screening_parameter%eps_schwarz
1082 ri_data%eps_schwarz_forces = x_data%screening_parameter%eps_schwarz_forces
1086 extension=
".dbcsrLog")
1089 extension=
".scfLog")
1096 WRITE (error_msg,
'(A,A,A)')
"File not found. Please check T_C_G_DATA "// &
1097 "in the INTERACTION_POTENTIAL section"
1100 t_c_filename = char_val
1103 CALL hfx_ri_init_read_input(ri_data, ri_section, qs_kind_set, particle_set, atomic_kind_set, &
1104 orb_basis_type, ri_basis_type, para_env, unit_nr, unit_nr_dbcsr, &
1105 nelectron_total, t_c_filename=t_c_filename)
1107 IF (dft_control%smear .AND. ri_data%flavor ==
ri_mo)
THEN
1108 cpabort(
"RI_FLAVOR MO is not consistent with smearing. Please use RI_FLAVOR RHO.")
1111 CALL timestop(handle)
1113 END SUBROUTINE hfx_ri_init_read_input_from_hfx
1130 SUBROUTINE hfx_ri_init_read_input(ri_data, ri_section, qs_kind_set, &
1131 particle_set, atomic_kind_set, orb_basis_type, ri_basis_type, para_env, &
1132 unit_nr, unit_nr_dbcsr, nelectron_total, t_c_filename)
1134 TYPE(section_vals_type),
POINTER :: ri_section
1135 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1136 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1137 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1138 CHARACTER(LEN=*),
INTENT(IN) :: orb_basis_type, ri_basis_type
1139 TYPE(mp_para_env_type) :: para_env
1140 INTEGER,
INTENT(IN) :: unit_nr, unit_nr_dbcsr, nelectron_total
1141 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: t_c_filename
1143 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init_read_input'
1147 REAL(dp) :: eps_storage_scaling
1149 CALL timeset(routinen, handle)
1151 CALL section_vals_val_get(ri_section,
"EPS_FILTER", r_val=ri_data%filter_eps)
1152 CALL section_vals_val_get(ri_section,
"EPS_FILTER_2C", r_val=ri_data%filter_eps_2c)
1153 CALL section_vals_val_get(ri_section,
"EPS_STORAGE_SCALING", r_val=eps_storage_scaling)
1154 ri_data%filter_eps_storage = ri_data%filter_eps*eps_storage_scaling
1155 CALL section_vals_val_get(ri_section,
"EPS_FILTER_MO", r_val=ri_data%filter_eps_mo)
1157 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
1158 CALL section_vals_val_get(ri_section,
"RI_METRIC", i_val=ri_metric%potential_type, explicit=explicit)
1159 IF (.NOT. explicit .OR. ri_metric%potential_type == 0)
THEN
1160 ri_metric%potential_type = hfx_pot%potential_type
1163 CALL section_vals_val_get(ri_section,
"OMEGA", r_val=ri_metric%omega, explicit=explicit)
1164 IF (.NOT. explicit)
THEN
1165 ri_metric%omega = hfx_pot%omega
1168 CALL section_vals_val_get(ri_section,
"CUTOFF_RADIUS", r_val=ri_metric%cutoff_radius, explicit=explicit)
1169 IF (.NOT. explicit)
THEN
1170 ri_metric%cutoff_radius = hfx_pot%cutoff_radius
1173 CALL section_vals_val_get(ri_section,
"SCALE_COULOMB", r_val=ri_metric%scale_coulomb, explicit=explicit)
1174 IF (.NOT. explicit)
THEN
1175 ri_metric%scale_coulomb = hfx_pot%scale_coulomb
1178 CALL section_vals_val_get(ri_section,
"SCALE_LONGRANGE", r_val=ri_metric%scale_longrange, explicit=explicit)
1179 IF (.NOT. explicit)
THEN
1180 ri_metric%scale_longrange = hfx_pot%scale_longrange
1183 IF (ri_metric%potential_type == do_potential_short) &
1184 CALL erfc_cutoff(ri_data%eps_schwarz, ri_metric%omega, ri_metric%cutoff_radius)
1185 IF (ri_metric%potential_type == do_potential_id) ri_metric%cutoff_radius = 0.0_dp
1188 CALL section_vals_val_get(ri_section,
"2C_MATRIX_FUNCTIONS", i_val=ri_data%t2c_method)
1189 CALL section_vals_val_get(ri_section,
"EPS_EIGVAL", r_val=ri_data%eps_eigval)
1190 CALL section_vals_val_get(ri_section,
"CHECK_2C_MATRIX", l_val=ri_data%check_2c_inv)
1191 CALL section_vals_val_get(ri_section,
"CALC_COND_NUM", l_val=ri_data%calc_condnum)
1192 CALL section_vals_val_get(ri_section,
"SQRT_ORDER", i_val=ri_data%t2c_sqrt_order)
1193 CALL section_vals_val_get(ri_section,
"EPS_LANCZOS", r_val=ri_data%eps_lanczos)
1194 CALL section_vals_val_get(ri_section,
"MAX_ITER_LANCZOS", i_val=ri_data%max_iter_lanczos)
1195 CALL section_vals_val_get(ri_section,
"RI_FLAVOR", i_val=ri_data%flavor)
1196 CALL section_vals_val_get(ri_section,
"EPS_PGF_ORB", r_val=ri_data%eps_pgf_orb)
1197 CALL section_vals_val_get(ri_section,
"MIN_BLOCK_SIZE", i_val=ri_data%min_bsize)
1198 CALL section_vals_val_get(ri_section,
"MAX_BLOCK_SIZE_MO", i_val=ri_data%max_bsize_MO)
1199 CALL section_vals_val_get(ri_section,
"MEMORY_CUT", i_val=ri_data%n_mem_input)
1200 CALL section_vals_val_get(ri_section,
"FLAVOR_SWITCH_MEMORY_CUT", i_val=ri_data%n_mem_flavor_switch)
1202 ri_data%orb_basis_type = orb_basis_type
1203 ri_data%ri_basis_type = ri_basis_type
1204 ri_data%nelectron_total = nelectron_total
1205 ri_data%input_flavor = ri_data%flavor
1207 IF (
PRESENT(t_c_filename))
THEN
1208 ri_data%ri_metric%filename = t_c_filename
1209 ri_data%hfx_pot%filename = t_c_filename
1212 ri_data%unit_nr_dbcsr = unit_nr_dbcsr
1213 ri_data%unit_nr = unit_nr
1214 ri_data%dbcsr_nflop = 0
1215 ri_data%dbcsr_time = 0.0_dp
1217 CALL hfx_ri_init(ri_data, qs_kind_set, particle_set, atomic_kind_set, para_env)
1219 CALL timestop(handle)
1221 END SUBROUTINE hfx_ri_init_read_input
1231 SUBROUTINE hfx_ri_init(ri_data, qs_kind_set, particle_set, atomic_kind_set, para_env)
1233 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1234 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1235 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1236 TYPE(mp_para_env_type) :: para_env
1238 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_init'
1240 INTEGER :: handle, i_mem, j_mem, mo_dim, natom, &
1242 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bsizes_ao_store, bsizes_ri_store, dist1, &
1243 dist2, dist3, dist_ao_1, dist_ao_2, &
1245 INTEGER,
DIMENSION(2) :: pdims_2d
1246 INTEGER,
DIMENSION(3) :: pdims
1248 TYPE(distribution_3d_type) :: dist_3d
1249 TYPE(gto_basis_set_p_type),
ALLOCATABLE, &
1250 DIMENSION(:) :: basis_set_ao, basis_set_ri
1251 TYPE(mp_cart_type) :: mp_comm_3d
1253 CALL cite_reference(bussy2023)
1255 CALL timeset(routinen, handle)
1258 CALL cp_libint_static_init()
1260 natom =
SIZE(particle_set)
1261 nkind =
SIZE(qs_kind_set, 1)
1262 nproc = para_env%num_pe
1264 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
1265 IF (ri_metric%potential_type == do_potential_short)
THEN
1266 CALL erfc_cutoff(ri_data%eps_schwarz, ri_metric%omega, ri_metric%cutoff_radius)
1269 IF (hfx_pot%potential_type == do_potential_short)
THEN
1272 CALL erfc_cutoff(ri_data%filter_eps_2c, hfx_pot%omega, hfx_pot%cutoff_radius)
1275 same_op = compare_potential_types(ri_metric, hfx_pot)
1278 ri_data%same_op = same_op
1281 CALL mp_comm_3d%create(para_env, 3, pdims)
1283 ALLOCATE (ri_data%bsizes_RI(natom))
1284 ALLOCATE (ri_data%bsizes_AO(natom))
1285 ALLOCATE (basis_set_ri(nkind), basis_set_ao(nkind))
1286 CALL basis_set_list_setup(basis_set_ri, ri_data%ri_basis_type, qs_kind_set)
1287 CALL get_particle_set(particle_set, qs_kind_set, nsgf=ri_data%bsizes_RI, basis=basis_set_ri)
1288 CALL basis_set_list_setup(basis_set_ao, ri_data%orb_basis_type, qs_kind_set)
1289 CALL get_particle_set(particle_set, qs_kind_set, nsgf=ri_data%bsizes_AO, basis=basis_set_ao)
1291 ALLOCATE (dist_ri(natom))
1292 ALLOCATE (dist_ao_1(natom))
1293 ALLOCATE (dist_ao_2(natom))
1294 CALL dbt_default_distvec(natom, pdims(1), ri_data%bsizes_RI, dist_ri)
1295 CALL dbt_default_distvec(natom, pdims(2), ri_data%bsizes_AO, dist_ao_1)
1296 CALL dbt_default_distvec(natom, pdims(3), ri_data%bsizes_AO, dist_ao_2)
1297 CALL distribution_3d_create(dist_3d, dist_ri, dist_ao_1, dist_ao_2, nkind, particle_set, &
1298 mp_comm_3d, own_comm=.true.)
1300 ALLOCATE (ri_data%pgrid)
1301 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid)
1303 ALLOCATE (ri_data%pgrid_2d)
1305 CALL dbt_pgrid_create(para_env, pdims_2d, ri_data%pgrid_2d)
1307 ri_data%dist_3d = dist_3d
1309 CALL dbt_distribution_new(ri_data%dist, ri_data%pgrid, &
1310 dist_ri, dist_ao_1, dist_ao_2)
1312 DEALLOCATE (dist_ao_1, dist_ao_2, dist_ri)
1314 ri_data%num_pe = para_env%num_pe
1317 CALL pgf_block_sizes(atomic_kind_set, basis_set_ao, ri_data%min_bsize, ri_data%bsizes_AO_split)
1318 CALL pgf_block_sizes(atomic_kind_set, basis_set_ri, ri_data%min_bsize, ri_data%bsizes_RI_split)
1320 CALL pgf_block_sizes(atomic_kind_set, basis_set_ao, 1, bsizes_ao_store)
1321 CALL pgf_block_sizes(atomic_kind_set, basis_set_ri, 1, bsizes_ri_store)
1323 CALL split_block_sizes([sum(ri_data%bsizes_AO)], ri_data%bsizes_AO_fit, default_block_size)
1324 CALL split_block_sizes([sum(ri_data%bsizes_RI)], ri_data%bsizes_RI_fit, default_block_size)
1326 IF (ri_data%flavor == ri_pmat)
THEN
1329 ri_data%n_mem = ri_data%n_mem_input
1330 ri_data%n_mem_RI = ri_data%n_mem_input
1332 CALL create_tensor_batches(ri_data%bsizes_AO_split, ri_data%n_mem, ri_data%starts_array_mem, &
1333 ri_data%ends_array_mem, ri_data%starts_array_mem_block, &
1334 ri_data%ends_array_mem_block)
1336 CALL create_tensor_batches(ri_data%bsizes_RI_split, ri_data%n_mem_RI, &
1337 ri_data%starts_array_RI_mem, ri_data%ends_array_RI_mem, &
1338 ri_data%starts_array_RI_mem_block, ri_data%ends_array_RI_mem_block)
1340 ALLOCATE (ri_data%pgrid_1)
1341 ALLOCATE (ri_data%pgrid_2)
1344 CALL dbt_mp_dims_create(nproc, pdims, [
SIZE(ri_data%bsizes_AO_split),
SIZE(ri_data%bsizes_RI_split), &
1345 SIZE(ri_data%bsizes_AO_split)])
1347 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_1)
1349 pdims = pdims([2, 1, 3])
1350 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_2)
1352 ALLOCATE (ri_data%t_3c_int_ctr_1(1, 1))
1353 CALL create_3c_tensor(ri_data%t_3c_int_ctr_1(1, 1), dist1, dist2, dist3, &
1354 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, &
1355 ri_data%bsizes_AO_split, [1, 2], [3], name=
"(AO RI | AO)")
1356 DEALLOCATE (dist1, dist2, dist3)
1358 ALLOCATE (ri_data%blk_indices(ri_data%n_mem, ri_data%n_mem_RI))
1359 ALLOCATE (ri_data%store_3c(ri_data%n_mem, ri_data%n_mem_RI))
1360 DO i_mem = 1, ri_data%n_mem
1361 DO j_mem = 1, ri_data%n_mem_RI
1366 ALLOCATE (ri_data%t_3c_int_ctr_2(1, 1))
1367 CALL create_3c_tensor(ri_data%t_3c_int_ctr_2(1, 1), dist1, dist2, dist3, &
1368 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, &
1369 ri_data%bsizes_AO_split, [1, 2], [3], name=
"(AO RI | AO)")
1370 DEALLOCATE (dist1, dist2, dist3)
1372 ALLOCATE (ri_data%t_3c_int_ctr_3(1, 1))
1373 CALL create_3c_tensor(ri_data%t_3c_int_ctr_3(1, 1), dist1, dist2, dist3, &
1374 ri_data%pgrid_2, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1375 ri_data%bsizes_AO_split, [1], [2, 3], name=
"(RI | AO AO)")
1376 DEALLOCATE (dist1, dist2, dist3)
1378 ALLOCATE (ri_data%t_2c_int(1, 1))
1379 CALL create_2c_tensor(ri_data%t_2c_int(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1380 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1382 DEALLOCATE (dist1, dist2)
1385 ALLOCATE (ri_data%rho_ao_t(2, 1))
1386 CALL create_2c_tensor(ri_data%rho_ao_t(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1387 ri_data%bsizes_AO_split, ri_data%bsizes_AO_split, &
1389 DEALLOCATE (dist1, dist2)
1390 CALL dbt_create(ri_data%rho_ao_t(1, 1), ri_data%rho_ao_t(2, 1))
1392 ALLOCATE (ri_data%ks_t(2, 1))
1393 CALL create_2c_tensor(ri_data%ks_t(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1394 ri_data%bsizes_AO_split, ri_data%bsizes_AO_split, &
1396 DEALLOCATE (dist1, dist2)
1397 CALL dbt_create(ri_data%ks_t(1, 1), ri_data%ks_t(2, 1))
1399 ELSEIF (ri_data%flavor == ri_mo)
THEN
1400 ALLOCATE (ri_data%t_2c_int(2, 1))
1402 CALL create_2c_tensor(ri_data%t_2c_int(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1403 ri_data%bsizes_RI_fit, ri_data%bsizes_RI_fit, &
1405 CALL dbt_create(ri_data%t_2c_int(1, 1), ri_data%t_2c_int(2, 1))
1407 DEALLOCATE (dist1, dist2)
1409 ALLOCATE (ri_data%t_3c_int_ctr_1(1, 1))
1411 ALLOCATE (ri_data%pgrid_1)
1412 ALLOCATE (ri_data%pgrid_2)
1415 ri_data%n_mem = ri_data%n_mem_input**2
1416 IF (ri_data%n_mem > ri_data%nelectron_total/2) ri_data%n_mem = max(ri_data%nelectron_total/2, 1)
1421 mo_dim = max((ri_data%nelectron_total/2 - 1)/ri_data%n_mem + 1, 1)
1422 mo_dim = (mo_dim - 1)/ri_data%max_bsize_MO + 1
1425 CALL dbt_mp_dims_create(nproc, pdims, [
SIZE(ri_data%bsizes_AO_split),
SIZE(ri_data%bsizes_RI_split), mo_dim])
1427 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_1)
1429 pdims = pdims([3, 2, 1])
1430 CALL dbt_pgrid_create(para_env, pdims, ri_data%pgrid_2)
1432 CALL create_3c_tensor(ri_data%t_3c_int_ctr_1(1, 1), dist1, dist2, dist3, &
1433 ri_data%pgrid_1, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1434 [1, 2], [3], name=
"(AO RI | AO)")
1435 DEALLOCATE (dist1, dist2, dist3)
1437 ALLOCATE (ri_data%t_3c_int_ctr_2(1, 1))
1438 CALL create_3c_tensor(ri_data%t_3c_int_ctr_2(1, 1), dist1, dist2, dist3, &
1439 ri_data%pgrid_2, ri_data%bsizes_AO_split, ri_data%bsizes_RI_split, ri_data%bsizes_AO_split, &
1440 [1], [2, 3], name=
"(AO | RI AO)")
1441 DEALLOCATE (dist1, dist2, dist3)
1446 ALLOCATE (ri_data%t_2c_inv(1, 1))
1447 CALL create_2c_tensor(ri_data%t_2c_inv(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1448 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1450 DEALLOCATE (dist1, dist2)
1452 ALLOCATE (ri_data%t_2c_pot(1, 1))
1453 CALL create_2c_tensor(ri_data%t_2c_pot(1, 1), dist1, dist2, ri_data%pgrid_2d, &
1454 ri_data%bsizes_RI_split, ri_data%bsizes_RI_split, &
1456 DEALLOCATE (dist1, dist2)
1458 CALL timestop(handle)
1466 SUBROUTINE hfx_ri_write_stats(ri_data)
1469 REAL(dp) :: my_flop_rate
1471 associate(unit_nr => ri_data%unit_nr, dbcsr_nflop => ri_data%dbcsr_nflop, &
1472 dbcsr_time => ri_data%dbcsr_time, num_pe => ri_data%num_pe)
1473 my_flop_rate = real(dbcsr_nflop, dp)/(1.0e09_dp*ri_data%dbcsr_time)
1474 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(/T2,A,T73,ES8.2)") &
1475 "RI-HFX PERFORMANCE| DBT total number of flops:", real(dbcsr_nflop*num_pe, dp)
1476 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(T2,A,T66,F15.2)") &
1477 "RI-HFX PERFORMANCE| DBT total execution time:", dbcsr_time
1478 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(T2,A,T66,F15.2)") &
1479 "RI-HFX PERFORMANCE| DBT flop rate (Gflops / MPI rank):", my_flop_rate
1481 END SUBROUTINE hfx_ri_write_stats
1490 LOGICAL,
OPTIONAL :: write_stats
1492 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_ri_release'
1494 INTEGER :: handle, i, i_mem, ispin, j, j_mem, unused
1495 LOGICAL :: my_write_stats
1497 CALL timeset(routinen, handle)
1500 CALL cp_libint_static_cleanup()
1502 my_write_stats = .true.
1503 IF (
PRESENT(write_stats)) my_write_stats = write_stats
1504 IF (my_write_stats)
CALL hfx_ri_write_stats(ri_data)
1506 IF (
ASSOCIATED(ri_data%pgrid))
THEN
1507 CALL dbt_pgrid_destroy(ri_data%pgrid)
1508 DEALLOCATE (ri_data%pgrid)
1510 IF (
ASSOCIATED(ri_data%pgrid_1))
THEN
1511 CALL dbt_pgrid_destroy(ri_data%pgrid_1)
1512 DEALLOCATE (ri_data%pgrid_1)
1514 IF (
ASSOCIATED(ri_data%pgrid_2))
THEN
1515 CALL dbt_pgrid_destroy(ri_data%pgrid_2)
1516 DEALLOCATE (ri_data%pgrid_2)
1518 IF (
ASSOCIATED(ri_data%pgrid_2d))
THEN
1519 CALL dbt_pgrid_destroy(ri_data%pgrid_2d)
1520 DEALLOCATE (ri_data%pgrid_2d)
1523 CALL distribution_3d_destroy(ri_data%dist_3d)
1524 CALL dbt_distribution_destroy(ri_data%dist)
1526 DEALLOCATE (ri_data%bsizes_RI)
1527 DEALLOCATE (ri_data%bsizes_AO)
1528 DEALLOCATE (ri_data%bsizes_AO_split)
1529 DEALLOCATE (ri_data%bsizes_RI_split)
1530 DEALLOCATE (ri_data%bsizes_AO_fit)
1531 DEALLOCATE (ri_data%bsizes_RI_fit)
1533 IF (ri_data%flavor == ri_pmat)
THEN
1534 DO i_mem = 1, ri_data%n_mem
1535 DO j_mem = 1, ri_data%n_mem_RI
1540 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_1, 2)
1541 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_1, 1)
1542 CALL dbt_destroy(ri_data%t_3c_int_ctr_1(i, j))
1545 DEALLOCATE (ri_data%t_3c_int_ctr_1)
1547 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_2, 2)
1548 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_2, 1)
1549 CALL dbt_destroy(ri_data%t_3c_int_ctr_2(i, j))
1552 DEALLOCATE (ri_data%t_3c_int_ctr_2)
1554 DO j = 1,
SIZE(ri_data%t_3c_int_ctr_3, 2)
1555 DO i = 1,
SIZE(ri_data%t_3c_int_ctr_3, 1)
1556 CALL dbt_destroy(ri_data%t_3c_int_ctr_3(i, j))
1559 DEALLOCATE (ri_data%t_3c_int_ctr_3)
1561 DO j = 1,
SIZE(ri_data%t_2c_int, 2)
1562 DO i = 1,
SIZE(ri_data%t_2c_int, 1)
1563 CALL dbt_destroy(ri_data%t_2c_int(i, j))
1566 DEALLOCATE (ri_data%t_2c_int)
1568 DO j = 1,
SIZE(ri_data%rho_ao_t, 2)
1569 DO i = 1,
SIZE(ri_data%rho_ao_t, 1)
1570 CALL dbt_destroy(ri_data%rho_ao_t(i, j))
1573 DEALLOCATE (ri_data%rho_ao_t)
1575 DO j = 1,
SIZE(ri_data%ks_t, 2)
1576 DO i = 1,
SIZE(ri_data%ks_t, 1)
1577 CALL dbt_destroy(ri_data%ks_t(i, j))
1580 DEALLOCATE (ri_data%ks_t)
1582 DEALLOCATE (ri_data%starts_array_mem_block, ri_data%ends_array_mem_block, &
1583 ri_data%starts_array_mem, ri_data%ends_array_mem)
1584 DEALLOCATE (ri_data%starts_array_RI_mem_block, ri_data%ends_array_RI_mem_block, &
1585 ri_data%starts_array_RI_mem, ri_data%ends_array_RI_mem)
1587 DEALLOCATE (ri_data%blk_indices)
1588 DEALLOCATE (ri_data%store_3c)
1589 ELSEIF (ri_data%flavor == ri_mo)
THEN
1590 CALL dbt_destroy(ri_data%t_3c_int_ctr_1(1, 1))
1591 CALL dbt_destroy(ri_data%t_3c_int_ctr_2(1, 1))
1592 DEALLOCATE (ri_data%t_3c_int_ctr_1)
1593 DEALLOCATE (ri_data%t_3c_int_ctr_2)
1595 DO ispin = 1,
SIZE(ri_data%t_3c_int_mo, 1)
1596 CALL dbt_destroy(ri_data%t_3c_int_mo(ispin, 1, 1))
1597 CALL dbt_destroy(ri_data%t_3c_ctr_RI(ispin, 1, 1))
1598 CALL dbt_destroy(ri_data%t_3c_ctr_KS(ispin, 1, 1))
1599 CALL dbt_destroy(ri_data%t_3c_ctr_KS_copy(ispin, 1, 1))
1602 CALL dbt_destroy(ri_data%t_2c_int(ispin, 1))
1604 DEALLOCATE (ri_data%t_2c_int)
1605 DEALLOCATE (ri_data%t_3c_int_mo)
1606 DEALLOCATE (ri_data%t_3c_ctr_RI)
1607 DEALLOCATE (ri_data%t_3c_ctr_KS)
1608 DEALLOCATE (ri_data%t_3c_ctr_KS_copy)
1611 DO j = 1,
SIZE(ri_data%t_2c_inv, 2)
1612 DO i = 1,
SIZE(ri_data%t_2c_inv, 1)
1613 CALL dbt_destroy(ri_data%t_2c_inv(i, j))
1616 DEALLOCATE (ri_data%t_2c_inv)
1618 DO j = 1,
SIZE(ri_data%t_2c_pot, 2)
1619 DO i = 1,
SIZE(ri_data%t_2c_pot, 1)
1620 CALL dbt_destroy(ri_data%t_2c_pot(i, j))
1623 DEALLOCATE (ri_data%t_2c_pot)
1625 IF (
ALLOCATED(ri_data%kp_mat_2c_pot))
THEN
1626 DO j = 1,
SIZE(ri_data%kp_mat_2c_pot, 2)
1627 DO i = 1,
SIZE(ri_data%kp_mat_2c_pot, 1)
1628 CALL dbcsr_release(ri_data%kp_mat_2c_pot(i, j))
1631 DEALLOCATE (ri_data%kp_mat_2c_pot)
1634 IF (
ALLOCATED(ri_data%kp_t_3c_int))
THEN
1635 DO i = 1,
SIZE(ri_data%kp_t_3c_int)
1636 CALL dbt_destroy(ri_data%kp_t_3c_int(i))
1638 DEALLOCATE (ri_data%kp_t_3c_int)
1641 IF (
ALLOCATED(ri_data%rho_ao_t))
THEN
1642 DO j = 1,
SIZE(ri_data%rho_ao_t, 2)
1643 DO i = 1,
SIZE(ri_data%rho_ao_t, 1)
1644 CALL dbt_destroy(ri_data%rho_ao_t(i, j))
1647 DEALLOCATE (ri_data%rho_ao_t)
1650 IF (
ALLOCATED(ri_data%ks_t))
THEN
1651 DO j = 1,
SIZE(ri_data%ks_t, 2)
1652 DO i = 1,
SIZE(ri_data%ks_t, 1)
1653 CALL dbt_destroy(ri_data%ks_t(i, j))
1656 DEALLOCATE (ri_data%ks_t)
1659 IF (
ALLOCATED(ri_data%iatom_to_subgroup))
THEN
1660 DO i = 1,
SIZE(ri_data%iatom_to_subgroup)
1661 DEALLOCATE (ri_data%iatom_to_subgroup(i)%array)
1663 DEALLOCATE (ri_data%iatom_to_subgroup)
1666 CALL timestop(handle)
1682 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1683 CHARACTER(LEN=*) :: basis_type
1685 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_create_basis_types'
1687 INTEGER :: co_counter, handle, i, ikind, ipgf, iset, j, k, la, max_am_kind, max_coeff, &
1688 max_nsgfl, max_pgf, max_pgf_kind, max_set, nkind, nl_count, nset, nseta, offset_a, &
1689 offset_a1, s_offset_nl_a, sgfa, so_counter
1690 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nshell
1691 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, nl_a
1692 REAL(dp),
DIMENSION(:, :),
POINTER :: sphi_a
1693 TYPE(gto_basis_set_type),
POINTER :: orb_basis_a
1695 CALL timeset(routinen, handle)
1698 nkind =
SIZE(qs_kind_set, 1)
1700 ALLOCATE (basis_parameter(nkind))
1703 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_a, basis_type=basis_type)
1704 CALL get_qs_kind_set(qs_kind_set, &
1705 maxsgf=basis_info%max_sgf, &
1706 maxnset=basis_info%max_set, &
1707 maxlgto=basis_info%max_am, &
1708 basis_type=basis_type)
1709 IF (basis_info%max_set < max_set) cpabort(
"UNEXPECTED MAX_SET")
1710 max_set = max(max_set, basis_info%max_set)
1711 CALL get_gto_basis_set(gto_basis_set=orb_basis_a, &
1712 lmax=basis_parameter(ikind)%lmax, &
1713 lmin=basis_parameter(ikind)%lmin, &
1714 npgf=basis_parameter(ikind)%npgf, &
1715 nset=basis_parameter(ikind)%nset, &
1716 zet=basis_parameter(ikind)%zet, &
1717 nsgf_set=basis_parameter(ikind)%nsgf, &
1718 first_sgf=basis_parameter(ikind)%first_sgf, &
1719 sphi=basis_parameter(ikind)%sphi, &
1720 nsgf=basis_parameter(ikind)%nsgf_total, &
1721 l=basis_parameter(ikind)%nl, &
1722 nshell=basis_parameter(ikind)%nshell, &
1723 set_radius=basis_parameter(ikind)%set_radius, &
1724 pgf_radius=basis_parameter(ikind)%pgf_radius, &
1725 kind_radius=basis_parameter(ikind)%kind_radius)
1728 ALLOCATE (basis_parameter(ikind)%nsgfl(0:basis_info%max_am, max_set))
1729 basis_parameter(ikind)%nsgfl = 0
1730 nset = basis_parameter(ikind)%nset
1731 nshell => basis_parameter(ikind)%nshell
1733 DO i = 0, basis_info%max_am
1735 DO j = 1, nshell(iset)
1736 IF (basis_parameter(ikind)%nl(j, iset) == i) nl_count = nl_count + 1
1738 basis_parameter(ikind)%nsgfl(i, iset) = nl_count
1749 npgfa => basis_parameter(ikind)%npgf
1750 nseta = basis_parameter(ikind)%nset
1751 nl_a => basis_parameter(ikind)%nsgfl
1752 la_max => basis_parameter(ikind)%lmax
1753 la_min => basis_parameter(ikind)%lmin
1755 max_pgf_kind = max(max_pgf_kind, npgfa(iset))
1756 max_pgf = max(max_pgf, npgfa(iset))
1757 DO la = la_min(iset), la_max(iset)
1758 max_nsgfl = max(max_nsgfl, nl_a(la, iset))
1759 max_coeff = max(max_coeff, nso(la)*nl_a(la, iset)*nco(la))
1760 max_am_kind = max(max_am_kind, la)
1763 ALLOCATE (basis_parameter(ikind)%sphi_ext(max_coeff, 0:max_am_kind, max_pgf_kind, nseta))
1764 basis_parameter(ikind)%sphi_ext = 0.0_dp
1768 sphi_a => basis_parameter(ikind)%sphi
1769 nseta = basis_parameter(ikind)%nset
1770 la_max => basis_parameter(ikind)%lmax
1771 la_min => basis_parameter(ikind)%lmin
1772 npgfa => basis_parameter(ikind)%npgf
1773 first_sgfa => basis_parameter(ikind)%first_sgf
1774 nl_a => basis_parameter(ikind)%nsgfl
1776 sgfa = first_sgfa(1, iset)
1777 DO ipgf = 1, npgfa(iset)
1778 offset_a1 = (ipgf - 1)*
ncoset(la_max(iset))
1780 DO la = la_min(iset), la_max(iset)
1781 offset_a = offset_a1 +
ncoset(la - 1)
1783 co_counter = co_counter + 1
1785 DO k = sgfa + s_offset_nl_a, sgfa + s_offset_nl_a + nso(la)*nl_a(la, iset) - 1
1786 DO i = offset_a + 1, offset_a + nco(la)
1787 so_counter = so_counter + 1
1788 basis_parameter(ikind)%sphi_ext(so_counter, la, ipgf, iset) = sphi_a(i, k)
1791 s_offset_nl_a = s_offset_nl_a + nso(la)*(nl_a(la, iset))
1797 CALL timestop(handle)
1808 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfx_release_basis_types'
1810 INTEGER :: handle, i
1812 CALL timeset(routinen, handle)
1815 DO i = 1,
SIZE(basis_parameter)
1816 DEALLOCATE (basis_parameter(i)%nsgfl)
1817 DEALLOCATE (basis_parameter(i)%sphi_ext)
1819 DEALLOCATE (basis_parameter)
1820 CALL timestop(handle)
1837 i_thread, n_threads, para_env, irep, skip_disk, skip_in_core_forces)
1839 TYPE(section_vals_type),
POINTER :: hf_sub_section
1840 INTEGER,
INTENT(OUT),
OPTIONAL :: storage_id
1841 INTEGER,
INTENT(IN),
OPTIONAL :: i_thread, n_threads
1842 TYPE(mp_para_env_type),
OPTIONAL :: para_env
1843 INTEGER,
INTENT(IN),
OPTIONAL :: irep
1844 LOGICAL,
INTENT(IN) :: skip_disk, skip_in_core_forces
1846 CHARACTER(LEN=512) :: error_msg
1847 CHARACTER(LEN=default_path_length) :: char_val, filename, orig_wd
1848 INTEGER :: int_val, stat
1849 LOGICAL :: check, logic_val
1850 REAL(dp) :: real_val
1852 check = (
PRESENT(storage_id) .EQV.
PRESENT(i_thread)) .AND. &
1853 (
PRESENT(storage_id) .EQV.
PRESENT(n_threads)) .AND. &
1854 (
PRESENT(storage_id) .EQV.
PRESENT(para_env)) .AND. &
1855 (
PRESENT(storage_id) .EQV.
PRESENT(irep))
1859 CALL section_vals_val_get(hf_sub_section,
"MAX_MEMORY", i_val=int_val)
1860 memory_parameter%max_memory = int_val
1861 memory_parameter%max_compression_counter = int_val*1024_int_8*128_int_8
1862 CALL section_vals_val_get(hf_sub_section,
"EPS_STORAGE", r_val=real_val)
1863 memory_parameter%eps_storage_scaling = real_val
1864 IF (int_val == 0)
THEN
1865 memory_parameter%do_all_on_the_fly = .true.
1867 memory_parameter%do_all_on_the_fly = .false.
1869 memory_parameter%cache_size = cache_size
1870 memory_parameter%bits_max_val = bits_max_val
1871 memory_parameter%actual_memory_usage = 1
1872 IF (.NOT. skip_in_core_forces)
THEN
1873 CALL section_vals_val_get(hf_sub_section,
"TREAT_FORCES_IN_CORE", l_val=logic_val)
1874 memory_parameter%treat_forces_in_core = logic_val
1878 IF (memory_parameter%do_all_on_the_fly) memory_parameter%treat_forces_in_core = .false.
1881 IF (.NOT. skip_disk)
THEN
1882 memory_parameter%actual_memory_usage_disk = 1
1883 CALL section_vals_val_get(hf_sub_section,
"MAX_DISK_SPACE", i_val=int_val)
1884 memory_parameter%max_compression_counter_disk = int_val*1024_int_8*128_int_8
1885 IF (int_val == 0)
THEN
1886 memory_parameter%do_disk_storage = .false.
1888 memory_parameter%do_disk_storage = .true.
1890 CALL section_vals_val_get(hf_sub_section,
"STORAGE_LOCATION", c_val=char_val)
1891 CALL compress(char_val, .true.)
1894 IF (scan(char_val,
"/", .true.) /= len_trim(char_val))
THEN
1895 WRITE (filename,
'(A,A)') trim(char_val),
"/"
1896 CALL compress(filename)
1898 filename = trim(char_val)
1900 CALL compress(filename, .true.)
1903 CALL m_getcwd(orig_wd)
1904 CALL m_chdir(trim(filename), stat)
1906 WRITE (error_msg,
'(A,A,A)')
"Request for disk storage failed due to unknown error while writing to ", &
1907 trim(filename),
". Please check STORAGE_LOCATION"
1910 CALL m_chdir(orig_wd, stat)
1912 memory_parameter%storage_location = filename
1913 CALL compress(memory_parameter%storage_location, .true.)
1915 memory_parameter%do_disk_storage = .false.
1917 IF (
PRESENT(storage_id))
THEN
1918 storage_id = (irep - 1)*para_env%num_pe*n_threads + para_env%mepos*n_threads + i_thread - 1
1930 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
1932 INTEGER :: i, i_thread, irep, n_rep_hf, n_threads
1933 TYPE(cp_logger_type),
POINTER :: logger
1934 TYPE(
hfx_type),
POINTER :: actual_x_data
1938 n_rep_hf = x_data(1, 1)%n_rep_hf
1939 n_threads =
SIZE(x_data, 2)
1941 IF (x_data(1, 1)%potential_parameter%potential_type == do_potential_truncated .OR. &
1942 x_data(1, 1)%potential_parameter%potential_type == do_potential_mix_cl_trunc)
THEN
1946 DO i_thread = 1, n_threads
1947 DO irep = 1, n_rep_hf
1948 actual_x_data => x_data(irep, i_thread)
1949 DEALLOCATE (actual_x_data%neighbor_cells)
1950 DEALLOCATE (actual_x_data%distribution_energy)
1951 DEALLOCATE (actual_x_data%distribution_forces)
1953 IF (actual_x_data%load_balance_parameter%blocks_initialized)
THEN
1954 DEALLOCATE (actual_x_data%blocks)
1955 IF (i_thread == 1)
THEN
1956 DEALLOCATE (actual_x_data%pmax_block)
1960 IF (i_thread == 1)
THEN
1961 DEALLOCATE (actual_x_data%atomic_pair_list)
1962 DEALLOCATE (actual_x_data%atomic_pair_list_forces)
1965 IF (actual_x_data%screening_parameter%do_initial_p_screening .OR. &
1966 actual_x_data%screening_parameter%do_p_screening_forces)
THEN
1967 IF (i_thread == 1)
THEN
1968 DEALLOCATE (actual_x_data%pmax_atom)
1969 DO i = 1,
SIZE(actual_x_data%initial_p)
1970 DEALLOCATE (actual_x_data%initial_p(i)%p_kind)
1972 DEALLOCATE (actual_x_data%initial_p)
1974 DEALLOCATE (actual_x_data%pmax_atom_forces)
1975 DO i = 1,
SIZE(actual_x_data%initial_p_forces)
1976 DEALLOCATE (actual_x_data%initial_p_forces(i)%p_kind)
1978 DEALLOCATE (actual_x_data%initial_p_forces)
1980 DEALLOCATE (actual_x_data%map_atom_to_kind_atom)
1982 IF (i_thread == 1)
THEN
1983 DEALLOCATE (actual_x_data%is_assoc_atomic_block)
1984 DEALLOCATE (actual_x_data%atomic_block_offset)
1985 DEALLOCATE (actual_x_data%set_offset)
1986 DEALLOCATE (actual_x_data%block_offset)
1993 CALL cp_libint_cleanup_eri(actual_x_data%lib)
1994 CALL cp_libint_cleanup_eri1(actual_x_data%lib_deriv)
1995 CALL cp_libint_static_cleanup()
1998 CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
1999 CALL dealloc_containers(actual_x_data%store_forces, actual_x_data%memory_parameter%actual_memory_usage)
2003 actual_x_data%memory_parameter%actual_memory_usage_disk, &
2005 IF (actual_x_data%memory_parameter%do_disk_storage)
THEN
2006 CALL close_file(unit_number=actual_x_data%store_ints%maxval_container_disk%unit, file_status=
"DELETE")
2008 DEALLOCATE (actual_x_data%store_ints%maxval_container_disk%first)
2009 DEALLOCATE (actual_x_data%store_ints%maxval_container_disk)
2013 actual_x_data%memory_parameter%actual_memory_usage_disk, &
2015 IF (actual_x_data%memory_parameter%do_disk_storage)
THEN
2016 CALL close_file(unit_number=actual_x_data%store_ints%integral_containers_disk(i)%unit, file_status=
"DELETE")
2018 DEALLOCATE (actual_x_data%store_ints%integral_containers_disk(i)%first)
2020 DEALLOCATE (actual_x_data%store_ints%integral_containers_disk)
2023 IF (actual_x_data%screen_funct_is_initialized)
THEN
2024 DEALLOCATE (actual_x_data%screen_funct_coeffs_set)
2025 DEALLOCATE (actual_x_data%screen_funct_coeffs_kind)
2026 DEALLOCATE (actual_x_data%pair_dist_radii_pgf)
2027 DEALLOCATE (actual_x_data%screen_funct_coeffs_pgf)
2028 actual_x_data%screen_funct_is_initialized = .false.
2032 IF (
ASSOCIATED(actual_x_data%map_atoms_to_cpus))
THEN
2033 DO i = 1,
SIZE(actual_x_data%map_atoms_to_cpus)
2034 DEALLOCATE (actual_x_data%map_atoms_to_cpus(i)%iatom_list)
2035 DEALLOCATE (actual_x_data%map_atoms_to_cpus(i)%jatom_list)
2037 DEALLOCATE (actual_x_data%map_atoms_to_cpus)
2040 IF (actual_x_data%do_hfx_ri)
THEN
2042 IF (
ASSOCIATED(actual_x_data%ri_data%ri_section))
THEN
2043 logger => cp_get_default_logger()
2044 CALL cp_print_key_finished_output(actual_x_data%ri_data%unit_nr_dbcsr, logger, actual_x_data%ri_data%ri_section, &
2047 IF (
ASSOCIATED(actual_x_data%ri_data%hfx_section))
THEN
2048 logger => cp_get_default_logger()
2049 CALL cp_print_key_finished_output(actual_x_data%ri_data%unit_nr, logger, actual_x_data%ri_data%hfx_section, &
2052 DEALLOCATE (actual_x_data%ri_data)
2075 INTEGER,
INTENT(INOUT) :: pbc_shells
2076 TYPE(cell_type),
POINTER :: cell
2077 INTEGER,
INTENT(IN) :: i_thread
2078 INTEGER,
DIMENSION(3),
OPTIONAL :: nkp_grid
2080 CHARACTER(LEN=512) :: error_msg
2081 CHARACTER(LEN=64) :: char_nshells
2082 INTEGER :: i,
idx, ikind, ipgf, iset, ishell, j, jkind, jpgf, jset, jshell, k, kshell, l, &
2083 m(3), max_shell, nkp(3), nseta, nsetb, perd(3), total_number_of_cells, ub, ub_max
2084 INTEGER,
DIMENSION(:),
POINTER :: la_max, lb_max, npgfa, npgfb
2085 LOGICAL :: do_kpoints, image_cell_found, &
2087 REAL(dp) :: cross_product(3), dist_min, distance(14), l_min, normal(3, 6), p(3, 14), &
2088 plane_vector(3, 2), point_in_plane(3), r(3), r1, r_max, r_max_stress, s(3), x, y, z, zeta1
2089 REAL(dp),
DIMENSION(:, :),
POINTER :: zeta, zetb
2090 TYPE(
hfx_cell_type),
ALLOCATABLE,
DIMENSION(:) :: tmp_neighbor_cells
2092 total_number_of_cells = 0
2095 IF (
PRESENT(nkp_grid)) nkp = nkp_grid
2096 do_kpoints = any(nkp > 1)
2099 IF (i_thread == 1)
THEN
2100 IF (x_data%potential_parameter%potential_type /= do_potential_truncated .AND. &
2101 x_data%potential_parameter%potential_type /= do_potential_short .AND. &
2102 x_data%potential_parameter%potential_type /= do_potential_mix_cl_trunc .AND. &
2103 x_data%potential_parameter%potential_type /= do_potential_id)
THEN
2104 CALL cp_warn(__location__, &
2105 "Periodic Hartree Fock calculation requested without use "// &
2106 "of a truncated or shortrange potential. This may lead to unphysical total energies. "// &
2107 "Use a truncated potential to avoid possible problems.")
2108 ELSE IF (x_data%potential_parameter%potential_type /= do_potential_id)
THEN
2110 l_min = min(real(nkp(1), dp)*plane_distance(1, 0, 0, cell), &
2111 REAL(nkp(2), dp)*plane_distance(0, 1, 0, cell), &
2112 REAL(nkp(3), dp)*plane_distance(0, 0, 1, cell))
2113 l_min = 0.5_dp*l_min
2114 IF (x_data%potential_parameter%cutoff_radius >= l_min)
THEN
2115 IF (.NOT. do_kpoints)
THEN
2116 WRITE (error_msg,
"(A,F6.3,A,F6.3,A)") &
2117 "Periodic Hartree Fock calculation requested with the use "// &
2118 "of a truncated or shortrange potential. "// &
2119 "The cutoff radius (", x_data%potential_parameter%cutoff_radius*a_bohr*1e+10_dp, &
2120 " A) is larger than half the minimal cell dimension (", &
2121 l_min*a_bohr*1e+10_dp,
" A). This may lead to unphysical "// &
2122 "total energies. Reduce the cutoff radius in order to avoid "// &
2123 "possible problems."
2125 WRITE (error_msg,
"(A,F6.3,A,F6.3,A)") &
2126 "K-point Hartree-Fock calculation requested with the use of a "// &
2127 "truncated or shortrange potential. The cutoff radius (", &
2128 x_data%potential_parameter%cutoff_radius*a_bohr*1e+10_dp, &
2129 " A) is larger than half the minimal Born-von Karman supercell dimension (", &
2130 l_min*a_bohr*1e+10_dp,
" A). This may lead "// &
2131 "to unphysical total energies. Reduce the cutoff radius or increase "// &
2132 "the number of K-points in order to avoid possible problems."
2134 CALL cp_warn(__location__, error_msg)
2139 SELECT CASE (x_data%potential_parameter%potential_type)
2140 CASE (do_potential_truncated, do_potential_mix_cl_trunc, do_potential_short)
2142 DO ikind = 1,
SIZE(x_data%basis_parameter)
2143 la_max => x_data%basis_parameter(ikind)%lmax
2144 zeta => x_data%basis_parameter(ikind)%zet
2145 nseta = x_data%basis_parameter(ikind)%nset
2146 npgfa => x_data%basis_parameter(ikind)%npgf
2147 DO jkind = 1,
SIZE(x_data%basis_parameter)
2148 lb_max => x_data%basis_parameter(jkind)%lmax
2149 zetb => x_data%basis_parameter(jkind)%zet
2150 nsetb = x_data%basis_parameter(jkind)%nset
2151 npgfb => x_data%basis_parameter(jkind)%npgf
2154 DO ipgf = 1, npgfa(iset)
2155 DO jpgf = 1, npgfb(jset)
2156 zeta1 = zeta(ipgf, iset) + zetb(jpgf, jset)
2157 r1 = 1.0_dp/sqrt(zeta1)*
mul_fact(la_max(iset) + lb_max(jset))* &
2158 sqrt(-log(x_data%screening_parameter%eps_schwarz))
2159 r_max = max(r1, r_max)
2167 r_max = 2.0_dp*r_max + x_data%potential_parameter%cutoff_radius
2168 nothing_more_to_add = .false.
2170 total_number_of_cells = 0
2172 DEALLOCATE (x_data%neighbor_cells)
2173 ALLOCATE (x_data%neighbor_cells(1))
2174 x_data%neighbor_cells(1)%cell = 0.0_dp
2175 x_data%neighbor_cells(1)%cell_r = 0.0_dp
2212 DO WHILE (.NOT. nothing_more_to_add)
2214 image_cell_found = .false.
2215 ALLOCATE (tmp_neighbor_cells(1:ub))
2217 tmp_neighbor_cells(i) = x_data%neighbor_cells(i)
2219 ub_max = (2*max_shell + 1)**3
2220 DEALLOCATE (x_data%neighbor_cells)
2221 ALLOCATE (x_data%neighbor_cells(1:ub_max))
2223 x_data%neighbor_cells(i) = tmp_neighbor_cells(i)
2226 x_data%neighbor_cells(i)%cell = 0.0_dp
2227 x_data%neighbor_cells(i)%cell_r = 0.0_dp
2230 DEALLOCATE (tmp_neighbor_cells)
2232 perd(1:3) = x_data%periodic_parameter%perd(1:3)
2234 DO ishell = -max_shell*perd(1), max_shell*perd(1)
2235 DO jshell = -max_shell*perd(2), max_shell*perd(2)
2236 DO kshell = -max_shell*perd(3), max_shell*perd(3)
2237 IF (max(abs(ishell), abs(jshell), abs(kshell)) /= max_shell) cycle
2240 x = -1.0_dp/2.0_dp + j*1.0_dp
2242 y = -1.0_dp/2.0_dp + k*1.0_dp
2244 z = -1.0_dp/2.0_dp + l*1.0_dp
2246 p(1,
idx) = x + ishell
2247 p(2,
idx) = y + jshell
2248 p(3,
idx) = z + kshell
2249 CALL scaled_to_real(r, p(:,
idx), cell)
2250 distance(
idx) = sqrt(sum(r**2))
2259 plane_vector(:, 1) = p(:, 3) - p(:, 1)
2260 plane_vector(:, 2) = p(:, 2) - p(:, 1)
2261 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2262 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2263 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2264 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2265 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2267 IF (point_is_in_quadrilateral(p(:, 1), p(:, 3), p(:, 4), p(:, 2), point_in_plane))
THEN
2268 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2270 distance(
idx) = huge(distance(
idx))
2275 plane_vector(:, 1) = p(:, 2) - p(:, 1)
2276 plane_vector(:, 2) = p(:, 5) - p(:, 1)
2277 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2278 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2279 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2280 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2281 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2283 IF (point_is_in_quadrilateral(p(:, 1), p(:, 5), p(:, 6), p(:, 2), point_in_plane))
THEN
2284 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2286 distance(
idx) = huge(distance(
idx))
2291 plane_vector(:, 1) = p(:, 7) - p(:, 5)
2292 plane_vector(:, 2) = p(:, 6) - p(:, 5)
2293 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2294 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2295 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2296 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2297 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 5) + normal(2, 1)*p(2, 5) + normal(3, 1)*p(3, 5))
2299 IF (point_is_in_quadrilateral(p(:, 5), p(:, 7), p(:, 8), p(:, 6), point_in_plane))
THEN
2300 distance(
idx) = abs(normal(1, 1)*p(1, 5) + normal(2, 1)*p(2, 5) + normal(3, 1)*p(3, 5))
2302 distance(
idx) = huge(distance(
idx))
2307 plane_vector(:, 1) = p(:, 7) - p(:, 3)
2308 plane_vector(:, 2) = p(:, 4) - p(:, 3)
2309 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2310 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2311 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2312 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2313 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 3) + normal(2, 1)*p(2, 3) + normal(3, 1)*p(3, 3))
2315 IF (point_is_in_quadrilateral(p(:, 3), p(:, 7), p(:, 8), p(:, 4), point_in_plane))
THEN
2316 distance(
idx) = abs(normal(1, 1)*p(1, 3) + normal(2, 1)*p(2, 3) + normal(3, 1)*p(3, 3))
2318 distance(
idx) = huge(distance(
idx))
2323 plane_vector(:, 1) = p(:, 6) - p(:, 2)
2324 plane_vector(:, 2) = p(:, 4) - p(:, 2)
2325 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2326 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2327 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2328 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2329 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 2) + normal(2, 1)*p(2, 2) + normal(3, 1)*p(3, 2))
2331 IF (point_is_in_quadrilateral(p(:, 2), p(:, 6), p(:, 8), p(:, 4), point_in_plane))
THEN
2332 distance(
idx) = abs(normal(1, 1)*p(1, 2) + normal(2, 1)*p(2, 2) + normal(3, 1)*p(3, 2))
2334 distance(
idx) = huge(distance(
idx))
2339 plane_vector(:, 1) = p(:, 5) - p(:, 1)
2340 plane_vector(:, 2) = p(:, 3) - p(:, 1)
2341 cross_product(1) = plane_vector(2, 1)*plane_vector(3, 2) - plane_vector(3, 1)*plane_vector(2, 2)
2342 cross_product(2) = plane_vector(3, 1)*plane_vector(1, 2) - plane_vector(1, 1)*plane_vector(3, 2)
2343 cross_product(3) = plane_vector(1, 1)*plane_vector(2, 2) - plane_vector(2, 1)*plane_vector(1, 2)
2344 normal(:, 1) = cross_product/sqrt(sum(cross_product**2))
2345 point_in_plane = -normal(:, 1)*(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2347 IF (point_is_in_quadrilateral(p(:, 1), p(:, 5), p(:, 7), p(:, 3), point_in_plane))
THEN
2348 distance(
idx) = abs(normal(1, 1)*p(1, 1) + normal(2, 1)*p(2, 1) + normal(3, 1)*p(3, 1))
2350 distance(
idx) = huge(distance(
idx))
2353 dist_min = minval(distance)
2354 IF (max_shell == 0)
THEN
2355 image_cell_found = .true.
2357 IF (dist_min < r_max)
THEN
2358 total_number_of_cells = total_number_of_cells + 1
2359 x_data%neighbor_cells(ub)%cell = real([ishell, jshell, kshell], dp)
2361 image_cell_found = .true.
2367 IF (image_cell_found)
THEN
2368 max_shell = max_shell + 1
2370 nothing_more_to_add = .true.
2374 ALLOCATE (tmp_neighbor_cells(total_number_of_cells))
2376 tmp_neighbor_cells(i) = x_data%neighbor_cells(i)
2378 DEALLOCATE (x_data%neighbor_cells)
2380 IF (total_number_of_cells == 0)
THEN
2381 total_number_of_cells = 1
2382 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2383 DO i = 1, total_number_of_cells
2384 x_data%neighbor_cells(i)%cell = 0.0_dp
2385 x_data%neighbor_cells(i)%cell_r = 0.0_dp
2388 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2389 DO i = 1, total_number_of_cells
2390 x_data%neighbor_cells(i) = tmp_neighbor_cells(i)
2393 DEALLOCATE (tmp_neighbor_cells)
2395 IF (x_data%periodic_parameter%number_of_shells == do_hfx_auto_shells)
THEN
2398 total_number_of_cells = 0
2399 DO i = 0, x_data%periodic_parameter%number_of_shells
2400 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2402 IF (total_number_of_cells <
SIZE(x_data%neighbor_cells))
THEN
2403 IF (i_thread == 1)
THEN
2404 WRITE (char_nshells,
'(I3)')
SIZE(x_data%neighbor_cells)
2405 WRITE (error_msg,
'(A,A,A)')
"Periodic Hartree Fock calculation requested with use "// &
2406 "of a truncated potential. The number of shells to be considered "// &
2407 "might be too small. CP2K conservatively estimates to need "//trim(char_nshells)//
" periodic images "// &
2408 "Please carefully check if you get converged results."
2412 total_number_of_cells = 0
2413 DO i = 0, x_data%periodic_parameter%number_of_shells
2414 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2416 DEALLOCATE (x_data%neighbor_cells)
2418 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2421 DO WHILE (sum(m**2) <= x_data%periodic_parameter%number_of_shells)
2422 x_data%neighbor_cells(i)%cell = real(m, dp)
2423 CALL next_image_cell_perd(m, x_data%periodic_parameter%perd)
2428 total_number_of_cells = 0
2429 IF (pbc_shells == -1) pbc_shells = 0
2430 DO i = 0, pbc_shells
2431 total_number_of_cells = total_number_of_cells + count_cells_perd(i, x_data%periodic_parameter%perd)
2433 DEALLOCATE (x_data%neighbor_cells)
2435 ALLOCATE (x_data%neighbor_cells(total_number_of_cells))
2439 DO WHILE (sum(m**2) <= pbc_shells)
2440 x_data%neighbor_cells(i)%cell = real(m, dp)
2441 CALL next_image_cell_perd(m, x_data%periodic_parameter%perd)
2447 DO i = 1,
SIZE(x_data%neighbor_cells)
2449 x_data%neighbor_cells(i)%cell_r(:) = 0.0_dp
2450 s = x_data%neighbor_cells(i)%cell(:)
2451 CALL scaled_to_real(x_data%neighbor_cells(i)%cell_r, s, cell)
2453 x_data%periodic_parameter%number_of_shells = pbc_shells
2455 r_max_stress = 0.0_dp
2456 DO i = 1,
SIZE(x_data%neighbor_cells)
2457 r_max_stress = max(r_max_stress, maxval(abs(x_data%neighbor_cells(i)%cell_r(:))))
2459 r_max_stress = r_max_stress + abs(maxval(cell%hmat(:, :)))
2460 x_data%periodic_parameter%R_max_stress = r_max_stress
2474 FUNCTION point_is_in_quadrilateral(A, B, C, D, P)
2475 REAL(dp) :: a(3), b(3), c(3), d(3), p(3)
2476 LOGICAL :: point_is_in_quadrilateral
2478 REAL(dp),
PARAMETER :: fuzzy = 1000.0_dp*epsilon(1.0_dp)
2480 REAL(dp) :: dot00, dot01, dot02, dot11, dot12, &
2481 invdenom, u, v, v0(3), v1(3), v2(3)
2483 point_is_in_quadrilateral = .false.
2502 dot00 = dot_product(v0, v0)
2503 dot01 = dot_product(v0, v1)
2504 dot02 = dot_product(v0, v2)
2505 dot11 = dot_product(v1, v1)
2506 dot12 = dot_product(v1, v2)
2509 invdenom = 1/(dot00*dot11 - dot01*dot01)
2510 u = (dot11*dot02 - dot01*dot12)*invdenom
2511 v = (dot00*dot12 - dot01*dot02)*invdenom
2513 IF ((u >= 0 - fuzzy) .AND. (v >= 0 - fuzzy) .AND. (u + v <= 1 + fuzzy))
THEN
2514 point_is_in_quadrilateral = .true.
2522 dot00 = dot_product(v0, v0)
2523 dot01 = dot_product(v0, v1)
2524 dot02 = dot_product(v0, v2)
2525 dot11 = dot_product(v1, v1)
2526 dot12 = dot_product(v1, v2)
2529 invdenom = 1/(dot00*dot11 - dot01*dot01)
2530 u = (dot11*dot02 - dot01*dot12)*invdenom
2531 v = (dot00*dot12 - dot01*dot02)*invdenom
2534 IF ((u >= 0 - fuzzy) .AND. (v >= 0 - fuzzy) .AND. (u + v <= 1 + fuzzy))
THEN
2535 point_is_in_quadrilateral = .true.
2539 END FUNCTION point_is_in_quadrilateral
2553 INTEGER :: memory_usage
2554 LOGICAL :: do_disk_storage
2556 TYPE(hfx_container_node),
POINTER :: current, next
2560 current => container%first
2561 DO WHILE (
ASSOCIATED(current))
2562 next => current%next
2563 DEALLOCATE (current)
2568 ALLOCATE (container%first)
2569 container%first%prev => null()
2570 container%first%next => null()
2571 container%current => container%first
2572 container%current%data = 0
2573 container%element_counter = 1
2576 IF (do_disk_storage)
THEN
2578 IF (container%unit /= -1)
THEN
2579 CALL close_file(unit_number=container%unit)
2581 CALL open_file(file_name=trim(container%filename), file_status=
"UNKNOWN", file_form=
"UNFORMATTED", file_action=
"WRITE", &
2582 unit_number=container%unit)
2600 DEALLOCATE (x_data%distribution_energy)
2602 ALLOCATE (x_data%distribution_energy(
SIZE(ptr_to_distr)))
2603 x_data%distribution_energy = ptr_to_distr
2620 DEALLOCATE (x_data%distribution_forces)
2622 ALLOCATE (x_data%distribution_forces(
SIZE(ptr_to_distr)))
2623 x_data%distribution_forces = ptr_to_distr
2640 INTEGER(int_8),
INTENT(IN) :: subtr_size_mb
2642 INTEGER(int_8) :: max_memory
2644 max_memory = memory_parameter%max_memory
2645 max_memory = max_memory - subtr_size_mb
2646 IF (max_memory <= 0)
THEN
2647 memory_parameter%do_all_on_the_fly = .true.
2648 memory_parameter%max_compression_counter = 0
2650 memory_parameter%do_all_on_the_fly = .false.
2651 memory_parameter%max_compression_counter = max_memory*1024_int_8*128_int_8
2663 SUBROUTINE hfx_print_std_info(x_data, hfx_section)
2665 TYPE(section_vals_type),
POINTER :: hfx_section
2668 TYPE(cp_logger_type),
POINTER :: logger
2671 logger => cp_get_default_logger()
2673 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2674 extension=
".scfLog")
2677 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2678 "HFX_INFO| EPS_SCHWARZ: ", x_data%screening_parameter%eps_schwarz
2679 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2680 "HFX_INFO| EPS_SCHWARZ_FORCES ", x_data%screening_parameter%eps_schwarz_forces
2681 WRITE (unit=iw, fmt=
"((T3,A,T73,ES8.1))") &
2682 "HFX_INFO| EPS_STORAGE_SCALING: ", x_data%memory_parameter%eps_storage_scaling
2683 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2684 "HFX_INFO| NBINS: ", x_data%load_balance_parameter%nbins
2685 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2686 "HFX_INFO| BLOCK_SIZE: ", x_data%load_balance_parameter%block_size
2687 IF (x_data%periodic_parameter%do_periodic)
THEN
2688 IF (x_data%periodic_parameter%mode == -1)
THEN
2689 WRITE (unit=iw, fmt=
"((T3,A,T77,A))") &
2690 "HFX_INFO| NUMBER_OF_SHELLS: ",
"AUTO"
2692 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2693 "HFX_INFO| NUMBER_OF_SHELLS: ", x_data%periodic_parameter%mode
2695 WRITE (unit=iw, fmt=
"((T3,A,T61,I20))") &
2696 "HFX_INFO| Number of periodic shells considered: ", x_data%periodic_parameter%number_of_shells
2697 WRITE (unit=iw, fmt=
"((T3,A,T61,I20),/)") &
2698 "HFX_INFO| Number of periodic cells considered: ",
SIZE(x_data%neighbor_cells)
2700 WRITE (unit=iw, fmt=
"((T3,A,T77,A))") &
2701 "HFX_INFO| Number of periodic shells considered: ",
"NONE"
2702 WRITE (unit=iw, fmt=
"((T3,A,T77,A),/)") &
2703 "HFX_INFO| Number of periodic cells considered: ",
"NONE"
2706 END SUBROUTINE hfx_print_std_info
2713 SUBROUTINE hfx_print_ri_info(ri_data, hfx_section)
2715 TYPE(section_vals_type),
POINTER :: hfx_section
2719 TYPE(cp_logger_type),
POINTER :: logger
2720 TYPE(section_vals_type),
POINTER :: ri_section
2722 NULLIFY (logger, ri_section)
2723 logger => cp_get_default_logger()
2725 ri_section => ri_data%ri_section
2727 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2728 extension=
".scfLog")
2732 associate(ri_metric => ri_data%ri_metric, hfx_pot => ri_data%hfx_pot)
2733 SELECT CASE (ri_metric%potential_type)
2734 CASE (do_potential_coulomb)
2735 WRITE (unit=iw, fmt=
"(/T3,A,T74,A)") &
2736 "HFX_RI_INFO| RI metric: ",
"COULOMB"
2737 CASE (do_potential_short)
2738 WRITE (unit=iw, fmt=
"(T3,A,T71,A)") &
2739 "HFX_RI_INFO| RI metric: ",
"SHORTRANGE"
2740 WRITE (iw,
'(T3,A,T61,F20.10)') &
2741 "HFX_RI_INFO| Omega: ", ri_metric%omega
2742 rc_ang = cp_unit_from_cp2k(ri_metric%cutoff_radius,
"angstrom")
2743 WRITE (iw,
'(T3,A,T61,F20.10)') &
2744 "HFX_RI_INFO| Cutoff Radius [angstrom]: ", rc_ang
2745 CASE (do_potential_long)
2746 WRITE (unit=iw, fmt=
"(T3,A,T72,A)") &
2747 "HFX_RI_INFO| RI metric: ",
"LONGRANGE"
2748 WRITE (iw,
'(T3,A,T61,F20.10)') &
2749 "HFX_RI_INFO| Omega: ", ri_metric%omega
2750 CASE (do_potential_id)
2751 WRITE (unit=iw, fmt=
"(T3,A,T74,A)") &
2752 "HFX_RI_INFO| RI metric: ",
"OVERLAP"
2753 CASE (do_potential_truncated)
2754 WRITE (unit=iw, fmt=
"(T3,A,T64,A)") &
2755 "HFX_RI_INFO| RI metric: ",
"TRUNCATED COULOMB"
2756 rc_ang = cp_unit_from_cp2k(ri_metric%cutoff_radius,
"angstrom")
2757 WRITE (iw,
'(T3,A,T61,F20.10)') &
2758 "HFX_RI_INFO| Cutoff Radius [angstrom]: ", rc_ang
2762 SELECT CASE (ri_data%flavor)
2764 WRITE (unit=iw, fmt=
"(T3, A, T79, A)") &
2765 "HFX_RI_INFO| RI flavor: ",
"MO"
2767 WRITE (unit=iw, fmt=
"(T3, A, T78, A)") &
2768 "HFX_RI_INFO| RI flavor: ",
"RHO"
2770 SELECT CASE (ri_data%t2c_method)
2771 CASE (hfx_ri_do_2c_iter)
2772 WRITE (unit=iw, fmt=
"(T3, A, T69, A)") &
2773 "HFX_RI_INFO| Matrix SQRT/INV",
"DBCSR / iter"
2774 CASE (hfx_ri_do_2c_diag)
2775 WRITE (unit=iw, fmt=
"(T3, A, T65, A)") &
2776 "HFX_RI_INFO| Matrix SQRT/INV",
"Dense / diag"
2778 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2779 "HFX_RI_INFO| EPS_FILTER", ri_data%filter_eps
2780 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2781 "HFX_RI_INFO| EPS_FILTER 2-center", ri_data%filter_eps_2c
2782 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2783 "HFX_RI_INFO| EPS_FILTER storage", ri_data%filter_eps_storage
2784 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2785 "HFX_RI_INFO| EPS_FILTER MO", ri_data%filter_eps_mo
2786 WRITE (unit=iw, fmt=
"(T3, A, T73, ES8.1)") &
2787 "HFX_RI_INFO| EPS_PGF_ORB", ri_data%eps_pgf_orb
2788 WRITE (unit=iw, fmt=
"((T3, A, T73, ES8.1))") &
2789 "HFX_RI_INFO| EPS_SCHWARZ: ", ri_data%eps_schwarz
2790 WRITE (unit=iw, fmt=
"((T3, A, T73, ES8.1))") &
2791 "HFX_RI_INFO| EPS_SCHWARZ_FORCES: ", ri_data%eps_schwarz_forces
2792 WRITE (unit=iw, fmt=
"(T3, A, T78, I3)") &
2793 "HFX_RI_INFO| Minimum block size", ri_data%min_bsize
2794 WRITE (unit=iw, fmt=
"(T3, A, T78, I3)") &
2795 "HFX_RI_INFO| MO block size", ri_data%max_bsize_MO
2796 WRITE (unit=iw, fmt=
"(T3, A, T79, I2)") &
2797 "HFX_RI_INFO| Memory reduction factor", ri_data%n_mem_input
2800 END SUBROUTINE hfx_print_ri_info
2808 SUBROUTINE hfx_print_info(x_data, hfx_section, i_rep)
2810 TYPE(section_vals_type),
POINTER :: hfx_section
2811 INTEGER,
INTENT(IN) :: i_rep
2815 TYPE(cp_logger_type),
POINTER :: logger
2818 logger => cp_get_default_logger()
2820 iw = cp_print_key_unit_nr(logger, hfx_section,
"HF_INFO", &
2821 extension=
".scfLog")
2824 WRITE (unit=iw, fmt=
"(/,(T3,A,T61,I20))") &
2825 "HFX_INFO| Replica ID: ", i_rep
2827 WRITE (iw,
'(T3,A,T61,F20.10)') &
2828 "HFX_INFO| FRACTION: ", x_data%general_parameter%fraction
2829 SELECT CASE (x_data%potential_parameter%potential_type)
2830 CASE (do_potential_coulomb)
2831 WRITE (unit=iw, fmt=
"((T3,A,T74,A))") &
2832 "HFX_INFO| Interaction Potential: ",
"COULOMB"
2833 CASE (do_potential_short)
2834 WRITE (unit=iw, fmt=
"((T3,A,T71,A))") &
2835 "HFX_INFO| Interaction Potential: ",
"SHORTRANGE"
2836 WRITE (iw,
'(T3,A,T61,F20.10)') &
2837 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2838 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2839 WRITE (iw,
'(T3,A,T61,F20.10)') &
2840 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2841 CASE (do_potential_long)
2842 WRITE (unit=iw, fmt=
"((T3,A,T72,A))") &
2843 "HFX_INFO| Interaction Potential: ",
"LONGRANGE"
2844 WRITE (iw,
'(T3,A,T61,F20.10)') &
2845 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2846 CASE (do_potential_mix_cl)
2847 WRITE (unit=iw, fmt=
"((T3,A,T75,A))") &
2848 "HFX_INFO| Interaction Potential: ",
"MIX_CL"
2849 WRITE (iw,
'(T3,A,T61,F20.10)') &
2850 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2851 WRITE (iw,
'(T3,A,T61,F20.10)') &
2852 "HFX_INFO| SCALE_COULOMB: ", x_data%potential_parameter%scale_coulomb
2853 WRITE (iw,
'(T3,A,T61,F20.10)') &
2854 "HFX_INFO| SCALE_LONGRANGE: ", x_data%potential_parameter%scale_longrange
2855 CASE (do_potential_gaussian)
2856 WRITE (unit=iw, fmt=
"((T3,A,T73,A))") &
2857 "HFX_INFO| Interaction Potential: ",
"GAUSSIAN"
2858 WRITE (iw,
'(T3,A,T61,F20.10)') &
2859 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2860 CASE (do_potential_mix_lg)
2861 WRITE (unit=iw, fmt=
"((T3,A,T75,A))") &
2862 "HFX_INFO| Interaction Potential: ",
"MIX_LG"
2863 WRITE (iw,
'(T3,A,T61,F20.10)') &
2864 "HFX_INFO| Omega: ", x_data%potential_parameter%omega
2865 WRITE (iw,
'(T3,A,T61,F20.10)') &
2866 "HFX_INFO| SCALE_LONGRANGE: ", x_data%potential_parameter%scale_longrange
2867 WRITE (iw,
'(T3,A,T61,F20.10)') &
2868 "HFX_INFO| SCALE_GAUSSIAN: ", x_data%potential_parameter%scale_gaussian
2869 CASE (do_potential_id)
2870 WRITE (unit=iw, fmt=
"((T3,A,T73,A))") &
2871 "HFX_INFO| Interaction Potential: ",
"IDENTITY"
2872 CASE (do_potential_truncated)
2873 WRITE (unit=iw, fmt=
"((T3,A,T72,A))") &
2874 "HFX_INFO| Interaction Potential: ",
"TRUNCATED"
2875 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2876 WRITE (iw,
'(T3,A,T61,F20.10)') &
2877 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2878 CASE (do_potential_mix_cl_trunc)
2879 WRITE (unit=iw, fmt=
"((T3,A,T65,A))") &
2880 "HFX_INFO| Interaction Potential: ",
"TRUNCATED MIX_CL"
2881 rc_ang = cp_unit_from_cp2k(x_data%potential_parameter%cutoff_radius,
"angstrom")
2882 WRITE (iw,
'(T3,A,T61,F20.10)') &
2883 "HFX_INFO| Cutoff Radius [angstrom]: ", rc_ang
2887 IF (x_data%do_hfx_ri)
THEN
2888 CALL hfx_print_ri_info(x_data%ri_data, hfx_section)
2890 CALL hfx_print_std_info(x_data, hfx_section)
2893 CALL cp_print_key_finished_output(iw, logger, hfx_section, &
2895 END SUBROUTINE hfx_print_info
2904 INTEGER :: memory_usage
2908 DO bin = 1,
SIZE(data%maxval_container)
2911 DEALLOCATE (data%maxval_container(bin)%first)
2913 DEALLOCATE (data%maxval_container)
2914 DEALLOCATE (data%maxval_cache)
2916 DO bin = 1,
SIZE(data%integral_containers, 2)
2920 DEALLOCATE (data%integral_containers(i, bin)%first)
2923 DEALLOCATE (data%integral_containers)
2925 DEALLOCATE (data%integral_caches)
2936 INTEGER,
INTENT(IN) :: bin_size
2940 ALLOCATE (data%maxval_cache(bin_size))
2941 DO bin = 1, bin_size
2942 data%maxval_cache(bin)%element_counter = 1
2944 ALLOCATE (data%maxval_container(bin_size))
2945 DO bin = 1, bin_size
2946 ALLOCATE (data%maxval_container(bin)%first)
2947 data%maxval_container(bin)%first%prev => null()
2948 data%maxval_container(bin)%first%next => null()
2949 data%maxval_container(bin)%current => data%maxval_container(bin)%first
2950 data%maxval_container(bin)%current%data = 0
2951 data%maxval_container(bin)%element_counter = 1
2954 ALLOCATE (data%integral_containers(64, bin_size))
2955 ALLOCATE (data%integral_caches(64, bin_size))
2957 DO bin = 1, bin_size
2959 data%integral_caches(i, bin)%element_counter = 1
2960 data%integral_caches(i, bin)%data = 0
2961 ALLOCATE (data%integral_containers(i, bin)%first)
2962 data%integral_containers(i, bin)%first%prev => null()
2963 data%integral_containers(i, bin)%first%next => null()
2964 data%integral_containers(i, bin)%current => data%integral_containers(i, bin)%first
2965 data%integral_containers(i, bin)%current%data = 0
2966 data%integral_containers(i, bin)%element_counter = 1
2983 TYPE(section_vals_type),
POINTER :: hfx_section1, hfx_section2
2984 LOGICAL,
INTENT(OUT) :: is_identical
2985 LOGICAL,
INTENT(OUT),
OPTIONAL :: same_except_frac
2987 CHARACTER(LEN=default_path_length) :: cval1, cval2
2988 INTEGER :: irep, ival1, ival2, n_rep_hf1, n_rep_hf2
2989 LOGICAL :: lval1, lval2
2990 REAL(dp) :: rval1, rval2
2991 TYPE(section_vals_type),
POINTER :: hfx_sub_section1, hfx_sub_section2
2993 is_identical = .true.
2994 IF (
PRESENT(same_except_frac)) same_except_frac = .false.
2996 CALL section_vals_get(hfx_section1, n_repetition=n_rep_hf1)
2997 CALL section_vals_get(hfx_section2, n_repetition=n_rep_hf2)
2998 is_identical = n_rep_hf1 == n_rep_hf2
2999 IF (.NOT. is_identical)
RETURN
3001 DO irep = 1, n_rep_hf1
3002 CALL section_vals_val_get(hfx_section1,
"PW_HFX", l_val=lval1, i_rep_section=irep)
3003 CALL section_vals_val_get(hfx_section2,
"PW_HFX", l_val=lval2, i_rep_section=irep)
3004 IF (lval1 .NEQV. lval2) is_identical = .false.
3006 CALL section_vals_val_get(hfx_section1,
"PW_HFX_BLOCKSIZE", i_val=ival1, i_rep_section=irep)
3007 CALL section_vals_val_get(hfx_section2,
"PW_HFX_BLOCKSIZE", i_val=ival2, i_rep_section=irep)
3008 IF (ival1 /= ival2) is_identical = .false.
3010 CALL section_vals_val_get(hfx_section1,
"TREAT_LSD_IN_CORE", l_val=lval1, i_rep_section=irep)
3011 CALL section_vals_val_get(hfx_section2,
"TREAT_LSD_IN_CORE", l_val=lval2, i_rep_section=irep)
3012 IF (lval1 .NEQV. lval2) is_identical = .false.
3014 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"INTERACTION_POTENTIAL", i_rep_section=irep)
3015 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"INTERACTION_POTENTIAL", i_rep_section=irep)
3017 CALL section_vals_val_get(hfx_sub_section1,
"OMEGA", r_val=rval1, i_rep_section=irep)
3018 CALL section_vals_val_get(hfx_sub_section2,
"OMEGA", r_val=rval2, i_rep_section=irep)
3019 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3021 CALL section_vals_val_get(hfx_sub_section1,
"POTENTIAL_TYPE", i_val=ival1, i_rep_section=irep)
3022 CALL section_vals_val_get(hfx_sub_section2,
"POTENTIAL_TYPE", i_val=ival2, i_rep_section=irep)
3023 IF (ival1 /= ival2) is_identical = .false.
3024 IF (.NOT. is_identical)
RETURN
3026 IF (ival1 == do_potential_truncated .OR. ival1 == do_potential_mix_cl_trunc)
THEN
3027 CALL section_vals_val_get(hfx_sub_section1,
"CUTOFF_RADIUS", r_val=rval1, i_rep_section=irep)
3028 CALL section_vals_val_get(hfx_sub_section2,
"CUTOFF_RADIUS", r_val=rval2, i_rep_section=irep)
3029 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3031 CALL section_vals_val_get(hfx_sub_section1,
"T_C_G_DATA", c_val=cval1, i_rep_section=irep)
3032 CALL section_vals_val_get(hfx_sub_section2,
"T_C_G_DATA", c_val=cval2, i_rep_section=irep)
3033 IF (cval1 /= cval2) is_identical = .false.
3036 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_COULOMB", r_val=rval1, i_rep_section=irep)
3037 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_COULOMB", r_val=rval2, i_rep_section=irep)
3038 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3040 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_GAUSSIAN", r_val=rval1, i_rep_section=irep)
3041 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_GAUSSIAN", r_val=rval2, i_rep_section=irep)
3042 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3044 CALL section_vals_val_get(hfx_sub_section1,
"SCALE_LONGRANGE", r_val=rval1, i_rep_section=irep)
3045 CALL section_vals_val_get(hfx_sub_section2,
"SCALE_LONGRANGE", r_val=rval2, i_rep_section=irep)
3046 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3048 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"PERIODIC", i_rep_section=irep)
3049 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"PERIODIC", i_rep_section=irep)
3051 CALL section_vals_val_get(hfx_sub_section1,
"NUMBER_OF_SHELLS", i_val=ival1, i_rep_section=irep)
3052 CALL section_vals_val_get(hfx_sub_section2,
"NUMBER_OF_SHELLS", i_val=ival2, i_rep_section=irep)
3053 IF (ival1 /= ival2) is_identical = .false.
3055 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"RI", i_rep_section=irep)
3056 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"RI", i_rep_section=irep)
3058 CALL section_vals_val_get(hfx_sub_section1,
"_SECTION_PARAMETERS_", l_val=lval1, i_rep_section=irep)
3059 CALL section_vals_val_get(hfx_sub_section2,
"_SECTION_PARAMETERS_", l_val=lval2, i_rep_section=irep)
3060 IF (lval1 .NEQV. lval2) is_identical = .false.
3062 CALL section_vals_val_get(hfx_sub_section1,
"CUTOFF_RADIUS", r_val=rval1, i_rep_section=irep)
3063 CALL section_vals_val_get(hfx_sub_section2,
"CUTOFF_RADIUS", r_val=rval2, i_rep_section=irep)
3064 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3066 CALL section_vals_val_get(hfx_sub_section1,
"EPS_EIGVAL", r_val=rval1, i_rep_section=irep)
3067 CALL section_vals_val_get(hfx_sub_section2,
"EPS_EIGVAL", r_val=rval2, i_rep_section=irep)
3068 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3070 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER", r_val=rval1, i_rep_section=irep)
3071 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER", r_val=rval2, i_rep_section=irep)
3072 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3074 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER_2C", r_val=rval1, i_rep_section=irep)
3075 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER_2C", r_val=rval2, i_rep_section=irep)
3076 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3078 CALL section_vals_val_get(hfx_sub_section1,
"EPS_FILTER_MO", r_val=rval1, i_rep_section=irep)
3079 CALL section_vals_val_get(hfx_sub_section2,
"EPS_FILTER_MO", r_val=rval2, i_rep_section=irep)
3080 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3082 CALL section_vals_val_get(hfx_sub_section1,
"EPS_PGF_ORB", r_val=rval1, i_rep_section=irep)
3083 CALL section_vals_val_get(hfx_sub_section2,
"EPS_PGF_ORB", r_val=rval2, i_rep_section=irep)
3084 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3086 CALL section_vals_val_get(hfx_sub_section1,
"MAX_BLOCK_SIZE_MO", i_val=ival1, i_rep_section=irep)
3087 CALL section_vals_val_get(hfx_sub_section2,
"MAX_BLOCK_SIZE_MO", i_val=ival2, i_rep_section=irep)
3088 IF (ival1 /= ival2) is_identical = .false.
3090 CALL section_vals_val_get(hfx_sub_section1,
"MIN_BLOCK_SIZE", i_val=ival1, i_rep_section=irep)
3091 CALL section_vals_val_get(hfx_sub_section2,
"MIN_BLOCK_SIZE", i_val=ival2, i_rep_section=irep)
3092 IF (ival1 /= ival2) is_identical = .false.
3094 CALL section_vals_val_get(hfx_sub_section1,
"OMEGA", r_val=rval1, i_rep_section=irep)
3095 CALL section_vals_val_get(hfx_sub_section2,
"OMEGA", 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,
"RI_FLAVOR", i_val=ival1, i_rep_section=irep)
3099 CALL section_vals_val_get(hfx_sub_section2,
"RI_FLAVOR", i_val=ival2, i_rep_section=irep)
3100 IF (ival1 /= ival2) is_identical = .false.
3102 CALL section_vals_val_get(hfx_sub_section1,
"RI_METRIC", i_val=ival1, i_rep_section=irep)
3103 CALL section_vals_val_get(hfx_sub_section2,
"RI_METRIC", i_val=ival2, i_rep_section=irep)
3104 IF (ival1 /= ival2) is_identical = .false.
3106 hfx_sub_section1 => section_vals_get_subs_vals(hfx_section1,
"SCREENING", i_rep_section=irep)
3107 hfx_sub_section2 => section_vals_get_subs_vals(hfx_section2,
"SCREENING", i_rep_section=irep)
3109 CALL section_vals_val_get(hfx_sub_section1,
"EPS_SCHWARZ", r_val=rval1, i_rep_section=irep)
3110 CALL section_vals_val_get(hfx_sub_section2,
"EPS_SCHWARZ", r_val=rval2, i_rep_section=irep)
3111 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3113 CALL section_vals_val_get(hfx_sub_section1,
"EPS_SCHWARZ_FORCES", r_val=rval1, i_rep_section=irep)
3114 CALL section_vals_val_get(hfx_sub_section2,
"EPS_SCHWARZ_FORCES", r_val=rval2, i_rep_section=irep)
3115 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3117 CALL section_vals_val_get(hfx_sub_section1,
"P_SCREEN_CORRECTION_FACTOR", r_val=rval1, i_rep_section=irep)
3118 CALL section_vals_val_get(hfx_sub_section2,
"P_SCREEN_CORRECTION_FACTOR", r_val=rval2, i_rep_section=irep)
3119 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3121 CALL section_vals_val_get(hfx_sub_section1,
"SCREEN_ON_INITIAL_P", l_val=lval1, i_rep_section=irep)
3122 CALL section_vals_val_get(hfx_sub_section2,
"SCREEN_ON_INITIAL_P", l_val=lval2, i_rep_section=irep)
3123 IF (lval1 .NEQV. lval2) is_identical = .false.
3125 CALL section_vals_val_get(hfx_sub_section1,
"SCREEN_P_FORCES", l_val=lval1, i_rep_section=irep)
3126 CALL section_vals_val_get(hfx_sub_section2,
"SCREEN_P_FORCES", l_val=lval2, i_rep_section=irep)
3127 IF (lval1 .NEQV. lval2) is_identical = .false.
3132 IF (is_identical)
THEN
3133 DO irep = 1, n_rep_hf1
3134 CALL section_vals_val_get(hfx_section1,
"FRACTION", r_val=rval1, i_rep_section=irep)
3135 CALL section_vals_val_get(hfx_section2,
"FRACTION", r_val=rval2, i_rep_section=irep)
3136 IF (abs(rval1 - rval2) > epsilon(1.0_dp)) is_identical = .false.
3139 IF (
PRESENT(same_except_frac))
THEN
3140 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)
...
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)
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.