45 USE dbcsr_api,
ONLY: dbcsr_copy,&
51 dbcsr_type_no_symmetry,&
74 localized_wfn_control_type,&
82 #include "./base/base_uses.f90"
92 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_dcdr_utils'
94 REAL(dp),
DIMENSION(3, 3, 3),
PARAMETER :: Levi_Civita = reshape((/ &
95 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, &
96 0.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 0.0_dp, &
97 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp/), &
113 TYPE(dbcsr_type),
INTENT(IN),
POINTER :: ao_matrix
114 TYPE(cp_fm_type),
INTENT(IN) :: mo_coeff, work
115 INTEGER,
INTENT(IN) :: nmo, icenter
116 TYPE(cp_fm_type),
INTENT(IN) :: res
118 CHARACTER(LEN=*),
PARAMETER :: routinen =
'multiply_localization'
122 CALL timeset(routinen, handle)
128 CALL cp_fm_to_fm(work, res, 1, icenter, icenter)
133 CALL timestop(handle)
148 TYPE(qs_environment_type),
POINTER :: qs_env
149 TYPE(section_vals_type),
POINTER :: linres_section
150 TYPE(cp_fm_type),
DIMENSION(:),
INTENT(IN) :: vec
151 INTEGER,
INTENT(IN) :: lambda, beta
152 CHARACTER(LEN=*) :: tag
154 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dcdr_read_restart'
156 CHARACTER(LEN=default_path_length) :: filename
157 CHARACTER(LEN=default_string_length) :: my_middle
158 INTEGER :: beta_tmp, handle, i, i_block, ia, ie, iostat, iounit, ispin, j, lambda_tmp, &
159 max_block, n_rep_val, nao, nao_tmp, nmo, nmo_tmp, nspins, nspins_tmp, rst_unit
160 LOGICAL :: file_exists
161 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: vecbuffer
162 TYPE(cp_fm_type),
POINTER :: mo_coeff
163 TYPE(cp_logger_type),
POINTER :: logger
164 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
165 TYPE(mp_para_env_type),
POINTER :: para_env
166 TYPE(section_vals_type),
POINTER :: print_key
168 file_exists = .false.
170 CALL timeset(routinen, handle)
172 NULLIFY (mos, para_env, logger, print_key, vecbuffer)
176 "PRINT%PROGRAM_RUN_INFO", extension=
".Log")
185 IF (para_env%is_source())
THEN
190 my_middle =
"RESTART-"//tag(ia:ie)//trim(
"-")//trim(adjustl(cp_to_string(beta))) &
191 //trim(
"-")//trim(adjustl(cp_to_string(lambda)))
193 IF (n_rep_val > 0)
THEN
196 filename = filename(ia:ie)//trim(my_middle)//
".lr"
201 extension=
".lr", middle_name=trim(my_middle), my_local=.false.)
203 INQUIRE (file=filename, exist=file_exists)
206 IF (file_exists)
THEN
207 CALL open_file(file_name=trim(filename), &
208 file_action=
"READ", &
209 file_form=
"UNFORMATTED", &
210 file_position=
"REWIND", &
212 unit_number=rst_unit)
214 IF (iounit > 0)
WRITE (iounit,
"(T2,A)") &
215 "LINRES| Reading response wavefunctions from the restart file <"//trim(adjustl(filename))//
">"
217 IF (iounit > 0)
WRITE (iounit,
"(T2,A)") &
218 "LINRES| Restart file <"//trim(adjustl(filename))//
"> not found"
222 CALL para_env%bcast(file_exists)
224 IF (file_exists)
THEN
227 CALL cp_fm_get_info(mo_coeff, nrow_global=nao, ncol_block=max_block)
229 ALLOCATE (vecbuffer(nao, max_block))
232 IF (rst_unit > 0)
READ (rst_unit, iostat=iostat) lambda_tmp, beta_tmp, nspins_tmp, nao_tmp
233 CALL para_env%bcast(iostat)
234 CALL para_env%bcast(beta_tmp)
235 CALL para_env%bcast(lambda_tmp)
236 CALL para_env%bcast(nspins_tmp)
237 CALL para_env%bcast(nao_tmp)
241 IF (nspins_tmp .NE. nspins)
THEN
242 cpabort(
"nspins not consistent")
244 IF (nao_tmp .NE. nao) cpabort(
"nao not consistent")
247 IF (lambda_tmp .NE. lambda) cpabort(
"lambda not consistent")
248 IF (beta_tmp .NE. beta) cpabort(
"beta not consistent")
251 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
254 IF (rst_unit > 0)
READ (rst_unit) nmo_tmp
255 CALL para_env%bcast(nmo_tmp)
256 IF (nmo_tmp .NE. nmo) cpabort(
"nmo not consistent")
259 DO i = 1, nmo, max(max_block, 1)
260 i_block = min(max_block, nmo - i + 1)
262 IF (rst_unit > 0)
READ (rst_unit) vecbuffer(1:nao, j)
264 CALL para_env%bcast(vecbuffer)
269 IF (iostat /= 0)
THEN
270 IF (iounit > 0)
WRITE (iounit,
"(T2,A)") &
271 "LINRES| Restart file <"//trim(adjustl(filename))//
"> not found"
274 DEALLOCATE (vecbuffer)
278 IF (para_env%is_source())
THEN
279 IF (file_exists)
CALL close_file(unit_number=rst_unit)
282 CALL timestop(handle)
298 TYPE(qs_environment_type),
POINTER :: qs_env
299 TYPE(section_vals_type),
POINTER :: linres_section
300 TYPE(cp_fm_type),
DIMENSION(:),
INTENT(IN) :: vec
301 INTEGER,
INTENT(IN) :: lambda, beta
302 CHARACTER(LEN=*) :: tag
304 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dcdr_write_restart'
306 CHARACTER(LEN=default_path_length) :: filename
307 CHARACTER(LEN=default_string_length) :: my_middle, my_pos, my_status
308 INTEGER :: handle, i, i_block, ia, ie, iounit, &
309 ispin, j, max_block, nao, nmo, nspins, &
311 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: vecbuffer
312 TYPE(cp_fm_type),
POINTER :: mo_coeff
313 TYPE(cp_logger_type),
POINTER :: logger
314 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
315 TYPE(mp_para_env_type),
POINTER :: para_env
316 TYPE(section_vals_type),
POINTER :: print_key
318 NULLIFY (logger, mo_coeff, mos, para_env, print_key, vecbuffer)
320 CALL timeset(routinen, handle)
325 used_print_key=print_key), &
329 "PRINT%PROGRAM_RUN_INFO", extension=
".Log")
337 my_status =
"REPLACE"
340 my_middle =
"RESTART-"//tag(ia:ie)//trim(
"-")//trim(adjustl(cp_to_string(beta))) &
341 //trim(
"-")//trim(adjustl(cp_to_string(lambda)))
343 extension=
".lr", middle_name=trim(my_middle), file_status=trim(my_status), &
344 file_position=trim(my_pos), file_action=
"WRITE", file_form=
"UNFORMATTED")
347 extension=
".lr", middle_name=trim(my_middle), my_local=.false.)
350 WRITE (unit=iounit, fmt=
"(T2,A)") &
351 "LINRES| Writing response functions to the restart file <"//trim(adjustl(filename))//
">"
358 CALL cp_fm_get_info(mo_coeff, nrow_global=nao, ncol_block=max_block)
359 ALLOCATE (vecbuffer(nao, max_block))
361 IF (rst_unit > 0)
WRITE (rst_unit) lambda, beta, nspins, nao
366 IF (rst_unit > 0)
WRITE (rst_unit) nmo
368 DO i = 1, nmo, max(max_block, 1)
369 i_block = min(max_block, nmo - i + 1)
375 IF (rst_unit > 0)
WRITE (rst_unit) vecbuffer(1:nao, j)
380 DEALLOCATE (vecbuffer)
386 CALL timestop(handle)
397 TYPE(dcdr_env_type) :: dcdr_env
398 TYPE(qs_environment_type),
POINTER :: qs_env
400 CHARACTER(LEN=default_string_length) :: description
401 INTEGER :: alpha, beta, delta,
gamma, i, k, l, &
402 lambda, natom, nsubset, output_unit
403 REAL(dp),
DIMENSION(:, :, :),
POINTER :: apt_el_dcdr, apt_nuc_dcdr, apt_total_dcdr
404 REAL(dp),
DIMENSION(:, :, :, :),
POINTER :: apt_center_dcdr, apt_subset_dcdr
405 REAL(kind=dp),
DIMENSION(3, 3) :: sum_rule_0, sum_rule_1, sum_rule_2
406 TYPE(cp_logger_type),
POINTER :: logger
407 TYPE(cp_result_type),
POINTER :: results
408 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
409 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
410 TYPE(section_vals_type),
POINTER :: dcdr_section
419 NULLIFY (particle_set)
420 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, molecule_set=molecule_set)
421 natom =
SIZE(particle_set)
422 nsubset =
SIZE(molecule_set)
424 apt_el_dcdr => dcdr_env%apt_el_dcdr
425 apt_nuc_dcdr => dcdr_env%apt_nuc_dcdr
426 apt_total_dcdr => dcdr_env%apt_total_dcdr
427 apt_subset_dcdr => dcdr_env%apt_el_dcdr_per_subset
428 apt_center_dcdr => dcdr_env%apt_el_dcdr_per_center
430 IF (dcdr_env%localized_psi0)
THEN
431 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A)")
'APT | Write the final apt matrix per atom per subset'
434 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit, *)
'APT | Subset', l
436 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A,I3,F15.6,F15.6,F15.6)") &
437 'APT | apt_subset ', i, apt_subset_dcdr(i, :, k, l)
443 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A)") &
444 'APT | Write the final apt matrix per atom (Position perturbation)'
446 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A,I3,A,F15.6)") &
447 'APT | Atom', l,
' - GAPT ', &
448 (apt_total_dcdr(1, 1, l) &
449 + apt_total_dcdr(2, 2, l) &
450 + apt_total_dcdr(3, 3, l))/3._dp
452 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A,F15.6,F15.6,F15.6)")
"APT | ", apt_total_dcdr(i, :, l)
456 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A)")
'APT | Write the total apt matrix'
458 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit, &
459 "(A,F15.6,F15.6,F15.6)")
"APT | ", sum(apt_total_dcdr(i, :, :), dim=2)
461 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A)")
'APT | End Write the final apt matrix'
465 description =
"[DIPOLE]"
466 CALL get_results(results=results, description=description, values=dcdr_env%dipole_pos(1:3))
477 sum_rule_0(alpha, beta) = sum_rule_0(alpha, beta) &
478 + apt_total_dcdr(alpha, beta, lambda)
483 sum_rule_1(alpha, beta) = sum_rule_1(alpha, beta) &
484 + levi_civita(alpha, beta,
gamma)*dcdr_env%dipole_pos(
gamma)
491 sum_rule_2(alpha, beta) = sum_rule_2(alpha, beta) &
492 + levi_civita(beta,
gamma, delta) &
493 *particle_set(lambda)%r(
gamma) &
494 *apt_total_dcdr(delta, alpha, lambda)
502 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A)")
"APT | Position perturbation sum rules"
503 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit,
"(A,T18,A,T34,A,T49,A)") &
504 "APT |",
"Total APT",
"Dipole",
"R * APT"
507 IF (dcdr_env%output_unit > 0)
WRITE (dcdr_env%output_unit, &
508 "(A,I3,I3,F15.6,F15.6,F15.6)") &
511 sum_rule_0(alpha, beta), &
512 sum_rule_1(alpha, beta), &
513 sum_rule_2(alpha, beta)
526 REAL(dp),
DIMENSION(3),
INTENT(in) :: r
527 TYPE(cell_type),
INTENT(in),
POINTER :: cell
528 REAL(dp),
DIMENSION(3),
INTENT(out) :: r_shifted
531 REAL(kind=dp),
DIMENSION(3) :: abc
537 IF (r(i) < 0._dp)
THEN
538 r_shifted(i) = r(i) + abc(i)
539 ELSE IF (r(i) > abc(i))
THEN
540 r_shifted(i) = r(i) - abc(i)
553 TYPE(dcdr_env_type) :: dcdr_env
554 TYPE(qs_environment_type),
POINTER :: qs_env
556 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_loc_setting'
558 INTEGER :: handle, is, ispin, istate, max_states, &
559 nmo, nmoloc, nstate, nstate_list(2)
560 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: state_list
561 REAL(dp),
DIMENSION(:, :),
POINTER :: center_array
562 TYPE(linres_control_type),
POINTER :: linres_control
563 TYPE(localized_wfn_control_type),
POINTER :: localized_wfn_control
564 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
565 TYPE(qs_loc_env_type),
POINTER :: qs_loc_env
566 TYPE(section_vals_type),
POINTER :: dcdr_section
568 CALL timeset(routinen, handle)
571 linres_control=linres_control, &
577 max_states = max(max_states, nmo)
580 nmoloc =
SIZE(linres_control%qs_loc_env%localized_wfn_control%centers_set(1)%array, 2)
581 IF (nmoloc .NE. nmo)
THEN
582 cpabort(
"The number of localized functions is not equal to the number of states.")
588 SELECT CASE (dcdr_env%orb_center)
590 dcdr_env%orb_center_name =
"WANNIER"
595 qs_loc_env => linres_control%qs_loc_env
596 CALL get_qs_loc_env(qs_loc_env, localized_wfn_control=localized_wfn_control)
598 ALLOCATE (dcdr_env%centers_set(dcdr_env%nspins))
599 ALLOCATE (dcdr_env%center_list(dcdr_env%nspins))
600 ALLOCATE (state_list(max_states, dcdr_env%nspins))
601 state_list(:, :) = huge(0)
602 nstate_list(:) = huge(0)
605 DO ispin = 1, dcdr_env%nspins
606 center_array => localized_wfn_control%centers_set(ispin)%array
608 DO istate = 1,
SIZE(center_array, 2)
610 state_list(nstate, ispin) = istate
612 nstate_list(ispin) = nstate
615 nstate = nstate_list(ispin)
616 dcdr_env%nstates(ispin) = nstate
618 ALLOCATE (dcdr_env%center_list(ispin)%array(2, nstate + 1))
619 ALLOCATE (dcdr_env%centers_set(ispin)%array(3, nstate))
620 dcdr_env%center_list(ispin)%array(:, :) = huge(0)
621 dcdr_env%centers_set(ispin)%array(:, :) = huge(0.0_dp)
623 center_array => localized_wfn_control%centers_set(ispin)%array
626 SELECT CASE (dcdr_env%orb_center)
629 dcdr_env%nbr_center(ispin) = nstate
631 istate = state_list(is, 1)
632 dcdr_env%centers_set(ispin)%array(1:3, is) = center_array(1:3, istate)
633 dcdr_env%center_list(ispin)%array(1, is) = is
634 dcdr_env%center_list(ispin)%array(2, is) = istate
636 dcdr_env%center_list(ispin)%array(1, nstate + 1) = nstate + 1
639 cpabort(
"Unknown orbital center...")
643 CALL timestop(handle)
652 TYPE(dcdr_env_type) :: dcdr_env
653 TYPE(qs_environment_type),
POINTER :: qs_env
655 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dcdr_env_init'
657 INTEGER :: handle, homo, i, isize, ispin, j, jg, &
658 n_rep, nao, natom, nmo, nspins, &
659 nsubset, output_unit, reference, &
661 INTEGER,
DIMENSION(:),
POINTER :: tmplist
663 REAL(kind=dp),
DIMENSION(:),
POINTER :: ref_point
664 TYPE(cp_fm_type) :: buf
665 TYPE(cp_fm_type),
POINTER :: mo_coeff
666 TYPE(cp_logger_type),
POINTER :: logger
667 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
668 TYPE(dft_control_type),
POINTER :: dft_control
669 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
670 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
671 TYPE(mp_para_env_type),
POINTER :: para_env
672 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
673 POINTER :: sab_all, sab_orb
674 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
675 TYPE(qs_ks_env_type),
POINTER :: ks_env
676 TYPE(section_vals_type),
POINTER :: dcdr_section, loc_section, lr_section
678 CALL timeset(routinen, handle)
681 NULLIFY (logger, loc_section, dcdr_section, lr_section)
686 extension=
".data", middle_name=
"dcdr", log_filename=.false., &
687 file_position=
"REWIND", file_status=
"REPLACE")
691 extension=
".linresLog")
692 unit_number =
cp_print_key_unit_nr(logger, lr_section,
"PRINT%PROGRAM_RUN_INFO", extension=
".linresLog")
694 IF (output_unit > 0)
THEN
695 WRITE (output_unit,
"(/,T20,A,/)")
"*** Start DCDR calculation ***"
698 NULLIFY (ks_env, dft_control, sab_orb, sab_all, particle_set, molecule_set, matrix_s, matrix_ks, mos, para_env)
701 dft_control=dft_control, &
704 particle_set=particle_set, &
705 molecule_set=molecule_set, &
707 matrix_ks=matrix_ks, &
711 natom =
SIZE(particle_set)
712 nsubset =
SIZE(molecule_set)
713 nspins = dft_control%nspins
714 dcdr_env%nspins = dft_control%nspins
716 NULLIFY (dcdr_env%matrix_s)
718 matrix_name=
"OVERLAP MATRIX", &
720 basis_type_a=
"ORB", &
721 basis_type_b=
"ORB", &
724 NULLIFY (dcdr_env%matrix_t)
726 matrix_name=
"KINETIC ENERGY MATRIX", &
728 sab_nl=sab_orb, nderivative=1, &
729 eps_filter=dft_control%qs_control%eps_filter_matrix)
732 CALL section_vals_val_get(dcdr_section,
"DISTRIBUTED_ORIGIN", l_val=dcdr_env%distributed_origin)
735 dcdr_env%ref_point = 0._dp
742 ALLOCATE (dcdr_env%list_of_atoms(natom))
744 dcdr_env%list_of_atoms(jg) = jg
748 ALLOCATE (dcdr_env%list_of_atoms(isize))
750 CALL reallocate(dcdr_env%list_of_atoms, 1, isize +
SIZE(tmplist))
751 dcdr_env%list_of_atoms(isize + 1:isize +
SIZE(tmplist)) = tmplist
752 isize =
SIZE(dcdr_env%list_of_atoms)
757 IF (dcdr_env%localized_psi0)
THEN
768 cpabort(
"User-defined reference point should be given explicitly")
772 reference=reference, &
777 NULLIFY (dcdr_env%aoao_fm_struct, &
778 dcdr_env%momo_fm_struct, &
779 dcdr_env%likemos_fm_struct, &
780 dcdr_env%homohomo_fm_struct)
781 CALL get_mo_set(mo_set=mos(1), mo_coeff=mo_coeff, &
782 nao=nao, nmo=nmo, homo=homo)
784 ncol_global=nao, para_env=para_env, &
785 context=mo_coeff%matrix_struct%context)
787 ncol_global=homo, para_env=para_env, &
788 context=mo_coeff%matrix_struct%context)
791 ALLOCATE (dcdr_env%nmo(nspins))
792 ALLOCATE (dcdr_env%momo_fm_struct(nspins))
793 ALLOCATE (dcdr_env%likemos_fm_struct(nspins))
795 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
796 nao=nao, nmo=nmo, homo=homo)
798 ncol_global=nmo, para_env=para_env, &
799 context=mo_coeff%matrix_struct%context)
801 template_fmstruct=mo_coeff%matrix_struct)
802 dcdr_env%nmo(ispin) = nmo
806 ALLOCATE (dcdr_env%deltaR(3, natom))
807 ALLOCATE (dcdr_env%delta_basis_function(3, natom))
808 ALLOCATE (dcdr_env%apt_el_dcdr(3, 3, natom))
809 ALLOCATE (dcdr_env%apt_nuc_dcdr(3, 3, natom))
810 ALLOCATE (dcdr_env%apt_total_dcdr(3, 3, natom))
812 dcdr_env%apt_el_dcdr = 0._dp
813 dcdr_env%apt_nuc_dcdr = 0._dp
814 dcdr_env%apt_total_dcdr = 0._dp
816 dcdr_env%deltaR = 0.0_dp
817 dcdr_env%delta_basis_function = 0._dp
820 IF (dcdr_env%localized_psi0)
THEN
821 ALLOCATE (dcdr_env%apt_el_dcdr_per_center(3, 3, natom, dcdr_env%nbr_center(1)))
822 ALLOCATE (dcdr_env%apt_el_dcdr_per_subset(3, 3, natom, nsubset))
823 ALLOCATE (dcdr_env%apt_subset(3, 3, natom, nsubset))
824 dcdr_env%apt_el_dcdr_per_center = 0._dp
825 dcdr_env%apt_el_dcdr_per_subset = 0._dp
826 dcdr_env%apt_subset = 0.0_dp
830 ALLOCATE (dcdr_env%mo_coeff(nspins))
831 ALLOCATE (dcdr_env%dCR(nspins))
832 ALLOCATE (dcdr_env%dCR_prime(nspins))
833 ALLOCATE (dcdr_env%chc(nspins))
834 ALLOCATE (dcdr_env%op_dR(nspins))
837 CALL cp_fm_create(dcdr_env%dCR(ispin), dcdr_env%likemos_fm_struct(ispin)%struct)
838 CALL cp_fm_create(dcdr_env%dCR_prime(ispin), dcdr_env%likemos_fm_struct(ispin)%struct)
839 CALL cp_fm_create(dcdr_env%mo_coeff(ispin), dcdr_env%likemos_fm_struct(ispin)%struct)
840 CALL cp_fm_create(dcdr_env%chc(ispin), dcdr_env%momo_fm_struct(ispin)%struct)
841 CALL cp_fm_create(dcdr_env%op_dR(ispin), dcdr_env%likemos_fm_struct(ispin)%struct)
843 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
844 CALL cp_fm_to_fm(mo_coeff, dcdr_env%mo_coeff(ispin))
848 NULLIFY (dcdr_env%hamiltonian1)
849 NULLIFY (dcdr_env%moments)
850 NULLIFY (dcdr_env%matrix_difdip)
851 NULLIFY (dcdr_env%matrix_core_charge_1)
852 NULLIFY (dcdr_env%matrix_s1)
853 NULLIFY (dcdr_env%matrix_t1)
854 NULLIFY (dcdr_env%matrix_apply_op_constant)
855 NULLIFY (dcdr_env%matrix_d_vhxc_dR)
856 NULLIFY (dcdr_env%matrix_vhxc_perturbed_basis)
857 NULLIFY (dcdr_env%matrix_hc)
858 NULLIFY (dcdr_env%matrix_ppnl_1)
876 CALL dbcsr_init_p(dcdr_env%matrix_nosym_temp(i)%matrix)
877 CALL dbcsr_create(dcdr_env%matrix_nosym_temp(i)%matrix, template=matrix_ks(1)%matrix, &
878 matrix_type=dbcsr_type_no_symmetry)
880 CALL dbcsr_set(dcdr_env%matrix_nosym_temp(i)%matrix, 0._dp)
882 CALL dbcsr_init_p(dcdr_env%matrix_nosym_temp2(i)%matrix)
883 CALL dbcsr_create(dcdr_env%matrix_nosym_temp2(i)%matrix, template=matrix_ks(1)%matrix, &
884 matrix_type=dbcsr_type_no_symmetry)
886 CALL dbcsr_set(dcdr_env%matrix_nosym_temp2(i)%matrix, 0._dp)
891 CALL dbcsr_init_p(dcdr_env%moments(i)%matrix)
892 CALL dbcsr_copy(dcdr_env%moments(i)%matrix, matrix_ks(1)%matrix,
"dcdr_env%moments")
893 CALL dbcsr_set(dcdr_env%moments(i)%matrix, 0.0_dp)
899 CALL dbcsr_init_p(dcdr_env%matrix_difdip(i, j)%matrix)
900 CALL dbcsr_copy(dcdr_env%matrix_difdip(i, j)%matrix, dcdr_env%matrix_nosym_temp(1)%matrix)
901 CALL dbcsr_set(dcdr_env%matrix_difdip(i, j)%matrix, 0.0_dp)
906 CALL dbcsr_init_p(dcdr_env%hamiltonian1(ispin)%matrix)
907 CALL dbcsr_init_p(dcdr_env%perturbed_dm_correction(ispin)%matrix)
908 CALL dbcsr_init_p(dcdr_env%matrix_apply_op_constant(ispin)%matrix)
909 CALL dbcsr_copy(dcdr_env%matrix_apply_op_constant(ispin)%matrix, matrix_ks(1)%matrix)
910 CALL dbcsr_copy(dcdr_env%perturbed_dm_correction(ispin)%matrix, matrix_ks(1)%matrix)
915 CALL dbcsr_init_p(dcdr_env%matrix_s1(1)%matrix)
916 CALL dbcsr_init_p(dcdr_env%matrix_t1(1)%matrix)
918 CALL dbcsr_copy(dcdr_env%matrix_s1(1)%matrix, matrix_s(1)%matrix)
919 CALL dbcsr_copy(dcdr_env%matrix_t1(1)%matrix, dcdr_env%matrix_t(1)%matrix)
922 CALL dbcsr_init_p(dcdr_env%matrix_s1(i)%matrix)
923 CALL dbcsr_copy(dcdr_env%matrix_s1(i)%matrix, dcdr_env%matrix_nosym_temp(1)%matrix)
925 CALL dbcsr_init_p(dcdr_env%matrix_t1(i)%matrix)
926 CALL dbcsr_copy(dcdr_env%matrix_t1(i)%matrix, dcdr_env%matrix_nosym_temp(1)%matrix)
932 CALL dbcsr_init_p(dcdr_env%matrix_vhxc_perturbed_basis(ispin, j)%matrix)
933 CALL dbcsr_copy(dcdr_env%matrix_vhxc_perturbed_basis(ispin, j)%matrix, dcdr_env%matrix_s1(1)%matrix)
938 CALL dbcsr_init_p(dcdr_env%matrix_hc(i)%matrix)
939 CALL dbcsr_create(dcdr_env%matrix_hc(i)%matrix, template=matrix_ks(1)%matrix, &
940 matrix_type=dbcsr_type_symmetric)
942 CALL dbcsr_set(dcdr_env%matrix_hc(i)%matrix, 0.0_dp)
946 CALL dbcsr_init_p(dcdr_env%matrix_ppnl_1(i)%matrix)
947 CALL dbcsr_create(dcdr_env%matrix_ppnl_1(i)%matrix, template=matrix_ks(1)%matrix, &
948 matrix_type=dbcsr_type_symmetric)
950 CALL dbcsr_set(dcdr_env%matrix_ppnl_1(i)%matrix, 0.0_dp)
955 CALL dbcsr_init_p(dcdr_env%matrix_d_vhxc_dR(i, ispin)%matrix)
956 CALL dbcsr_copy(dcdr_env%matrix_d_vhxc_dR(i, ispin)%matrix, dcdr_env%matrix_s1(1)%matrix)
959 CALL dbcsr_init_p(dcdr_env%matrix_core_charge_1(i)%matrix)
960 CALL dbcsr_copy(dcdr_env%matrix_core_charge_1(i)%matrix, dcdr_env%matrix_s1(1)%matrix)
961 CALL dbcsr_set(dcdr_env%matrix_core_charge_1(i)%matrix, 0.0_dp)
966 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
967 CALL cp_fm_create(buf, dcdr_env%likemos_fm_struct(ispin)%struct)
971 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, &
972 1.0_dp, mo_coeff, buf, &
973 0.0_dp, dcdr_env%chc(ispin))
975 CALL cp_fm_release(buf)
979 "PRINT%PROGRAM_RUN_INFO")
981 CALL timestop(handle)
991 TYPE(qs_environment_type),
POINTER :: qs_env
992 TYPE(dcdr_env_type) :: dcdr_env
995 TYPE(cp_logger_type),
POINTER :: logger
996 TYPE(section_vals_type),
POINTER :: dcdr_section
1003 DEALLOCATE (dcdr_env%list_of_atoms)
1007 DO ispin = 1, dcdr_env%nspins
1011 DEALLOCATE (dcdr_env%momo_fm_struct)
1012 DEALLOCATE (dcdr_env%likemos_fm_struct)
1014 DEALLOCATE (dcdr_env%deltar)
1015 DEALLOCATE (dcdr_env%delta_basis_function)
1017 IF (dcdr_env%localized_psi0)
THEN
1019 DEALLOCATE (dcdr_env%centers_set(1)%array)
1020 DEALLOCATE (dcdr_env%center_list(1)%array)
1021 DEALLOCATE (dcdr_env%centers_set)
1022 DEALLOCATE (dcdr_env%center_list)
1023 DEALLOCATE (dcdr_env%apt_subset)
1026 DEALLOCATE (dcdr_env%apt_el_dcdr)
1027 DEALLOCATE (dcdr_env%apt_nuc_dcdr)
1028 DEALLOCATE (dcdr_env%apt_total_dcdr)
1029 IF (dcdr_env%localized_psi0)
THEN
1030 DEALLOCATE (dcdr_env%apt_el_dcdr_per_center)
1031 DEALLOCATE (dcdr_env%apt_el_dcdr_per_subset)
1035 CALL cp_fm_release(dcdr_env%dCR)
1036 CALL cp_fm_release(dcdr_env%dCR_prime)
1037 CALL cp_fm_release(dcdr_env%mo_coeff)
1038 CALL cp_fm_release(dcdr_env%chc)
1039 CALL cp_fm_release(dcdr_env%op_dR)
Handles all functions related to the CELL.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
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
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
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_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
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...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
set of type/routines to handle the storage of results in force_envs
set of type/routines to handle the storage of results in force_envs
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Utility routines for the memory handling.
Interface to the message passing library MPI.
Define the data structure for the molecule information.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Calculate the derivatives of the MO coefficients wrt nuclear coordinates.
subroutine, public dcdr_env_cleanup(qs_env, dcdr_env)
Deallocate the dcdr environment.
subroutine, public multiply_localization(ao_matrix, mo_coeff, work, nmo, icenter, res)
Multiply (ao_matrix @ mo_coeff) and store the column icenter in res.
subroutine, public dcdr_print(dcdr_env, qs_env)
Print the APT and sum rules.
subroutine, public dcdr_read_restart(qs_env, linres_section, vec, lambda, beta, tag)
Copied from linres_read_restart.
subroutine, public shift_wannier_into_cell(r, cell, r_shifted)
...
subroutine, public get_loc_setting(dcdr_env, qs_env)
...
subroutine, public dcdr_write_restart(qs_env, linres_section, vec, lambda, beta, tag)
Copied from linres_write_restart.
subroutine, public dcdr_env_init(dcdr_env, qs_env)
Initialize the dcdr environment.
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_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, 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, rhs)
Get the QUICKSTEP environment.
Calculation of kinetic energy matrix and forces.
subroutine, public build_kinetic_matrix(ks_env, matrix_t, matrixkp_t, matrix_name, basis_type, sab_nl, calculate_forces, matrix_p, matrixkp_p, eps_filter, nderivative)
Calculation of the kinetic energy matrix over Cartesian Gaussian functions.
Type definitiona for linear response calculations.
New version of the module for the localization of the molecular orbitals This should be able to use d...
subroutine, public get_qs_loc_env(qs_loc_env, cell, local_molecules, localized_wfn_control, moloc_coeff, op_sm_set, op_fm_set, para_env, particle_set, weights, dim_op)
...
Definition and initialisation of the mo data type.
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.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
subroutine, public build_local_moment_matrix(qs_env, moments, nmoments, ref_point, ref_points, basis_type)
...
Define the neighbor list data types and the corresponding functionality.
Calculation of overlap matrix, its derivatives and forces.
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Utilities for string manipulations.
elemental subroutine, public xstring(string, ia, ib)
...