154 subroutine build_contracted_hamiltonian (this, matrix_elements)
155 class(contracted_hamiltonian) :: this
156 class(basematrix),
intent(inout) :: matrix_elements
157 integer :: num_target_sym, target_sym, num_targets_per_sym, i1, i2, n1, n2, l1, loop_skip, loop_ido, my_idx, ido
158 integer :: num_csfs, m, n, num_continuum, total_l1_cont_elems, matrix_block_size, estimated_mat_size
161 matrix_block_size = this % options % contracted_mat_size - this % total_num_csf + this % options % last_continuum
163 write (stdout,
"('continuum block_size =',i8)") matrix_block_size
165 call matrix_elements % initialize_matrix_structure(this % options % contracted_mat_size,
mat_sparse, matrix_block_size)
168 num_target_sym = this % options % num_target_sym
174 this % orbitals % MFLG = 0
177 call master_timer % start_timer(
"Class 1")
180 do i1 = 1, num_target_sym
181 call this % evaluate_class_1(i1, this % options % num_target_state_sym(i1), matrix_elements)
183 call master_timer % stop_timer(
"Class 1")
184 write (stdout,
"('Class 1 complete')")
186 call master_timer % report_timers
209 call master_memory % print_memory_report
218 this % orbitals % MFLG = 1
220 call master_timer % start_timer(
"Class 3")
222 do i1 = 1, num_target_sym
223 call this % evaluate_class_3(i1, this % options % num_target_state_sym(i1), matrix_elements)
225 call master_timer % stop_timer(
"Class 3")
229 write (stdout,
"('Class 3 complete')")
232 call master_timer % report_timers
233 call master_memory % print_memory_report
237 loop_skip = max(1, grid % gprocs)
238 my_idx = max(grid % grank, 0)
240 call master_timer % start_timer(
"Class 4")
241 do i1 = 1, num_target_sym
242 total_l1_cont_elems = this % options % num_target_state_sym(i1) * this % options % num_continuum_orbitals_target(i1)
243 do loop_ido = this % start_L2, this % total_num_csf, loop_skip
244 l1 = my_idx + loop_ido
246 if (l1 > this % total_num_csf)
then
248 do ido = 1, total_l1_cont_elems
249 call matrix_elements % update_pure_L2(.false.)
253 call this % evaluate_class_4(i1, this % options % num_target_state_sym(i1), l1, matrix_elements)
258 call master_timer % stop_timer(
"Class 4")
259 write (stdout,
"('Class 4 complete')")
262 call master_timer % report_timers
267 call master_timer % start_timer(
"Class 567")
269 do i1 = 1, num_target_sym - 1
270 do i2 = i1 + 1, num_target_sym
275 if (this % options % lambda_continuum_orbitals_target(i1) == &
276 this % options % lambda_continuum_orbitals_target(i2))
then
277 if (this % options % gerade_sym_continuum_orbital_target(i1) == &
278 this % options % gerade_sym_continuum_orbital_target(i2))
then
281 call this % evaluate_class_5(i1, this % options % num_target_state_sym(i1), i2, &
282 this % options % num_target_state_sym(i2), matrix_elements)
285 call this % evaluate_class_6 (i1, this % options % num_target_state_sym(i1), i2, &
286 this % options % num_target_state_sym(i2), matrix_elements)
295 call this % evaluate_class_7(i1, this % options % num_target_state_sym(i1), i2, &
296 this % options % num_target_state_sym(i2), matrix_elements)
303 call master_timer % stop_timer(
"Class 567")
304 write (stdout,
"('Class 567 complete')")
307 call master_timer % report_timers
308 call master_memory % print_memory_report
309 call master_timer % start_timer(
"Class 2+8")
312 call this % evaluate_class_2_and_8(matrix_elements)
314 call master_timer % stop_timer(
"Class 2+8")
316 write (stdout,
"('Class 2+8 complete')")
319 call master_timer % report_timers
320 call master_memory % print_memory_report
323 call matrix_elements % update_pure_L2(.true.)
326 call matrix_elements % finalize_matrix
329 n = (this % options % num_csfs * (this % options % num_csfs + 1)) / 2
330 m = (this % options % contracted_mat_size * (this % options % contracted_mat_size + 1)) / 2
332 write (stdout, 6000) m, matrix_elements % get_size()
333 6000
format(//,
' TOTAL H Matrix ELEMENTS =',i15,/,
' NON-ZERO ELEMENTS evaluated =',i15)
334 write (stdout, 6010) n, this % non_zero_prototype
335 6010
format(
' Total prototype ELEMENTS =',i15,/,
' Non-zero prototype ELEMENTS =',i15)
337 6020
format(/,
' Number (prototype) integrals =',i15,/,
' Compressed (prototype) integrals =',i15)
338 write (stdout, 6030) this % number_of_integrals
339 6030
format(
' Number integrals evaluated =',i15)
355 subroutine evaluate_class_1 (this, i1, num_targets, matrix_elements)
356 class(contracted_hamiltonian) :: this
357 class(basematrix),
intent(inout) :: matrix_elements
358 integer,
intent(in) :: i1
359 integer,
intent(in) :: num_targets
362 type(contractedsymbolicelementvector) :: master_prototype
364 type(symbolicelementvector) :: temp_prototype
366 integer,
allocatable :: matrix_index(:,:)
373 integer :: starting_index, ido, jdo, ii, jj, ij, err
375 integer :: loop_idx, loop_ido, my_idx, loop_skip
377 integer :: num_configurations
379 integer :: config_idx_a, config_idx_b
381 real(wp),
allocatable :: alpha_coeffs(:,:)
383 real(wp),
allocatable :: mat_coeffs(:,:)
385 integer :: continuum_orbital, num_continuum_orbitals
387 allocate(matrix_index(2,num_targets*(num_targets+1)/2), stat = err)
388 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS1::MATRIX_INDEX')
389 allocate(alpha_coeffs(num_targets*(num_targets+1)/2,1), stat = err)
390 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS1::alpha_coeffs')
391 allocate(mat_coeffs(num_targets*(num_targets+1)/2,1), stat = err)
392 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS1::mat_coeffs')
394 num_continuum_orbitals = this % options % num_continuum_orbitals_target(i1)
397 num_ci = num_targets * (num_targets + 1) / 2
400 do n1 = 1, this % options % num_target_state_sym(i1)
401 do n2 = n1, this % options % num_target_state_sym(i1)
404 call this % compute_matrix_ij(i1, n1, 1, i1, n2, 1, matrix_index(1,ii), matrix_index(2,ii))
409 call master_prototype % construct(num_ci, 1)
412 call temp_prototype % construct
415 starting_index = this % get_starting_index(i1)
418 num_configurations = this % options % num_ci_target_sym(i1)
421 loop_skip = max(1, grid % lprocs)
422 my_idx = max(grid % lrank, 0)
423 call master_timer % start_timer(
"Class 1 prototype")
426 do loop_ido = 1, num_configurations, loop_skip
427 this % orbitals % MFLG = 0
429 ido = loop_ido + my_idx
431 if (ido > num_configurations) cycle
433 config_idx_a = starting_index + (ido - 1) * this % csf_skip
435 call this % slater_rules(this % csfs(config_idx_a), this % csfs(config_idx_a), temp_prototype, 0, .false.)
436 alpha_coeffs = 0.0_wp
439 do n1 = 1, this % options % num_target_state_sym(i1)
440 do n2 = n1, this % options % num_target_state_sym(i1)
442 alpha_coeffs(ii,1) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i1, ido, n2)
446 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
450 call temp_prototype % clear
456 config_idx_b = starting_index + (jdo - 1) * this % csf_skip
458 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 1, .false.)
461 if (temp_prototype % is_empty()) cycle
465 do n1 = 1, this % options % num_target_state_sym(i1)
466 do n2 = n1, this % options % num_target_state_sym(i1)
468 alpha_coeffs(ii,1) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i1, jdo, n2) &
469 + this % get_target_coeff(i1, jdo, n1) * this % get_target_coeff(i1, ido, n2)
476 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
479 call temp_prototype % clear
482 call master_timer % stop_timer(
"Class 1 prototype")
485 call master_prototype % synchronize_symbols()
503 config_idx_a = starting_index + (num_configurations - 1) * this % csf_skip
505 continuum_orbital = this % csfs(config_idx_a) % orbital_sequence_number
508 loop_skip = max(1, grid % gprocs)
509 my_idx = max(grid % grank, 0)
511 call master_timer % start_timer(
"Class 1 Expansion")
513 do loop_ido = 1, num_continuum_orbitals, loop_skip
514 ido = loop_ido + my_idx
515 call matrix_elements % update_pure_L2(.false., num_targets * (num_targets - 1))
517 if (ido > num_continuum_orbitals) cycle
521 call this % contr_expand_diagonal_eval(continuum_orbital, master_prototype, ido, mat_coeffs)
523 do ii = 1, num_targets
524 do jj = ii, num_targets
527 mat_coeffs(ij,1) = mat_coeffs(ij,1) + this % rmat_ci(i1) % eigenvalues(ii)
529 call matrix_elements % insert_matrix_element(matrix_index(2,ij) + ido - 1, &
530 matrix_index(1,ij) + ido - 1, mat_coeffs(ij,1), 8)
537 call master_timer % stop_timer(
"Class 1 Expansion")
539 call temp_prototype %destroy
542 call master_prototype % destroy
544 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
545 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
546 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
547 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
549 this % non_zero_prototype = this % non_zero_prototype + 1
564 subroutine evaluate_class_2 (this, matrix_elements)
565 class(contracted_hamiltonian) :: this
566 class(basematrix),
intent(inout) :: matrix_elements
567 type(symbolicelementvector) :: symbolic_elements
568 real(wp) :: mat_coeff
569 integer :: l1, mat_offset, loop_ido, loop_skip, my_idx
571 this % diagonal_flag = 0
574 call symbolic_elements % construct
576 loop_skip = max(1, grid % gprocs)
577 my_idx = max(1, grid % grank)
580 do l1 = this % start_L2, this % total_num_csf
581 call matrix_elements % update_pure_L2(.false.)
583 call this % slater_rules(this % csfs(l1), this % csfs(l1), symbolic_elements, 0)
585 if (symbolic_elements % is_empty()) cycle
587 mat_coeff = this % evaluate_integrals(symbolic_elements,
normal_phase)
589 call matrix_elements % insert_matrix_element(l1 + this % L2_mat_offset, l1 + this % L2_mat_offset, mat_coeff, 2)
591 call symbolic_elements % clear
593 this % non_zero_prototype = this % non_zero_prototype + 1
597 call symbolic_elements % destroy
613 subroutine evaluate_class_3 (this, i1, num_targets, matrix_elements)
614 class(contracted_hamiltonian) :: this
615 class(basematrix),
intent(inout) :: matrix_elements
616 integer,
intent(in) :: i1, num_targets
619 type(contractedsymbolicelementvector) :: master_prototype
621 type(symbolicelementvector) :: temp_prototype
623 integer,
allocatable :: matrix_index(:,:)
629 integer :: starting_index, ido, jdo, ii
631 integer :: loop_idx, loop_ido, my_idx, loop_skip, err
633 integer :: num_configurations
635 integer :: config_idx_a, config_idx_b
637 real(wp),
allocatable :: alpha_coeffs(:,:)
639 real(wp),
allocatable :: mat_coeffs(:,:)
641 integer :: continuum_orbital_a, continuum_orbital_b, num_continuum_orbitals, total_orbs
643 allocate(matrix_index(2,num_targets*(num_targets+1)/2), stat = err)
644 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS3::MATRIX_INDEX')
646 allocate(alpha_coeffs(num_targets*(num_targets+1)/2,1), stat = err)
647 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS3::alpha_coeffs')
649 allocate(mat_coeffs(num_targets*(num_targets+1)/2,1), stat = err)
650 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS3::mat_coeffs')
653 num_continuum_orbitals = this % options % num_continuum_orbitals_target(i1)
656 num_ci = num_targets * (num_targets + 1) / 2
659 do n1 = 1, this % options % num_target_state_sym(i1)
660 do n2 = n1, this % options % num_target_state_sym(i1)
663 call this % compute_matrix_ij(i1, n1, 2, i1, n2, 1, matrix_index(1,ii), matrix_index(2,ii))
668 call master_prototype % construct(num_targets * (num_targets + 1) / 2, 1)
671 call temp_prototype % construct
674 starting_index = this % get_starting_index(i1)
677 num_configurations = this % options % num_ci_target_sym(i1)
680 loop_skip = max(1, grid % lprocs)
681 my_idx = max(grid % lrank, 0)
682 call master_timer % start_timer(
"Class 3 Prototype")
685 do loop_ido = 1, num_configurations, loop_skip
687 ido = loop_ido + my_idx
689 if (ido > num_configurations) cycle
691 config_idx_a = starting_index + (ido - 1) * this % csf_skip
693 config_idx_b = config_idx_a + 1
695 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 0, .false.)
697 alpha_coeffs = 0.0_wp
700 do n1 = 1, this % options % num_target_state_sym(i1)
701 do n2 = n1, this % options % num_target_state_sym(i1)
702 alpha_coeffs(ii,1) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i1, ido, n2)
706 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
709 call temp_prototype % clear
712 do jdo = 1, num_configurations
714 if (jdo == ido) cycle
716 config_idx_b = starting_index + 1 + (jdo - 1) * this % csf_skip
718 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 1, .false.)
721 if (temp_prototype % is_empty()) cycle
722 alpha_coeffs = 0.0_wp
726 do n1 = 1, this % options % num_target_state_sym(i1)
727 do n2 = n1, this % options % num_target_state_sym(i1)
728 alpha_coeffs(ii,1) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i1, jdo, n2)
732 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
734 call temp_prototype % clear
737 call master_timer % stop_timer(
"Class 3 Prototype")
739 call master_prototype % synchronize_symbols()
773 config_idx_a = starting_index + (num_configurations - 1) * this % csf_skip
774 config_idx_b = config_idx_a + 1
776 continuum_orbital_a = this % csfs(config_idx_a) % orbital_sequence_number
777 continuum_orbital_b = this % csfs(config_idx_b) % orbital_sequence_number
778 call master_timer % start_timer(
"Class 3 Expansion")
781 loop_skip = max(1, grid % gprocs)
782 my_idx = max(grid % grank, 0)
784 total_orbs = compute_total_box(num_continuum_orbitals, num_continuum_orbitals)
786 do loop_ido = 1, total_orbs, loop_skip
788 loop_idx = loop_ido + my_idx
789 call matrix_elements % update_pure_L2(.false., num_targets * (num_targets - 1))
791 if (loop_idx > total_orbs) cycle
793 call box_index_to_ij(loop_idx, num_continuum_orbitals, ido, jdo)
795 if (ido > num_continuum_orbitals) cycle
796 if (jdo > num_continuum_orbitals) cycle
797 if (jdo < ido + 1) cycle
798 if (ido == jdo) cycle
807 call this % contr_expand_off_diagonal_eval(continuum_orbital_a, continuum_orbital_b, &
808 master_prototype, ido, jdo, mat_coeffs)
810 do n1 = 1, num_targets
811 do n2 = n1, num_targets
813 call matrix_elements % insert_matrix_element(matrix_index(2,ii) + jdo - 1, &
814 matrix_index(1,ii) + ido - 2, mat_coeffs(ii,1), 8)
820 call matrix_elements % insert_matrix_element (matrix_index(2,ii) + ido - 1, &
821 matrix_index(1,ii) + jdo - 2, mat_coeffs(ii,1), 8)
831 call master_timer % stop_timer(
"Class 3 Expansion")
835 call master_prototype % destroy
838 call temp_prototype % destroy
840 this % non_zero_prototype = this % non_zero_prototype + 1
842 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
843 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
844 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
845 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
862 subroutine evaluate_class_4 (this, i1, num_states, l1, matrix_elements)
864 class(contracted_hamiltonian) :: this
865 class(basematrix),
intent(inout) :: matrix_elements
866 integer,
intent(in) :: i1, num_states, l1
868 integer :: config_idx_a
869 integer :: num_continuum_orbitals
870 integer :: num_configurations
872 integer :: continuum_orbital
874 integer :: ido, jdo, starting_index, i, j
875 integer :: loop_skip, loop_idx, my_idx, err
876 integer,
allocatable :: matrix_index(:)
878 type(contractedsymbolicelementvector) :: master_prototype
879 type(symbolicelementvector) :: temp_prototype
880 real(wp),
allocatable :: alpha_coeffs(:,:), mat_coeffs(:)
882 allocate(matrix_index(num_states), stat = err)
883 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS4::MATRIX_INDEX')
885 allocate(alpha_coeffs(num_states,1), stat = err)
886 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS4::alpha_coeffs')
888 allocate(mat_coeffs(num_states), stat = err)
889 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS4::mat_coeffs')
892 num_continuum_orbitals = this % options % num_continuum_orbitals_target(i1)
894 num_configurations = this % options % num_ci_target_sym(i1)
897 starting_index = this % get_starting_index(i1)
899 do n1 = 1, num_states
902 call this % compute_matrix_ij(i1, n1, 1, 1, 1, 1, matrix_index(n1), j)
905 call master_prototype % construct(num_states, 1)
908 call temp_prototype % construct
910 call temp_prototype % clear
917 do ido = 1, num_configurations
923 config_idx_a = starting_index + (ido - 1) * this % csf_skip
926 call this % slater_rules(this % csfs(l1), this % csfs(config_idx_a), temp_prototype, 1, .false.)
928 if (temp_prototype % is_empty()) cycle
931 do n1 = 1, num_states
932 alpha_coeffs(n1,1) = this % get_target_coeff(i1, ido, n1)
935 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
936 call temp_prototype % clear
939 call temp_prototype % clear
942 config_idx_a = starting_index + (num_configurations - 1) * this % csf_skip
944 continuum_orbital = this % csfs(config_idx_a) % orbital_sequence_number
947 j = l1 + this % L2_mat_offset
962 do ido = 1, num_continuum_orbitals
967 call this % contr_expand_continuum_L2_eval(continuum_orbital, master_prototype, ido, mat_coeffs)
969 do n1 = 1, num_states
972 call matrix_elements % insert_matrix_element(j, matrix_index(n1) + ido - 1, mat_coeffs(n1), 8, 0.0_wp)
974 call matrix_elements % update_pure_L2(.false.)
979 call master_prototype % destroy
980 call temp_prototype % destroy
982 this % non_zero_prototype = this % non_zero_prototype + 1
984 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
985 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
986 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
988 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
1007 subroutine evaluate_class_5 (this, i1, num_target_1, i2, num_target_2, matrix_elements)
1008 class(contracted_hamiltonian) :: this
1009 class(basematrix),
intent(inout) :: matrix_elements
1010 integer,
intent(in) :: i1, i2, num_target_1, num_target_2
1015 type(contractedsymbolicelementvector) :: master_prototype
1017 integer,
allocatable :: matrix_index(:,:,:)
1018 real(wp),
allocatable :: alpha_coeffs(:,:)
1020 type(symbolicelementvector) :: temp_prototype
1022 integer :: config_idx_a,config_idx_b,n1,n2
1024 integer :: num_continuum_orbitals
1026 integer :: num_configurations_a,num_configurations_b,total_configurations
1028 integer :: loop_idx,my_idx,loop_skip,loop_ido
1030 integer :: ido,jdo,starting_index_a,starting_index_b,i,j,err
1032 integer :: continuum_orbital
1037 real(wp),
allocatable :: mat_coeffs(:,:)
1039 allocate(matrix_index(2, num_target_1, num_target_2), stat = err)
1040 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS5::MATRIX_INDEX')
1042 allocate(alpha_coeffs(num_target_1, num_target_2), stat = err)
1043 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS5::alpha_coeffs')
1045 allocate(mat_coeffs(num_target_1, num_target_2), stat = err)
1046 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS5::mat_coeffs')
1049 num_continuum_orbitals = min(this % options % num_continuum_orbitals_target(i1), &
1050 this % options % num_continuum_orbitals_target(i2))
1053 starting_index_a = this % get_starting_index(i1)
1056 starting_index_b = this % get_starting_index(i2)
1059 num_configurations_a = this % options % num_ci_target_sym(i1)
1062 num_configurations_b = this % options % num_ci_target_sym(i2)
1065 do n1 = 1, num_target_1
1066 do n2 = 1, num_target_2
1067 call this % compute_matrix_ij(i1, n1, 1, i2, n2, 1, matrix_index(1,n1,n2), matrix_index(2,n1,n2))
1070 call master_prototype % construct(num_target_1, num_target_2)
1073 call temp_prototype % construct
1074 call temp_prototype % clear
1079 total_configurations = compute_total_box(num_configurations_a, num_configurations_b)
1082 loop_skip = max(1, grid % lprocs)
1083 my_idx = max(grid % lrank, 0)
1085 call master_timer % start_timer(
"Class 5 prototype")
1091 do loop_ido = 1, total_configurations, loop_skip
1092 alpha_coeffs = 0.0_wp
1095 loop_idx = loop_ido + my_idx
1097 if (loop_idx > total_configurations) cycle
1099 call box_index_to_ij(loop_idx, num_configurations_a, ido, jdo)
1101 alpha_coeffs = 0.0_wp
1104 config_idx_a = starting_index_a + (ido - 1) * this % csf_skip
1105 config_idx_b = starting_index_b + (jdo - 1) * this % csf_skip
1108 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 1, .false.)
1110 if (temp_prototype % is_empty()) cycle
1119 do n1 = 1, num_target_1
1120 do n2 = 1, num_target_2
1121 alpha_coeffs(n1,n2) = this % get_target_coeff(i1,ido,n1) * this % get_target_coeff(i2,jdo,n2)
1125 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
1128 call temp_prototype % clear
1131 call master_timer % stop_timer(
"Class 5 prototype")
1132 call temp_prototype % destroy
1137 config_idx_a = starting_index_a + (num_configurations_a - 1) * this % csf_skip
1138 continuum_orbital = this % csfs(config_idx_a) % orbital_sequence_number
1149 call master_timer % start_timer(
"Class 5 Synchonize")
1152 call master_prototype % synchronize_symbols
1154 call master_timer % stop_timer(
"Class 5 Synchonize")
1157 loop_skip = max(1, grid % gprocs)
1158 my_idx = max(grid % grank, 0)
1161 do loop_ido = 1, num_continuum_orbitals, loop_skip
1163 ido = loop_ido + my_idx
1164 call matrix_elements % update_pure_L2(.false., num_target_1 * num_target_2)
1166 if (ido > num_continuum_orbitals) cycle
1168 call this % contr_expand_diagonal_eval(continuum_orbital, master_prototype, ido, mat_coeffs)
1170 do n1 = 1, num_target_1
1171 do n2 = 1, num_target_2
1174 call matrix_elements % insert_matrix_element(matrix_index(2,n1,n2) + ido - 1, &
1175 matrix_index(1,n1,n2) + ido - 1, mat_coeffs(n1,n2), 8)
1183 call master_prototype % destroy
1185 this % non_zero_prototype = this % non_zero_prototype + 1
1187 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
1188 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
1189 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
1191 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
1210 subroutine evaluate_class_6 (this, i1, num_target_1, i2, num_target_2, matrix_elements)
1211 class(contracted_hamiltonian) :: this
1212 integer,
intent(in) :: i1, i2, num_target_1, num_target_2
1213 class(basematrix),
intent(inout) :: matrix_elements
1218 type(contractedsymbolicelementvector) :: master_prototype
1221 integer,
allocatable :: matrix_index(:,:,:)
1222 real(wp),
allocatable :: alpha_coeffs(:,:)
1225 type(symbolicelementvector) :: temp_prototype
1228 integer :: config_idx_a, config_idx_b, n1, n2
1231 integer :: num_continuum_orbitals_a, num_continuum_orbitals_b
1234 integer :: num_configurations_a, num_configurations_b, total_configurations
1237 integer :: loop_idx, my_idx, loop_skip, loop_ido
1240 integer :: ido, jdo, starting_index_a, starting_index_b, i, j, err
1243 integer :: continuum_orbital_a, continuum_orbital_b, total_orbs
1247 real(wp),
allocatable :: mat_coeffs(:,:)
1249 allocate(matrix_index(2, num_target_1, num_target_2), stat = err)
1250 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS6::MATRIX_INDEX')
1252 allocate(alpha_coeffs(num_target_1, num_target_2), stat = err)
1253 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS6::alpha_coeffs')
1255 allocate(mat_coeffs(num_target_1, num_target_2), stat = err)
1256 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS6::mat_coeffs')
1259 num_continuum_orbitals_a = this % options % num_continuum_orbitals_target(i1)
1262 num_continuum_orbitals_b = this % options % num_continuum_orbitals_target(i2)
1265 starting_index_a = this % get_starting_index(i1)
1268 starting_index_b = this % get_starting_index(i2)
1271 num_configurations_a = this % options % num_ci_target_sym(i1)
1274 num_configurations_b = this % options % num_ci_target_sym(i2)
1277 do n1 = 1, num_target_1
1278 do n2 = 1, num_target_2
1279 call this % compute_matrix_ij(i1, n1, 1, i2, n2, 1, matrix_index(1,n1,n2), matrix_index(2,n1,n2))
1282 call master_prototype % construct(num_target_1, num_target_2)
1285 call temp_prototype % construct
1286 call temp_prototype % clear
1290 total_configurations = compute_total_box(num_configurations_a, num_configurations_b)
1293 loop_skip = max(1, grid % lprocs)
1294 my_idx = max(grid % lrank, 0)
1299 call master_timer % start_timer(
"Class 6 prototype")
1305 do loop_ido = 1, total_configurations, loop_skip
1306 alpha_coeffs = 0.0_wp
1309 loop_idx = loop_ido + my_idx
1311 if (loop_idx > total_configurations) cycle
1313 call box_index_to_ij(loop_idx, num_configurations_a, ido, jdo)
1316 config_idx_a = starting_index_a + (ido - 1) * this % csf_skip
1317 config_idx_b = starting_index_b + 1 + (jdo - 1) * this % csf_skip
1320 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 1, .false.)
1322 if (temp_prototype % is_empty()) cycle
1331 do n1 = 1, num_target_1
1332 do n2 = 1, num_target_2
1333 alpha_coeffs(n1,n2) = this % get_target_coeff(i1,ido,n1) * this % get_target_coeff(i2,jdo,n2)
1337 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
1340 call temp_prototype % clear
1343 call master_timer % stop_timer(
"Class 6 prototype")
1344 call temp_prototype % clear
1349 n1 = config_idx_a;
call mpi_reduceall_max(n1, config_idx_a, grid % lcomm)
1350 n2 = config_idx_b;
call mpi_reduceall_max(n2, config_idx_b, grid % lcomm)
1353 continuum_orbital_a = this % csfs(config_idx_a) % orbital_sequence_number
1354 continuum_orbital_b = this % csfs(config_idx_b) % orbital_sequence_number
1356 call master_timer % start_timer(
"Class 6 Synchonize")
1359 call master_prototype % synchronize_symbols
1360 call master_timer % stop_timer(
"Class 6 Synchonize")
1362 total_orbs = compute_total_box(num_continuum_orbitals_a, num_continuum_orbitals_b)
1365 loop_skip = max(1, grid % gprocs)
1366 my_idx = max(grid % grank, 0)
1369 do loop_ido = 1, total_orbs, loop_skip
1372 loop_idx = loop_ido + my_idx
1373 call matrix_elements%update_pure_L2(.false.,num_target_1*num_target_2)
1376 if(loop_idx > total_orbs) cycle
1379 call box_index_to_ij(loop_idx,num_continuum_orbitals_a,ido,jdo)
1380 if (ido == jdo) cycle
1384 call this % contr_expand_off_diagonal_eval (continuum_orbital_a, continuum_orbital_b, &
1385 master_prototype, ido, jdo, mat_coeffs)
1386 do n1 = 1, num_target_1
1388 do n2 = 1, num_target_2
1390 call matrix_elements % insert_matrix_element (matrix_index(2,n1,n2) + jdo - 1, &
1391 matrix_index(1,n1,n2) + ido - 1, &
1392 mat_coeffs(n1,n2), 8)
1400 call master_prototype % destroy
1401 call temp_prototype % destroy
1403 this % non_zero_prototype = this % non_zero_prototype + 1
1405 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
1406 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
1407 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
1409 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
1427 subroutine evaluate_class_7 (this, i1, num_target_1, i2, num_target_2, matrix_elements)
1428 class(contracted_hamiltonian) :: this
1429 integer,
intent(in) :: i1, i2, num_target_1, num_target_2
1430 class(basematrix),
intent(inout) :: matrix_elements
1435 type(contractedsymbolicelementvector) :: master_prototype
1438 integer,
allocatable :: matrix_index(:,:,:)
1439 real(wp),
allocatable :: alpha_coeffs(:,:)
1442 type(symbolicelementvector) :: temp_prototype
1445 integer :: config_idx_a, config_idx_b, n1, n2
1448 integer :: num_continuum_orbitals_a, num_continuum_orbitals_b
1451 integer :: num_configurations_a, num_configurations_b, total_configurations
1454 integer :: loop_idx, my_idx, loop_skip, loop_ido
1457 integer :: ido, jdo, starting_index_a, starting_index_b, i, j, err
1460 integer :: continuum_orbital_a, continuum_orbital_b, total_orbs
1464 real(wp),
allocatable :: mat_coeffs(:,:)
1466 allocate(matrix_index(2,num_target_1,num_target_2), stat = err)
1467 call master_memory % track_memory(storage_size(matrix_index)/8,
size(matrix_index), err,
'CLASS7::MATRIX_INDEX')
1469 allocate(alpha_coeffs(num_target_1,num_target_2), stat = err)
1470 call master_memory % track_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs), err,
'CLASS7::alpha_coeffs')
1472 allocate(mat_coeffs(num_target_1,num_target_2), stat = err)
1473 call master_memory % track_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs), err,
'CLASS7::mat_coeffs')
1479 num_continuum_orbitals_a = this % options % num_continuum_orbitals_target(i1)
1481 num_continuum_orbitals_b = this % options % num_continuum_orbitals_target(i2)
1484 starting_index_a = this % get_starting_index(i1)
1486 starting_index_b = this % get_starting_index(i2)
1489 num_configurations_a = this % options % num_ci_target_sym(i1)
1491 num_configurations_b = this % options % num_ci_target_sym(i2)
1494 do n1 = 1, num_target_1
1495 do n2= 1, num_target_2
1496 call this % compute_matrix_ij(i1, n1, 1, i2, n2, 1, matrix_index(1,n1,n2), matrix_index(2,n1,n2))
1500 call master_prototype % construct(num_target_1, num_target_2)
1503 call temp_prototype % construct
1504 call temp_prototype % clear
1508 total_configurations = compute_total_box(num_configurations_a, num_configurations_b)
1511 loop_skip = max(1, grid % lprocs)
1512 my_idx = max(grid % lrank, 0)
1514 call master_timer % start_timer(
"Class 7 prototype")
1520 do loop_ido = 1, total_configurations, loop_skip
1521 alpha_coeffs = 0.0_wp
1524 loop_idx = loop_ido + my_idx
1526 if (loop_idx > total_configurations) cycle
1528 call box_index_to_ij(loop_idx, num_configurations_a, ido, jdo)
1531 config_idx_a = starting_index_a + (ido - 1) * this % csf_skip
1532 config_idx_b = starting_index_b + (jdo - 1) * this % csf_skip
1535 call this % slater_rules(this % csfs(config_idx_b), this % csfs(config_idx_a), temp_prototype, 1, .false.)
1538 if (temp_prototype % is_empty()) cycle
1548 do n1 = 1, num_target_1
1549 do n2 = 1, num_target_2
1550 alpha_coeffs(n1,n2) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i2, jdo, n2)
1554 call master_prototype % add_symbols(temp_prototype, alpha_coeffs)
1557 call temp_prototype % clear
1560 call master_timer % stop_timer(
"Class 7 prototype")
1561 call temp_prototype % clear
1566 n1 = config_idx_a;
call mpi_reduceall_max(n1, config_idx_a, grid % lcomm)
1567 n2 = config_idx_b;
call mpi_reduceall_max(n2, config_idx_b, grid % lcomm)
1570 continuum_orbital_a = this % csfs(config_idx_a) % orbital_sequence_number
1571 continuum_orbital_b = this % csfs(config_idx_b) % orbital_sequence_number
1573 call master_timer % start_timer(
"Class 7 Synchonize")
1574 call master_prototype % synchronize_symbols
1575 call master_timer % stop_timer(
"Class 7 Synchonize")
1577 total_orbs = compute_total_box(num_continuum_orbitals_a, num_continuum_orbitals_b)
1580 loop_skip = max(1, grid % gprocs)
1581 my_idx = max(grid % grank, 0)
1583 call master_timer % start_timer(
"Class 7 expansion")
1586 do loop_ido = 1, total_orbs, loop_skip
1589 loop_idx = loop_ido + my_idx
1590 call matrix_elements % update_pure_L2(.false., num_target_1 * num_target_2)
1592 if (loop_idx > total_orbs) cycle
1594 call box_index_to_ij(loop_idx, num_continuum_orbitals_a, ido, jdo)
1597 call this % expand_off_diagonal_gen_eval(continuum_orbital_a, continuum_orbital_b, master_prototype, &
1598 ido, jdo, mat_coeffs)
1600 do n1 = 1, num_target_1
1602 do n2 = 1, num_target_2
1604 call matrix_elements % insert_matrix_element(matrix_index(2,n1,n2) + jdo - 1, &
1605 matrix_index(1,n1,n2) + ido - 1, &
1606 mat_coeffs(n1,n2), 8)
1612 call master_timer % stop_timer(
"Class 7 expansion")
1615 call temp_prototype % destroy
1616 call master_prototype % destroy
1618 this % non_zero_prototype = this % non_zero_prototype + 1
1620 call master_memory % free_memory(storage_size(matrix_index)/8,
size(matrix_index))
1621 call master_memory % free_memory(storage_size(alpha_coeffs)/8,
size(alpha_coeffs))
1622 call master_memory % free_memory(storage_size(mat_coeffs)/8,
size(mat_coeffs))
1624 deallocate(matrix_index, alpha_coeffs, mat_coeffs)
1638 subroutine evaluate_class_8 (this, matrix_elements)
1639 class(contracted_hamiltonian) :: this
1640 class(basematrix),
intent(inout) :: matrix_elements
1642 type(symbolicelementvector) :: symbolic_elements
1644 real(wp) :: mat_coeff
1645 integer :: loop_ido, my_idx, loop_skip
1648 call symbolic_elements % construct
1650 my_idx = max(1, grid % grank)
1651 loop_skip = max(1, grid % gprocs)
1654 do loop_ido = this % start_L2, this % total_num_csf - 1, loop_skip
1655 l1 = loop_ido + my_idx
1656 call matrix_elements % update_pure_L2(.false.)
1659 do l2 = this % start_L2, l1 - 1
1662 if (l1 > this % total_num_csf - 1)
exit
1665 call this % slater_rules(this % csfs(l1), this % csfs(l2), symbolic_elements, 1, .false.)
1667 if (symbolic_elements % is_empty()) cycle
1669 mat_coeff = this % evaluate_integrals(symbolic_elements,
normal_phase)
1671 call matrix_elements % insert_matrix_element(l2 + this % L2_mat_offset, l1 + this % L2_mat_offset, mat_coeff, 8)
1673 call symbolic_elements % clear
1675 this % non_zero_prototype = this % non_zero_prototype + 1
1680 call symbolic_elements % destroy
1696 subroutine evaluate_class_2_and_8 (this, matrix_elements)
1697 class(contracted_hamiltonian) :: this
1698 class(basematrix),
intent(inout) :: matrix_elements
1701 type(symbolicelementvector) :: symbolic_elements
1702 real(wp) :: mat_coeff
1703 integer :: loop_idx, ido
1704 integer :: total_vals
1705 integer :: loop_skip, my_idx
1709 call symbolic_elements % construct
1710 trig_n = this % num_L2_functions
1711 total_vals = compute_total_box(trig_n, trig_n)
1713 this % diagonal_flag = 0
1716 loop_skip = max(1, grid % gprocs)
1717 my_idx= max(grid % grank, 0)
1719 write (stdout,
"('start,total: ',2i12)") this % start_L2, total_vals
1724 do ido = 1, total_vals, loop_skip
1727 call matrix_elements % update_pure_L2(.false.)
1728 call symbolic_elements % clear
1731 loop_idx = ido + my_idx
1733 if (loop_idx > total_vals) cycle
1735 call box_index_to_ij(loop_idx, trig_n, l1, l2)
1738 l1 = l1 + this % start_L2 - 1
1739 l2 = l2 + this % start_L2 - 1
1742 if ((l2 + this % L2_mat_offset) < (l1 + this % L2_mat_offset)) cycle
1745 if (l1 > this % total_num_csf .or. l2 > this % total_num_csf) cycle
1746 if (l1 < this % start_L2 .or. l2 < this % start_L2 ) cycle
1752 if (l1 == l2) diag = 0
1755 call this % slater_rules(this % csfs(l1), this % csfs(l2), symbolic_elements, diag, .false.)
1757 if (symbolic_elements % is_empty()) cycle
1759 mat_coeff = this % evaluate_integrals(symbolic_elements,
normal_phase)
1765 call matrix_elements % insert_matrix_element(l2 + this % L2_mat_offset, l1 + this % L2_mat_offset, mat_coeff, 8)
1768 this % non_zero_prototype = this % non_zero_prototype + 1
1773 call symbolic_elements % destroy
1828 subroutine expand_diagonal (this, continuum_orbital, master_prototype, j1, expanded_prototype)
1829 class(contracted_hamiltonian) :: this
1830 class(symbolicelementvector),
intent(in) :: master_prototype, expanded_prototype
1831 integer,
intent(in) :: continuum_orbital, j1
1833 integer(longint) :: integral(NIDX)
1834 real(wp) :: integral_coeff
1835 integer :: lwd(8), lw1, lw2, ido, i, num_integrals
1837 num_integrals = master_prototype % get_size()
1839 do ido = 1, num_integrals
1842 call master_prototype % get_coeff_and_integral(ido, integral_coeff, integral)
1843 call unpack_ints(integral, lwd)
1849 if (lwd(i) == continuum_orbital)
then
1859 call expanded_prototype % insert_symbol(integral, integral_coeff, .false.)
1861 else if (lw2 == 0)
then
1862 lwd(lw1) = continuum_orbital + j1 - 1
1864 lwd(lw1) = continuum_orbital + j1 - 1
1865 lwd(lw2) = continuum_orbital + j1 - 1
1868 call expanded_prototype % insert_ijklm_symbol(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), integral_coeff, .false.)
1875 subroutine expand_off_diagonal (this, continuum_orbital_a, continuum_orbital_b, master_prototype, ja, jb, expanded_prototype)
1876 class(contracted_hamiltonian) :: this
1877 class(symbolicelementvector),
intent(in) :: master_prototype, expanded_prototype
1878 integer,
intent(in) :: continuum_orbital_a, continuum_orbital_b, ja, jb
1880 integer(longint) :: integral(NIDX)
1881 real(wp) :: integral_coeff
1882 integer :: lwd(8), lwa, lwb, ido, i, num_integrals
1884 num_integrals = master_prototype % get_size()
1886 do ido = 1, num_integrals
1889 call master_prototype % get_coeff_and_integral(ido, integral_coeff, integral)
1890 call unpack_ints(integral, lwd)
1896 if (lwd(i) == continuum_orbital_a) lwa = i
1897 if (lwd(i) == continuum_orbital_b) lwb = i
1901 if (max(lwa, lwb) == 0)
then
1902 call expanded_prototype % insert_symbol(integral, integral_coeff, .false.)
1904 else if (lwb == 0)
then
1905 lwd(lwa) = continuum_orbital_a + ja - 1
1906 else if (lwa == 0)
then
1907 lwd(lwb) = continuum_orbital_b + jb - 2
1909 lwd(lwa) = continuum_orbital_a + ja - 1
1910 lwd(lwb) = continuum_orbital_b + jb - 2
1915 call expanded_prototype % insert_ijklm_symbol(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), integral_coeff, .false.)
1961 subroutine expand_off_diagonal_general (this, continuum_orbital_a, continuum_orbital_b, master_prototype, &
1962 ja, jb, expanded_prototype)
1963 class(contracted_hamiltonian) :: this
1964 class(symbolicelementvector),
intent(in) :: master_prototype, expanded_prototype
1965 integer,
intent(in) :: continuum_orbital_a, continuum_orbital_b, ja, jb
1967 integer(longint) :: integral(NIDX)
1968 real(wp) :: integral_coeff
1969 integer :: lwd(8), lwa, lwb, ido, i, num_integrals
1971 num_integrals = master_prototype % get_size()
1973 do ido = 1, num_integrals
1976 call master_prototype % get_coeff_and_integral(ido, integral_coeff, integral)
1977 call unpack_ints(integral, lwd)
1983 if (lwd(i) == continuum_orbital_a) lwa = i
1984 if (lwd(i) == continuum_orbital_b) lwb = i
1988 if (max(lwa, lwb) == 0)
then
1989 call expanded_prototype % insert_symbol(integral, integral_coeff, .false.)
1991 else if(lwb == 0)
then
1992 lwd(lwa) = continuum_orbital_a + ja - 1
1993 else if (lwa == 0)
then
1994 lwd(lwb) = continuum_orbital_b + jb - 1
1996 lwd(lwa) = continuum_orbital_a + ja - 1
1997 lwd(lwb) = continuum_orbital_b + jb - 1
2001 call expanded_prototype % insert_ijklm_symbol(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), integral_coeff, .false.)
2020 subroutine expand_diagonal_eval (this, continuum_orbital, master_prototype, j1, mat_coeffs)
2021 class(contracted_hamiltonian) :: this
2022 integer,
intent(in) :: continuum_orbital, j1
2023 type(symbolicelementvector),
intent(in) :: master_prototype(:)
2024 real(wp),
intent(out) :: mat_coeffs(:)
2026 integer(longint) :: integral(NIDX)
2027 real(wp) :: integral_coeff
2028 integer :: lwd(8), lw1, lw2, ido, i, prototypes, num_prototypes, num_integrals
2030 num_prototypes =
size(master_prototype)
2031 num_integrals = master_prototype(1) % get_size()
2034 if (num_integrals == 0)
return
2036 do ido = 1, num_integrals
2039 call master_prototype(1) % get_coeff_and_integral(ido, integral_coeff, integral)
2040 call unpack_ints(integral, lwd)
2042 integral_coeff = 1.0_wp
2048 if (lwd(i) == continuum_orbital)
then
2058 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2059 do prototypes = 1, num_prototypes
2060 mat_coeffs(prototypes) = mat_coeffs(prototypes) &
2061 + master_prototype(prototypes) % get_coefficient(ido) * integral_coeff
2064 else if (lw2 == 0)
then
2065 lwd(lw1) = continuum_orbital + j1 - 1
2067 lwd(lw1) = continuum_orbital + j1 - 1
2068 lwd(lw2) = continuum_orbital + j1 - 1
2071 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2072 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2074 do prototypes = 1, num_prototypes
2075 mat_coeffs(prototypes) = mat_coeffs(prototypes) + master_prototype(prototypes)%get_coefficient(ido) * integral_coeff
2093 subroutine contr_expand_diagonal_eval (this, continuum_orbital, master_prototype, j1, mat_coeffs)
2094 class(contracted_hamiltonian) :: this
2095 type(contractedsymbolicelementvector),
intent(in) :: master_prototype
2096 integer,
intent(in) :: continuum_orbital, j1
2097 real(wp),
intent(out) :: mat_coeffs(:,:)
2099 integer(longint) :: integral(NIDX)
2100 real(wp) :: integral_coeff
2102 integer :: lwd(8), lw1, lw2, ido, i, prototypes, num_prototypes, num_integrals, num_targets_1, num_targets_2, n1, n2
2104 num_integrals = master_prototype % get_size()
2105 num_targets_1 = master_prototype % get_num_targets_sym1()
2106 num_targets_2 = master_prototype % get_num_targets_sym2()
2109 if (num_integrals == 0)
return
2111 do ido = 1, num_integrals
2114 integral = master_prototype % get_integral_label(ido)
2115 call unpack_ints(integral, lwd)
2117 integral_coeff = 1.0_wp
2122 if (lwd(i) == continuum_orbital)
then
2132 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2133 do n1 = 1,num_targets_1
2134 do n2 = 1,num_targets_2
2135 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2139 else if (lw2 == 0)
then
2140 lwd(lw1) = continuum_orbital + j1 - 1
2142 lwd(lw1) = continuum_orbital + j1 - 1
2143 lwd(lw2) = continuum_orbital + j1 - 1
2146 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2147 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2149 do n1 = 1,num_targets_1
2150 do n2 = 1,num_targets_2
2151 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2170 subroutine expand_continuum_l2_eval (this, continuum_orbital, master_prototype, j1, mat_coeffs)
2171 class(contracted_hamiltonian) :: this
2172 class(symbolicelementvector),
intent(in) :: master_prototype(:)
2173 integer,
intent(in) :: continuum_orbital, j1
2174 real(wp),
intent(out) :: mat_coeffs(:)
2176 integer(longint) :: integral(NIDX)
2177 real(wp) :: integral_coeff
2178 integer :: lwd(8), lw, ido, i, prototypes, num_prototypes, num_integrals
2180 num_prototypes =
size(master_prototype)
2181 num_integrals = master_prototype(1) % get_size()
2185 if (num_integrals == 0)
return
2187 do ido = 1, num_integrals
2190 call master_prototype(1) % get_coeff_and_integral(ido, integral_coeff, integral)
2191 call unpack_ints(integral, lwd)
2193 integral_coeff = 1.0_wp
2197 if (lwd(i) == continuum_orbital) lw = i
2201 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2202 do prototypes = 1, num_prototypes
2203 mat_coeffs(prototypes) = mat_coeffs(prototypes) &
2204 + master_prototype(prototypes) % get_coefficient(ido) * integral_coeff
2207 lwd(lw) = continuum_orbital + j1 - 1
2210 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2212 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2214 do prototypes = 1, num_prototypes
2215 mat_coeffs(prototypes) = mat_coeffs(prototypes) + master_prototype(prototypes)%get_coefficient(ido) * integral_coeff
2233 subroutine contr_expand_continuum_l2_eval (this, continuum_orbital, master_prototype, j1, mat_coeffs)
2234 class(contracted_hamiltonian) :: this
2235 class(contractedsymbolicelementvector),
intent(in) :: master_prototype
2236 integer,
intent(in) :: continuum_orbital, j1
2237 real(wp),
intent(out) :: mat_coeffs(:)
2239 integer(longint) :: integral(NIDX)
2240 real(wp) :: integral_coeff
2241 integer :: lwd(8), lw, ido, i, num_targets_1, num_targets_2, n1, n2, num_integrals
2243 num_targets_1 = master_prototype % get_num_targets_sym1()
2244 num_integrals = master_prototype % get_size()
2247 if (num_integrals == 0)
return
2249 do ido = 1, num_integrals
2252 integral = master_prototype % get_integral_label(ido)
2253 call unpack_ints(integral, lwd)
2255 integral_coeff = 1.0_wp
2260 if (lwd(i) == continuum_orbital) lw = i
2264 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2265 do n1 = 1, num_targets_1
2266 mat_coeffs(n1) = mat_coeffs(n1) + master_prototype % get_coefficient(ido, n1, 1) * integral_coeff
2270 lwd(lw) = continuum_orbital + j1 - 1
2273 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2275 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2277 do n1 = 1, num_targets_1
2278 mat_coeffs(n1) = mat_coeffs(n1) + master_prototype % get_coefficient(ido, n1, 1) * integral_coeff
2298 subroutine expand_off_diagonal_eval (this, continuum_orbital_a, continuum_orbital_b, master_prototype, ja, jb, mat_coeffs)
2299 class(contracted_hamiltonian) :: this
2300 class(symbolicelementvector),
intent(in) :: master_prototype(:)
2301 integer,
intent(in) :: continuum_orbital_a, continuum_orbital_b, ja, jb
2302 real(wp),
intent(out) :: mat_coeffs(:)
2304 integer(longint) :: integral(NIDX)
2305 real(wp) :: integral_coeff
2306 integer :: lwd(8), lwa, lwb, ido, i, prototypes, num_prototypes, num_integrals
2308 num_prototypes =
size(master_prototype)
2309 num_integrals = master_prototype(1) % get_size()
2312 if (num_integrals == 0)
return
2314 do ido = 1, num_integrals
2317 call master_prototype(1) % get_coeff_and_integral(ido, integral_coeff, integral)
2318 call unpack_ints(integral, lwd)
2320 integral_coeff = 1.0_wp
2326 if (lwd(i) == continuum_orbital_a) lwa = i
2327 if (lwd(i) == continuum_orbital_b) lwb = i
2331 if (max(lwa, lwb) == 0)
then
2332 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2334 do prototypes = 1,num_prototypes
2335 mat_coeffs(prototypes) = mat_coeffs(prototypes) &
2336 + master_prototype(prototypes) % get_coefficient(ido) * integral_coeff
2340 else if (lwb == 0)
then
2341 lwd(lwa) = continuum_orbital_a + ja - 1
2342 else if (lwa == 0)
then
2343 lwd(lwb) = continuum_orbital_b + jb - 2
2345 lwd(lwa) = continuum_orbital_a + ja - 1
2346 lwd(lwb) = continuum_orbital_b + jb - 2
2349 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2351 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2353 do prototypes = 1,num_prototypes
2354 mat_coeffs(prototypes) = mat_coeffs(prototypes) + master_prototype(prototypes)%get_coefficient(ido) * integral_coeff
2374 subroutine contr_expand_off_diagonal_eval (this, continuum_orbital_a, continuum_orbital_b, master_prototype, ja, jb, mat_coeffs)
2375 class(contracted_hamiltonian) :: this
2376 class(contractedsymbolicelementvector),
intent(in) :: master_prototype
2377 integer,
intent(in) :: continuum_orbital_a, continuum_orbital_b, ja, jb
2378 real(wp),
intent(out) :: mat_coeffs(:,:)
2380 integer(longint) :: integral(NIDX)
2381 real(wp) :: integral_coeff
2383 integer :: lwd(8), lwa, lwb, ido, i, prototypes, num_prototypes, num_integrals, num_targets_1, num_targets_2, n1, n2
2386 num_integrals = master_prototype % get_size()
2387 num_targets_1 = master_prototype % get_num_targets_sym1()
2388 num_targets_2 = master_prototype % get_num_targets_sym2()
2391 if (num_integrals == 0)
return
2393 do ido = 1, num_integrals
2396 integral = master_prototype % get_integral_label(ido)
2397 call unpack_ints(integral, lwd)
2399 integral_coeff = 1.0_wp
2405 if (lwd(i) == continuum_orbital_a) lwa = i
2406 if (lwd(i) == continuum_orbital_b) lwb = i
2410 if (max(lwa, lwb) == 0)
then
2411 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2413 do n1 = 1, num_targets_1
2414 do n2 = 1, num_targets_2
2415 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2420 else if (lwb == 0)
then
2421 lwd(lwa) = continuum_orbital_a + ja - 1
2422 else if (lwa == 0)
then
2423 lwd(lwb) = continuum_orbital_b + jb - 2
2425 lwd(lwa) = continuum_orbital_a + ja - 1
2426 lwd(lwb) = continuum_orbital_b + jb - 2
2429 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2431 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2433 do n1 = 1, num_targets_1
2434 do n2 = 1, num_targets_2
2435 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2456 subroutine expand_off_diagonal_gen_eval (this, continuum_orbital_a, continuum_orbital_b, master_prototype, ja, jb, mat_coeffs)
2457 class(contracted_hamiltonian) :: this
2458 class(contractedsymbolicelementvector),
intent(in) :: master_prototype
2459 integer,
intent(in) :: continuum_orbital_a, continuum_orbital_b, ja, jb
2460 real(wp),
intent(out) :: mat_coeffs(:,:)
2462 integer(longint) :: integral(NIDX)
2463 real(wp) :: integral_coeff
2464 integer :: lwd(8), lwa, lwb, ido, i, n1, n2, num_targets_1, num_targets_2, ii, num_integrals
2466 num_targets_1 = master_prototype % get_num_targets_sym1()
2467 num_targets_2 = master_prototype % get_num_targets_sym2()
2468 num_integrals = master_prototype % get_size()
2471 if (num_integrals == 0)
return
2473 do ido = 1, num_integrals
2476 integral = master_prototype % get_integral_label(ido)
2477 call unpack_ints(integral, lwd)
2479 integral_coeff = 1.0_wp
2485 if (lwd(i) == continuum_orbital_a) lwa = i
2486 if (lwd(i) == continuum_orbital_b) lwb = i
2490 if (max(lwa, lwb) == 0)
then
2491 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2492 do n1 = 1,num_targets_1
2493 do n2 = 1,num_targets_2
2494 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2498 else if(lwb == 0)
then
2499 lwd(lwa) = continuum_orbital_a + ja - 1
2500 else if (lwa == 0)
then
2501 lwd(lwb) = continuum_orbital_b + jb - 1
2503 lwd(lwa) = continuum_orbital_a + ja - 1
2504 lwd(lwb) = continuum_orbital_b + jb - 1
2507 call pack_ints(lwd(1), lwd(2), lwd(3), lwd(4), lwd(5), 0, 0, 0, integral)
2509 integral_coeff = this % evaluate_integrals_singular(integral, 1.0_wp,
normal_phase)
2511 do n1 = 1, num_targets_1
2512 do n2 = 1, num_targets_2
2513 mat_coeffs(n1,n2) = mat_coeffs(n1,n2) + master_prototype % get_coefficient(ido, n1, n2) * integral_coeff
2592 subroutine fast_contract_class_1_3_diag (this, i1, num_targets, ido, temp_prototype, master_prototypes)
2593 class(contracted_hamiltonian) :: this
2594 integer,
intent(in) :: i1, ido, num_targets
2595 class(symbolicelementvector),
intent(in) :: temp_prototype, master_prototypes(num_targets * (num_targets + 1) / 2)
2597 integer(longint) :: label(NIDX)
2599 integer :: found_idx, ii, n1, n2, num_symbols, jdo
2600 real(wp) :: alpha(num_targets * (num_targets + 1) / 2), coeff
2605 do n1 = 1, num_targets
2606 do n2 = n1, num_targets
2608 alpha(ii) = this % get_target_coeff(i1, ido, n1) * this % get_target_coeff(i1, ido, n2)
2614 num_symbols = temp_prototype % get_size()
2616 do jdo = 1, num_symbols
2617 call temp_prototype % get_coeff_and_integral(jdo, coeff, label)
2619 if (master_prototypes(1) % check_same_integral(label, found_idx))
then
2622 do n1 = 1, num_targets
2623 do n2 = n1, num_targets
2624 call master_prototypes(ii) % modify_coeff(found_idx, alpha(ii) * coeff)
2631 do n1 = 1, num_targets
2632 do n2 = n1, num_targets
2634 call master_prototypes(ii) % insert_symbol(label, alpha(ii) * coeff, .false.)
2644 subroutine fast_contract_class_1_3_offdiag (this, i1, num_targets, s1, s2, temp_prototype, master_prototypes)
2645 class(contracted_hamiltonian) :: this
2646 integer,
intent(in) :: i1, s1, s2, num_targets
2647 class(symbolicelementvector),
intent(in) :: temp_prototype, master_prototypes(num_targets * (num_targets + 1) / 2)
2649 integer(longint) :: label(NIDX)
2651 integer :: found_idx, ii, n1, n2, num_symbols, jdo
2652 real(wp) :: alpha(num_targets * (num_targets + 1) / 2), coeff
2657 do n1 = 1, num_targets
2658 do n2 = n1, num_targets
2660 alpha(ii) = this % get_target_coeff(i1, s1, n1) * this % get_target_coeff(i1, s2, n2) &
2661 + this % get_target_coeff(i1, s2, n1) * this % get_target_coeff(i1, s1, n2)
2667 num_symbols = temp_prototype % get_size()
2669 do jdo = 1, num_symbols
2670 call temp_prototype % get_coeff_and_integral(jdo, coeff, label)
2672 if (master_prototypes(1) % check_same_integral(label, found_idx))
then
2675 do n1 = 1, num_targets
2676 do n2 = n1, num_targets
2677 call master_prototypes(ii) % modify_coeff(found_idx, alpha(ii) * coeff)
2684 do n1 = 1, num_targets
2685 do n2 = n1, num_targets
2687 call master_prototypes(ii) % insert_symbol(label, alpha(ii) * coeff, .false.)
2697 subroutine fast_contract_class_567 (this, i1, i2, num_targets1, num_targets2, s1, s2, temp_prototype, master_prototypes)
2698 class(contracted_hamiltonian) :: this
2699 integer,
intent(in) :: i1, i2, s1, s2, num_targets1, num_targets2
2700 class(symbolicelementvector),
intent(in) :: temp_prototype, master_prototypes(num_targets1, num_targets2)
2702 integer(longint) :: label(NIDX)
2704 integer :: found_idx, ii, n1, n2, num_symbols, jdo
2705 real(wp) :: alpha(num_targets1, num_targets2), coeff
2709 do n1 = 1, num_targets1
2710 do n2 = 1, num_targets2
2712 alpha(n1,n2) = this % get_target_coeff(i1, s1, n1) * this % get_target_coeff(i2, s2, n2)
2717 num_symbols = temp_prototype % get_size()
2719 do jdo = 1, num_symbols
2720 call temp_prototype % get_coeff_and_integral(jdo, coeff, label)
2722 if (master_prototypes(1,1) % check_same_integral(label, found_idx))
then
2724 do n1 = 1, num_targets1
2725 do n2 = 1, num_targets2
2726 call master_prototypes(n1,n2) % modify_coeff(found_idx, alpha(n1,n2) * coeff)
2731 do n1 = 1, num_targets1
2732 do n2 = 1, num_targets2
2734 call master_prototypes(n1,n2) % insert_symbol(label, alpha(n1,n2) * coeff, .false.)