39 optimizer_options_type,&
56 USE dbcsr_api,
ONLY: &
57 dbcsr_add, dbcsr_add_on_diag, dbcsr_binary_read, dbcsr_checksum, dbcsr_copy, dbcsr_create, &
58 dbcsr_distribution_get, dbcsr_distribution_type, dbcsr_filter, dbcsr_finalize, &
59 dbcsr_get_info, dbcsr_get_stored_coordinates, dbcsr_init_random, &
60 dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, dbcsr_iterator_start, &
61 dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_multiply, dbcsr_nblkcols_total, &
62 dbcsr_nblkrows_total, dbcsr_p_type, dbcsr_release, dbcsr_reserve_block2d, dbcsr_scale, &
63 dbcsr_set, dbcsr_type, dbcsr_type_no_symmetry, dbcsr_type_symmetric, dbcsr_work_create
86 molecular_scf_guess_env_type
99 #include "./base/base_uses.f90"
105 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'almo_scf'
109 LOGICAL,
PARAMETER :: debug_mode = .false.
110 LOGICAL,
PARAMETER :: safe_mode = .false.
123 TYPE(qs_environment_type),
POINTER :: qs_env
124 LOGICAL,
INTENT(IN) :: calc_forces
126 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_entry_scf'
129 TYPE(almo_scf_env_type),
POINTER :: almo_scf_env
131 CALL timeset(routinen, handle)
136 CALL get_qs_env(qs_env, almo_scf_env=almo_scf_env)
139 CALL almo_scf_init(qs_env, almo_scf_env, calc_forces)
142 CALL almo_scf_initial_guess(qs_env, almo_scf_env)
145 CALL almo_scf_main(qs_env, almo_scf_env)
148 CALL almo_scf_delocalization(qs_env, almo_scf_env)
151 CALL construct_nlmos(qs_env, almo_scf_env)
157 CALL almo_scf_post(qs_env, almo_scf_env)
160 CALL almo_scf_clean_up(almo_scf_env)
162 CALL timestop(handle)
176 SUBROUTINE almo_scf_init(qs_env, almo_scf_env, calc_forces)
177 TYPE(qs_environment_type),
POINTER :: qs_env
178 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
179 LOGICAL,
INTENT(IN) :: calc_forces
181 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_init'
183 INTEGER :: ao, handle, i, iao, idomain, ispin, &
184 multip, naos, natoms, ndomains, nelec, &
185 nelec_a, nelec_b, nmols, nspins, &
187 TYPE(cp_logger_type),
POINTER :: logger
188 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s
189 TYPE(dft_control_type),
POINTER :: dft_control
190 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
191 TYPE(section_vals_type),
POINTER :: input
193 CALL timeset(routinen, handle)
197 IF (logger%para_env%is_source())
THEN
205 almo_scf_env%opt_block_diag_pcg%optimizer_type =
optimizer_pcg
215 nelectron_total=almo_scf_env%nelectrons_total, &
217 dft_control=dft_control, &
218 molecule_set=molecule_set, &
220 has_unit_metric=almo_scf_env%orthogonal_basis, &
221 para_env=almo_scf_env%para_env, &
222 blacs_env=almo_scf_env%blacs_env, &
223 nelectron_spin=almo_scf_env%nelectrons_spin)
224 CALL almo_scf_env%para_env%retain()
225 CALL almo_scf_env%blacs_env%retain()
228 almo_scf_env%nspins = dft_control%nspins
229 almo_scf_env%natoms = dbcsr_nblkrows_total(matrix_s(1)%matrix)
230 almo_scf_env%nmolecules =
SIZE(molecule_set)
231 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=naos)
232 almo_scf_env%naos = naos
235 almo_scf_env%smear = dft_control%smear
236 IF (almo_scf_env%smear)
THEN
238 IF ((almo_scf_env%almo_update_algorithm .NE.
almo_scf_diag) .OR. &
240 (almo_scf_env%xalmo_update_algorithm .NE.
almo_scf_diag)))
THEN
241 cpabort(
"ALMO smearing is currently implemented for DIAG algorithm only")
244 cpabort(
"Only Fermi-Dirac smearing is currently compatible with ALMO")
246 almo_scf_env%smear_e_temp = qs_env%scf_control%smear%electronic_temperature
249 cpabort(
"ALMO smearing was designed to work with molecular fragments only")
254 nspins = almo_scf_env%nspins
255 nmols = almo_scf_env%nmolecules
256 natoms = almo_scf_env%natoms
260 almo_scf_env%ndomains = almo_scf_env%nmolecules
262 almo_scf_env%ndomains = almo_scf_env%natoms
266 ndomains = almo_scf_env%ndomains
267 ALLOCATE (almo_scf_env%domain_index_of_atom(natoms))
268 ALLOCATE (almo_scf_env%domain_index_of_ao(naos))
269 ALLOCATE (almo_scf_env%first_atom_of_domain(ndomains))
270 ALLOCATE (almo_scf_env%last_atom_of_domain(ndomains))
271 ALLOCATE (almo_scf_env%nbasis_of_domain(ndomains))
272 ALLOCATE (almo_scf_env%nocc_of_domain(ndomains, nspins))
273 ALLOCATE (almo_scf_env%real_ne_of_domain(ndomains, nspins))
274 ALLOCATE (almo_scf_env%nvirt_full_of_domain(ndomains, nspins))
275 ALLOCATE (almo_scf_env%nvirt_of_domain(ndomains, nspins))
276 ALLOCATE (almo_scf_env%nvirt_disc_of_domain(ndomains, nspins))
277 ALLOCATE (almo_scf_env%mu_of_domain(ndomains, nspins))
278 ALLOCATE (almo_scf_env%cpu_of_domain(ndomains))
279 ALLOCATE (almo_scf_env%charge_of_domain(ndomains))
280 ALLOCATE (almo_scf_env%multiplicity_of_domain(ndomains))
286 atom_to_mol=almo_scf_env%domain_index_of_atom, &
287 mol_to_first_atom=almo_scf_env%first_atom_of_domain, &
288 mol_to_last_atom=almo_scf_env%last_atom_of_domain, &
289 mol_to_nelectrons=almo_scf_env%nocc_of_domain(1:ndomains, 1), &
290 mol_to_nbasis=almo_scf_env%nbasis_of_domain, &
291 mol_to_charge=almo_scf_env%charge_of_domain, &
292 mol_to_multiplicity=almo_scf_env%multiplicity_of_domain)
297 DO idomain = 1, ndomains
298 nelec = almo_scf_env%nocc_of_domain(idomain, 1)
299 multip = almo_scf_env%multiplicity_of_domain(idomain)
300 nelec_a = (nelec + multip - 1)/2
301 nelec_b = nelec - nelec_a
303 IF (almo_scf_env%smear)
THEN
304 IF (multip .GT. 1)
THEN
305 cpwarn(
"BEWARE: Non singlet state detected, treating it as closed-shell")
309 almo_scf_env%real_ne_of_domain(idomain, :) = real(nelec, kind=
dp)/2.0_dp
312 almo_scf_env%nocc_of_domain(idomain, :) = ceiling(almo_scf_env%real_ne_of_domain(idomain, :)) &
313 + (almo_scf_env%last_atom_of_domain(idomain) &
314 - almo_scf_env%first_atom_of_domain(idomain) + 1)
316 almo_scf_env%nocc_of_domain(idomain, 1) = nelec_a
317 IF (nelec_a .NE. nelec_b)
THEN
318 IF (nspins .EQ. 1)
THEN
319 WRITE (*, *)
"Domain ", idomain,
" out of ", ndomains,
". Electrons = ", nelec
320 cpabort(
"odd e- -- use unrestricted methods")
322 almo_scf_env%nocc_of_domain(idomain, 2) = nelec_b
325 cpabort(
"Unrestricted ALMO methods are NYI")
331 almo_scf_env%nvirt_full_of_domain(:, ispin) = &
332 almo_scf_env%nbasis_of_domain(:) - &
333 almo_scf_env%nocc_of_domain(:, ispin)
335 SELECT CASE (almo_scf_env%deloc_truncate_virt)
337 almo_scf_env%nvirt_of_domain(:, ispin) = &
338 almo_scf_env%nvirt_full_of_domain(:, ispin)
339 almo_scf_env%nvirt_disc_of_domain(:, ispin) = 0
341 DO idomain = 1, ndomains
342 almo_scf_env%nvirt_of_domain(idomain, ispin) = &
343 min(almo_scf_env%deloc_virt_per_domain, &
344 almo_scf_env%nvirt_full_of_domain(idomain, ispin))
345 almo_scf_env%nvirt_disc_of_domain(idomain, ispin) = &
346 almo_scf_env%nvirt_full_of_domain(idomain, ispin) - &
347 almo_scf_env%nvirt_of_domain(idomain, ispin)
350 DO idomain = 1, ndomains
351 almo_scf_env%nvirt_of_domain(idomain, ispin) = &
352 min(almo_scf_env%nocc_of_domain(idomain, ispin), &
353 almo_scf_env%nvirt_full_of_domain(idomain, ispin))
354 almo_scf_env%nvirt_disc_of_domain(idomain, ispin) = &
355 almo_scf_env%nvirt_full_of_domain(idomain, ispin) - &
356 almo_scf_env%nvirt_of_domain(idomain, ispin)
359 cpabort(
"illegal method for virtual space truncation")
364 almo_scf_env%domain_index_of_atom(1:natoms) = (/(i, i=1, natoms)/)
368 DO idomain = 1, ndomains
369 DO iao = 1, almo_scf_env%nbasis_of_domain(idomain)
370 almo_scf_env%domain_index_of_ao(ao) = idomain
375 almo_scf_env%mu_of_domain(:, :) = almo_scf_env%mu
380 ALLOCATE (almo_scf_env%domain_index_of_ao_block(natoms))
381 almo_scf_env%domain_index_of_ao_block(:) = &
382 almo_scf_env%domain_index_of_atom(:)
384 ALLOCATE (almo_scf_env%domain_index_of_ao_block(nmols))
386 almo_scf_env%domain_index_of_ao_block(:) = (/(i, i=1, nmols)/)
390 ALLOCATE (almo_scf_env%domain_index_of_mo_block(natoms))
391 almo_scf_env%domain_index_of_mo_block(:) = &
392 almo_scf_env%domain_index_of_atom(:)
394 ALLOCATE (almo_scf_env%domain_index_of_mo_block(nmols))
396 almo_scf_env%domain_index_of_mo_block(:) = (/(i, i=1, nmols)/)
402 almo_scf_env%need_previous_ks = .true.
408 almo_scf_env%need_virtuals = .true.
409 almo_scf_env%need_orbital_energies = .true.
412 almo_scf_env%calc_forces = calc_forces
413 IF (calc_forces)
THEN
418 cpabort(
"Forces for perturbative methods are NYI. Change DELOCALIZE_METHOD")
421 IF (almo_scf_env%almo_history%istore .GT. (almo_scf_env%almo_history%nstore + 1))
THEN
422 IF (almo_scf_env%opt_block_diag_pcg%eps_error_early .GT. 0.0_dp)
THEN
423 almo_scf_env%opt_block_diag_pcg%eps_error = almo_scf_env%opt_block_diag_pcg%eps_error_early
424 almo_scf_env%opt_block_diag_pcg%early_stopping_on = .true.
425 IF (unit_nr > 0)
WRITE (*, *)
"ALMO_OPTIMIZER_PCG: EPS_ERROR_EARLY is on"
427 IF (almo_scf_env%opt_block_diag_diis%eps_error_early .GT. 0.0_dp)
THEN
428 almo_scf_env%opt_block_diag_diis%eps_error = almo_scf_env%opt_block_diag_diis%eps_error_early
429 almo_scf_env%opt_block_diag_diis%early_stopping_on = .true.
430 IF (unit_nr > 0)
WRITE (*, *)
"ALMO_OPTIMIZER_DIIS: EPS_ERROR_EARLY is on"
432 IF (almo_scf_env%opt_block_diag_pcg%max_iter_early .GT. 0)
THEN
433 almo_scf_env%opt_block_diag_pcg%max_iter = almo_scf_env%opt_block_diag_pcg%max_iter_early
434 almo_scf_env%opt_block_diag_pcg%early_stopping_on = .true.
435 IF (unit_nr > 0)
WRITE (*, *)
"ALMO_OPTIMIZER_PCG: MAX_ITER_EARLY is on"
437 IF (almo_scf_env%opt_block_diag_diis%max_iter_early .GT. 0)
THEN
438 almo_scf_env%opt_block_diag_diis%max_iter = almo_scf_env%opt_block_diag_diis%max_iter_early
439 almo_scf_env%opt_block_diag_diis%early_stopping_on = .true.
440 IF (unit_nr > 0)
WRITE (*, *)
"ALMO_OPTIMIZER_DIIS: MAX_ITER_EARLY is on"
443 almo_scf_env%opt_block_diag_diis%early_stopping_on = .false.
444 almo_scf_env%opt_block_diag_pcg%early_stopping_on = .false.
446 IF (almo_scf_env%xalmo_history%istore .GT. (almo_scf_env%xalmo_history%nstore + 1))
THEN
447 IF (almo_scf_env%opt_xalmo_pcg%eps_error_early .GT. 0.0_dp)
THEN
448 almo_scf_env%opt_xalmo_pcg%eps_error = almo_scf_env%opt_xalmo_pcg%eps_error_early
449 almo_scf_env%opt_xalmo_pcg%early_stopping_on = .true.
450 IF (unit_nr > 0)
WRITE (*, *)
"XALMO_OPTIMIZER_PCG: EPS_ERROR_EARLY is on"
452 IF (almo_scf_env%opt_xalmo_pcg%max_iter_early .GT. 0.0_dp)
THEN
453 almo_scf_env%opt_xalmo_pcg%max_iter = almo_scf_env%opt_xalmo_pcg%max_iter_early
454 almo_scf_env%opt_xalmo_pcg%early_stopping_on = .true.
455 IF (unit_nr > 0)
WRITE (*, *)
"XALMO_OPTIMIZER_PCG: MAX_ITER_EARLY is on"
458 almo_scf_env%opt_xalmo_pcg%early_stopping_on = .false.
463 CALL almo_scf_env_create_matrices(almo_scf_env, matrix_s(1)%matrix)
466 almo_scf_env%s_inv_done = .false.
467 almo_scf_env%s_sqrt_done = .false.
468 CALL almo_scf_init_ao_overlap(matrix_s(1)%matrix, almo_scf_env)
475 CALL almo_scf_print_job_info(almo_scf_env, unit_nr)
478 ALLOCATE (almo_scf_env%domain_preconditioner(ndomains, nspins))
479 CALL init_submatrices(almo_scf_env%domain_preconditioner)
482 ALLOCATE (almo_scf_env%domain_ks_xx(ndomains, nspins))
483 CALL init_submatrices(almo_scf_env%domain_ks_xx)
486 ALLOCATE (almo_scf_env%domain_s_inv(ndomains, nspins))
487 CALL init_submatrices(almo_scf_env%domain_s_inv)
488 ALLOCATE (almo_scf_env%domain_s_sqrt_inv(ndomains, nspins))
489 CALL init_submatrices(almo_scf_env%domain_s_sqrt_inv)
490 ALLOCATE (almo_scf_env%domain_s_sqrt(ndomains, nspins))
491 CALL init_submatrices(almo_scf_env%domain_s_sqrt)
492 ALLOCATE (almo_scf_env%domain_t(ndomains, nspins))
493 CALL init_submatrices(almo_scf_env%domain_t)
494 ALLOCATE (almo_scf_env%domain_err(ndomains, nspins))
495 CALL init_submatrices(almo_scf_env%domain_err)
496 ALLOCATE (almo_scf_env%domain_r_down_up(ndomains, nspins))
497 CALL init_submatrices(almo_scf_env%domain_r_down_up)
501 almo_scf_env%matrix_ks, &
502 almo_scf_env%mat_distr_aos, &
503 almo_scf_env%eps_filter)
506 CALL timestop(handle)
508 END SUBROUTINE almo_scf_init
519 SUBROUTINE almo_scf_initial_guess(qs_env, almo_scf_env)
520 TYPE(qs_environment_type),
POINTER :: qs_env
521 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
523 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_initial_guess'
525 CHARACTER(LEN=default_path_length) :: file_name, project_name
526 INTEGER :: handle, iaspc, ispin, istore, naspc, &
528 INTEGER,
DIMENSION(2) :: nelectron_spin
529 LOGICAL :: aspc_guess, has_unit_metric
530 REAL(kind=
dp) :: alpha, cs_pos, energy, kts_sum
531 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
532 TYPE(cp_logger_type),
POINTER :: logger
533 TYPE(dbcsr_distribution_type) :: dist
534 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao
535 TYPE(dft_control_type),
POINTER :: dft_control
536 TYPE(molecular_scf_guess_env_type),
POINTER :: mscfg_env
537 TYPE(mp_para_env_type),
POINTER :: para_env
538 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
539 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
540 TYPE(qs_rho_type),
POINTER :: rho
542 CALL timeset(routinen, handle)
544 NULLIFY (rho, rho_ao)
548 IF (logger%para_env%is_source())
THEN
556 dft_control=dft_control, &
558 atomic_kind_set=atomic_kind_set, &
559 qs_kind_set=qs_kind_set, &
560 particle_set=particle_set, &
561 has_unit_metric=has_unit_metric, &
563 nelectron_spin=nelectron_spin, &
564 mscfg_env=mscfg_env, &
568 cpassert(
ASSOCIATED(mscfg_env))
574 IF (almo_scf_env%almo_history%istore == 0)
THEN
580 nspins = almo_scf_env%nspins
583 IF (.NOT. aspc_guess)
THEN
585 SELECT CASE (almo_scf_env%almo_scf_guess)
594 almo_scf_env%matrix_t_blk(ispin), ispin)
595 CALL dbcsr_filter(almo_scf_env%matrix_t_blk(ispin), &
596 almo_scf_env%eps_filter)
602 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%semi_empirical .OR. &
603 dft_control%qs_control%xtb)
THEN
605 matrix_s(1)%matrix, has_unit_metric, &
606 dft_control, particle_set, atomic_kind_set, qs_kind_set, &
607 nspins, nelectron_spin, &
611 nspins, nelectron_spin, unit_nr, para_env)
617 almo_scf_env%matrix_p_blk(ispin), almo_scf_env%mat_distr_aos, &
619 CALL dbcsr_filter(almo_scf_env%matrix_p_blk(ispin), &
620 almo_scf_env%eps_filter)
629 project_name = logger%iter_info%project_name
632 WRITE (file_name,
'(A,I0,A)') trim(project_name)//
"_ALMO_SPIN_", ispin,
"_RESTART.mo"
633 CALL dbcsr_get_info(almo_scf_env%matrix_t_blk(ispin), distribution=dist)
634 CALL dbcsr_binary_read(file_name, distribution=dist, matrix_new=almo_scf_env%matrix_t_blk(ispin))
635 cs_pos = dbcsr_checksum(almo_scf_env%matrix_t_blk(ispin), pos=.true.)
636 IF (unit_nr > 0)
THEN
637 WRITE (unit_nr,
'(T2,A,E20.8)')
"Read restart ALMO "//trim(file_name)//
" with checksum: ", cs_pos
647 naspc = min(almo_scf_env%almo_history%istore, almo_scf_env%almo_history%nstore)
648 IF (unit_nr > 0)
THEN
649 WRITE (unit_nr, fmt=
"(/,T2,A,/,/,T3,A,I0)") &
650 "Parameters for the always stable predictor-corrector (ASPC) method:", &
651 "ASPC order: ", naspc
658 istore = mod(almo_scf_env%almo_history%istore - iaspc, almo_scf_env%almo_history%nstore) + 1
659 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=
dp)* &
661 IF (unit_nr > 0)
THEN
662 WRITE (unit_nr, fmt=
"(T3,A2,I0,A4,F10.6)") &
663 "B(", iaspc,
") = ", alpha
666 CALL dbcsr_copy(almo_scf_env%matrix_t_blk(ispin), &
667 almo_scf_env%almo_history%matrix_t(ispin), &
668 keep_sparsity=.true.)
669 CALL dbcsr_scale(almo_scf_env%matrix_t_blk(ispin), alpha)
671 CALL dbcsr_multiply(
"N",
"N", alpha, &
672 almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
673 almo_scf_env%almo_history%matrix_t(ispin), &
674 1.0_dp, almo_scf_env%matrix_t_blk(ispin), &
675 retain_sparsity=.true.)
686 overlap=almo_scf_env%matrix_sigma_blk(ispin), &
687 metric=almo_scf_env%matrix_s_blk(1), &
688 retain_locality=.true., &
689 only_normalize=.false., &
690 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
691 eps_filter=almo_scf_env%eps_filter, &
692 order_lanczos=almo_scf_env%order_lanczos, &
693 eps_lanczos=almo_scf_env%eps_lanczos, &
694 max_iter_lanczos=almo_scf_env%max_iter_lanczos)
697 IF (almo_scf_env%smear)
THEN
699 mo_energies=almo_scf_env%mo_energies(:, ispin), &
700 mu_of_domain=almo_scf_env%mu_of_domain(:, ispin), &
701 real_ne_of_domain=almo_scf_env%real_ne_of_domain(:, ispin), &
702 spin_kts=almo_scf_env%kTS(ispin), &
703 smear_e_temp=almo_scf_env%smear_e_temp, &
704 ndomains=almo_scf_env%ndomains, &
705 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin))
709 p=almo_scf_env%matrix_p(ispin), &
710 eps_filter=almo_scf_env%eps_filter, &
711 orthog_orbs=.false., &
712 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
713 s=almo_scf_env%matrix_s(1), &
714 sigma=almo_scf_env%matrix_sigma(ispin), &
715 sigma_inv=almo_scf_env%matrix_sigma_inv(ispin), &
717 smear=almo_scf_env%smear, &
718 algorithm=almo_scf_env%sigma_inv_algorithm, &
719 eps_lanczos=almo_scf_env%eps_lanczos, &
720 max_iter_lanczos=almo_scf_env%max_iter_lanczos, &
721 inv_eps_factor=almo_scf_env%matrix_iter_eps_error_factor, &
722 para_env=almo_scf_env%para_env, &
723 blacs_env=almo_scf_env%blacs_env)
728 IF (nspins == 1)
THEN
729 CALL dbcsr_scale(almo_scf_env%matrix_p(1), 2.0_dp)
731 IF (almo_scf_env%smear)
THEN
732 almo_scf_env%kTS(1) = almo_scf_env%kTS(1)*2.0_dp
736 IF (almo_scf_env%smear)
THEN
737 kts_sum = sum(almo_scf_env%kTS)
743 almo_scf_env%matrix_p, &
744 almo_scf_env%matrix_ks, &
746 almo_scf_env%eps_filter, &
747 almo_scf_env%mat_distr_aos, &
748 smear=almo_scf_env%smear, &
751 IF (unit_nr > 0)
THEN
753 WRITE (unit_nr,
'(T2,A38,F40.10)')
"Single-molecule energy:", &
754 sum(mscfg_env%energy_of_frag)
756 WRITE (unit_nr,
'(T2,A38,F40.10)')
"Energy of the initial guess:", energy
757 WRITE (unit_nr,
'()')
760 CALL timestop(handle)
762 END SUBROUTINE almo_scf_initial_guess
771 SUBROUTINE almo_scf_store_extrapolation_data(almo_scf_env)
772 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
774 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_store_extrapolation_data'
776 INTEGER :: handle, ispin, istore, unit_nr
777 LOGICAL :: delocalization_uses_extrapolation
778 TYPE(cp_logger_type),
POINTER :: logger
779 TYPE(dbcsr_type) :: matrix_no_tmp1, matrix_no_tmp2, &
780 matrix_no_tmp3, matrix_no_tmp4
782 CALL timeset(routinen, handle)
786 IF (logger%para_env%is_source())
THEN
792 IF (almo_scf_env%almo_history%nstore > 0)
THEN
794 almo_scf_env%almo_history%istore = almo_scf_env%almo_history%istore + 1
796 DO ispin = 1,
SIZE(almo_scf_env%matrix_t_blk)
798 istore = mod(almo_scf_env%almo_history%istore - 1, almo_scf_env%almo_history%nstore) + 1
800 IF (almo_scf_env%almo_history%istore == 1)
THEN
801 CALL dbcsr_create(almo_scf_env%almo_history%matrix_t(ispin), &
802 template=almo_scf_env%matrix_t_blk(ispin), &
803 matrix_type=dbcsr_type_no_symmetry)
805 CALL dbcsr_copy(almo_scf_env%almo_history%matrix_t(ispin), &
806 almo_scf_env%matrix_t_blk(ispin))
808 IF (almo_scf_env%almo_history%istore <= almo_scf_env%almo_history%nstore)
THEN
809 CALL dbcsr_create(almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
810 template=almo_scf_env%matrix_s(1), &
811 matrix_type=dbcsr_type_no_symmetry)
814 CALL dbcsr_create(matrix_no_tmp1, template=almo_scf_env%matrix_t_blk(ispin), &
815 matrix_type=dbcsr_type_no_symmetry)
816 CALL dbcsr_create(matrix_no_tmp2, template=almo_scf_env%matrix_t_blk(ispin), &
817 matrix_type=dbcsr_type_no_symmetry)
820 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, almo_scf_env%matrix_s(1), &
821 almo_scf_env%matrix_t_blk(ispin), &
822 0.0_dp, matrix_no_tmp1, &
823 filter_eps=almo_scf_env%eps_filter)
824 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_no_tmp1, &
825 almo_scf_env%matrix_sigma_inv_0deloc(ispin), &
826 0.0_dp, matrix_no_tmp2, &
827 filter_eps=almo_scf_env%eps_filter)
828 CALL dbcsr_multiply(
"N",
"T", 1.0_dp, &
829 almo_scf_env%matrix_t_blk(ispin), &
831 0.0_dp, almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
832 filter_eps=almo_scf_env%eps_filter)
834 CALL dbcsr_release(matrix_no_tmp1)
835 CALL dbcsr_release(matrix_no_tmp2)
842 delocalization_uses_extrapolation = &
845 IF (almo_scf_env%xalmo_history%nstore > 0 .AND. &
846 delocalization_uses_extrapolation)
THEN
848 almo_scf_env%xalmo_history%istore = almo_scf_env%xalmo_history%istore + 1
850 DO ispin = 1,
SIZE(almo_scf_env%matrix_t)
852 istore = mod(almo_scf_env%xalmo_history%istore - 1, almo_scf_env%xalmo_history%nstore) + 1
854 IF (almo_scf_env%xalmo_history%istore == 1)
THEN
855 CALL dbcsr_create(almo_scf_env%xalmo_history%matrix_t(ispin), &
856 template=almo_scf_env%matrix_t(ispin), &
857 matrix_type=dbcsr_type_no_symmetry)
859 CALL dbcsr_copy(almo_scf_env%xalmo_history%matrix_t(ispin), &
860 almo_scf_env%matrix_t(ispin))
862 IF (almo_scf_env%xalmo_history%istore <= almo_scf_env%xalmo_history%nstore)
THEN
867 CALL dbcsr_create(almo_scf_env%xalmo_history%matrix_p_up_down(ispin, istore), &
868 template=almo_scf_env%matrix_s(1), &
869 matrix_type=dbcsr_type_no_symmetry)
872 CALL dbcsr_create(matrix_no_tmp3, template=almo_scf_env%matrix_t(ispin), &
873 matrix_type=dbcsr_type_no_symmetry)
874 CALL dbcsr_create(matrix_no_tmp4, template=almo_scf_env%matrix_t(ispin), &
875 matrix_type=dbcsr_type_no_symmetry)
878 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, almo_scf_env%matrix_s(1), &
879 almo_scf_env%matrix_t(ispin), &
880 0.0_dp, matrix_no_tmp3, &
881 filter_eps=almo_scf_env%eps_filter)
882 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_no_tmp3, &
883 almo_scf_env%matrix_sigma_inv(ispin), &
884 0.0_dp, matrix_no_tmp4, &
885 filter_eps=almo_scf_env%eps_filter)
886 CALL dbcsr_multiply(
"N",
"T", 1.0_dp, &
887 almo_scf_env%matrix_t(ispin), &
889 0.0_dp, almo_scf_env%xalmo_history%matrix_p_up_down(ispin, istore), &
890 filter_eps=almo_scf_env%eps_filter)
898 CALL dbcsr_release(matrix_no_tmp3)
899 CALL dbcsr_release(matrix_no_tmp4)
905 CALL timestop(handle)
907 END SUBROUTINE almo_scf_store_extrapolation_data
917 SUBROUTINE almo_scf_print_job_info(almo_scf_env, unit_nr)
919 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
920 INTEGER,
INTENT(IN) :: unit_nr
922 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_print_job_info'
924 CHARACTER(len=13) :: neig_string
925 CHARACTER(len=33) :: deloc_method_string
926 INTEGER :: handle, idomain, index1_prev, sum_temp
927 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nneighbors
929 CALL timeset(routinen, handle)
931 IF (unit_nr > 0)
THEN
932 WRITE (unit_nr,
'()')
933 WRITE (unit_nr,
'(T2,A,A,A)') repeat(
"-", 32),
" ALMO SETTINGS ", repeat(
"-", 32)
935 WRITE (unit_nr,
'(T2,A,T48,E33.3)')
"eps_filter:", almo_scf_env%eps_filter
937 IF (almo_scf_env%almo_update_algorithm .EQ.
almo_scf_skip)
THEN
938 WRITE (unit_nr,
'(T2,A)')
"skip optimization of block-diagonal ALMOs"
940 WRITE (unit_nr,
'(T2,A)')
"optimization of block-diagonal ALMOs:"
941 SELECT CASE (almo_scf_env%almo_update_algorithm)
954 SELECT CASE (almo_scf_env%deloc_method)
956 deloc_method_string =
"NONE"
958 deloc_method_string =
"FULL_X"
960 deloc_method_string =
"FULL_SCF"
962 deloc_method_string =
"FULL_X_THEN_SCF"
964 deloc_method_string =
"XALMO_1DIAG"
966 deloc_method_string =
"XALMO_X"
968 deloc_method_string =
"XALMO_SCF"
970 WRITE (unit_nr,
'(T2,A,T48,A33)')
"delocalization:", trim(deloc_method_string)
974 SELECT CASE (almo_scf_env%deloc_method)
976 WRITE (unit_nr,
'(T2,A,T48,A33)')
"delocalization cutoff radius:", &
978 deloc_method_string =
"FULL_X_THEN_SCF"
980 WRITE (unit_nr,
'(T2,A,T48,F33.5)')
"XALMO cutoff radius:", &
981 almo_scf_env%quencher_r0_factor
987 WRITE (unit_nr,
'(T2,A)')
"optimization of extended orbitals:"
988 SELECT CASE (almo_scf_env%xalmo_update_algorithm)
1031 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1032 WRITE (unit_nr,
'(T2,A,T48,I33)')
"Total fragments:", &
1033 almo_scf_env%ndomains
1035 sum_temp = sum(almo_scf_env%nbasis_of_domain(:))
1036 WRITE (unit_nr,
'(T2,A,T53,I5,F9.2,I5,I9)') &
1037 "Basis set size per fragment (min, av, max, total):", &
1038 minval(almo_scf_env%nbasis_of_domain(:)), &
1039 (1.0_dp*sum_temp)/almo_scf_env%ndomains, &
1040 maxval(almo_scf_env%nbasis_of_domain(:)), &
1048 sum_temp = sum(almo_scf_env%nocc_of_domain(:, :))
1049 WRITE (unit_nr,
'(T2,A,T53,I5,F9.2,I5,I9)') &
1050 "Occupied MOs per fragment (min, av, max, total):", &
1051 minval(sum(almo_scf_env%nocc_of_domain, dim=2)), &
1052 (1.0_dp*sum_temp)/almo_scf_env%ndomains, &
1053 maxval(sum(almo_scf_env%nocc_of_domain, dim=2)), &
1061 sum_temp = sum(almo_scf_env%nvirt_of_domain(:, :))
1062 WRITE (unit_nr,
'(T2,A,T53,I5,F9.2,I5,I9)') &
1063 "Virtual MOs per fragment (min, av, max, total):", &
1064 minval(sum(almo_scf_env%nvirt_of_domain, dim=2)), &
1065 (1.0_dp*sum_temp)/almo_scf_env%ndomains, &
1066 maxval(sum(almo_scf_env%nvirt_of_domain, dim=2)), &
1074 sum_temp = sum(almo_scf_env%charge_of_domain(:))
1075 WRITE (unit_nr,
'(T2,A,T53,I5,F9.2,I5,I9)') &
1076 "Charges per fragment (min, av, max, total):", &
1077 minval(almo_scf_env%charge_of_domain(:)), &
1078 (1.0_dp*sum_temp)/almo_scf_env%ndomains, &
1079 maxval(almo_scf_env%charge_of_domain(:)), &
1088 ALLOCATE (nneighbors(almo_scf_env%ndomains))
1090 DO idomain = 1, almo_scf_env%ndomains
1092 IF (idomain .EQ. 1)
THEN
1095 index1_prev = almo_scf_env%domain_map(1)%index1(idomain - 1)
1098 SELECT CASE (almo_scf_env%deloc_method)
1100 nneighbors(idomain) = 0
1102 nneighbors(idomain) = almo_scf_env%ndomains - 1
1104 nneighbors(idomain) = almo_scf_env%domain_map(1)%index1(idomain) - index1_prev - 1
1106 nneighbors(idomain) = -1
1111 sum_temp = sum(nneighbors(:))
1112 WRITE (unit_nr,
'(T2,A,T53,I5,F9.2,I5,I9)') &
1113 "Deloc. neighbors of fragment (min, av, max, total):", &
1114 minval(nneighbors(:)), &
1115 (1.0_dp*sum_temp)/almo_scf_env%ndomains, &
1116 maxval(nneighbors(:)), &
1119 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1120 WRITE (unit_nr,
'()')
1122 IF (almo_scf_env%ndomains .LE. 64)
THEN
1125 WRITE (unit_nr,
'(T2,A10,A13,A13,A13,A13,A13)') &
1126 "Fragment",
"Basis Set",
"Occupied",
"Virtual",
"Charge",
"Deloc Neig"
1127 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1128 DO idomain = 1, almo_scf_env%ndomains
1130 SELECT CASE (almo_scf_env%deloc_method)
1132 neig_string =
"NONE"
1136 WRITE (neig_string,
'(I13)') nneighbors(idomain)
1141 WRITE (unit_nr,
'(T2,I10,I13,I13,I13,I13,A13)') &
1142 idomain, almo_scf_env%nbasis_of_domain(idomain), &
1143 sum(almo_scf_env%nocc_of_domain(idomain, :)), &
1144 sum(almo_scf_env%nvirt_of_domain(idomain, :)), &
1146 almo_scf_env%charge_of_domain(idomain), &
1147 adjustr(trim(neig_string))
1151 SELECT CASE (almo_scf_env%deloc_method)
1154 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1157 WRITE (unit_nr,
'(T2,A78)') &
1158 "Neighbor lists (including self)"
1159 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1160 DO idomain = 1, almo_scf_env%ndomains
1162 IF (idomain .EQ. 1)
THEN
1165 index1_prev = almo_scf_env%domain_map(1)%index1(idomain - 1)
1168 WRITE (unit_nr,
'(T2,I10,":")') idomain
1169 WRITE (unit_nr,
'(T12,11I6)') &
1170 almo_scf_env%domain_map(1)%pairs &
1171 (index1_prev:almo_scf_env%domain_map(1)%index1(idomain) - 1, 1)
1179 WRITE (unit_nr,
'(T2,A)')
"The system is too big to print details for each fragment."
1183 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
1185 WRITE (unit_nr,
'()')
1187 DEALLOCATE (nneighbors)
1191 CALL timestop(handle)
1193 END SUBROUTINE almo_scf_print_job_info
1204 SUBROUTINE almo_scf_init_ao_overlap(matrix_s, almo_scf_env)
1205 TYPE(dbcsr_type),
INTENT(IN) :: matrix_s
1206 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1208 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_init_ao_overlap'
1210 INTEGER :: handle, unit_nr
1211 TYPE(cp_logger_type),
POINTER :: logger
1213 CALL timeset(routinen, handle)
1217 IF (logger%para_env%is_source())
THEN
1225 IF (almo_scf_env%orthogonal_basis)
THEN
1226 CALL dbcsr_set(almo_scf_env%matrix_s(1), 0.0_dp)
1227 CALL dbcsr_add_on_diag(almo_scf_env%matrix_s(1), 1.0_dp)
1228 CALL dbcsr_set(almo_scf_env%matrix_s_blk(1), 0.0_dp)
1229 CALL dbcsr_add_on_diag(almo_scf_env%matrix_s_blk(1), 1.0_dp)
1232 almo_scf_env%mat_distr_aos, .false.)
1233 CALL dbcsr_copy(almo_scf_env%matrix_s_blk(1), &
1234 almo_scf_env%matrix_s(1), keep_sparsity=.true.)
1237 CALL dbcsr_filter(almo_scf_env%matrix_s(1), almo_scf_env%eps_filter)
1238 CALL dbcsr_filter(almo_scf_env%matrix_s_blk(1), almo_scf_env%eps_filter)
1240 IF (almo_scf_env%almo_update_algorithm .EQ.
almo_scf_diag)
THEN
1242 almo_scf_env%matrix_s_blk_sqrt_inv(1), &
1243 almo_scf_env%matrix_s_blk(1), &
1244 threshold=almo_scf_env%eps_filter, &
1245 order=almo_scf_env%order_lanczos, &
1247 eps_lanczos=almo_scf_env%eps_lanczos, &
1248 max_iter_lanczos=almo_scf_env%max_iter_lanczos)
1251 almo_scf_env%matrix_s_blk(1), &
1252 threshold=almo_scf_env%eps_filter, &
1253 filter_eps=almo_scf_env%eps_filter)
1256 CALL timestop(handle)
1258 END SUBROUTINE almo_scf_init_ao_overlap
1269 SUBROUTINE almo_scf_main(qs_env, almo_scf_env)
1270 TYPE(qs_environment_type),
POINTER :: qs_env
1271 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1273 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_main'
1275 INTEGER :: handle, ispin, unit_nr
1276 TYPE(cp_logger_type),
POINTER :: logger
1278 CALL timeset(routinen, handle)
1282 IF (logger%para_env%is_source())
THEN
1288 SELECT CASE (almo_scf_env%almo_update_algorithm)
1291 SELECT CASE (almo_scf_env%almo_update_algorithm)
1296 almo_scf_env=almo_scf_env, &
1297 optimizer=almo_scf_env%opt_block_diag_pcg, &
1298 quench_t=almo_scf_env%quench_t_blk, &
1299 matrix_t_in=almo_scf_env%matrix_t_blk, &
1300 matrix_t_out=almo_scf_env%matrix_t_blk, &
1301 assume_t0_q0x=.false., &
1302 perturbation_only=.false., &
1308 almo_scf_env=almo_scf_env, &
1309 optimizer=almo_scf_env%opt_block_diag_trustr, &
1310 quench_t=almo_scf_env%quench_t_blk, &
1311 matrix_t_in=almo_scf_env%matrix_t_blk, &
1312 matrix_t_out=almo_scf_env%matrix_t_blk, &
1313 perturbation_only=.false., &
1318 DO ispin = 1, almo_scf_env%nspins
1320 overlap=almo_scf_env%matrix_sigma_blk(ispin), &
1321 metric=almo_scf_env%matrix_s_blk(1), &
1322 retain_locality=.true., &
1323 only_normalize=.false., &
1324 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
1325 eps_filter=almo_scf_env%eps_filter, &
1326 order_lanczos=almo_scf_env%order_lanczos, &
1327 eps_lanczos=almo_scf_env%eps_lanczos, &
1328 max_iter_lanczos=almo_scf_env%max_iter_lanczos)
1335 almo_scf_env%opt_block_diag_diis)
1340 DO ispin = 1, almo_scf_env%nspins
1341 CALL dbcsr_copy(almo_scf_env%matrix_ks_0deloc(ispin), &
1342 almo_scf_env%matrix_ks(ispin))
1343 CALL dbcsr_copy(almo_scf_env%matrix_sigma_inv_0deloc(ispin), &
1344 almo_scf_env%matrix_sigma_inv(ispin))
1347 CALL timestop(handle)
1349 END SUBROUTINE almo_scf_main
1359 SUBROUTINE almo_scf_delocalization(qs_env, almo_scf_env)
1361 TYPE(qs_environment_type),
POINTER :: qs_env
1362 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1364 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_delocalization'
1366 INTEGER :: col, handle, hold, iblock_col, &
1367 iblock_row, ispin, mynode, &
1368 nblkcols_tot, nblkrows_tot, row, &
1370 LOGICAL :: almo_experimental, tr
1371 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_new_block
1372 TYPE(cp_logger_type),
POINTER :: logger
1373 TYPE(dbcsr_distribution_type) :: dist
1374 TYPE(dbcsr_type),
ALLOCATABLE,
DIMENSION(:) :: no_quench
1375 TYPE(optimizer_options_type) :: arbitrary_optimizer
1377 CALL timeset(routinen, handle)
1381 IF (logger%para_env%is_source())
THEN
1392 arbitrary_optimizer%max_iter = 3
1393 arbitrary_optimizer%eps_error = 1.0e-6_dp
1394 arbitrary_optimizer%ndiis = 2
1396 SELECT CASE (almo_scf_env%deloc_method)
1403 ALLOCATE (no_quench(almo_scf_env%nspins))
1404 CALL dbcsr_create(no_quench(1), &
1405 template=almo_scf_env%matrix_t(1), &
1406 matrix_type=dbcsr_type_no_symmetry)
1407 CALL dbcsr_get_info(no_quench(1), distribution=dist)
1408 CALL dbcsr_distribution_get(dist, mynode=mynode)
1409 CALL dbcsr_work_create(no_quench(1), &
1410 work_mutable=.true.)
1411 nblkrows_tot = dbcsr_nblkrows_total(no_quench(1))
1412 nblkcols_tot = dbcsr_nblkcols_total(no_quench(1))
1417 DO row = 1, nblkrows_tot
1418 DO col = 1, nblkcols_tot
1422 CALL dbcsr_get_stored_coordinates(no_quench(1), &
1423 iblock_row, iblock_col, hold)
1424 IF (hold .EQ. mynode)
THEN
1425 NULLIFY (p_new_block)
1426 CALL dbcsr_reserve_block2d(no_quench(1), &
1427 iblock_row, iblock_col, p_new_block)
1428 cpassert(
ASSOCIATED(p_new_block))
1429 p_new_block(:, :) = 1.0_dp
1433 CALL dbcsr_finalize(no_quench(1))
1434 IF (almo_scf_env%nspins .GT. 1)
THEN
1435 DO ispin = 2, almo_scf_env%nspins
1436 CALL dbcsr_create(no_quench(ispin), &
1437 template=almo_scf_env%matrix_t(1), &
1438 matrix_type=dbcsr_type_no_symmetry)
1439 CALL dbcsr_copy(no_quench(ispin), no_quench(1))
1445 SELECT CASE (almo_scf_env%deloc_method)
1448 DO ispin = 1, almo_scf_env%nspins
1449 CALL dbcsr_copy(almo_scf_env%matrix_t(ispin), &
1450 almo_scf_env%matrix_t_blk(ispin))
1478 IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_pcg)
THEN
1481 almo_scf_env=almo_scf_env, &
1482 optimizer=almo_scf_env%opt_xalmo_pcg, &
1483 quench_t=no_quench, &
1484 matrix_t_in=almo_scf_env%matrix_t_blk, &
1485 matrix_t_out=almo_scf_env%matrix_t, &
1487 perturbation_only=.true., &
1490 ELSE IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_trustr)
THEN
1493 almo_scf_env=almo_scf_env, &
1494 optimizer=almo_scf_env%opt_xalmo_trustr, &
1495 quench_t=no_quench, &
1496 matrix_t_in=almo_scf_env%matrix_t_blk, &
1497 matrix_t_out=almo_scf_env%matrix_t, &
1498 perturbation_only=.true., &
1503 cpabort(
"Other algorithms do not exist")
1509 IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_diag)
THEN
1511 almo_scf_env%perturbative_delocalization = .true.
1512 DO ispin = 1, almo_scf_env%nspins
1513 CALL dbcsr_copy(almo_scf_env%matrix_t(ispin), &
1514 almo_scf_env%matrix_t_blk(ispin))
1517 arbitrary_optimizer)
1521 cpabort(
"Other algorithms do not exist")
1527 IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_pcg)
THEN
1530 almo_scf_env=almo_scf_env, &
1531 optimizer=almo_scf_env%opt_xalmo_pcg, &
1532 quench_t=almo_scf_env%quench_t, &
1533 matrix_t_in=almo_scf_env%matrix_t_blk, &
1534 matrix_t_out=almo_scf_env%matrix_t, &
1536 perturbation_only=.true., &
1539 ELSE IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_trustr)
THEN
1542 almo_scf_env=almo_scf_env, &
1543 optimizer=almo_scf_env%opt_xalmo_trustr, &
1544 quench_t=almo_scf_env%quench_t, &
1545 matrix_t_in=almo_scf_env%matrix_t_blk, &
1546 matrix_t_out=almo_scf_env%matrix_t, &
1547 perturbation_only=.true., &
1552 cpabort(
"Other algorithms do not exist")
1558 IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_diag)
THEN
1560 cpabort(
"Should not be here: convergence will fail!")
1562 almo_scf_env%perturbative_delocalization = .false.
1563 DO ispin = 1, almo_scf_env%nspins
1564 CALL dbcsr_copy(almo_scf_env%matrix_t(ispin), &
1565 almo_scf_env%matrix_t_blk(ispin))
1568 arbitrary_optimizer)
1570 ELSE IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_pcg)
THEN
1573 almo_scf_env=almo_scf_env, &
1574 optimizer=almo_scf_env%opt_xalmo_pcg, &
1575 quench_t=almo_scf_env%quench_t, &
1576 matrix_t_in=almo_scf_env%matrix_t_blk, &
1577 matrix_t_out=almo_scf_env%matrix_t, &
1579 perturbation_only=.false., &
1583 almo_experimental = .false.
1584 IF (almo_experimental)
THEN
1585 almo_scf_env%perturbative_delocalization = .true.
1591 arbitrary_optimizer)
1594 ELSE IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_trustr)
THEN
1597 almo_scf_env=almo_scf_env, &
1598 optimizer=almo_scf_env%opt_xalmo_trustr, &
1599 quench_t=almo_scf_env%quench_t, &
1600 matrix_t_in=almo_scf_env%matrix_t_blk, &
1601 matrix_t_out=almo_scf_env%matrix_t, &
1602 perturbation_only=.false., &
1607 cpabort(
"Other algorithms do not exist")
1613 cpabort(
"Illegal delocalization method")
1617 SELECT CASE (almo_scf_env%deloc_method)
1620 IF (almo_scf_env%deloc_truncate_virt .NE.
virt_full)
THEN
1621 cpabort(
"full scf is NYI for truncated virtual space")
1624 IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_pcg)
THEN
1627 almo_scf_env=almo_scf_env, &
1628 optimizer=almo_scf_env%opt_xalmo_pcg, &
1629 quench_t=no_quench, &
1630 matrix_t_in=almo_scf_env%matrix_t, &
1631 matrix_t_out=almo_scf_env%matrix_t, &
1632 assume_t0_q0x=.false., &
1633 perturbation_only=.false., &
1636 ELSE IF (almo_scf_env%xalmo_update_algorithm .EQ.
almo_scf_trustr)
THEN
1639 almo_scf_env=almo_scf_env, &
1640 optimizer=almo_scf_env%opt_xalmo_trustr, &
1641 quench_t=no_quench, &
1642 matrix_t_in=almo_scf_env%matrix_t, &
1643 matrix_t_out=almo_scf_env%matrix_t, &
1644 perturbation_only=.false., &
1649 cpabort(
"Other algorithms do not exist")
1656 SELECT CASE (almo_scf_env%deloc_method)
1658 DO ispin = 1, almo_scf_env%nspins
1659 CALL dbcsr_release(no_quench(ispin))
1661 DEALLOCATE (no_quench)
1664 CALL timestop(handle)
1666 END SUBROUTINE almo_scf_delocalization
1676 SUBROUTINE construct_nlmos(qs_env, almo_scf_env)
1678 TYPE(qs_environment_type),
POINTER :: qs_env
1679 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1683 IF (almo_scf_env%construct_nlmos)
THEN
1685 DO ispin = 1, almo_scf_env%nspins
1688 overlap=almo_scf_env%matrix_sigma(ispin), &
1689 metric=almo_scf_env%matrix_s(1), &
1690 retain_locality=.false., &
1691 only_normalize=.false., &
1692 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
1693 eps_filter=almo_scf_env%eps_filter, &
1694 order_lanczos=almo_scf_env%order_lanczos, &
1695 eps_lanczos=almo_scf_env%eps_lanczos, &
1696 max_iter_lanczos=almo_scf_env%max_iter_lanczos)
1699 CALL construct_nlmos_wrapper(qs_env, almo_scf_env, virtuals=.false.)
1701 IF (almo_scf_env%opt_nlmo_pcg%opt_penalty%virtual_nlmos)
THEN
1702 CALL construct_virtuals(almo_scf_env)
1703 CALL construct_nlmos_wrapper(qs_env, almo_scf_env, virtuals=.true.)
1706 IF (almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start .GT. 0.0_dp)
THEN
1707 CALL nlmo_compactification(qs_env, almo_scf_env, almo_scf_env%matrix_t)
1712 END SUBROUTINE construct_nlmos
1723 SUBROUTINE construct_nlmos_wrapper(qs_env, almo_scf_env, virtuals)
1725 TYPE(qs_environment_type),
POINTER :: qs_env
1726 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1727 LOGICAL,
INTENT(IN) :: virtuals
1729 REAL(kind=
dp) :: det_diff, prev_determinant
1731 almo_scf_env%overlap_determinant = 1.0
1733 almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength = &
1734 -1.0_dp*almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength
1737 prev_determinant = 10.0_dp
1738 DO WHILE (almo_scf_env%overlap_determinant .GT. almo_scf_env%opt_nlmo_pcg%opt_penalty%final_determinant)
1740 IF (.NOT. virtuals)
THEN
1742 optimizer=almo_scf_env%opt_nlmo_pcg, &
1743 matrix_s=almo_scf_env%matrix_s(1), &
1744 matrix_mo_in=almo_scf_env%matrix_t, &
1745 matrix_mo_out=almo_scf_env%matrix_t, &
1746 template_matrix_sigma=almo_scf_env%matrix_sigma_inv, &
1747 overlap_determinant=almo_scf_env%overlap_determinant, &
1748 mat_distr_aos=almo_scf_env%mat_distr_aos, &
1749 virtuals=virtuals, &
1750 eps_filter=almo_scf_env%eps_filter)
1753 optimizer=almo_scf_env%opt_nlmo_pcg, &
1754 matrix_s=almo_scf_env%matrix_s(1), &
1755 matrix_mo_in=almo_scf_env%matrix_v, &
1756 matrix_mo_out=almo_scf_env%matrix_v, &
1757 template_matrix_sigma=almo_scf_env%matrix_sigma_vv, &
1758 overlap_determinant=almo_scf_env%overlap_determinant, &
1759 mat_distr_aos=almo_scf_env%mat_distr_aos, &
1760 virtuals=virtuals, &
1761 eps_filter=almo_scf_env%eps_filter)
1765 det_diff = prev_determinant - almo_scf_env%overlap_determinant
1766 almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength = &
1767 almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength/ &
1768 abs(almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength_dec_factor)
1770 IF (det_diff < almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance)
THEN
1773 prev_determinant = almo_scf_env%overlap_determinant
1777 END SUBROUTINE construct_nlmos_wrapper
1786 SUBROUTINE construct_virtuals(almo_scf_env)
1788 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1791 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
1792 TYPE(dbcsr_type) :: tempnv1, tempvocc1, tempvocc2, tempvv1, &
1795 DO ispin = 1, almo_scf_env%nspins
1797 CALL dbcsr_create(tempnv1, &
1798 template=almo_scf_env%matrix_v(ispin), &
1799 matrix_type=dbcsr_type_no_symmetry)
1800 CALL dbcsr_create(tempvocc1, &
1801 template=almo_scf_env%matrix_vo(ispin), &
1802 matrix_type=dbcsr_type_no_symmetry)
1803 CALL dbcsr_create(tempvocc2, &
1804 template=almo_scf_env%matrix_vo(ispin), &
1805 matrix_type=dbcsr_type_no_symmetry)
1806 CALL dbcsr_create(tempvv1, &
1807 template=almo_scf_env%matrix_sigma_vv(ispin), &
1808 matrix_type=dbcsr_type_no_symmetry)
1809 CALL dbcsr_create(tempvv2, &
1810 template=almo_scf_env%matrix_sigma_vv(ispin), &
1811 matrix_type=dbcsr_type_no_symmetry)
1814 CALL dbcsr_init_random(almo_scf_env%matrix_v(ispin), &
1815 keep_sparsity=.false.)
1818 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, &
1819 almo_scf_env%matrix_s(1), &
1820 almo_scf_env%matrix_v(ispin), &
1822 filter_eps=almo_scf_env%eps_filter)
1824 CALL dbcsr_multiply(
"T",
"N", 1.0_dp, &
1826 almo_scf_env%matrix_t(ispin), &
1827 0.0_dp, tempvocc1, &
1828 filter_eps=almo_scf_env%eps_filter)
1830 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, &
1832 almo_scf_env%matrix_sigma_inv(ispin), &
1833 0.0_dp, tempvocc2, &
1834 filter_eps=almo_scf_env%eps_filter)
1836 CALL dbcsr_multiply(
"N",
"T", 1.0_dp, &
1837 almo_scf_env%matrix_t(ispin), &
1840 filter_eps=almo_scf_env%eps_filter)
1842 CALL dbcsr_add(almo_scf_env%matrix_v(ispin), tempnv1, 1.0_dp, -1.0_dp)
1845 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, &
1846 almo_scf_env%matrix_s(1), &
1847 almo_scf_env%matrix_v(ispin), &
1849 filter_eps=almo_scf_env%eps_filter)
1851 CALL dbcsr_multiply(
"T",
"N", 1.0_dp, &
1852 almo_scf_env%matrix_v(ispin), &
1855 filter_eps=almo_scf_env%eps_filter)
1859 metric=almo_scf_env%matrix_s(1), &
1860 retain_locality=.false., &
1861 only_normalize=.false., &
1862 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
1863 eps_filter=almo_scf_env%eps_filter, &
1864 order_lanczos=almo_scf_env%order_lanczos, &
1865 eps_lanczos=almo_scf_env%eps_lanczos, &
1866 max_iter_lanczos=almo_scf_env%max_iter_lanczos)
1869 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, &
1870 almo_scf_env%matrix_ks(ispin), &
1871 almo_scf_env%matrix_v(ispin), &
1873 filter_eps=almo_scf_env%eps_filter)
1875 CALL dbcsr_multiply(
"T",
"N", 1.0_dp, &
1876 almo_scf_env%matrix_v(ispin), &
1879 filter_eps=almo_scf_env%eps_filter)
1881 CALL dbcsr_get_info(tempvv1, nfullrows_total=n)
1882 ALLOCATE (eigenvalues(n))
1885 para_env=almo_scf_env%para_env, &
1886 blacs_env=almo_scf_env%blacs_env)
1887 DEALLOCATE (eigenvalues)
1889 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, &
1890 almo_scf_env%matrix_v(ispin), &
1893 filter_eps=almo_scf_env%eps_filter)
1895 CALL dbcsr_copy(almo_scf_env%matrix_v(ispin), tempnv1)
1897 CALL dbcsr_release(tempnv1)
1898 CALL dbcsr_release(tempvocc1)
1899 CALL dbcsr_release(tempvocc2)
1900 CALL dbcsr_release(tempvv1)
1901 CALL dbcsr_release(tempvv2)
1905 END SUBROUTINE construct_virtuals
1916 SUBROUTINE nlmo_compactification(qs_env, almo_scf_env, matrix)
1918 TYPE(qs_environment_type),
POINTER :: qs_env
1919 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
1920 TYPE(dbcsr_type),
ALLOCATABLE,
DIMENSION(:), &
1921 INTENT(IN) :: matrix
1923 INTEGER :: iblock_col, iblock_col_size, iblock_row, iblock_row_size, icol, irow, ispin, &
1924 ncols, nrows, nspins, para_group_handle, unit_nr
1925 LOGICAL :: element_by_element
1926 REAL(kind=
dp) :: energy, eps_local, eps_start, &
1927 max_element, spin_factor
1928 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: occ, retained
1929 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_p
1930 TYPE(cp_logger_type),
POINTER :: logger
1931 TYPE(dbcsr_iterator_type) :: iter
1932 TYPE(dbcsr_type),
ALLOCATABLE,
DIMENSION(:) :: matrix_p_tmp, matrix_t_tmp
1933 TYPE(mp_comm_type) :: para_group
1937 IF (logger%para_env%is_source())
THEN
1943 nspins =
SIZE(matrix)
1944 element_by_element = .false.
1946 IF (nspins .EQ. 1)
THEN
1947 spin_factor = 2.0_dp
1949 spin_factor = 1.0_dp
1952 ALLOCATE (matrix_t_tmp(nspins))
1953 ALLOCATE (matrix_p_tmp(nspins))
1954 ALLOCATE (retained(nspins))
1957 DO ispin = 1, nspins
1960 CALL dbcsr_create(matrix_t_tmp(ispin), &
1961 template=matrix(ispin), &
1962 matrix_type=dbcsr_type_no_symmetry)
1963 CALL dbcsr_copy(matrix_t_tmp(ispin), matrix(ispin))
1965 CALL dbcsr_create(matrix_p_tmp(ispin), &
1966 template=almo_scf_env%matrix_p(ispin), &
1967 matrix_type=dbcsr_type_no_symmetry)
1968 CALL dbcsr_copy(matrix_p_tmp(ispin), almo_scf_env%matrix_p(ispin))
1972 IF (unit_nr > 0)
THEN
1974 WRITE (unit_nr,
'(T2,A)') &
1975 "Energy dependence on the (block-by-block) filtering of the NLMO coefficients"
1976 IF (unit_nr > 0)
WRITE (unit_nr,
'(T2,A13,A20,A20,A25)') &
1977 "EPS filter",
"Occupation Alpha",
"Occupation Beta",
"Energy"
1980 eps_start = almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start
1981 eps_local = max(eps_start, 10e-14_dp)
1985 IF (eps_local > 0.11_dp)
EXIT
1987 DO ispin = 1, nspins
1990 CALL dbcsr_work_create(matrix_t_tmp(ispin), work_mutable=.true.)
1991 CALL dbcsr_iterator_start(iter, matrix_t_tmp(ispin))
1992 DO WHILE (dbcsr_iterator_blocks_left(iter))
1993 CALL dbcsr_iterator_next_block(iter, iblock_row, iblock_col, data_p, &
1994 row_size=iblock_row_size, col_size=iblock_col_size)
1995 DO icol = 1, iblock_col_size
1997 IF (element_by_element)
THEN
1999 DO irow = 1, iblock_row_size
2000 IF (abs(data_p(irow, icol)) .LT. eps_local)
THEN
2001 data_p(irow, icol) = 0.0_dp
2003 retained(ispin) = retained(ispin) + 1
2009 max_element = 0.0_dp
2010 DO irow = 1, iblock_row_size
2011 IF (abs(data_p(irow, icol)) .GT. max_element)
THEN
2012 max_element = abs(data_p(irow, icol))
2015 IF (max_element .LT. eps_local)
THEN
2016 DO irow = 1, iblock_row_size
2017 data_p(irow, icol) = 0.0_dp
2020 retained(ispin) = retained(ispin) + iblock_row_size
2027 CALL dbcsr_iterator_stop(iter)
2028 CALL dbcsr_finalize(matrix_t_tmp(ispin))
2029 CALL dbcsr_filter(matrix_t_tmp(ispin), eps_local)
2031 CALL dbcsr_get_info(matrix_t_tmp(ispin), group=para_group_handle, &
2032 nfullrows_total=nrows, &
2033 nfullcols_total=ncols)
2034 CALL para_group%set_handle(para_group_handle)
2035 CALL para_group%sum(retained(ispin))
2038 occ(ispin) = retained(ispin)/nrows/ncols
2042 t=matrix_t_tmp(ispin), &
2043 p=matrix_p_tmp(ispin), &
2044 eps_filter=almo_scf_env%eps_filter, &
2045 orthog_orbs=.false., &
2046 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
2047 s=almo_scf_env%matrix_s(1), &
2048 sigma=almo_scf_env%matrix_sigma(ispin), &
2049 sigma_inv=almo_scf_env%matrix_sigma_inv(ispin), &
2050 use_guess=.false., &
2051 algorithm=almo_scf_env%sigma_inv_algorithm, &
2052 inv_eps_factor=almo_scf_env%matrix_iter_eps_error_factor, &
2053 inverse_accelerator=almo_scf_env%order_lanczos, &
2054 eps_lanczos=almo_scf_env%eps_lanczos, &
2055 max_iter_lanczos=almo_scf_env%max_iter_lanczos, &
2056 para_env=almo_scf_env%para_env, &
2057 blacs_env=almo_scf_env%blacs_env)
2060 CALL dbcsr_scale(matrix_p_tmp(ispin), spin_factor)
2067 almo_scf_env%matrix_ks, &
2069 almo_scf_env%eps_filter, &
2070 almo_scf_env%mat_distr_aos)
2072 IF (nspins .LT. 2) occ(2) = occ(1)
2073 IF (unit_nr > 0)
WRITE (unit_nr,
'(T2,E13.3,F20.10,F20.10,F25.15)') &
2074 eps_local, occ(1), occ(2), energy
2076 eps_local = 2.0_dp*eps_local
2080 DO ispin = 1, nspins
2082 CALL dbcsr_release(matrix_t_tmp(ispin))
2083 CALL dbcsr_release(matrix_p_tmp(ispin))
2087 DEALLOCATE (matrix_t_tmp)
2088 DEALLOCATE (matrix_p_tmp)
2090 DEALLOCATE (retained)
2092 END SUBROUTINE nlmo_compactification
2103 SUBROUTINE almo_scf_post(qs_env, almo_scf_env)
2104 TYPE(qs_environment_type),
POINTER :: qs_env
2105 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
2107 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_post'
2109 INTEGER :: handle, ispin
2110 TYPE(cp_fm_type),
POINTER :: mo_coeff
2111 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_w
2112 TYPE(dbcsr_type),
ALLOCATABLE,
DIMENSION(:) :: matrix_t_processed
2113 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
2114 TYPE(qs_scf_env_type),
POINTER :: scf_env
2116 CALL timeset(routinen, handle)
2119 CALL almo_scf_store_extrapolation_data(almo_scf_env)
2122 ALLOCATE (matrix_t_processed(almo_scf_env%nspins))
2125 DO ispin = 1, almo_scf_env%nspins
2127 CALL dbcsr_create(matrix_t_processed(ispin), &
2128 template=almo_scf_env%matrix_t(ispin), &
2129 matrix_type=dbcsr_type_no_symmetry)
2131 CALL dbcsr_copy(matrix_t_processed(ispin), &
2132 almo_scf_env%matrix_t(ispin))
2141 IF (almo_scf_env%return_orthogonalized_mos)
THEN
2144 overlap=almo_scf_env%matrix_sigma(ispin), &
2145 metric=almo_scf_env%matrix_s(1), &
2146 retain_locality=.false., &
2147 only_normalize=.false., &
2148 nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
2149 eps_filter=almo_scf_env%eps_filter, &
2150 order_lanczos=almo_scf_env%order_lanczos, &
2151 eps_lanczos=almo_scf_env%eps_lanczos, &
2152 max_iter_lanczos=almo_scf_env%max_iter_lanczos, &
2153 smear=almo_scf_env%smear)
2169 NULLIFY (mos, mo_coeff, scf_env)
2171 CALL get_qs_env(qs_env, mos=mos, scf_env=scf_env)
2173 DO ispin = 1, almo_scf_env%nspins
2176 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
2178 CALL dbcsr_release(matrix_t_processed(ispin))
2180 DO ispin = 1, almo_scf_env%nspins
2181 CALL dbcsr_release(matrix_t_processed(ispin))
2183 DEALLOCATE (matrix_t_processed)
2187 CALL almo_post_scf_compute_properties(qs_env)
2190 IF (almo_scf_env%calc_forces)
THEN
2192 IF (
ASSOCIATED(matrix_w))
THEN
2195 cpabort(
"Matrix W is needed but not associated")
2199 CALL timestop(handle)
2201 END SUBROUTINE almo_scf_post
2211 SUBROUTINE almo_scf_env_create_matrices(almo_scf_env, matrix_s0)
2213 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
2214 TYPE(dbcsr_type),
INTENT(IN) :: matrix_s0
2216 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_env_create_matrices'
2218 INTEGER :: handle, ispin, nspins
2220 CALL timeset(routinen, handle)
2222 nspins = almo_scf_env%nspins
2226 matrix_qs=matrix_s0, &
2227 almo_scf_env=almo_scf_env, &
2230 symmetry_new=dbcsr_type_symmetric, &
2232 init_domains=.false.)
2234 matrix_qs=matrix_s0, &
2235 almo_scf_env=almo_scf_env, &
2238 symmetry_new=dbcsr_type_symmetric, &
2240 init_domains=.true.)
2241 IF (almo_scf_env%almo_update_algorithm .EQ.
almo_scf_diag)
THEN
2243 matrix_qs=matrix_s0, &
2244 almo_scf_env=almo_scf_env, &
2245 name_new=
"S_BLK_SQRT_INV", &
2247 symmetry_new=dbcsr_type_symmetric, &
2249 init_domains=.true.)
2251 matrix_qs=matrix_s0, &
2252 almo_scf_env=almo_scf_env, &
2253 name_new=
"S_BLK_SQRT", &
2255 symmetry_new=dbcsr_type_symmetric, &
2257 init_domains=.true.)
2260 matrix_qs=matrix_s0, &
2261 almo_scf_env=almo_scf_env, &
2262 name_new=
"S_BLK_INV", &
2264 symmetry_new=dbcsr_type_symmetric, &
2266 init_domains=.true.)
2270 ALLOCATE (almo_scf_env%matrix_t_blk(nspins))
2271 ALLOCATE (almo_scf_env%quench_t_blk(nspins))
2272 ALLOCATE (almo_scf_env%matrix_err_blk(nspins))
2273 ALLOCATE (almo_scf_env%matrix_err_xx(nspins))
2274 ALLOCATE (almo_scf_env%matrix_sigma(nspins))
2275 ALLOCATE (almo_scf_env%matrix_sigma_inv(nspins))
2276 ALLOCATE (almo_scf_env%matrix_sigma_sqrt(nspins))
2277 ALLOCATE (almo_scf_env%matrix_sigma_sqrt_inv(nspins))
2278 ALLOCATE (almo_scf_env%matrix_sigma_blk(nspins))
2279 ALLOCATE (almo_scf_env%matrix_sigma_inv_0deloc(nspins))
2280 ALLOCATE (almo_scf_env%matrix_t(nspins))
2281 ALLOCATE (almo_scf_env%matrix_t_tr(nspins))
2282 DO ispin = 1, nspins
2285 matrix_qs=matrix_s0, &
2286 almo_scf_env=almo_scf_env, &
2289 symmetry_new=dbcsr_type_no_symmetry, &
2291 init_domains=.true.)
2294 matrix_qs=matrix_s0, &
2295 almo_scf_env=almo_scf_env, &
2298 symmetry_new=dbcsr_type_no_symmetry, &
2300 init_domains=.true.)
2303 matrix_qs=matrix_s0, &
2304 almo_scf_env=almo_scf_env, &
2305 name_new=
"ERR_BLK", &
2307 symmetry_new=dbcsr_type_no_symmetry, &
2309 init_domains=.true.)
2312 matrix_qs=matrix_s0, &
2313 almo_scf_env=almo_scf_env, &
2314 name_new=
"ERR_XX", &
2316 symmetry_new=dbcsr_type_no_symmetry, &
2318 init_domains=.false.)
2322 matrix_qs=matrix_s0, &
2323 almo_scf_env=almo_scf_env, &
2326 symmetry_new=dbcsr_type_no_symmetry, &
2328 init_domains=.false.)
2331 matrix_qs=matrix_s0, &
2332 almo_scf_env=almo_scf_env, &
2335 symmetry_new=dbcsr_type_symmetric, &
2337 init_domains=.false.)
2340 matrix_qs=matrix_s0, &
2341 almo_scf_env=almo_scf_env, &
2342 name_new=
"SIG_BLK", &
2344 symmetry_new=dbcsr_type_symmetric, &
2346 init_domains=.true.)
2349 matrix_qs=matrix_s0, &
2350 almo_scf_env=almo_scf_env, &
2351 name_new=
"SIGINV_BLK", &
2353 symmetry_new=dbcsr_type_symmetric, &
2355 init_domains=.true.)
2358 matrix_new=almo_scf_env%matrix_sigma_inv(ispin), &
2359 matrix_qs=matrix_s0, &
2360 almo_scf_env=almo_scf_env, &
2361 name_new=
"SIGINV", &
2363 symmetry_new=dbcsr_type_symmetric, &
2365 init_domains=.false.)
2368 matrix_new=almo_scf_env%matrix_t(ispin), &
2369 matrix_qs=matrix_s0, &
2370 almo_scf_env=almo_scf_env, &
2373 symmetry_new=dbcsr_type_no_symmetry, &
2375 init_domains=.false.)
2376 CALL dbcsr_create(almo_scf_env%matrix_sigma_sqrt(ispin), &
2377 template=almo_scf_env%matrix_sigma(ispin), &
2378 matrix_type=dbcsr_type_no_symmetry)
2379 CALL dbcsr_create(almo_scf_env%matrix_sigma_sqrt_inv(ispin), &
2380 template=almo_scf_env%matrix_sigma(ispin), &
2381 matrix_type=dbcsr_type_no_symmetry)
2385 IF (almo_scf_env%need_virtuals)
THEN
2386 ALLOCATE (almo_scf_env%matrix_v_blk(nspins))
2387 ALLOCATE (almo_scf_env%matrix_v_full_blk(nspins))
2388 ALLOCATE (almo_scf_env%matrix_v(nspins))
2389 ALLOCATE (almo_scf_env%matrix_vo(nspins))
2390 ALLOCATE (almo_scf_env%matrix_x(nspins))
2391 ALLOCATE (almo_scf_env%matrix_ov(nspins))
2392 ALLOCATE (almo_scf_env%matrix_ov_full(nspins))
2393 ALLOCATE (almo_scf_env%matrix_sigma_vv(nspins))
2394 ALLOCATE (almo_scf_env%matrix_sigma_vv_blk(nspins))
2395 ALLOCATE (almo_scf_env%matrix_sigma_vv_sqrt(nspins))
2396 ALLOCATE (almo_scf_env%matrix_sigma_vv_sqrt_inv(nspins))
2397 ALLOCATE (almo_scf_env%matrix_vv_full_blk(nspins))
2399 IF (almo_scf_env%deloc_truncate_virt .NE.
virt_full)
THEN
2400 ALLOCATE (almo_scf_env%matrix_k_blk(nspins))
2401 ALLOCATE (almo_scf_env%matrix_k_blk_ones(nspins))
2402 ALLOCATE (almo_scf_env%matrix_k_tr(nspins))
2403 ALLOCATE (almo_scf_env%matrix_v_disc(nspins))
2404 ALLOCATE (almo_scf_env%matrix_v_disc_blk(nspins))
2405 ALLOCATE (almo_scf_env%matrix_ov_disc(nspins))
2406 ALLOCATE (almo_scf_env%matrix_vv_disc_blk(nspins))
2407 ALLOCATE (almo_scf_env%matrix_vv_disc(nspins))
2408 ALLOCATE (almo_scf_env%opt_k_t_dd(nspins))
2409 ALLOCATE (almo_scf_env%opt_k_t_rr(nspins))
2410 ALLOCATE (almo_scf_env%opt_k_denom(nspins))
2413 DO ispin = 1, nspins
2415 matrix_qs=matrix_s0, &
2416 almo_scf_env=almo_scf_env, &
2417 name_new=
"V_FULL_BLK", &
2419 symmetry_new=dbcsr_type_no_symmetry, &
2421 init_domains=.false.)
2423 matrix_qs=matrix_s0, &
2424 almo_scf_env=almo_scf_env, &
2427 symmetry_new=dbcsr_type_no_symmetry, &
2429 init_domains=.false.)
2431 matrix_qs=matrix_s0, &
2432 almo_scf_env=almo_scf_env, &
2435 symmetry_new=dbcsr_type_no_symmetry, &
2437 init_domains=.false.)
2439 matrix_qs=matrix_s0, &
2440 almo_scf_env=almo_scf_env, &
2441 name_new=
"OV_FULL", &
2443 symmetry_new=dbcsr_type_no_symmetry, &
2445 init_domains=.false.)
2447 matrix_qs=matrix_s0, &
2448 almo_scf_env=almo_scf_env, &
2451 symmetry_new=dbcsr_type_no_symmetry, &
2453 init_domains=.false.)
2455 matrix_qs=matrix_s0, &
2456 almo_scf_env=almo_scf_env, &
2459 symmetry_new=dbcsr_type_no_symmetry, &
2461 init_domains=.false.)
2463 matrix_qs=matrix_s0, &
2464 almo_scf_env=almo_scf_env, &
2467 symmetry_new=dbcsr_type_no_symmetry, &
2469 init_domains=.false.)
2471 matrix_qs=matrix_s0, &
2472 almo_scf_env=almo_scf_env, &
2473 name_new=
"SIG_VV", &
2475 symmetry_new=dbcsr_type_symmetric, &
2477 init_domains=.false.)
2479 matrix_qs=matrix_s0, &
2480 almo_scf_env=almo_scf_env, &
2481 name_new=
"VV_FULL_BLK", &
2483 symmetry_new=dbcsr_type_no_symmetry, &
2485 init_domains=.true.)
2487 matrix_qs=matrix_s0, &
2488 almo_scf_env=almo_scf_env, &
2489 name_new=
"SIG_VV_BLK", &
2491 symmetry_new=dbcsr_type_symmetric, &
2493 init_domains=.true.)
2494 CALL dbcsr_create(almo_scf_env%matrix_sigma_vv_sqrt(ispin), &
2495 template=almo_scf_env%matrix_sigma_vv(ispin), &
2496 matrix_type=dbcsr_type_no_symmetry)
2497 CALL dbcsr_create(almo_scf_env%matrix_sigma_vv_sqrt_inv(ispin), &
2498 template=almo_scf_env%matrix_sigma_vv(ispin), &
2499 matrix_type=dbcsr_type_no_symmetry)
2501 IF (almo_scf_env%deloc_truncate_virt .NE.
virt_full)
THEN
2503 matrix_qs=matrix_s0, &
2504 almo_scf_env=almo_scf_env, &
2505 name_new=
"OPT_K_U_RR", &
2507 symmetry_new=dbcsr_type_no_symmetry, &
2509 init_domains=.false.)
2511 matrix_qs=matrix_s0, &
2512 almo_scf_env=almo_scf_env, &
2513 name_new=
"VV_DISC", &
2515 symmetry_new=dbcsr_type_symmetric, &
2517 init_domains=.false.)
2519 matrix_qs=matrix_s0, &
2520 almo_scf_env=almo_scf_env, &
2521 name_new=
"OPT_K_U_DD", &
2523 symmetry_new=dbcsr_type_no_symmetry, &
2525 init_domains=.false.)
2527 matrix_qs=matrix_s0, &
2528 almo_scf_env=almo_scf_env, &
2529 name_new=
"VV_DISC_BLK", &
2531 symmetry_new=dbcsr_type_symmetric, &
2533 init_domains=.true.)
2535 matrix_qs=matrix_s0, &
2536 almo_scf_env=almo_scf_env, &
2539 symmetry_new=dbcsr_type_no_symmetry, &
2541 init_domains=.true.)
2543 matrix_qs=matrix_s0, &
2544 almo_scf_env=almo_scf_env, &
2545 name_new=
"K_BLK_1", &
2547 symmetry_new=dbcsr_type_no_symmetry, &
2549 init_domains=.true.)
2551 matrix_qs=matrix_s0, &
2552 almo_scf_env=almo_scf_env, &
2553 name_new=
"OPT_K_DENOM", &
2555 symmetry_new=dbcsr_type_no_symmetry, &
2557 init_domains=.false.)
2559 matrix_qs=matrix_s0, &
2560 almo_scf_env=almo_scf_env, &
2563 symmetry_new=dbcsr_type_no_symmetry, &
2565 init_domains=.false.)
2567 matrix_qs=matrix_s0, &
2568 almo_scf_env=almo_scf_env, &
2569 name_new=
"V_DISC_BLK", &
2571 symmetry_new=dbcsr_type_no_symmetry, &
2573 init_domains=.false.)
2575 matrix_qs=matrix_s0, &
2576 almo_scf_env=almo_scf_env, &
2577 name_new=
"V_DISC", &
2579 symmetry_new=dbcsr_type_no_symmetry, &
2581 init_domains=.false.)
2583 matrix_qs=matrix_s0, &
2584 almo_scf_env=almo_scf_env, &
2585 name_new=
"OV_DISC", &
2587 symmetry_new=dbcsr_type_no_symmetry, &
2589 init_domains=.false.)
2597 IF (almo_scf_env%need_orbital_energies)
THEN
2598 ALLOCATE (almo_scf_env%matrix_eoo(nspins))
2599 ALLOCATE (almo_scf_env%matrix_evv_full(nspins))
2600 DO ispin = 1, nspins
2602 matrix_qs=matrix_s0, &
2603 almo_scf_env=almo_scf_env, &
2606 symmetry_new=dbcsr_type_no_symmetry, &
2608 init_domains=.false.)
2610 matrix_qs=matrix_s0, &
2611 almo_scf_env=almo_scf_env, &
2612 name_new=
"E_VIRT", &
2614 symmetry_new=dbcsr_type_no_symmetry, &
2616 init_domains=.false.)
2621 ALLOCATE (almo_scf_env%matrix_p(nspins))
2622 ALLOCATE (almo_scf_env%matrix_p_blk(nspins))
2623 ALLOCATE (almo_scf_env%matrix_ks(nspins))
2624 ALLOCATE (almo_scf_env%matrix_ks_blk(nspins))
2625 IF (almo_scf_env%need_previous_ks) &
2626 ALLOCATE (almo_scf_env%matrix_ks_0deloc(nspins))
2627 DO ispin = 1, nspins
2629 CALL dbcsr_create(almo_scf_env%matrix_p(ispin), &
2630 template=almo_scf_env%matrix_s(1), &
2631 matrix_type=dbcsr_type_symmetric)
2632 CALL dbcsr_create(almo_scf_env%matrix_ks(ispin), &
2633 template=almo_scf_env%matrix_s(1), &
2634 matrix_type=dbcsr_type_symmetric)
2635 IF (almo_scf_env%need_previous_ks)
THEN
2636 CALL dbcsr_create(almo_scf_env%matrix_ks_0deloc(ispin), &
2637 template=almo_scf_env%matrix_s(1), &
2638 matrix_type=dbcsr_type_symmetric)
2641 matrix_qs=matrix_s0, &
2642 almo_scf_env=almo_scf_env, &
2645 symmetry_new=dbcsr_type_symmetric, &
2647 init_domains=.true.)
2649 matrix_qs=matrix_s0, &
2650 almo_scf_env=almo_scf_env, &
2651 name_new=
"KS_BLK", &
2653 symmetry_new=dbcsr_type_symmetric, &
2655 init_domains=.true.)
2658 CALL timestop(handle)
2660 END SUBROUTINE almo_scf_env_create_matrices
2670 SUBROUTINE almo_scf_clean_up(almo_scf_env)
2672 TYPE(almo_scf_env_type),
INTENT(INOUT) :: almo_scf_env
2674 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_clean_up'
2676 INTEGER :: handle, ispin, unit_nr
2677 TYPE(cp_logger_type),
POINTER :: logger
2679 CALL timeset(routinen, handle)
2683 IF (logger%para_env%is_source())
THEN
2690 CALL dbcsr_release(almo_scf_env%matrix_s(1))
2691 CALL dbcsr_release(almo_scf_env%matrix_s_blk(1))
2692 IF (almo_scf_env%almo_update_algorithm .EQ.
almo_scf_diag)
THEN
2693 CALL dbcsr_release(almo_scf_env%matrix_s_blk_sqrt_inv(1))
2694 CALL dbcsr_release(almo_scf_env%matrix_s_blk_sqrt(1))
2696 CALL dbcsr_release(almo_scf_env%matrix_s_blk_inv(1))
2698 DO ispin = 1, almo_scf_env%nspins
2699 CALL dbcsr_release(almo_scf_env%quench_t(ispin))
2700 CALL dbcsr_release(almo_scf_env%quench_t_blk(ispin))
2701 CALL dbcsr_release(almo_scf_env%matrix_t_blk(ispin))
2702 CALL dbcsr_release(almo_scf_env%matrix_err_blk(ispin))
2703 CALL dbcsr_release(almo_scf_env%matrix_err_xx(ispin))
2704 CALL dbcsr_release(almo_scf_env%matrix_t_tr(ispin))
2705 CALL dbcsr_release(almo_scf_env%matrix_sigma(ispin))
2706 CALL dbcsr_release(almo_scf_env%matrix_sigma_blk(ispin))
2707 CALL dbcsr_release(almo_scf_env%matrix_sigma_inv_0deloc(ispin))
2708 CALL dbcsr_release(almo_scf_env%matrix_sigma_inv(ispin))
2709 CALL dbcsr_release(almo_scf_env%matrix_t(ispin))
2710 CALL dbcsr_release(almo_scf_env%matrix_sigma_sqrt(ispin))
2711 CALL dbcsr_release(almo_scf_env%matrix_sigma_sqrt_inv(ispin))
2712 CALL dbcsr_release(almo_scf_env%matrix_p(ispin))
2713 CALL dbcsr_release(almo_scf_env%matrix_ks(ispin))
2714 CALL dbcsr_release(almo_scf_env%matrix_p_blk(ispin))
2715 CALL dbcsr_release(almo_scf_env%matrix_ks_blk(ispin))
2716 IF (almo_scf_env%need_previous_ks)
THEN
2717 CALL dbcsr_release(almo_scf_env%matrix_ks_0deloc(ispin))
2719 IF (almo_scf_env%need_virtuals)
THEN
2720 CALL dbcsr_release(almo_scf_env%matrix_v_blk(ispin))
2721 CALL dbcsr_release(almo_scf_env%matrix_v_full_blk(ispin))
2722 CALL dbcsr_release(almo_scf_env%matrix_v(ispin))
2723 CALL dbcsr_release(almo_scf_env%matrix_vo(ispin))
2724 CALL dbcsr_release(almo_scf_env%matrix_x(ispin))
2725 CALL dbcsr_release(almo_scf_env%matrix_ov(ispin))
2726 CALL dbcsr_release(almo_scf_env%matrix_ov_full(ispin))
2727 CALL dbcsr_release(almo_scf_env%matrix_sigma_vv(ispin))
2728 CALL dbcsr_release(almo_scf_env%matrix_sigma_vv_blk(ispin))
2729 CALL dbcsr_release(almo_scf_env%matrix_sigma_vv_sqrt(ispin))
2730 CALL dbcsr_release(almo_scf_env%matrix_sigma_vv_sqrt_inv(ispin))
2731 CALL dbcsr_release(almo_scf_env%matrix_vv_full_blk(ispin))
2732 IF (almo_scf_env%deloc_truncate_virt .NE.
virt_full)
THEN
2733 CALL dbcsr_release(almo_scf_env%matrix_k_tr(ispin))
2734 CALL dbcsr_release(almo_scf_env%matrix_k_blk(ispin))
2735 CALL dbcsr_release(almo_scf_env%matrix_k_blk_ones(ispin))
2736 CALL dbcsr_release(almo_scf_env%matrix_v_disc(ispin))
2737 CALL dbcsr_release(almo_scf_env%matrix_v_disc_blk(ispin))
2738 CALL dbcsr_release(almo_scf_env%matrix_ov_disc(ispin))
2739 CALL dbcsr_release(almo_scf_env%matrix_vv_disc_blk(ispin))
2740 CALL dbcsr_release(almo_scf_env%matrix_vv_disc(ispin))
2741 CALL dbcsr_release(almo_scf_env%opt_k_t_dd(ispin))
2742 CALL dbcsr_release(almo_scf_env%opt_k_t_rr(ispin))
2743 CALL dbcsr_release(almo_scf_env%opt_k_denom(ispin))
2746 IF (almo_scf_env%need_orbital_energies)
THEN
2747 CALL dbcsr_release(almo_scf_env%matrix_eoo(ispin))
2748 CALL dbcsr_release(almo_scf_env%matrix_evv_full(ispin))
2753 DEALLOCATE (almo_scf_env%matrix_p)
2754 DEALLOCATE (almo_scf_env%matrix_p_blk)
2755 DEALLOCATE (almo_scf_env%matrix_ks)
2756 DEALLOCATE (almo_scf_env%matrix_ks_blk)
2757 DEALLOCATE (almo_scf_env%matrix_t_blk)
2758 DEALLOCATE (almo_scf_env%matrix_err_blk)
2759 DEALLOCATE (almo_scf_env%matrix_err_xx)
2760 DEALLOCATE (almo_scf_env%matrix_t)
2761 DEALLOCATE (almo_scf_env%matrix_t_tr)
2762 DEALLOCATE (almo_scf_env%matrix_sigma)
2763 DEALLOCATE (almo_scf_env%matrix_sigma_blk)
2764 DEALLOCATE (almo_scf_env%matrix_sigma_inv_0deloc)
2765 DEALLOCATE (almo_scf_env%matrix_sigma_sqrt)
2766 DEALLOCATE (almo_scf_env%matrix_sigma_sqrt_inv)
2767 DEALLOCATE (almo_scf_env%matrix_sigma_inv)
2768 DEALLOCATE (almo_scf_env%quench_t)
2769 DEALLOCATE (almo_scf_env%quench_t_blk)
2770 IF (almo_scf_env%need_virtuals)
THEN
2771 DEALLOCATE (almo_scf_env%matrix_v_blk)
2772 DEALLOCATE (almo_scf_env%matrix_v_full_blk)
2773 DEALLOCATE (almo_scf_env%matrix_v)
2774 DEALLOCATE (almo_scf_env%matrix_vo)
2775 DEALLOCATE (almo_scf_env%matrix_x)
2776 DEALLOCATE (almo_scf_env%matrix_ov)
2777 DEALLOCATE (almo_scf_env%matrix_ov_full)
2778 DEALLOCATE (almo_scf_env%matrix_sigma_vv)
2779 DEALLOCATE (almo_scf_env%matrix_sigma_vv_blk)
2780 DEALLOCATE (almo_scf_env%matrix_sigma_vv_sqrt)
2781 DEALLOCATE (almo_scf_env%matrix_sigma_vv_sqrt_inv)
2782 DEALLOCATE (almo_scf_env%matrix_vv_full_blk)
2783 IF (almo_scf_env%deloc_truncate_virt .NE.
virt_full)
THEN
2784 DEALLOCATE (almo_scf_env%matrix_k_tr)
2785 DEALLOCATE (almo_scf_env%matrix_k_blk)
2786 DEALLOCATE (almo_scf_env%matrix_v_disc)
2787 DEALLOCATE (almo_scf_env%matrix_v_disc_blk)
2788 DEALLOCATE (almo_scf_env%matrix_ov_disc)
2789 DEALLOCATE (almo_scf_env%matrix_vv_disc_blk)
2790 DEALLOCATE (almo_scf_env%matrix_vv_disc)
2791 DEALLOCATE (almo_scf_env%matrix_k_blk_ones)
2792 DEALLOCATE (almo_scf_env%opt_k_t_dd)
2793 DEALLOCATE (almo_scf_env%opt_k_t_rr)
2794 DEALLOCATE (almo_scf_env%opt_k_denom)
2797 IF (almo_scf_env%need_previous_ks)
THEN
2798 DEALLOCATE (almo_scf_env%matrix_ks_0deloc)
2800 IF (almo_scf_env%need_orbital_energies)
THEN
2801 DEALLOCATE (almo_scf_env%matrix_eoo)
2802 DEALLOCATE (almo_scf_env%matrix_evv_full)
2806 DO ispin = 1, almo_scf_env%nspins
2807 CALL release_submatrices( &
2808 almo_scf_env%domain_preconditioner(:, ispin))
2809 CALL release_submatrices(almo_scf_env%domain_s_inv(:, ispin))
2810 CALL release_submatrices(almo_scf_env%domain_s_sqrt_inv(:, ispin))
2811 CALL release_submatrices(almo_scf_env%domain_s_sqrt(:, ispin))
2812 CALL release_submatrices(almo_scf_env%domain_ks_xx(:, ispin))
2813 CALL release_submatrices(almo_scf_env%domain_t(:, ispin))
2814 CALL release_submatrices(almo_scf_env%domain_err(:, ispin))
2815 CALL release_submatrices(almo_scf_env%domain_r_down_up(:, ispin))
2817 DEALLOCATE (almo_scf_env%domain_preconditioner)
2818 DEALLOCATE (almo_scf_env%domain_s_inv)
2819 DEALLOCATE (almo_scf_env%domain_s_sqrt_inv)
2820 DEALLOCATE (almo_scf_env%domain_s_sqrt)
2821 DEALLOCATE (almo_scf_env%domain_ks_xx)
2822 DEALLOCATE (almo_scf_env%domain_t)
2823 DEALLOCATE (almo_scf_env%domain_err)
2824 DEALLOCATE (almo_scf_env%domain_r_down_up)
2825 DO ispin = 1, almo_scf_env%nspins
2826 DEALLOCATE (almo_scf_env%domain_map(ispin)%pairs)
2827 DEALLOCATE (almo_scf_env%domain_map(ispin)%index1)
2829 DEALLOCATE (almo_scf_env%domain_map)
2830 DEALLOCATE (almo_scf_env%domain_index_of_ao)
2831 DEALLOCATE (almo_scf_env%domain_index_of_atom)
2832 DEALLOCATE (almo_scf_env%first_atom_of_domain)
2833 DEALLOCATE (almo_scf_env%last_atom_of_domain)
2834 DEALLOCATE (almo_scf_env%nbasis_of_domain)
2835 DEALLOCATE (almo_scf_env%nocc_of_domain)
2836 DEALLOCATE (almo_scf_env%real_ne_of_domain)
2837 DEALLOCATE (almo_scf_env%nvirt_full_of_domain)
2838 DEALLOCATE (almo_scf_env%nvirt_of_domain)
2839 DEALLOCATE (almo_scf_env%nvirt_disc_of_domain)
2840 DEALLOCATE (almo_scf_env%mu_of_domain)
2841 DEALLOCATE (almo_scf_env%cpu_of_domain)
2842 DEALLOCATE (almo_scf_env%charge_of_domain)
2843 DEALLOCATE (almo_scf_env%multiplicity_of_domain)
2844 IF (almo_scf_env%smear)
THEN
2845 DEALLOCATE (almo_scf_env%mo_energies)
2846 DEALLOCATE (almo_scf_env%kTS)
2849 DEALLOCATE (almo_scf_env%domain_index_of_ao_block)
2850 DEALLOCATE (almo_scf_env%domain_index_of_mo_block)
2855 CALL timestop(handle)
2857 END SUBROUTINE almo_scf_clean_up
2868 SUBROUTINE almo_post_scf_compute_properties(qs_env)
2869 TYPE(qs_environment_type),
POINTER :: qs_env
2873 END SUBROUTINE almo_post_scf_compute_properties
Subroutines for ALMO SCF.
subroutine, public distribute_domains(almo_scf_env)
Load balancing of the submatrix computations.
subroutine, public almo_scf_p_blk_to_t_blk(almo_scf_env, ionic)
computes occupied ALMOs from the superimposed atomic density blocks
subroutine, public almo_scf_t_rescaling(matrix_t, mo_energies, mu_of_domain, real_ne_of_domain, spin_kTS, smear_e_temp, ndomains, nocc_of_domain)
Apply an occupation-rescaling trick to ALMOs for smearing. Partially occupied orbitals are considered...
subroutine, public almo_scf_t_to_proj(t, p, eps_filter, orthog_orbs, nocc_of_domain, s, sigma, sigma_inv, use_guess, smear, algorithm, para_env, blacs_env, eps_lanczos, max_iter_lanczos, inverse_accelerator, inv_eps_factor)
computes the idempotent density matrix from MOs MOs can be either orthogonal or non-orthogonal
subroutine, public orthogonalize_mos(ket, overlap, metric, retain_locality, only_normalize, nocc_of_domain, eps_filter, order_lanczos, eps_lanczos, max_iter_lanczos, overlap_sqrti, smear)
orthogonalize MOs
Optimization routines for all ALMO-based SCF methods.
subroutine, public almo_scf_xalmo_trustr(qs_env, almo_scf_env, optimizer, quench_t, matrix_t_in, matrix_t_out, perturbation_only, special_case)
Optimization of ALMOs using trust region minimizers.
subroutine, public almo_scf_xalmo_pcg(qs_env, almo_scf_env, optimizer, quench_t, matrix_t_in, matrix_t_out, assume_t0_q0x, perturbation_only, special_case)
Optimization of ALMOs using PCG-like minimizers.
subroutine, public almo_scf_xalmo_eigensolver(qs_env, almo_scf_env, optimizer)
An eigensolver-based SCF to optimize extended ALMOs (i.e. ALMOs on overlapping domains)
subroutine, public almo_scf_construct_nlmos(qs_env, optimizer, matrix_s, matrix_mo_in, matrix_mo_out, template_matrix_sigma, overlap_determinant, mat_distr_aos, virtuals, eps_filter)
Optimization of NLMOs using PCG minimizers.
subroutine, public almo_scf_block_diagonal(qs_env, almo_scf_env, optimizer)
An SCF procedure that optimizes block-diagonal ALMOs using DIIS.
Interface between ALMO SCF and QS.
subroutine, public construct_qs_mos(qs_env, almo_scf_env)
Create MOs in the QS env to be able to return ALMOs to QS.
subroutine, public matrix_qs_to_almo(matrix_qs, matrix_almo, mat_distr_aos, keep_sparsity)
convert between two types of matrices: QS style to ALMO style
subroutine, public calculate_w_matrix_almo(matrix_w, almo_scf_env)
Compute matrix W (energy-weighted density matrix) that is needed for the evaluation of forces.
subroutine, public matrix_almo_create(matrix_new, matrix_qs, almo_scf_env, name_new, size_keys, symmetry_new, spin_key, init_domains)
create the ALMO matrix templates
subroutine, public init_almo_ks_matrix_via_qs(qs_env, matrix_ks, mat_distr_aos, eps_filter)
Initialization of the QS and ALMO KS matrix.
subroutine, public almo_dm_to_almo_ks(qs_env, matrix_p, matrix_ks, energy_total, eps_filter, mat_distr_aos, smear, kTS_sum)
uses the ALMO density matrix to compute ALMO KS matrix and the new energy
subroutine, public almo_scf_construct_quencher(qs_env, almo_scf_env)
Creates the matrix that imposes absolute locality on MOs.
Types for all ALMO-based methods.
integer, parameter, public almo_mat_dim_occ
integer, parameter, public almo_mat_dim_virt_full
integer, parameter, public almo_mat_dim_aobasis
subroutine, public print_optimizer_options(optimizer, unit_nr)
Prints out the options of an optimizer.
integer, parameter, public almo_mat_dim_virt
integer, parameter, public almo_mat_dim_virt_disc
Routines for all ALMO-based SCF methods 'RZK-warning' marks unresolved issues.
subroutine, public almo_entry_scf(qs_env, calc_forces)
The entry point into ALMO SCF routines.
Define the atomic kind types and their sub types.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public scheiber2018
integer, save, public kuhne2007
integer, save, public staub2019
integer, save, public khaliullin2013
integer, save, public kolafa2004
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_syevd(matrix, eigenvectors, eigenvalues, para_env, blacs_env)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
represent a full matrix distributed on many processors
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Subroutines to handle submatrices.
Routines useful for iterative matrix calculations.
subroutine, public matrix_sqrt_newton_schulz(matrix_sqrt, matrix_sqrt_inv, matrix, threshold, order, eps_lanczos, max_iter_lanczos, symmetrize, converged)
compute the sqrt of a matrix via the sign function and the corresponding Newton-Schulz iterations the...
subroutine, public invert_hotelling(matrix_inverse, matrix, threshold, use_inv_as_guess, norm_convergence, filter_eps, accelerator_order, max_iter_lanczos, eps_lanczos, silent)
invert a symmetric positive definite matrix by Hotelling's method explicit symmetrization makes this ...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Collection of simple mathematical functions and subroutines.
elemental real(kind=dp) function, public binomial(n, k)
The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Define the data structure for the molecule information.
subroutine, public get_molecule_set_info(molecule_set, atom_to_mol, mol_to_first_atom, mol_to_last_atom, mol_to_nelectrons, mol_to_nbasis, mol_to_charge, mol_to_multiplicity)
returns information about molecules in the set.
Types used to generate the molecular SCF guess.
subroutine, public get_matrix_from_submatrices(mscfg_env, matrix_out, iset)
Creates a distributed matrix from MOs on fragments.
Define the data structure for the particle information.
Routine to return block diagonal density matrix. Blocks correspond to the atomic densities.
subroutine, public calculate_atomic_block_dm(pmatrix, matrix_s, atomic_kind_set, qs_kind_set, nspin, nelectron_spin, ounit, para_env)
returns a block diagonal density matrix. Blocks correspond to the atomic densities.
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.
Routines to somehow generate an initial guess.
subroutine, public calculate_mopac_dm(pmat, matrix_s, has_unit_metric, dft_control, particle_set, atomic_kind_set, qs_kind_set, nspin, nelectron_spin, para_env)
returns a block diagonal density matrix. Blocks correspond to the mopac initial guess.
Define the quickstep kind type and their sub types.
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.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Utility routines for qs_scf.
subroutine, public qs_scf_compute_properties(qs_env, wf_type, do_mp2)
computes properties for a given hamilonian using the current wfn
module that contains the definitions of the scf types