49 dbt_contract, dbt_copy, dbt_copy_matrix_to_tensor, dbt_create, dbt_default_distvec, &
50 dbt_destroy, dbt_distribution_destroy, dbt_distribution_new, dbt_distribution_type, &
51 dbt_finalize, dbt_get_block, dbt_get_info, dbt_iterator_blocks_left, &
52 dbt_iterator_next_block, dbt_iterator_start, dbt_iterator_stop, dbt_iterator_type, &
53 dbt_pgrid_create, dbt_pgrid_destroy, dbt_pgrid_type, dbt_put_block, dbt_type
83#include "./base/base_uses.f90"
88 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xas_tdp_correction'
102 SUBROUTINE gw2x_shift(donor_state, xas_tdp_env, xas_tdp_control, qs_env)
109 CHARACTER(len=*),
PARAMETER :: routinen =
'GW2X_shift'
111 INTEGER :: ex_idx, exat, first_domo(2), handle, i, ido_mo, iloc, ilocat, ispin, jspin, &
112 locat, nao, natom, ndo_mo, nhomo(2), nlumo(2), nonloc, nspins, start_sgf
113 INTEGER,
DIMENSION(:),
POINTER :: nsgf_blk
114 LOGICAL :: pseudo_canonical
115 REAL(
dp) :: og_hfx_frac
116 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: contract_coeffs_backup
118 TYPE(
cp_1d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: homo_evals, lumo_evals
121 DIMENSION(:) :: all_struct, homo_struct, lumo_struct
123 TYPE(
cp_fm_type) :: hoho_fock, hoho_work, homo_work, &
124 lulu_fock, lulu_work, lumo_work
125 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: all_coeffs, homo_coeffs, lumo_coeffs
127 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dbcsr_work, fock_matrix, matrix_ks
128 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: ja_x, oi_y
129 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: mo_template
135 NULLIFY (xc_fun_empty, xc_fun_original, xc_section, mos, dft_control, dbcsr_work, &
136 fock_matrix, matrix_ks, para_env, mo_coeff, blacs_env, nsgf_blk)
141 CALL timeset(routinen, handle)
158 pseudo_canonical = xas_tdp_control%pseudo_canonical
161 ndo_mo = donor_state%ndo_mo
162 nspins = 1;
IF (xas_tdp_control%do_uks .OR. xas_tdp_control%do_roks) nspins = 2
166 CALL get_qs_env(qs_env, matrix_ks=matrix_ks, mos=mos, para_env=para_env, &
167 blacs_env=blacs_env, natom=natom)
169 ALLOCATE (lumo_struct(nspins), lumo_coeffs(nspins))
172 CALL get_mo_set(mos(ispin), homo=nhomo(ispin), nao=nao)
173 nlumo(ispin) = nao - nhomo(ispin)
175 CALL cp_fm_struct_create(lumo_struct(ispin)%struct, para_env=para_env, context=blacs_env, &
176 ncol_global=nlumo(ispin), nrow_global=nao)
178 CALL cp_fm_create(lumo_coeffs(ispin), lumo_struct(ispin)%struct)
179 CALL cp_fm_to_fm(xas_tdp_env%lumo_evecs(ispin), lumo_coeffs(ispin))
184 ALLOCATE (homo_struct(nspins), homo_coeffs(nspins))
187 nonloc = nhomo(ispin) - xas_tdp_control%n_search
188 exat = donor_state%at_index
189 ex_idx = minloc(abs(xas_tdp_env%ex_atom_indices - exat), 1)
190 locat = count(xas_tdp_env%mos_of_ex_atoms(:, ex_idx, ispin) == 1)
192 CALL cp_fm_struct_create(homo_struct(ispin)%struct, para_env=para_env, context=blacs_env, &
193 ncol_global=locat + nonloc, nrow_global=nao)
194 CALL cp_fm_create(homo_coeffs(ispin), homo_struct(ispin)%struct)
196 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
197 CALL cp_fm_to_fm_submat(mo_coeff, homo_coeffs(ispin), nrow=nao, ncol=nonloc, s_firstrow=1, &
198 s_firstcol=xas_tdp_control%n_search + 1, t_firstrow=1, t_firstcol=locat + 1)
202 DO iloc = 1, xas_tdp_control%n_search
203 IF (xas_tdp_env%mos_of_ex_atoms(iloc, ex_idx, ispin) == -1) cycle
204 CALL cp_fm_to_fm_submat(mo_coeff, homo_coeffs(ispin), nrow=nao, ncol=1, s_firstrow=1, &
205 s_firstcol=iloc, t_firstrow=1, t_firstcol=ilocat)
207 IF (iloc == donor_state%mo_indices(1, ispin)) first_domo(ispin) = ilocat
211 nhomo(ispin) = locat + nonloc
215 IF (
ASSOCIATED(xas_tdp_env%fock_matrix))
THEN
216 fock_matrix => xas_tdp_env%fock_matrix
219 TYPE(
mo_set_type),
DIMENSION(:),
ALLOCATABLE :: backup_mos
221 ALLOCATE (xas_tdp_env%fock_matrix(nspins))
222 fock_matrix => xas_tdp_env%fock_matrix
231 og_hfx_frac = qs_env%x_data(1, 1)%general_parameter%fraction
232 qs_env%x_data(:, :)%general_parameter%fraction = 1.0_dp
236 CALL get_qs_env(qs_env, dft_control=dft_control, admm_env=admm_env)
237 IF (dft_control%do_admm)
THEN
238 IF (
ASSOCIATED(admm_env%xc_section_primary))
CALL section_vals_release(admm_env%xc_section_primary)
242 ALLOCATE (backup_mos(
SIZE(mos)))
248 ALLOCATE (dbcsr_work(nspins))
250 ALLOCATE (dbcsr_work(ispin)%matrix)
251 CALL dbcsr_copy(dbcsr_work(ispin)%matrix, matrix_ks(ispin)%matrix)
258 ALLOCATE (fock_matrix(ispin)%matrix)
259 CALL dbcsr_copy(fock_matrix(ispin)%matrix, matrix_ks(ispin)%matrix, name=
"FOCK MATRIX")
261 CALL dbcsr_copy(matrix_ks(ispin)%matrix, dbcsr_work(ispin)%matrix)
266 IF (dft_control%do_admm)
THEN
275 qs_env%x_data(:, :)%general_parameter%fraction = og_hfx_frac
277 IF (dft_control%do_admm)
THEN
278 IF (
ASSOCIATED(admm_env%xc_section_primary))
CALL section_vals_release(admm_env%xc_section_primary)
286 DEALLOCATE (backup_mos)
292 ALLOCATE (all_struct(nspins), all_coeffs(nspins))
293 ALLOCATE (homo_evals(nspins), lumo_evals(nspins))
295 ALLOCATE (contract_coeffs_backup(nsgf_blk(exat), nspins*ndo_mo))
299 ncol_global=nhomo(ispin), nrow_global=nhomo(ispin))
301 ncol_global=nlumo(ispin), nrow_global=nlumo(ispin))
308 IF (pseudo_canonical)
THEN
314 NULLIFY (homo_evals(ispin)%array)
315 ALLOCATE (homo_evals(ispin)%array(nhomo(ispin)))
317 homo_work, ncol=nhomo(ispin))
318 CALL parallel_gemm(
'T',
'N', nhomo(ispin), nhomo(ispin), nao, 1.0_dp, homo_coeffs(ispin), &
319 homo_work, 0.0_dp, hoho_fock)
323 CALL parallel_gemm(
'N',
'N', nao, nhomo(ispin), nhomo(ispin), 1.0_dp, homo_coeffs(ispin), &
324 hoho_work, 0.0_dp, homo_work)
328 contract_coeffs_backup(:, (ispin - 1)*ndo_mo + 1:ispin*ndo_mo) = &
329 donor_state%contract_coeffs(:, (ispin - 1)*ndo_mo + 1:ispin*ndo_mo)
330 start_sgf = sum(nsgf_blk(1:exat - 1)) + 1
332 donor_state%contract_coeffs(:, (ispin - 1)*ndo_mo + 1:ispin*ndo_mo), &
333 start_row=start_sgf, start_col=first_domo(ispin), &
334 n_rows=nsgf_blk(exat), n_cols=ndo_mo)
338 NULLIFY (lumo_evals(ispin)%array)
339 ALLOCATE (lumo_evals(ispin)%array(nlumo(ispin)))
341 lumo_work, ncol=nlumo(ispin))
342 CALL parallel_gemm(
'T',
'N', nlumo(ispin), nlumo(ispin), nao, 1.0_dp, lumo_coeffs(ispin), &
343 lumo_work, 0.0_dp, lulu_fock)
347 CALL parallel_gemm(
'N',
'N', nao, nlumo(ispin), nlumo(ispin), 1.0_dp, lumo_coeffs(ispin), &
348 lulu_work, 0.0_dp, lumo_work)
357 ALLOCATE (homo_evals(ispin)%array(nhomo(ispin)))
359 homo_work, ncol=nhomo(ispin))
360 CALL parallel_gemm(
'T',
'N', nhomo(ispin), nhomo(ispin), nao, 1.0_dp, homo_coeffs(ispin), &
361 homo_work, 0.0_dp, hoho_work)
364 ALLOCATE (lumo_evals(ispin)%array(nlumo(ispin)))
366 lumo_work, ncol=nlumo(ispin))
367 CALL parallel_gemm(
'T',
'N', nlumo(ispin), nlumo(ispin), nao, 1.0_dp, lumo_coeffs(ispin), &
368 lumo_work, 0.0_dp, lulu_work)
381 ncol_global=nhomo(ispin) + nlumo(ispin), nrow_global=nao)
382 CALL cp_fm_create(all_coeffs(ispin), all_struct(ispin)%struct)
383 CALL cp_fm_to_fm(homo_coeffs(ispin), all_coeffs(ispin), ncol=nhomo(ispin), &
384 source_start=1, target_start=1)
385 CALL cp_fm_to_fm(lumo_coeffs(ispin), all_coeffs(ispin), ncol=nlumo(ispin), &
386 source_start=1, target_start=nhomo(ispin) + 1)
391 CALL contract_aos_to_mos(ja_x, oi_y, mo_template, all_coeffs, nhomo, nlumo, &
392 donor_state, xas_tdp_env, xas_tdp_control, qs_env)
406 IF (nspins == 1)
THEN
408 CALL gw2x_rcs_iterations(first_domo(1), ja_x(1), oi_y, mo_template(1, 1), homo_evals(1)%array, &
409 lumo_evals(1)%array, donor_state, xas_tdp_control, qs_env)
412 CALL gw2x_os_iterations(first_domo, ja_x, oi_y, mo_template, homo_evals, lumo_evals, &
413 donor_state, xas_tdp_control, qs_env)
417 IF (pseudo_canonical)
THEN
418 donor_state%contract_coeffs(:, :) = contract_coeffs_backup(:, :)
422 DO ido_mo = 1, nspins*ndo_mo
423 CALL dbt_destroy(oi_y(ido_mo))
426 CALL dbt_destroy(ja_x(ispin))
427 DEALLOCATE (homo_evals(ispin)%array)
428 DEALLOCATE (lumo_evals(ispin)%array)
430 CALL dbt_destroy(mo_template(ispin, jspin))
433 DEALLOCATE (oi_y, homo_evals, lumo_evals)
435 CALL timestop(handle)
452 SUBROUTINE gw2x_rcs_iterations(first_domo, ja_X, oI_Y, mo_template, homo_evals, lumo_evals, &
453 donor_state, xas_tdp_control, qs_env)
455 INTEGER,
INTENT(IN) :: first_domo
456 TYPE(dbt_type),
INTENT(inout) :: ja_x
457 TYPE(dbt_type),
DIMENSION(:),
INTENT(inout) :: oi_y
458 TYPE(dbt_type),
INTENT(inout) :: mo_template
459 REAL(dp),
DIMENSION(:),
INTENT(IN) :: homo_evals, lumo_evals
460 TYPE(donor_state_type),
POINTER :: donor_state
461 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
462 TYPE(qs_environment_type),
POINTER :: qs_env
464 CHARACTER(len=*),
PARAMETER :: routinen =
'GW2X_rcs_iterations'
466 INTEGER :: batch_size, bounds_1d(2), bounds_2d(2, 2), handle, i, ibatch, ido_mo, iloop, &
467 max_iter, nbatch_occ, nbatch_virt, nblk_occ, nblk_virt, nblks(3), ndo_mo, nhomo, nlumo, &
468 occ_bo(2), output_unit, tmp_sum, virt_bo(2)
469 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: mo_blk_size
470 REAL(dp) :: c_os, c_ss, dg, diff, ds1, ds2, eps_i, &
471 eps_iter, g, omega_k, parts(4), s1, s2
472 TYPE(dbt_type) :: aj_ib, aj_ib_diff, aj_x, ja_ik, &
474 TYPE(mp_para_env_type),
POINTER :: para_env
476 CALL timeset(routinen, handle)
478 eps_iter = xas_tdp_control%gw2x_eps
479 max_iter = xas_tdp_control%max_gw2x_iter
480 c_os = xas_tdp_control%c_os
481 c_ss = xas_tdp_control%c_ss
482 batch_size = xas_tdp_control%batch_size
484 ndo_mo = donor_state%ndo_mo
485 output_unit = cp_logger_get_default_io_unit()
487 nhomo =
SIZE(homo_evals)
488 nlumo =
SIZE(lumo_evals)
490 CALL get_qs_env(qs_env, para_env=para_env)
498 CALL dbt_create(ja_x, aj_x)
499 CALL dbt_copy(ja_x, aj_x, order=[2, 1, 3])
503 CALL dbt_get_info(ja_x, nblks_total=nblks)
504 ALLOCATE (mo_blk_size(nblks(1)))
505 CALL dbt_get_info(ja_x, blk_size_1=mo_blk_size)
509 tmp_sum = tmp_sum + mo_blk_size(i)
510 IF (tmp_sum == nhomo)
THEN
512 nblk_virt = nblks(1) - i
516 nbatch_occ = max(1, nblk_occ/batch_size)
517 nbatch_virt = max(1, nblk_virt/batch_size)
520 DO ido_mo = 1, ndo_mo
521 IF (output_unit > 0)
THEN
522 WRITE (unit=output_unit, fmt=
"(/,T5,A,I2,A,I4,A,/,T5,A)") &
523 "- GW2X correction for donor MO with spin ", 1, &
524 " and MO index ", donor_state%mo_indices(ido_mo, 1),
":", &
525 " iteration convergence (eV)"
526 CALL m_flush(output_unit)
530 eps_i = homo_evals(first_domo + ido_mo - 1)
533 diff = 2.0_dp*eps_iter
535 DO WHILE (abs(diff) > eps_iter)
542 DO ibatch = 1, nbatch_occ
544 occ_bo = get_limit(nblk_occ, nbatch_occ, ibatch - 1)
545 bounds_1d = [sum(mo_blk_size(1:occ_bo(1) - 1)) + 1, sum(mo_blk_size(1:occ_bo(2)))]
547 CALL dbt_create(mo_template, ja_ik)
548 CALL dbt_contract(alpha=1.0_dp, tensor_1=ja_x, tensor_2=oi_y(ido_mo), &
549 beta=0.0_dp, tensor_3=ja_ik, contract_1=[3], &
550 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
551 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
554 CALL calc_os_oov_contrib(parts(1), parts(2), ja_ik, homo_evals, lumo_evals, homo_evals, &
555 omega_k, c_os, nhomo)
557 bounds_2d(:, 2) = bounds_1d
558 bounds_2d(1, 1) = nhomo + 1
559 bounds_2d(2, 1) = nhomo + nlumo
563 IF (abs(c_ss) > epsilon(1.0_dp))
THEN
565 CALL dbt_create(ja_ik, ja_ik_diff, map1_2d=[1], map2_2d=[2, 3])
566 CALL dbt_copy(ja_ik, ja_ik_diff, move_data=.true.)
568 CALL dbt_contract(alpha=-1.0_dp, tensor_1=oi_y(ido_mo), tensor_2=aj_x, &
569 beta=1.0_dp, tensor_3=ja_ik_diff, contract_1=[2], &
570 notcontract_1=[1], contract_2=[3], notcontract_2=[1, 2], &
571 map_1=[1], map_2=[2, 3], bounds_2=[1, nhomo], bounds_3=bounds_2d)
573 CALL calc_ss_oov_contrib(parts(1), parts(2), ja_ik_diff, homo_evals, lumo_evals, omega_k, c_ss)
575 CALL dbt_destroy(ja_ik_diff)
578 CALL dbt_destroy(ja_ik)
581 DO ibatch = 1, nbatch_virt
583 virt_bo = get_limit(nblk_virt, nbatch_virt, ibatch - 1)
584 bounds_1d = [sum(mo_blk_size(1:nblk_occ + virt_bo(1) - 1)) + 1, &
585 sum(mo_blk_size(1:nblk_occ + virt_bo(2)))]
587 CALL dbt_create(mo_template, aj_ib)
588 CALL dbt_contract(alpha=1.0_dp, tensor_1=aj_x, tensor_2=oi_y(ido_mo), &
589 beta=0.0_dp, tensor_3=aj_ib, contract_1=[3], &
590 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
591 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
594 CALL calc_os_ovv_contrib(parts(3), parts(4), aj_ib, lumo_evals, homo_evals, lumo_evals, &
595 omega_k, c_os, nhomo, nhomo)
599 IF (abs(c_ss) > epsilon(1.0_dp))
THEN
601 bounds_2d(2, 1) = nhomo
602 bounds_2d(:, 2) = bounds_1d
604 CALL dbt_create(aj_ib, aj_ib_diff, map1_2d=[1], map2_2d=[2, 3])
605 CALL dbt_copy(aj_ib, aj_ib_diff, move_data=.true.)
607 CALL dbt_contract(alpha=-1.0_dp, tensor_1=oi_y(ido_mo), tensor_2=ja_x, &
608 beta=1.0_dp, tensor_3=aj_ib_diff, contract_1=[2], &
609 notcontract_1=[1], contract_2=[3], notcontract_2=[1, 2], &
610 map_1=[1], map_2=[2, 3], &
611 bounds_2=[nhomo + 1, nhomo + nlumo], bounds_3=bounds_2d)
613 CALL calc_ss_ovv_contrib(parts(3), parts(4), aj_ib_diff, homo_evals, lumo_evals, omega_k, c_ss)
615 CALL dbt_destroy(aj_ib_diff)
618 CALL dbt_destroy(aj_ib)
621 CALL para_env%sum(parts)
622 s1 = parts(1); ds1 = parts(2)
623 s2 = parts(3); ds2 = parts(4)
626 g = eps_i - omega_k + s1 + s2
627 dg = -1.0_dp + ds1 + ds2
633 omega_k = omega_k + diff
636 IF (output_unit > 0)
THEN
637 WRITE (unit=output_unit, fmt=
"(T21,I18,F32.6)") &
639 CALL m_flush(output_unit)
642 IF (iloop > max_iter)
THEN
643 cpwarn(
"GW2X iteration not converged.")
649 donor_state%gw2x_evals(ido_mo, 1) = omega_k
651 IF (output_unit > 0)
THEN
652 WRITE (unit=output_unit, fmt=
"(/T7,A,F11.6,/,T5,A,F11.6)") &
653 "Final GW2X shift for this donor MO (eV):", &
654 (donor_state%energy_evals(ido_mo, 1) - omega_k)*evolt
659 CALL dbt_destroy(aj_x)
661 CALL timestop(handle)
663 END SUBROUTINE gw2x_rcs_iterations
678 SUBROUTINE gw2x_os_iterations(first_domo, ja_X, oI_Y, mo_template, homo_evals, lumo_evals, &
679 donor_state, xas_tdp_control, qs_env)
681 INTEGER,
INTENT(IN) :: first_domo(2)
682 TYPE(dbt_type),
DIMENSION(:),
INTENT(inout) :: ja_x, oi_y
683 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(inout) :: mo_template
684 TYPE(cp_1d_r_p_type),
DIMENSION(:),
INTENT(in) :: homo_evals, lumo_evals
685 TYPE(donor_state_type),
POINTER :: donor_state
686 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
687 TYPE(qs_environment_type),
POINTER :: qs_env
689 CHARACTER(len=*),
PARAMETER :: routinen =
'GW2X_os_iterations'
691 INTEGER :: batch_size, bounds_1d(2), bounds_2d(2, 2), handle, i, ibatch, ido_mo, iloop, &
692 ispin, max_iter, nbatch_occ, nbatch_virt, nblk_occ, nblk_virt, nblks(3), ndo_mo, &
693 nhomo(2), nlumo(2), nspins, occ_bo(2), other_spin, output_unit, tmp_sum, virt_bo(2)
694 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: mo_blk_size
695 REAL(dp) :: c_os, c_ss, dg, diff, ds1, ds2, eps_i, &
696 eps_iter, g, omega_k, parts(4), s1, s2
697 TYPE(dbt_type) :: aj_ib, aj_ib_diff, ja_ik, ja_ik_diff
698 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: aj_x
699 TYPE(mp_para_env_type),
POINTER :: para_env
701 CALL timeset(routinen, handle)
703 eps_iter = xas_tdp_control%gw2x_eps
704 max_iter = xas_tdp_control%max_gw2x_iter
705 c_os = xas_tdp_control%c_os
706 c_ss = xas_tdp_control%c_ss
707 batch_size = xas_tdp_control%batch_size
710 ndo_mo = donor_state%ndo_mo
711 output_unit = cp_logger_get_default_io_unit()
714 nhomo(ispin) =
SIZE(homo_evals(ispin)%array)
715 nlumo(ispin) =
SIZE(lumo_evals(ispin)%array)
718 CALL get_qs_env(qs_env, para_env=para_env)
729 CALL dbt_create(ja_x(ispin), aj_x(ispin))
730 CALL dbt_copy(ja_x(ispin), aj_x(ispin), order=[2, 1, 3])
735 other_spin = 3 - ispin
739 CALL dbt_get_info(ja_x(ispin), nblks_total=nblks)
740 ALLOCATE (mo_blk_size(nblks(1)))
741 CALL dbt_get_info(ja_x(ispin), blk_size_1=mo_blk_size)
745 tmp_sum = tmp_sum + mo_blk_size(i)
746 IF (tmp_sum == nhomo(ispin))
THEN
748 nblk_virt = nblks(1) - i
752 nbatch_occ = max(1, nblk_occ/batch_size)
753 nbatch_virt = max(1, nblk_virt/batch_size)
756 DO ido_mo = 1, ndo_mo
757 IF (output_unit > 0)
THEN
758 WRITE (unit=output_unit, fmt=
"(/,T5,A,I2,A,I4,A,/,T5,A)") &
759 "- GW2X correction for donor MO with spin ", ispin, &
760 " and MO index ", donor_state%mo_indices(ido_mo, ispin),
":", &
761 " iteration convergence (eV)"
762 CALL m_flush(output_unit)
766 eps_i = homo_evals(ispin)%array(first_domo(ispin) + ido_mo - 1)
769 diff = 2.0_dp*eps_iter
771 DO WHILE (abs(diff) > eps_iter)
778 DO ibatch = 1, nbatch_occ
782 occ_bo = get_limit(nblk_occ, nbatch_occ, ibatch - 1)
783 bounds_1d = [sum(mo_blk_size(1:occ_bo(1) - 1)) + 1, sum(mo_blk_size(1:occ_bo(2)))]
785 CALL dbt_create(mo_template(other_spin, ispin), ja_ik)
786 CALL dbt_contract(alpha=1.0_dp, tensor_1=ja_x(other_spin), &
787 tensor_2=oi_y((ispin - 1)*ndo_mo + ido_mo), &
788 beta=0.0_dp, tensor_3=ja_ik, contract_1=[3], &
789 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
790 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
792 CALL calc_os_oov_contrib(parts(1), parts(2), ja_ik, homo_evals(other_spin)%array, &
793 lumo_evals(other_spin)%array, homo_evals(ispin)%array, &
794 omega_k, c_os, nhomo(other_spin))
796 CALL dbt_destroy(ja_ik)
800 IF (abs(c_ss) > epsilon(1.0_dp))
THEN
803 CALL dbt_create(mo_template(ispin, ispin), ja_ik)
804 CALL dbt_contract(alpha=1.0_dp, tensor_1=ja_x(ispin), &
805 tensor_2=oi_y((ispin - 1)*ndo_mo + ido_mo), &
806 beta=0.0_dp, tensor_3=ja_ik, contract_1=[3], &
807 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
808 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
810 bounds_2d(:, 2) = bounds_1d
811 bounds_2d(1, 1) = nhomo(ispin) + 1
812 bounds_2d(2, 1) = nhomo(ispin) + nlumo(ispin)
815 CALL dbt_create(ja_ik, ja_ik_diff, map1_2d=[1], map2_2d=[2, 3])
816 CALL dbt_copy(ja_ik, ja_ik_diff, move_data=.true.)
818 CALL dbt_contract(alpha=-1.0_dp, tensor_1=oi_y((ispin - 1)*ndo_mo + ido_mo), &
819 tensor_2=aj_x(ispin), beta=1.0_dp, tensor_3=ja_ik_diff, &
820 contract_1=[2], notcontract_1=[1], contract_2=[3], notcontract_2=[1, 2], &
821 map_1=[1], map_2=[2, 3], bounds_2=[1, nhomo(ispin)], bounds_3=bounds_2d)
823 CALL calc_ss_oov_contrib(parts(1), parts(2), ja_ik_diff, homo_evals(ispin)%array, &
824 lumo_evals(ispin)%array, omega_k, c_ss)
826 CALL dbt_destroy(ja_ik_diff)
827 CALL dbt_destroy(ja_ik)
832 DO ibatch = 1, nbatch_virt
836 virt_bo = get_limit(nblk_virt, nbatch_virt, ibatch - 1)
837 bounds_1d = [sum(mo_blk_size(1:nblk_occ + virt_bo(1) - 1)) + 1, &
838 sum(mo_blk_size(1:nblk_occ + virt_bo(2)))]
840 CALL dbt_create(mo_template(other_spin, ispin), aj_ib)
841 CALL dbt_contract(alpha=1.0_dp, tensor_1=aj_x(other_spin), &
842 tensor_2=oi_y((ispin - 1)*ndo_mo + ido_mo), &
843 beta=0.0_dp, tensor_3=aj_ib, contract_1=[3], &
844 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
845 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
847 CALL calc_os_ovv_contrib(parts(3), parts(4), aj_ib, lumo_evals(other_spin)%array, &
848 homo_evals(other_spin)%array, lumo_evals(ispin)%array, &
849 omega_k, c_os, nhomo(other_spin), nhomo(ispin))
851 CALL dbt_destroy(aj_ib)
855 IF (abs(c_ss) > epsilon(1.0_dp))
THEN
858 CALL dbt_create(mo_template(ispin, ispin), aj_ib)
859 CALL dbt_contract(alpha=1.0_dp, tensor_1=aj_x(ispin), &
860 tensor_2=oi_y((ispin - 1)*ndo_mo + ido_mo), &
861 beta=0.0_dp, tensor_3=aj_ib, contract_1=[3], &
862 notcontract_1=[1, 2], contract_2=[2], notcontract_2=[1], &
863 map_1=[1, 2], map_2=[3], bounds_3=bounds_1d)
866 bounds_2d(2, 1) = nhomo(ispin)
867 bounds_2d(:, 2) = bounds_1d
869 CALL dbt_create(aj_ib, aj_ib_diff, map1_2d=[1], map2_2d=[2, 3])
870 CALL dbt_copy(aj_ib, aj_ib_diff, move_data=.true.)
872 CALL dbt_contract(alpha=-1.0_dp, tensor_1=oi_y((ispin - 1)*ndo_mo + ido_mo), &
873 tensor_2=ja_x(ispin), beta=1.0_dp, tensor_3=aj_ib_diff, &
874 contract_1=[2], notcontract_1=[1], contract_2=[3], &
875 notcontract_2=[1, 2], map_1=[1], map_2=[2, 3], &
876 bounds_2=[nhomo(ispin) + 1, nhomo(ispin) + nlumo(ispin)], &
879 CALL calc_ss_ovv_contrib(parts(3), parts(4), aj_ib_diff, homo_evals(ispin)%array, &
880 lumo_evals(ispin)%array, omega_k, c_ss)
882 CALL dbt_destroy(aj_ib_diff)
883 CALL dbt_destroy(aj_ib)
888 CALL para_env%sum(parts)
889 s1 = parts(1); ds1 = parts(2)
890 s2 = parts(3); ds2 = parts(4)
893 g = eps_i - omega_k + s1 + s2
894 dg = -1.0_dp + ds1 + ds2
900 omega_k = omega_k + diff
903 IF (output_unit > 0)
THEN
904 WRITE (unit=output_unit, fmt=
"(T21,I18,F32.6)") &
906 CALL m_flush(output_unit)
909 IF (iloop > max_iter)
THEN
910 cpwarn(
"GW2X iteration not converged.")
916 donor_state%gw2x_evals(ido_mo, ispin) = omega_k
918 IF (output_unit > 0)
THEN
919 WRITE (unit=output_unit, fmt=
"(/T7,A,F11.6,/,T5,A,F11.6)") &
920 "Final GW2X shift for this donor MO (eV):", &
921 (donor_state%energy_evals(ido_mo, ispin) - omega_k)*evolt
926 DEALLOCATE (mo_blk_size)
930 CALL dbt_destroy(aj_x(ispin))
933 CALL timestop(handle)
935 END SUBROUTINE gw2x_os_iterations
947 SUBROUTINE get_full_pqx_from_3c_ex(pq_X, exat, xas_tdp_env, qs_env)
949 TYPE(dbt_type),
INTENT(INOUT) :: pq_x
950 INTEGER,
INTENT(IN) :: exat
951 TYPE(xas_tdp_env_type),
POINTER :: xas_tdp_env
952 TYPE(qs_environment_type),
POINTER :: qs_env
954 INTEGER :: i, ind(3), natom, nblk_ri, nsgf_x
955 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: orb_blk_size, proc_dist_1, proc_dist_2, &
957 INTEGER,
DIMENSION(3) :: pdims
959 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: pblock
960 TYPE(dbt_distribution_type) :: t_dist
961 TYPE(dbt_iterator_type) :: iter
962 TYPE(dbt_pgrid_type) :: t_pgrid
963 TYPE(dbt_type) :: pq_x_tmp, work
964 TYPE(mp_para_env_type),
POINTER :: para_env
969 CALL get_qs_env(qs_env, para_env=para_env, natom=natom)
970 CALL dbt_get_info(xas_tdp_env%ri_3c_ex, pdims=pdims)
971 nsgf_x =
SIZE(xas_tdp_env%ri_inv_ex, 1)
974 CALL dbt_pgrid_create(para_env, pdims, t_pgrid)
975 ALLOCATE (proc_dist_1(natom), proc_dist_2(natom), orb_blk_size(natom))
976 CALL dbt_get_info(xas_tdp_env%ri_3c_ex, proc_dist_1=proc_dist_1, proc_dist_2=proc_dist_2, &
977 blk_size_1=orb_blk_size)
978 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=proc_dist_1, nd_dist_2=proc_dist_2, &
979 nd_dist_3=[(0, i=1, nblk_ri)])
981 CALL dbt_create(work, name=
"(pq|X)", dist=t_dist, map1_2d=[1], map2_2d=[2, 3], &
982 blk_size_1=orb_blk_size, blk_size_2=orb_blk_size, blk_size_3=[nsgf_x])
983 CALL dbt_distribution_destroy(t_dist)
989 CALL dbt_iterator_start(iter, xas_tdp_env%ri_3c_ex)
990 DO WHILE (dbt_iterator_blocks_left(iter))
991 CALL dbt_iterator_next_block(iter, ind)
992 CALL dbt_get_block(xas_tdp_env%ri_3c_ex, ind, pblock, found)
994 IF (ind(1) == ind(2)) pblock = 0.5_dp*pblock
995 IF (ind(3) /= exat) cycle
997 CALL dbt_put_block(work, [ind(1), ind(2), 1], &
998 [orb_blk_size(ind(1)), orb_blk_size(ind(2)), nsgf_x], pblock)
1002 CALL dbt_iterator_stop(iter)
1004 CALL dbt_finalize(work)
1007 CALL dbt_create(work, pq_x_tmp)
1008 CALL dbt_copy(work, pq_x_tmp)
1009 CALL dbt_copy(work, pq_x_tmp, order=[2, 1, 3], summation=.true., move_data=.true.)
1011 CALL dbt_destroy(work)
1014 CALL dbt_pgrid_destroy(t_pgrid)
1016 CALL dbt_pgrid_create(para_env, pdims, t_pgrid, tensor_dims=[natom, natom, 1])
1019 ALLOCATE (proc_dist_3(nblk_ri))
1020 CALL dbt_default_distvec(natom, pdims(1), orb_blk_size, proc_dist_1)
1021 CALL dbt_default_distvec(natom, pdims(2), orb_blk_size, proc_dist_2)
1022 CALL dbt_default_distvec(nblk_ri, pdims(3), [nsgf_x], proc_dist_3)
1023 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=proc_dist_1, nd_dist_2=proc_dist_2, &
1024 nd_dist_3=proc_dist_3)
1026 CALL dbt_create(pq_x, name=
"(pq|X)", dist=t_dist, map1_2d=[2, 3], map2_2d=[1], &
1027 blk_size_1=orb_blk_size, blk_size_2=orb_blk_size, blk_size_3=[nsgf_x])
1028 CALL dbt_copy(pq_x_tmp, pq_x, move_data=.true.)
1030 CALL dbt_distribution_destroy(t_dist)
1031 CALL dbt_pgrid_destroy(t_pgrid)
1032 CALL dbt_destroy(pq_x_tmp)
1034 END SUBROUTINE get_full_pqx_from_3c_ex
1052 SUBROUTINE contract_aos_to_mos(ja_X, oI_Y, ja_Io_template, mo_coeffs, nocc, nvirt, &
1053 donor_state, xas_tdp_env, xas_tdp_control, qs_env)
1055 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:), &
1056 INTENT(INOUT) :: ja_x, oi_y
1057 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :), &
1058 INTENT(INOUT) :: ja_io_template
1059 TYPE(cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: mo_coeffs
1060 INTEGER,
INTENT(IN) :: nocc(2), nvirt(2)
1061 TYPE(donor_state_type),
POINTER :: donor_state
1062 TYPE(xas_tdp_env_type),
POINTER :: xas_tdp_env
1063 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
1064 TYPE(qs_environment_type),
POINTER :: qs_env
1066 CHARACTER(len=*),
PARAMETER :: routinen =
'contract_AOs_to_MOs'
1068 INTEGER :: bo(2), handle, i, ispin, jspin, &
1069 nblk_aos, nblk_mos(2), nblk_occ(2), &
1070 nblk_pqx(3), nblk_ri, nblk_virt(2), &
1072 INTEGER,
DIMENSION(3) :: pdims
1073 INTEGER,
DIMENSION(:),
POINTER :: ao_blk_size, ao_col_dist, ao_row_dist, &
1074 mo_dist_3, ri_blk_size, ri_dist_3
1075 INTEGER,
DIMENSION(:, :),
POINTER :: mat_pgrid
1076 TYPE(cp_1d_i_p_type),
ALLOCATABLE,
DIMENSION(:) :: mo_blk_size, mo_col_dist, mo_row_dist
1077 TYPE(dbcsr_distribution_type) :: mat_dist
1078 TYPE(dbcsr_distribution_type),
POINTER :: std_mat_dist
1079 TYPE(dbcsr_type) :: dbcsr_mo_coeffs
1080 TYPE(dbt_distribution_type) :: t_dist
1081 TYPE(dbt_pgrid_type) :: t_pgrid
1082 TYPE(dbt_type) :: jq_x, pq_x, t_mo_coeffs
1083 TYPE(mp_para_env_type),
POINTER :: para_env
1085 NULLIFY (ao_blk_size, ao_col_dist, ao_row_dist, mo_dist_3, ri_blk_size, ri_dist_3, mat_pgrid, &
1086 para_env, std_mat_dist)
1088 CALL timeset(routinen, handle)
1090 nspins = 1;
IF (xas_tdp_control%do_uks .OR. xas_tdp_control%do_roks) nspins = 2
1096 CALL get_qs_env(qs_env, para_env=para_env)
1097 ALLOCATE (mo_blk_size(nspins), mo_row_dist(nspins), mo_col_dist(nspins))
1098 ALLOCATE (ja_x(nspins))
1099 ALLOCATE (oi_y(nspins*donor_state%ndo_mo))
1101 DO ispin = 1, nspins
1104 CALL get_full_pqx_from_3c_ex(pq_x, donor_state%at_index, xas_tdp_env, qs_env)
1107 IF (ispin == 1)
THEN
1108 CALL dbt_get_info(pq_x, pdims=pdims, nblks_total=nblk_pqx)
1109 CALL dbt_pgrid_create(para_env, pdims, t_pgrid)
1110 nblk_aos = nblk_pqx(1)
1111 nblk_ri = nblk_pqx(3)
1115 nblk_occ(ispin) = max(pdims(1), nocc(ispin)/16)
1116 nblk_virt(ispin) = max(pdims(2), nvirt(ispin)/16)
1117 nblk_mos(ispin) = nblk_occ(ispin) + nblk_virt(ispin)
1118 ALLOCATE (mo_blk_size(ispin)%array(nblk_mos(ispin)))
1119 DO i = 1, nblk_occ(ispin)
1120 bo = get_limit(nocc(ispin), nblk_occ(ispin), i - 1)
1121 mo_blk_size(ispin)%array(i) = bo(2) - bo(1) + 1
1123 DO i = 1, nblk_virt(ispin)
1124 bo = get_limit(nvirt(ispin), nblk_virt(ispin), i - 1)
1125 mo_blk_size(ispin)%array(nblk_occ(ispin) + i) = bo(2) - bo(1) + 1
1129 CALL get_qs_env(qs_env, dbcsr_dist=std_mat_dist)
1130 CALL dbcsr_distribution_get(std_mat_dist, pgrid=mat_pgrid)
1131 ALLOCATE (ao_blk_size(nblk_aos), ri_blk_size(nblk_ri))
1132 CALL dbt_get_info(pq_x, blk_size_1=ao_blk_size, blk_size_3=ri_blk_size)
1135 ALLOCATE (ao_row_dist(nblk_aos), mo_col_dist(ispin)%array(nblk_mos(ispin)))
1136 CALL dbt_default_distvec(nblk_aos,
SIZE(mat_pgrid, 1), ao_blk_size, ao_row_dist)
1137 CALL dbt_default_distvec(nblk_mos(ispin),
SIZE(mat_pgrid, 2), mo_blk_size(ispin)%array, &
1138 mo_col_dist(ispin)%array)
1139 CALL dbcsr_distribution_new(mat_dist, group=para_env%get_handle(), pgrid=mat_pgrid, &
1140 row_dist=ao_row_dist, col_dist=mo_col_dist(ispin)%array)
1142 CALL dbcsr_create(dbcsr_mo_coeffs, name=
"MO coeffs", matrix_type=
"N", dist=mat_dist, &
1143 row_blk_size=ao_blk_size, col_blk_size=mo_blk_size(ispin)%array)
1144 CALL copy_fm_to_dbcsr(mo_coeffs(ispin), dbcsr_mo_coeffs)
1146 CALL dbt_create(dbcsr_mo_coeffs, t_mo_coeffs)
1147 CALL dbt_copy_matrix_to_tensor(dbcsr_mo_coeffs, t_mo_coeffs)
1150 ALLOCATE (mo_row_dist(ispin)%array(nblk_mos(ispin)), ao_col_dist(nblk_aos), ri_dist_3(nblk_ri))
1151 CALL dbt_default_distvec(nblk_mos(ispin), pdims(1), mo_blk_size(ispin)%array, mo_row_dist(ispin)%array)
1152 CALL dbt_default_distvec(nblk_aos, pdims(2), ao_blk_size, ao_col_dist)
1153 CALL dbt_default_distvec(nblk_ri, pdims(3), ri_blk_size, ri_dist_3)
1154 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=mo_row_dist(ispin)%array, &
1155 nd_dist_2=ao_col_dist, nd_dist_3=ri_dist_3)
1157 CALL dbt_create(jq_x, name=
"(jq|X)", dist=t_dist, map1_2d=[1, 3], map2_2d=[2], &
1158 blk_size_1=mo_blk_size(ispin)%array, blk_size_2=ao_blk_size, blk_size_3=ri_blk_size)
1159 CALL dbt_distribution_destroy(t_dist)
1162 CALL dbt_contract(alpha=1.0_dp, tensor_1=pq_x, tensor_2=t_mo_coeffs, &
1163 beta=0.0_dp, tensor_3=jq_x, contract_1=[1], &
1164 notcontract_1=[2, 3], contract_2=[1], notcontract_2=[2], &
1165 map_1=[2, 3], map_2=[1], bounds_3=[1, nocc(ispin)], &
1168 CALL dbt_destroy(pq_x)
1169 CALL dbt_copy_matrix_to_tensor(dbcsr_mo_coeffs, t_mo_coeffs)
1174 CALL dbt_default_distvec(nblk_occ(ispin), pdims(1), mo_blk_size(ispin)%array(1:nblk_occ(ispin)), &
1175 mo_row_dist(ispin)%array(1:nblk_occ(ispin)))
1176 CALL dbt_default_distvec(nblk_virt(ispin), pdims(1), &
1177 mo_blk_size(ispin)%array(nblk_occ(ispin) + 1:nblk_mos(ispin)), &
1178 mo_row_dist(ispin)%array(nblk_occ(ispin) + 1:nblk_mos(ispin)))
1179 CALL dbt_default_distvec(nblk_occ(ispin), pdims(2), mo_blk_size(ispin)%array(1:nblk_occ(ispin)), &
1180 mo_col_dist(ispin)%array(1:nblk_occ(ispin)))
1181 CALL dbt_default_distvec(nblk_virt(ispin), pdims(2), &
1182 mo_blk_size(ispin)%array(nblk_occ(ispin) + 1:nblk_mos(ispin)), &
1183 mo_col_dist(ispin)%array(nblk_occ(ispin) + 1:nblk_mos(ispin)))
1184 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=mo_row_dist(ispin)%array, &
1185 nd_dist_2=mo_col_dist(ispin)%array, nd_dist_3=ri_dist_3)
1187 CALL dbt_create(ja_x(ispin), name=
"(ja|X)", dist=t_dist, map1_2d=[1, 2], map2_2d=[3], &
1188 blk_size_1=mo_blk_size(ispin)%array, blk_size_2=mo_blk_size(ispin)%array, &
1189 blk_size_3=ri_blk_size)
1190 CALL dbt_distribution_destroy(t_dist)
1193 CALL dbt_contract(alpha=1.0_dp, tensor_1=jq_x, tensor_2=t_mo_coeffs, &
1194 beta=0.0_dp, tensor_3=ja_x(ispin), contract_1=[2], &
1195 notcontract_1=[1, 3], contract_2=[1], notcontract_2=[2], &
1196 map_1=[1, 3], map_2=[2], move_data=.true., &
1197 bounds_3=[nocc(ispin) + 1, nocc(ispin) + nvirt(ispin)])
1199 CALL dbt_destroy(jq_x)
1200 CALL dbt_copy_matrix_to_tensor(dbcsr_mo_coeffs, t_mo_coeffs)
1203 CALL get_oiy_tensors(oi_y, ispin, ao_blk_size, mo_blk_size(ispin)%array, ri_blk_size, &
1204 t_mo_coeffs, donor_state, xas_tdp_env, xas_tdp_control, qs_env)
1207 CALL dbt_destroy(t_mo_coeffs)
1208 CALL dbcsr_distribution_release(mat_dist)
1209 CALL dbcsr_release(dbcsr_mo_coeffs)
1210 DEALLOCATE (ao_col_dist, ri_dist_3, ri_blk_size, ao_blk_size, ao_row_dist)
1216 ALLOCATE (ja_io_template(nspins, nspins))
1217 DO ispin = 1, nspins
1218 DO jspin = 1, nspins
1219 ALLOCATE (mo_dist_3(nblk_mos(jspin)))
1220 CALL dbt_default_distvec(nblk_occ(jspin), pdims(3), mo_blk_size(jspin)%array(1:nblk_occ(jspin)), &
1221 mo_dist_3(1:nblk_occ(jspin)))
1222 CALL dbt_default_distvec(nblk_virt(jspin), pdims(3), &
1223 mo_blk_size(jspin)%array(nblk_occ(jspin) + 1:nblk_mos(jspin)), &
1224 mo_dist_3(nblk_occ(jspin) + 1:nblk_mos(jspin)))
1225 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=mo_row_dist(ispin)%array, &
1226 nd_dist_2=mo_col_dist(ispin)%array, nd_dist_3=mo_dist_3)
1228 CALL dbt_create(ja_io_template(ispin, jspin), name=
"(ja|Io)", dist=t_dist, map1_2d=[1, 2], &
1229 map2_2d=[3], blk_size_1=mo_blk_size(ispin)%array, &
1230 blk_size_2=mo_blk_size(ispin)%array, blk_size_3=mo_blk_size(jspin)%array)
1231 CALL dbt_distribution_destroy(t_dist)
1232 DEALLOCATE (mo_dist_3)
1237 CALL dbt_pgrid_destroy(t_pgrid)
1238 DO ispin = 1, nspins
1239 DEALLOCATE (mo_blk_size(ispin)%array)
1240 DEALLOCATE (mo_col_dist(ispin)%array)
1241 DEALLOCATE (mo_row_dist(ispin)%array)
1244 CALL timestop(handle)
1246 END SUBROUTINE contract_aos_to_mos
1261 SUBROUTINE get_oiy_tensors(oI_Y, ispin, ao_blk_size, mo_blk_size, ri_blk_size, t_mo_coeffs, &
1262 donor_state, xas_tdp_env, xas_tdp_control, qs_env)
1264 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:), &
1265 INTENT(INOUT) :: oi_y
1266 INTEGER,
INTENT(IN) :: ispin
1267 INTEGER,
DIMENSION(:),
POINTER :: ao_blk_size, mo_blk_size, ri_blk_size
1268 TYPE(dbt_type),
INTENT(inout) :: t_mo_coeffs
1269 TYPE(donor_state_type),
POINTER :: donor_state
1270 TYPE(xas_tdp_env_type),
POINTER :: xas_tdp_env
1271 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
1272 TYPE(qs_environment_type),
POINTER :: qs_env
1274 CHARACTER(len=*),
PARAMETER :: routinen =
'get_oIY_tensors'
1276 INTEGER :: bo(2), handle, i, ido_mo, ind(2), natom, &
1277 nblk_aos, nblk_mos, nblk_ri, ndo_mo, &
1278 pdims_2d(2), proc_id
1279 INTEGER,
DIMENSION(:),
POINTER :: ao_row_dist, mo_row_dist, ri_col_dist
1280 INTEGER,
DIMENSION(:, :),
POINTER :: mat_pgrid
1282 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :) :: pblock
1283 TYPE(dbcsr_distribution_type),
POINTER :: std_mat_dist
1284 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: pi_y
1285 TYPE(dbt_distribution_type) :: t_dist
1286 TYPE(dbt_iterator_type) :: iter
1287 TYPE(dbt_pgrid_type) :: t_pgrid
1288 TYPE(dbt_type) :: t_pi_y, t_work
1289 TYPE(mp_para_env_type),
POINTER :: para_env
1291 CALL timeset(routinen, handle)
1293 CALL get_qs_env(qs_env, natom=natom, para_env=para_env, dbcsr_dist=std_mat_dist)
1294 ndo_mo = donor_state%ndo_mo
1295 nblk_aos =
SIZE(ao_blk_size)
1296 nblk_mos =
SIZE(mo_blk_size)
1297 nblk_ri =
SIZE(ri_blk_size)
1300 CALL contract2_ao_to_domo(pi_y,
"EXCHANGE", donor_state, xas_tdp_env, xas_tdp_control, qs_env)
1303 CALL ri_all_blocks_mm(pi_y, xas_tdp_env%ri_inv_ex)
1306 CALL dbcsr_distribution_get(std_mat_dist, pgrid=mat_pgrid)
1309 DO ido_mo = (ispin - 1)*ndo_mo + 1, ispin*ndo_mo
1312 CALL dbt_create(pi_y(ido_mo)%matrix, t_work)
1313 CALL dbt_copy_matrix_to_tensor(pi_y(ido_mo)%matrix, t_work)
1316 ALLOCATE (ri_col_dist(natom))
1317 CALL dbt_get_info(t_work, proc_dist_2=ri_col_dist)
1318 proc_id = ri_col_dist(donor_state%at_index)
1319 DEALLOCATE (ri_col_dist)
1322 pdims_2d(1) =
SIZE(mat_pgrid, 1); pdims_2d(2) =
SIZE(mat_pgrid, 2)
1323 CALL dbt_pgrid_create(para_env, pdims_2d, t_pgrid)
1325 ALLOCATE (ri_col_dist(nblk_ri), ao_row_dist(nblk_aos), mo_row_dist(nblk_mos))
1326 CALL dbt_get_info(t_work, proc_dist_1=ao_row_dist)
1327 ri_col_dist = proc_id
1329 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=ao_row_dist, nd_dist_2=ri_col_dist)
1330 CALL dbt_create(t_pi_y, name=
"(pI|Y)", dist=t_dist, map1_2d=[1], map2_2d=[2], &
1331 blk_size_1=ao_blk_size, blk_size_2=ri_blk_size)
1332 CALL dbt_distribution_destroy(t_dist)
1338 CALL dbt_iterator_start(iter, t_work)
1339 DO WHILE (dbt_iterator_blocks_left(iter))
1340 CALL dbt_iterator_next_block(iter, ind)
1341 CALL dbt_get_block(t_work, ind, pblock, found)
1344 bo(1) = sum(ri_blk_size(1:i - 1)) + 1
1345 bo(2) = bo(1) + ri_blk_size(i) - 1
1346 CALL dbt_put_block(t_pi_y, [ind(1), i], [ao_blk_size(ind(1)), ri_blk_size(i)], &
1347 pblock(:, bo(1):bo(2)))
1352 CALL dbt_iterator_stop(iter)
1354 CALL dbt_finalize(t_pi_y)
1357 CALL dbt_pgrid_destroy(t_pgrid)
1359 CALL dbt_pgrid_create(para_env, pdims_2d, t_pgrid, tensor_dims=[nblk_mos, nblk_ri])
1361 CALL dbt_default_distvec(nblk_aos, pdims_2d(1), ao_blk_size, ao_row_dist)
1362 CALL dbt_default_distvec(nblk_mos, pdims_2d(1), mo_blk_size, mo_row_dist)
1363 CALL dbt_default_distvec(nblk_ri, pdims_2d(2), ri_blk_size, ri_col_dist)
1366 CALL dbt_destroy(t_work)
1367 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=ao_row_dist, nd_dist_2=ri_col_dist)
1368 CALL dbt_create(t_work, name=
"t_pI_Y", dist=t_dist, map1_2d=[1], map2_2d=[2], &
1369 blk_size_1=ao_blk_size, blk_size_2=ri_blk_size)
1370 CALL dbt_copy(t_pi_y, t_work, move_data=.true.)
1371 CALL dbt_distribution_destroy(t_dist)
1374 CALL dbt_distribution_new(t_dist, t_pgrid, nd_dist_1=mo_row_dist, nd_dist_2=ri_col_dist)
1375 CALL dbt_create(oi_y(ido_mo), name=
"(oI|Y)", dist=t_dist, map1_2d=[1], map2_2d=[2], &
1376 blk_size_1=mo_blk_size, blk_size_2=ri_blk_size)
1377 CALL dbt_distribution_destroy(t_dist)
1380 CALL dbt_contract(alpha=1.0_dp, tensor_1=t_work, tensor_2=t_mo_coeffs, &
1381 beta=0.0_dp, tensor_3=oi_y(ido_mo), contract_1=[1], &
1382 notcontract_1=[2], contract_2=[1], notcontract_2=[2], &
1383 map_1=[2], map_2=[1])
1386 CALL dbt_destroy(t_work)
1387 CALL dbt_destroy(t_pi_y)
1388 CALL dbt_pgrid_destroy(t_pgrid)
1389 DEALLOCATE (ri_col_dist, ao_row_dist, mo_row_dist)
1394 CALL dbcsr_deallocate_matrix_set(pi_y)
1396 CALL timestop(handle)
1398 END SUBROUTINE get_oiy_tensors
1413 SUBROUTINE calc_ss_oov_contrib(contrib, dev, ja_Ik_diff, occ_evals, virt_evals, omega, c_ss)
1415 REAL(dp),
INTENT(inout) :: contrib, dev
1416 TYPE(dbt_type),
INTENT(inout) :: ja_ik_diff
1417 REAL(dp),
DIMENSION(:),
INTENT(IN) :: occ_evals, virt_evals
1418 REAL(dp),
INTENT(in) :: omega, c_ss
1420 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_ss_oov_contrib'
1422 INTEGER :: a, boff(3), bsize(3), handle, idx1, &
1425 REAL(dp) :: denom, tmp
1426 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: tensor_blk
1427 TYPE(dbt_iterator_type) :: iter
1429 CALL timeset(routinen, handle)
1434 nocc =
SIZE(occ_evals, 1)
1441 CALL dbt_iterator_start(iter, ja_ik_diff)
1442 DO WHILE (dbt_iterator_blocks_left(iter))
1443 CALL dbt_iterator_next_block(iter, ind, blk_offset=boff, blk_size=bsize)
1444 CALL dbt_get_block(ja_ik_diff, ind, tensor_blk, found)
1448 DO idx3 = 1, bsize(3)
1449 DO idx2 = 1, bsize(2)
1450 DO idx1 = 1, bsize(1)
1453 j = boff(1) + idx1 - 1
1454 a = boff(2) +
idx2 - 1 - nocc
1455 k = boff(3) +
idx3 - 1
1458 denom = omega + virt_evals(a) - occ_evals(j) - occ_evals(k)
1461 tmp = c_ss*tensor_blk(idx1,
idx2,
idx3)**2
1463 contrib = contrib + 0.5_dp*tmp/denom
1464 dev = dev - 0.5_dp*tmp/denom**2
1470 DEALLOCATE (tensor_blk)
1472 CALL dbt_iterator_stop(iter)
1475 CALL timestop(handle)
1477 END SUBROUTINE calc_ss_oov_contrib
1494 SUBROUTINE calc_os_oov_contrib(contrib, dev, ja_Ik, j_evals, a_evals, k_evals, omega, c_os, a_offset)
1496 REAL(dp),
INTENT(inout) :: contrib, dev
1497 TYPE(dbt_type),
INTENT(inout) :: ja_ik
1498 REAL(dp),
DIMENSION(:),
INTENT(IN) :: j_evals, a_evals, k_evals
1499 REAL(dp),
INTENT(in) :: omega, c_os
1500 INTEGER,
INTENT(IN) :: a_offset
1502 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_os_oov_contrib'
1504 INTEGER :: a, boff(3), bsize(3), handle, idx1, &
1507 REAL(dp) :: denom, tmp
1508 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ja_ik_blk
1509 TYPE(dbt_iterator_type) :: iter
1511 CALL timeset(routinen, handle)
1524 CALL dbt_iterator_start(iter, ja_ik)
1525 DO WHILE (dbt_iterator_blocks_left(iter))
1526 CALL dbt_iterator_next_block(iter, ind, blk_offset=boff, blk_size=bsize)
1527 CALL dbt_get_block(ja_ik, ind, ja_ik_blk, found)
1531 DO idx3 = 1, bsize(3)
1532 DO idx2 = 1, bsize(2)
1533 DO idx1 = 1, bsize(1)
1536 j = boff(1) + idx1 - 1
1537 a = boff(2) +
idx2 - 1 - a_offset
1538 k = boff(3) +
idx3 - 1
1541 denom = omega + a_evals(a) - j_evals(j) - k_evals(k)
1544 tmp = c_os*ja_ik_blk(idx1,
idx2,
idx3)**2
1547 contrib = contrib + tmp/denom
1548 dev = dev - tmp/denom**2
1554 DEALLOCATE (ja_ik_blk)
1556 CALL dbt_iterator_stop(iter)
1559 CALL timestop(handle)
1561 END SUBROUTINE calc_os_oov_contrib
1576 SUBROUTINE calc_ss_ovv_contrib(contrib, dev, aj_Ib_diff, occ_evals, virt_evals, omega, c_ss)
1578 REAL(dp),
INTENT(inout) :: contrib, dev
1579 TYPE(dbt_type),
INTENT(inout) :: aj_ib_diff
1580 REAL(dp),
DIMENSION(:),
INTENT(IN) :: occ_evals, virt_evals
1581 REAL(dp),
INTENT(in) :: omega, c_ss
1583 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_ss_ovv_contrib'
1585 INTEGER :: a, b, boff(3), bsize(3), handle, idx1, &
1588 REAL(dp) :: denom, tmp
1589 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: tensor_blk
1590 TYPE(dbt_iterator_type) :: iter
1592 CALL timeset(routinen, handle)
1597 nocc =
SIZE(occ_evals, 1)
1604 CALL dbt_iterator_start(iter, aj_ib_diff)
1605 DO WHILE (dbt_iterator_blocks_left(iter))
1606 CALL dbt_iterator_next_block(iter, ind, blk_offset=boff, blk_size=bsize)
1607 CALL dbt_get_block(aj_ib_diff, ind, tensor_blk, found)
1611 DO idx3 = 1, bsize(3)
1612 DO idx2 = 1, bsize(2)
1613 DO idx1 = 1, bsize(1)
1616 a = boff(1) + idx1 - 1 - nocc
1617 j = boff(2) +
idx2 - 1
1618 b = boff(3) +
idx3 - 1 - nocc
1621 denom = omega + occ_evals(j) - virt_evals(a) - virt_evals(b)
1624 tmp = c_ss*tensor_blk(idx1,
idx2,
idx3)**2
1626 contrib = contrib + 0.5_dp*tmp/denom
1627 dev = dev - 0.5_dp*tmp/denom**2
1633 DEALLOCATE (tensor_blk)
1635 CALL dbt_iterator_stop(iter)
1638 CALL timestop(handle)
1640 END SUBROUTINE calc_ss_ovv_contrib
1658 SUBROUTINE calc_os_ovv_contrib(contrib, dev, aj_Ib, a_evals, j_evals, b_evals, omega, c_os, &
1661 REAL(dp),
INTENT(inout) :: contrib, dev
1662 TYPE(dbt_type),
INTENT(inout) :: aj_ib
1663 REAL(dp),
DIMENSION(:),
INTENT(IN) :: a_evals, j_evals, b_evals
1664 REAL(dp),
INTENT(in) :: omega, c_os
1665 INTEGER,
INTENT(IN) :: a_offset, b_offset
1667 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_os_ovv_contrib'
1669 INTEGER :: a, b, boff(3), bsize(3), handle, idx1, &
1672 REAL(dp) :: denom, tmp
1673 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: aj_ib_blk
1674 TYPE(dbt_iterator_type) :: iter
1676 CALL timeset(routinen, handle)
1686 CALL dbt_iterator_start(iter, aj_ib)
1687 DO WHILE (dbt_iterator_blocks_left(iter))
1688 CALL dbt_iterator_next_block(iter, ind, blk_offset=boff, blk_size=bsize)
1689 CALL dbt_get_block(aj_ib, ind, aj_ib_blk, found)
1693 DO idx3 = 1, bsize(3)
1694 DO idx2 = 1, bsize(2)
1695 DO idx1 = 1, bsize(1)
1698 a = boff(1) + idx1 - 1 - a_offset
1699 j = boff(2) +
idx2 - 1
1700 b = boff(3) +
idx3 - 1 - b_offset
1703 denom = omega + j_evals(j) - a_evals(a) - b_evals(b)
1706 tmp = c_os*(aj_ib_blk(idx1,
idx2,
idx3))**2
1708 contrib = contrib + tmp/denom
1709 dev = dev - tmp/denom**2
1715 DEALLOCATE (aj_ib_blk)
1717 CALL dbt_iterator_stop(iter)
1720 CALL timestop(handle)
1722 END SUBROUTINE calc_os_ovv_contrib
1735 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :), &
1736 INTENT(out) :: soc_shifts
1737 TYPE(donor_state_type),
POINTER :: donor_state
1738 TYPE(xas_tdp_env_type),
POINTER :: xas_tdp_env
1739 TYPE(xas_tdp_control_type),
POINTER :: xas_tdp_control
1740 TYPE(qs_environment_type),
POINTER :: qs_env
1742 CHARACTER(len=*),
PARAMETER :: routinen =
'get_soc_splitting'
1744 COMPLEX(dp),
ALLOCATABLE,
DIMENSION(:, :) :: evecs, hami
1745 INTEGER :: beta_spin, handle, ialpha, ibeta, &
1746 ido_mo, ispin, nao, ndo_mo, ndo_so, &
1748 REAL(dp) :: alpha_tot_contrib, beta_tot_contrib
1749 REAL(dp),
ALLOCATABLE,
DIMENSION(:) :: evals
1750 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :) :: tmp_shifts
1751 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
1752 TYPE(cp_cfm_type) :: hami_cfm
1753 TYPE(cp_fm_struct_type),
POINTER :: ao_domo_struct, domo_domo_struct, &
1755 TYPE(cp_fm_type) :: alpha_gs_coeffs, ao_domo_work, &
1756 beta_gs_coeffs, domo_domo_work, &
1758 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks
1759 TYPE(dbcsr_type),
POINTER :: orb_soc_x, orb_soc_y, orb_soc_z
1760 TYPE(mp_para_env_type),
POINTER :: para_env
1762 NULLIFY (matrix_ks, para_env, blacs_env, ao_domo_struct, domo_domo_struct, &
1763 doso_doso_struct, orb_soc_x, orb_soc_y, orb_soc_z)
1765 CALL timeset(routinen, handle)
1771 CALL get_qs_env(qs_env, matrix_ks=matrix_ks, para_env=para_env, blacs_env=blacs_env)
1773 orb_soc_x => xas_tdp_env%orb_soc(1)%matrix
1774 orb_soc_y => xas_tdp_env%orb_soc(2)%matrix
1775 orb_soc_z => xas_tdp_env%orb_soc(3)%matrix
1779 ndo_mo = donor_state%ndo_mo
1780 ndo_so = nspins*ndo_mo
1781 CALL dbcsr_get_info(matrix_ks(1)%matrix, nfullrows_total=nao)
1784 CALL cp_fm_struct_create(ao_domo_struct, context=blacs_env, para_env=para_env, &
1785 nrow_global=nao, ncol_global=ndo_mo)
1786 CALL cp_fm_struct_create(domo_domo_struct, context=blacs_env, para_env=para_env, &
1787 nrow_global=ndo_mo, ncol_global=ndo_mo)
1788 CALL cp_fm_struct_create(doso_doso_struct, context=blacs_env, para_env=para_env, &
1789 nrow_global=ndo_so, ncol_global=ndo_so)
1791 CALL cp_fm_create(alpha_gs_coeffs, ao_domo_struct)
1792 CALL cp_fm_create(beta_gs_coeffs, ao_domo_struct)
1793 CALL cp_fm_create(ao_domo_work, ao_domo_struct)
1794 CALL cp_fm_create(domo_domo_work, domo_domo_struct)
1795 CALL cp_fm_create(real_fm, doso_doso_struct)
1796 CALL cp_fm_create(img_fm, doso_doso_struct)
1799 IF (xas_tdp_control%do_uks)
THEN
1801 CALL cp_fm_to_fm_submat(msource=donor_state%gs_coeffs, mtarget=alpha_gs_coeffs, nrow=nao, &
1802 ncol=ndo_mo, s_firstrow=1, s_firstcol=1, t_firstrow=1, t_firstcol=1)
1803 CALL cp_fm_to_fm_submat(msource=donor_state%gs_coeffs, mtarget=beta_gs_coeffs, nrow=nao, &
1804 ncol=ndo_mo, s_firstrow=1, s_firstcol=ndo_mo + 1, t_firstrow=1, t_firstcol=1)
1808 CALL cp_fm_to_fm(donor_state%gs_coeffs, alpha_gs_coeffs)
1809 CALL cp_fm_to_fm(donor_state%gs_coeffs, beta_gs_coeffs)
1814 CALL cp_dbcsr_sm_fm_multiply(matrix_ks(1)%matrix, alpha_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1815 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, alpha_gs_coeffs, ao_domo_work, 0.0_dp, &
1817 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=real_fm, nrow=ndo_mo, ncol=ndo_mo, &
1818 s_firstrow=1, s_firstcol=1, t_firstrow=1, t_firstcol=1)
1821 beta_spin = 1;
IF (xas_tdp_control%do_uks .OR. xas_tdp_control%do_roks) beta_spin = 2
1822 CALL cp_dbcsr_sm_fm_multiply(matrix_ks(beta_spin)%matrix, beta_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1823 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, beta_gs_coeffs, ao_domo_work, 0.0_dp, &
1825 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=real_fm, nrow=ndo_mo, ncol=ndo_mo, &
1826 s_firstrow=1, s_firstcol=1, t_firstrow=ndo_mo + 1, t_firstcol=ndo_mo + 1)
1830 CALL cp_dbcsr_sm_fm_multiply(orb_soc_z, alpha_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1831 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, alpha_gs_coeffs, ao_domo_work, 0.0_dp, &
1833 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=img_fm, nrow=ndo_mo, ncol=ndo_mo, &
1834 s_firstrow=1, s_firstcol=1, t_firstrow=1, t_firstcol=1)
1837 CALL cp_dbcsr_sm_fm_multiply(orb_soc_z, beta_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1838 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, -1.0_dp, beta_gs_coeffs, ao_domo_work, 0.0_dp, &
1840 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=img_fm, nrow=ndo_mo, ncol=ndo_mo, &
1841 s_firstrow=1, s_firstcol=1, t_firstrow=ndo_mo + 1, t_firstcol=ndo_mo + 1)
1845 CALL cp_dbcsr_sm_fm_multiply(orb_soc_x, beta_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1846 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, alpha_gs_coeffs, ao_domo_work, 0.0_dp, &
1848 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=img_fm, nrow=ndo_mo, ncol=ndo_mo, &
1849 s_firstrow=1, s_firstcol=1, t_firstrow=1, t_firstcol=ndo_mo + 1)
1851 CALL cp_dbcsr_sm_fm_multiply(orb_soc_y, beta_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1852 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, alpha_gs_coeffs, ao_domo_work, 0.0_dp, &
1854 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=real_fm, nrow=ndo_mo, ncol=ndo_mo, &
1855 s_firstrow=1, s_firstcol=1, t_firstrow=1, t_firstcol=ndo_mo + 1)
1859 CALL cp_dbcsr_sm_fm_multiply(orb_soc_x, alpha_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1860 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, 1.0_dp, beta_gs_coeffs, ao_domo_work, 0.0_dp, &
1862 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=img_fm, nrow=ndo_mo, ncol=ndo_mo, &
1863 s_firstrow=1, s_firstcol=1, t_firstrow=ndo_mo + 1, t_firstcol=1)
1865 CALL cp_dbcsr_sm_fm_multiply(orb_soc_y, alpha_gs_coeffs, ao_domo_work, ncol=ndo_mo)
1866 CALL parallel_gemm(
'T',
'N', ndo_mo, ndo_mo, nao, -1.0_dp, beta_gs_coeffs, ao_domo_work, 0.0_dp, &
1868 CALL cp_fm_to_fm_submat(msource=domo_domo_work, mtarget=real_fm, nrow=ndo_mo, ncol=ndo_mo, &
1869 s_firstrow=1, s_firstcol=1, t_firstrow=ndo_mo + 1, t_firstcol=1)
1872 CALL cp_cfm_create(hami_cfm, doso_doso_struct)
1873 CALL cp_fm_to_cfm(real_fm, img_fm, hami_cfm)
1876 ALLOCATE (evals(ndo_so), evecs(ndo_so, ndo_so), hami(ndo_so, ndo_so))
1877 CALL cp_cfm_get_submatrix(hami_cfm, hami)
1878 CALL diag_complex(hami, evecs, evals)
1881 ALLOCATE (tmp_shifts(ndo_mo, 2))
1883 ialpha = 1; ibeta = 1;
1884 DO ido_mo = 1, ndo_so
1886 alpha_tot_contrib = real(dot_product(evecs(1:ndo_mo, ido_mo), evecs(1:ndo_mo, ido_mo)))
1887 beta_tot_contrib = real(dot_product(evecs(ndo_mo + 1:ndo_so, ido_mo), evecs(ndo_mo + 1:ndo_so, ido_mo)))
1889 IF (alpha_tot_contrib > beta_tot_contrib)
THEN
1890 tmp_shifts(ialpha, 1) = evals(ido_mo)
1893 tmp_shifts(ibeta, 2) = evals(ido_mo)
1899 ALLOCATE (soc_shifts(ndo_mo,
SIZE(donor_state%energy_evals, 2)))
1900 DO ispin = 1,
SIZE(donor_state%energy_evals, 2)
1901 soc_shifts(:, ispin) = tmp_shifts(:, ispin) - donor_state%energy_evals(:, ispin)
1905 CALL cp_fm_release(alpha_gs_coeffs)
1906 CALL cp_fm_release(beta_gs_coeffs)
1907 CALL cp_fm_release(ao_domo_work)
1908 CALL cp_fm_release(domo_domo_work)
1909 CALL cp_fm_release(real_fm)
1910 CALL cp_fm_release(img_fm)
1912 CALL cp_cfm_release(hami_cfm)
1914 CALL cp_fm_struct_release(ao_domo_struct)
1915 CALL cp_fm_struct_release(domo_domo_struct)
1916 CALL cp_fm_struct_release(doso_doso_struct)
1918 CALL timestop(handle)
Types and set/get functions for auxiliary density matrix methods.
Contains methods used in the context of density fitting.
subroutine, public admm_correct_for_eigenvalues(ispin, admm_env, ks_matrix)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public shigeta2001
integer, save, public bussy2021b
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
Extract a sub-matrix from the full matrix: op(target_m)(1:n_rows,1:n_cols) = fm(start_row:start_row+n...
subroutine, public cp_cfm_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_diag(matrix, diag)
returns the diagonal elements of a fm
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
This is the start of a dbt_api, all publically needed functions are exported here....
Utilities for hfx and admm methods.
subroutine, public create_admm_xc_section(x_data, xc_section, admm_env)
This routine modifies the xc section depending on the potential type used for the HF exchange and the...
Defines the basic variable types.
integer, parameter, public dp
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Collection of simple mathematical functions and subroutines.
subroutine, public diag_complex(matrix, eigenvectors, eigenvalues)
Diagonalizes a local complex Hermitian matrix using LAPACK. Based on cp_cfm_heevd.
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Definition of physical constants:
real(kind=dp), parameter, public evolt
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Get the QUICKSTEP environment.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_build_kohn_sham_matrix(qs_env, calculate_forces, just_energy, print_active, ext_ks_matrix)
routine where the real calculations are made: the KS matrix is calculated
Definition and initialisation of the mo data type.
subroutine, public duplicate_mo_set(mo_set_new, mo_set_old)
allocate a new mo_set, and copy the old data
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
subroutine, public reassign_allocated_mos(mo_set_new, mo_set_old)
reassign an already allocated mo_set
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Second order perturbation correction to XAS_TDP spectra (i.e. shift)
subroutine, public gw2x_shift(donor_state, xas_tdp_env, xas_tdp_control, qs_env)
Computes the ionization potential using the GW2X method of Shigeta et. al. The result cam be used for...
subroutine, public get_soc_splitting(soc_shifts, donor_state, xas_tdp_env, xas_tdp_control, qs_env)
We try to compute the spin-orbit splitting via perturbation theory. We keep it \ cheap by only inculd...
All the kernel specific subroutines for XAS TDP calculations.
subroutine, public contract2_ao_to_domo(contr_int, op_type, donor_state, xas_tdp_env, xas_tdp_control, qs_env)
Contract the ri 3-center integrals stored in a tensor with repect to the donor MOs coeffs,...
subroutine, public ri_all_blocks_mm(contr_int, pq)
Multiply all the blocks of a contracted RI integral (aI|P) by a matrix of type (P|....
Define XAS TDP control type and associated create, release, etc subroutines, as well as XAS TDP envir...
stores some data used in wavefunction fitting
represent a pointer to a 1d array
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment
Type containing informations about a single donor state.
Type containing control information for TDP XAS calculations.
Type containing informations such as inputs and results for TDP XAS calculations.