forked from cp2k/cp2k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
almo_scf.F
2876 lines (2473 loc) · 138 KB
/
almo_scf.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2023 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Routines for all ALMO-based SCF methods
!> 'RZK-warning' marks unresolved issues
!> \par History
!> 2011.05 created [Rustam Z Khaliullin]
!> \author Rustam Z Khaliullin
! **************************************************************************************************
MODULE almo_scf
USE almo_scf_methods, ONLY: almo_scf_p_blk_to_t_blk,&
almo_scf_t_rescaling,&
almo_scf_t_to_proj,&
distribute_domains,&
orthogonalize_mos
USE almo_scf_optimizer, ONLY: almo_scf_block_diagonal,&
almo_scf_construct_nlmos,&
almo_scf_xalmo_eigensolver,&
almo_scf_xalmo_pcg,&
almo_scf_xalmo_trustr
USE almo_scf_qs, ONLY: almo_dm_to_almo_ks,&
almo_scf_construct_quencher,&
calculate_w_matrix_almo,&
construct_qs_mos,&
init_almo_ks_matrix_via_qs,&
matrix_almo_create,&
matrix_qs_to_almo
USE almo_scf_types, ONLY: almo_mat_dim_aobasis,&
almo_mat_dim_occ,&
almo_mat_dim_virt,&
almo_mat_dim_virt_disc,&
almo_mat_dim_virt_full,&
almo_scf_env_type,&
optimizer_options_type,&
print_optimizer_options
USE atomic_kind_types, ONLY: atomic_kind_type
USE bibliography, ONLY: Khaliullin2013,&
Kolafa2004,&
Kuhne2007,&
Scheiber2018,&
Staub2019,&
cite_reference
USE cp_blacs_env, ONLY: cp_blacs_env_release
USE cp_control_types, ONLY: dft_control_type
USE cp_dbcsr_diag, ONLY: cp_dbcsr_syevd
USE cp_dbcsr_operations, ONLY: copy_dbcsr_to_fm
USE cp_fm_types, ONLY: cp_fm_type
USE cp_log_handling, ONLY: cp_get_default_logger,&
cp_logger_get_default_unit_nr,&
cp_logger_type
USE dbcsr_api, ONLY: &
dbcsr_add, dbcsr_add_on_diag, dbcsr_binary_read, dbcsr_checksum, dbcsr_copy, dbcsr_create, &
dbcsr_distribution_get, dbcsr_distribution_type, dbcsr_filter, dbcsr_finalize, &
dbcsr_get_info, dbcsr_get_stored_coordinates, dbcsr_init_random, &
dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, dbcsr_iterator_start, &
dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_multiply, dbcsr_nblkcols_total, &
dbcsr_nblkrows_total, dbcsr_p_type, dbcsr_release, dbcsr_reserve_block2d, dbcsr_scale, &
dbcsr_set, dbcsr_type, dbcsr_type_no_symmetry, dbcsr_type_symmetric, dbcsr_work_create
USE domain_submatrix_methods, ONLY: init_submatrices,&
release_submatrices
USE input_constants, ONLY: &
almo_deloc_none, almo_deloc_scf, almo_deloc_x, almo_deloc_x_then_scf, &
almo_deloc_xalmo_1diag, almo_deloc_xalmo_scf, almo_deloc_xalmo_x, almo_deloc_xk, &
almo_domain_layout_molecular, almo_mat_distr_atomic, almo_mat_distr_molecular, &
almo_scf_diag, almo_scf_dm_sign, almo_scf_pcg, almo_scf_skip, almo_scf_trustr, &
atomic_guess, molecular_guess, optimizer_diis, optimizer_lin_eq_pcg, optimizer_pcg, &
optimizer_trustr, restart_guess, smear_fermi_dirac, virt_full, virt_number, virt_occ_size, &
xalmo_case_block_diag, xalmo_case_fully_deloc, xalmo_case_normal, xalmo_trial_r0_out
USE input_section_types, ONLY: section_vals_type
USE iterate_matrix, ONLY: invert_Hotelling,&
matrix_sqrt_Newton_Schulz
USE kinds, ONLY: default_path_length,&
dp
USE mathlib, ONLY: binomial
USE message_passing, ONLY: mp_comm_type,&
mp_para_env_release,&
mp_para_env_type
USE molecule_types, ONLY: get_molecule_set_info,&
molecule_type
USE mscfg_types, ONLY: get_matrix_from_submatrices,&
molecular_scf_guess_env_type
USE particle_types, ONLY: particle_type
USE qs_atomic_block, ONLY: calculate_atomic_block_dm
USE qs_environment_types, ONLY: get_qs_env,&
qs_environment_type
USE qs_initial_guess, ONLY: calculate_mopac_dm
USE qs_kind_types, ONLY: qs_kind_type
USE qs_mo_types, ONLY: get_mo_set,&
mo_set_type
USE qs_rho_types, ONLY: qs_rho_get,&
qs_rho_type
USE qs_scf_post_scf, ONLY: qs_scf_compute_properties
USE qs_scf_types, ONLY: qs_scf_env_type
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'almo_scf'
PUBLIC :: almo_entry_scf
LOGICAL, PARAMETER :: debug_mode = .FALSE.
LOGICAL, PARAMETER :: safe_mode = .FALSE.
CONTAINS
! **************************************************************************************************
!> \brief The entry point into ALMO SCF routines
!> \param qs_env pointer to the QS environment
!> \param calc_forces calculate forces?
!> \par History
!> 2011.05 created [Rustam Z Khaliullin]
!> \author Rustam Z Khaliullin
! **************************************************************************************************
SUBROUTINE almo_entry_scf(qs_env, calc_forces)
TYPE(qs_environment_type), POINTER :: qs_env
LOGICAL, INTENT(IN) :: calc_forces
CHARACTER(len=*), PARAMETER :: routineN = 'almo_entry_scf'
INTEGER :: handle
TYPE(almo_scf_env_type), POINTER :: almo_scf_env
CALL timeset(routineN, handle)
CALL cite_reference(Khaliullin2013)
! get a pointer to the almo environment
CALL get_qs_env(qs_env, almo_scf_env=almo_scf_env)
! initialize scf
CALL almo_scf_init(qs_env, almo_scf_env, calc_forces)
! create the initial guess for ALMOs
CALL almo_scf_initial_guess(qs_env, almo_scf_env)
! perform SCF for block diagonal ALMOs
CALL almo_scf_main(qs_env, almo_scf_env)
! allow electron delocalization
CALL almo_scf_delocalization(qs_env, almo_scf_env)
! construct NLMOs
CALL construct_nlmos(qs_env, almo_scf_env)
! electron correlation methods
!CALL almo_correlation_main(qs_env,almo_scf_env)
! do post scf processing
CALL almo_scf_post(qs_env, almo_scf_env)
! clean up the mess
CALL almo_scf_clean_up(almo_scf_env)
CALL timestop(handle)
END SUBROUTINE almo_entry_scf
! **************************************************************************************************
!> \brief Initialization of the almo_scf_env_type.
!> \param qs_env ...
!> \param almo_scf_env ...
!> \param calc_forces ...
!> \par History
!> 2011.05 created [Rustam Z Khaliullin]
!> 2018.09 smearing support [Ruben Staub]
!> \author Rustam Z Khaliullin
! **************************************************************************************************
SUBROUTINE almo_scf_init(qs_env, almo_scf_env, calc_forces)
TYPE(qs_environment_type), POINTER :: qs_env
TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env
LOGICAL, INTENT(IN) :: calc_forces
CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_init'
INTEGER :: ao, handle, i, iao, idomain, ispin, &
multip, naos, natoms, ndomains, nelec, &
nelec_a, nelec_b, nmols, nspins, &
unit_nr
TYPE(cp_logger_type), POINTER :: logger
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
TYPE(dft_control_type), POINTER :: dft_control
TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
TYPE(section_vals_type), POINTER :: input
CALL timeset(routineN, handle)
! define the output_unit
logger => cp_get_default_logger()
IF (logger%para_env%is_source()) THEN
unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
ELSE
unit_nr = -1
END IF
! set optimizers' types
almo_scf_env%opt_block_diag_diis%optimizer_type = optimizer_diis
almo_scf_env%opt_block_diag_pcg%optimizer_type = optimizer_pcg
almo_scf_env%opt_xalmo_diis%optimizer_type = optimizer_diis
almo_scf_env%opt_xalmo_pcg%optimizer_type = optimizer_pcg
almo_scf_env%opt_xalmo_trustr%optimizer_type = optimizer_trustr
almo_scf_env%opt_nlmo_pcg%optimizer_type = optimizer_pcg
almo_scf_env%opt_block_diag_trustr%optimizer_type = optimizer_trustr
almo_scf_env%opt_xalmo_newton_pcg_solver%optimizer_type = optimizer_lin_eq_pcg
! get info from the qs_env
CALL get_qs_env(qs_env, &
nelectron_total=almo_scf_env%nelectrons_total, &
matrix_s=matrix_s, &
dft_control=dft_control, &
molecule_set=molecule_set, &
input=input, &
has_unit_metric=almo_scf_env%orthogonal_basis, &
para_env=almo_scf_env%para_env, &
blacs_env=almo_scf_env%blacs_env, &
nelectron_spin=almo_scf_env%nelectrons_spin)
CALL almo_scf_env%para_env%retain()
CALL almo_scf_env%blacs_env%retain()
! copy basic quantities
almo_scf_env%nspins = dft_control%nspins
almo_scf_env%natoms = dbcsr_nblkrows_total(matrix_s(1)%matrix)
almo_scf_env%nmolecules = SIZE(molecule_set)
CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=naos)
almo_scf_env%naos = naos
!! retrieve smearing parameters, and check compatibility of methods requested
almo_scf_env%smear = dft_control%smear
IF (almo_scf_env%smear) THEN
CALL cite_reference(Staub2019)
IF ((almo_scf_env%almo_update_algorithm .NE. almo_scf_diag) .OR. &
((almo_scf_env%deloc_method .NE. almo_deloc_none) .AND. &
(almo_scf_env%xalmo_update_algorithm .NE. almo_scf_diag))) THEN
CPABORT("ALMO smearing is currently implemented for DIAG algorithm only")
END IF
IF (qs_env%scf_control%smear%method .NE. smear_fermi_dirac) THEN
CPABORT("Only Fermi-Dirac smearing is currently compatible with ALMO")
END IF
almo_scf_env%smear_e_temp = qs_env%scf_control%smear%electronic_temperature
IF ((almo_scf_env%mat_distr_aos .NE. almo_mat_distr_molecular) .OR. &
(almo_scf_env%domain_layout_mos .NE. almo_domain_layout_molecular)) THEN
CPABORT("ALMO smearing was designed to work with molecular fragments only")
END IF
END IF
! convenient local varibales
nspins = almo_scf_env%nspins
nmols = almo_scf_env%nmolecules
natoms = almo_scf_env%natoms
! Define groups: either atomic or molecular
IF (almo_scf_env%domain_layout_mos == almo_domain_layout_molecular) THEN
almo_scf_env%ndomains = almo_scf_env%nmolecules
ELSE
almo_scf_env%ndomains = almo_scf_env%natoms
END IF
! allocate domain descriptors
ndomains = almo_scf_env%ndomains
ALLOCATE (almo_scf_env%domain_index_of_atom(natoms))
ALLOCATE (almo_scf_env%domain_index_of_ao(naos))
ALLOCATE (almo_scf_env%first_atom_of_domain(ndomains))
ALLOCATE (almo_scf_env%last_atom_of_domain(ndomains))
ALLOCATE (almo_scf_env%nbasis_of_domain(ndomains))
ALLOCATE (almo_scf_env%nocc_of_domain(ndomains, nspins)) !! with smearing, nb of available orbitals for occupation
ALLOCATE (almo_scf_env%real_ne_of_domain(ndomains, nspins)) !! with smearing, nb of fully-occupied orbitals
ALLOCATE (almo_scf_env%nvirt_full_of_domain(ndomains, nspins))
ALLOCATE (almo_scf_env%nvirt_of_domain(ndomains, nspins))
ALLOCATE (almo_scf_env%nvirt_disc_of_domain(ndomains, nspins))
ALLOCATE (almo_scf_env%mu_of_domain(ndomains, nspins))
ALLOCATE (almo_scf_env%cpu_of_domain(ndomains))
ALLOCATE (almo_scf_env%charge_of_domain(ndomains))
ALLOCATE (almo_scf_env%multiplicity_of_domain(ndomains))
! fill out domain descriptors and group descriptors
IF (almo_scf_env%domain_layout_mos == almo_domain_layout_molecular) THEN
! get domain info from molecule_set
CALL get_molecule_set_info(molecule_set, &
atom_to_mol=almo_scf_env%domain_index_of_atom, &
mol_to_first_atom=almo_scf_env%first_atom_of_domain, &
mol_to_last_atom=almo_scf_env%last_atom_of_domain, &
mol_to_nelectrons=almo_scf_env%nocc_of_domain(1:ndomains, 1), &
mol_to_nbasis=almo_scf_env%nbasis_of_domain, &
mol_to_charge=almo_scf_env%charge_of_domain, &
mol_to_multiplicity=almo_scf_env%multiplicity_of_domain)
! calculate number of alpha and beta occupied orbitals from
! the number of electrons and multiplicity of each molecule
! Na + Nb = Ne
! Na - Nb = Mult - 1 (assume Na > Nb as we do not have more info from get_molecule_set_info)
DO idomain = 1, ndomains
nelec = almo_scf_env%nocc_of_domain(idomain, 1)
multip = almo_scf_env%multiplicity_of_domain(idomain)
nelec_a = (nelec + multip - 1)/2
nelec_b = nelec - nelec_a
!! Initializing an occupation-rescaling trick if smearing is on
IF (almo_scf_env%smear) THEN
IF (multip .GT. 1) THEN
CPWARN("BEWARE: Non singlet state detected, treating it as closed-shell")
END IF
!! Save real number of electrons of each spin, as it is required for Fermi-dirac smearing
!! BEWARE : Non singlet states are allowed but treated as closed-shell
almo_scf_env%real_ne_of_domain(idomain, :) = REAL(nelec, KIND=dp)/2.0_dp
!! Add a number of added_mos equal to the number of atoms in domain
!! (since fragments were computed this way with smearing)
almo_scf_env%nocc_of_domain(idomain, :) = CEILING(almo_scf_env%real_ne_of_domain(idomain, :)) &
+ (almo_scf_env%last_atom_of_domain(idomain) &
- almo_scf_env%first_atom_of_domain(idomain) + 1)
ELSE
almo_scf_env%nocc_of_domain(idomain, 1) = nelec_a
IF (nelec_a .NE. nelec_b) THEN
IF (nspins .EQ. 1) THEN
WRITE (*, *) "Domain ", idomain, " out of ", ndomains, ". Electrons = ", nelec
CPABORT("odd e- -- use unrestricted methods")
END IF
almo_scf_env%nocc_of_domain(idomain, 2) = nelec_b
! RZK-warning: open-shell procedures have not been tested yet
! Stop the program now
CPABORT("Unrestricted ALMO methods are NYI")
END IF
END IF
END DO
DO ispin = 1, nspins
! take care of the full virtual subspace
almo_scf_env%nvirt_full_of_domain(:, ispin) = &
almo_scf_env%nbasis_of_domain(:) - &
almo_scf_env%nocc_of_domain(:, ispin)
! and the truncated virtual subspace
SELECT CASE (almo_scf_env%deloc_truncate_virt)
CASE (virt_full)
almo_scf_env%nvirt_of_domain(:, ispin) = &
almo_scf_env%nvirt_full_of_domain(:, ispin)
almo_scf_env%nvirt_disc_of_domain(:, ispin) = 0
CASE (virt_number)
DO idomain = 1, ndomains
almo_scf_env%nvirt_of_domain(idomain, ispin) = &
MIN(almo_scf_env%deloc_virt_per_domain, &
almo_scf_env%nvirt_full_of_domain(idomain, ispin))
almo_scf_env%nvirt_disc_of_domain(idomain, ispin) = &
almo_scf_env%nvirt_full_of_domain(idomain, ispin) - &
almo_scf_env%nvirt_of_domain(idomain, ispin)
END DO
CASE (virt_occ_size)
DO idomain = 1, ndomains
almo_scf_env%nvirt_of_domain(idomain, ispin) = &
MIN(almo_scf_env%nocc_of_domain(idomain, ispin), &
almo_scf_env%nvirt_full_of_domain(idomain, ispin))
almo_scf_env%nvirt_disc_of_domain(idomain, ispin) = &
almo_scf_env%nvirt_full_of_domain(idomain, ispin) - &
almo_scf_env%nvirt_of_domain(idomain, ispin)
END DO
CASE DEFAULT
CPABORT("illegal method for virtual space truncation")
END SELECT
END DO ! spin
ELSE ! domains are atomic
! RZK-warning do the same for atomic domains/groups
almo_scf_env%domain_index_of_atom(1:natoms) = (/(i, i=1, natoms)/)
END IF
ao = 1
DO idomain = 1, ndomains
DO iao = 1, almo_scf_env%nbasis_of_domain(idomain)
almo_scf_env%domain_index_of_ao(ao) = idomain
ao = ao + 1
END DO
END DO
almo_scf_env%mu_of_domain(:, :) = almo_scf_env%mu
! build domain (i.e. layout) indices for distribution blocks
! ao blocks
IF (almo_scf_env%mat_distr_aos == almo_mat_distr_atomic) THEN
ALLOCATE (almo_scf_env%domain_index_of_ao_block(natoms))
almo_scf_env%domain_index_of_ao_block(:) = &
almo_scf_env%domain_index_of_atom(:)
ELSE IF (almo_scf_env%mat_distr_aos == almo_mat_distr_molecular) THEN
ALLOCATE (almo_scf_env%domain_index_of_ao_block(nmols))
! if distr blocks are molecular then domain layout is also molecular
almo_scf_env%domain_index_of_ao_block(:) = (/(i, i=1, nmols)/)
END IF
! mo blocks
IF (almo_scf_env%mat_distr_mos == almo_mat_distr_atomic) THEN
ALLOCATE (almo_scf_env%domain_index_of_mo_block(natoms))
almo_scf_env%domain_index_of_mo_block(:) = &
almo_scf_env%domain_index_of_atom(:)
ELSE IF (almo_scf_env%mat_distr_mos == almo_mat_distr_molecular) THEN
ALLOCATE (almo_scf_env%domain_index_of_mo_block(nmols))
! if distr blocks are molecular then domain layout is also molecular
almo_scf_env%domain_index_of_mo_block(:) = (/(i, i=1, nmols)/)
END IF
! set all flags
!almo_scf_env%need_previous_ks=.FALSE.
!IF (almo_scf_env%deloc_method==almo_deloc_harris) THEN
almo_scf_env%need_previous_ks = .TRUE.
!ENDIF
!almo_scf_env%need_virtuals=.FALSE.
!almo_scf_env%need_orbital_energies=.FALSE.
!IF (almo_scf_env%almo_update_algorithm==almo_scf_diag) THEN
almo_scf_env%need_virtuals = .TRUE.
almo_scf_env%need_orbital_energies = .TRUE.
!ENDIF
almo_scf_env%calc_forces = calc_forces
IF (calc_forces) THEN
CALL cite_reference(Scheiber2018)
IF (almo_scf_env%deloc_method .EQ. almo_deloc_x .OR. &
almo_scf_env%deloc_method .EQ. almo_deloc_xalmo_x .OR. &
almo_scf_env%deloc_method .EQ. almo_deloc_xalmo_1diag) THEN
CPABORT("Forces for perturbative methods are NYI. Change DELOCALIZE_METHOD")
END IF
! switch to ASPC after a certain number of exact steps is done
IF (almo_scf_env%almo_history%istore .GT. (almo_scf_env%almo_history%nstore + 1)) THEN
IF (almo_scf_env%opt_block_diag_pcg%eps_error_early .GT. 0.0_dp) THEN
almo_scf_env%opt_block_diag_pcg%eps_error = almo_scf_env%opt_block_diag_pcg%eps_error_early
almo_scf_env%opt_block_diag_pcg%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "ALMO_OPTIMIZER_PCG: EPS_ERROR_EARLY is on"
END IF
IF (almo_scf_env%opt_block_diag_diis%eps_error_early .GT. 0.0_dp) THEN
almo_scf_env%opt_block_diag_diis%eps_error = almo_scf_env%opt_block_diag_diis%eps_error_early
almo_scf_env%opt_block_diag_diis%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "ALMO_OPTIMIZER_DIIS: EPS_ERROR_EARLY is on"
END IF
IF (almo_scf_env%opt_block_diag_pcg%max_iter_early .GT. 0) THEN
almo_scf_env%opt_block_diag_pcg%max_iter = almo_scf_env%opt_block_diag_pcg%max_iter_early
almo_scf_env%opt_block_diag_pcg%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "ALMO_OPTIMIZER_PCG: MAX_ITER_EARLY is on"
END IF
IF (almo_scf_env%opt_block_diag_diis%max_iter_early .GT. 0) THEN
almo_scf_env%opt_block_diag_diis%max_iter = almo_scf_env%opt_block_diag_diis%max_iter_early
almo_scf_env%opt_block_diag_diis%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "ALMO_OPTIMIZER_DIIS: MAX_ITER_EARLY is on"
END IF
ELSE
almo_scf_env%opt_block_diag_diis%early_stopping_on = .FALSE.
almo_scf_env%opt_block_diag_pcg%early_stopping_on = .FALSE.
END IF
IF (almo_scf_env%xalmo_history%istore .GT. (almo_scf_env%xalmo_history%nstore + 1)) THEN
IF (almo_scf_env%opt_xalmo_pcg%eps_error_early .GT. 0.0_dp) THEN
almo_scf_env%opt_xalmo_pcg%eps_error = almo_scf_env%opt_xalmo_pcg%eps_error_early
almo_scf_env%opt_xalmo_pcg%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "XALMO_OPTIMIZER_PCG: EPS_ERROR_EARLY is on"
END IF
IF (almo_scf_env%opt_xalmo_pcg%max_iter_early .GT. 0.0_dp) THEN
almo_scf_env%opt_xalmo_pcg%max_iter = almo_scf_env%opt_xalmo_pcg%max_iter_early
almo_scf_env%opt_xalmo_pcg%early_stopping_on = .TRUE.
IF (unit_nr > 0) WRITE (*, *) "XALMO_OPTIMIZER_PCG: MAX_ITER_EARLY is on"
END IF
ELSE
almo_scf_env%opt_xalmo_pcg%early_stopping_on = .FALSE.
END IF
END IF
! create all matrices
CALL almo_scf_env_create_matrices(almo_scf_env, matrix_s(1)%matrix)
! set up matrix S and all required functions of S
almo_scf_env%s_inv_done = .FALSE.
almo_scf_env%s_sqrt_done = .FALSE.
CALL almo_scf_init_ao_overlap(matrix_s(1)%matrix, almo_scf_env)
! create the quencher (imposes sparsity template)
CALL almo_scf_construct_quencher(qs_env, almo_scf_env)
CALL distribute_domains(almo_scf_env)
! FINISH setting job parameters here, print out job info
CALL almo_scf_print_job_info(almo_scf_env, unit_nr)
! allocate and init the domain preconditioner
ALLOCATE (almo_scf_env%domain_preconditioner(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_preconditioner)
! allocate and init projected KS for domains
ALLOCATE (almo_scf_env%domain_ks_xx(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_ks_xx)
! init ao-overlap subblocks
ALLOCATE (almo_scf_env%domain_s_inv(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_s_inv)
ALLOCATE (almo_scf_env%domain_s_sqrt_inv(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_s_sqrt_inv)
ALLOCATE (almo_scf_env%domain_s_sqrt(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_s_sqrt)
ALLOCATE (almo_scf_env%domain_t(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_t)
ALLOCATE (almo_scf_env%domain_err(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_err)
ALLOCATE (almo_scf_env%domain_r_down_up(ndomains, nspins))
CALL init_submatrices(almo_scf_env%domain_r_down_up)
! initialization of the KS matrix
CALL init_almo_ks_matrix_via_qs(qs_env, &
almo_scf_env%matrix_ks, &
almo_scf_env%mat_distr_aos, &
almo_scf_env%eps_filter)
CALL construct_qs_mos(qs_env, almo_scf_env)
CALL timestop(handle)
END SUBROUTINE almo_scf_init
! **************************************************************************************************
!> \brief create the scf initial guess for ALMOs
!> \param qs_env ...
!> \param almo_scf_env ...
!> \par History
!> 2016.11 created [Rustam Z Khaliullin]
!> 2018.09 smearing support [Ruben Staub]
!> \author Rustam Z Khaliullin
! **************************************************************************************************
SUBROUTINE almo_scf_initial_guess(qs_env, almo_scf_env)
TYPE(qs_environment_type), POINTER :: qs_env
TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env
CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_initial_guess'
CHARACTER(LEN=default_path_length) :: file_name, project_name
INTEGER :: handle, iaspc, ispin, istore, naspc, &
nspins, unit_nr
INTEGER, DIMENSION(2) :: nelectron_spin
LOGICAL :: aspc_guess, has_unit_metric
REAL(KIND=dp) :: alpha, cs_pos, energy, kTS_sum
TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
TYPE(cp_logger_type), POINTER :: logger
TYPE(dbcsr_distribution_type) :: dist
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, rho_ao
TYPE(dft_control_type), POINTER :: dft_control
TYPE(molecular_scf_guess_env_type), POINTER :: mscfg_env
TYPE(mp_para_env_type), POINTER :: para_env
TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
TYPE(qs_rho_type), POINTER :: rho
CALL timeset(routineN, handle)
NULLIFY (rho, rho_ao)
! get a useful output_unit
logger => cp_get_default_logger()
IF (logger%para_env%is_source()) THEN
unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
ELSE
unit_nr = -1
END IF
! get basic quantities from the qs_env
CALL get_qs_env(qs_env, &
dft_control=dft_control, &
matrix_s=matrix_s, &
atomic_kind_set=atomic_kind_set, &
qs_kind_set=qs_kind_set, &
particle_set=particle_set, &
has_unit_metric=has_unit_metric, &
para_env=para_env, &
nelectron_spin=nelectron_spin, &
mscfg_env=mscfg_env, &
rho=rho)
CALL qs_rho_get(rho, rho_ao=rho_ao)
CPASSERT(ASSOCIATED(mscfg_env))
! initial guess on the first simulation step is determined by almo_scf_env%almo_scf_guess
! the subsequent simulation steps are determined by extrapolation_order
! if extrapolation order is zero then again almo_scf_env%almo_scf_guess is used
! ... the number of stored history points will remain zero if extrapolation order is zero
IF (almo_scf_env%almo_history%istore == 0) THEN
aspc_guess = .FALSE.
ELSE
aspc_guess = .TRUE.
END IF
nspins = almo_scf_env%nspins
! create an initial guess
IF (.NOT. aspc_guess) THEN
SELECT CASE (almo_scf_env%almo_scf_guess)
CASE (molecular_guess)
DO ispin = 1, nspins
! the calculations on "isolated" molecules has already been done
! all we need to do is convert the MOs of molecules into
! the ALMO matrix taking into account different distributions
CALL get_matrix_from_submatrices(mscfg_env, &
almo_scf_env%matrix_t_blk(ispin), ispin)
CALL dbcsr_filter(almo_scf_env%matrix_t_blk(ispin), &
almo_scf_env%eps_filter)
END DO
CASE (atomic_guess)
IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%semi_empirical .OR. &
dft_control%qs_control%xtb) THEN
CALL calculate_mopac_dm(rho_ao, &
matrix_s(1)%matrix, has_unit_metric, &
dft_control, particle_set, atomic_kind_set, qs_kind_set, &
nspins, nelectron_spin, &
para_env)
ELSE
CALL calculate_atomic_block_dm(rho_ao, matrix_s(1)%matrix, atomic_kind_set, qs_kind_set, &
nspins, nelectron_spin, unit_nr, para_env)
END IF
DO ispin = 1, nspins
! copy the atomic-block dm into matrix_p_blk
CALL matrix_qs_to_almo(rho_ao(ispin)%matrix, &
almo_scf_env%matrix_p_blk(ispin), almo_scf_env%mat_distr_aos, &
.FALSE.)
CALL dbcsr_filter(almo_scf_env%matrix_p_blk(ispin), &
almo_scf_env%eps_filter)
END DO ! ispin
! obtain orbitals from the density matrix
! (the current version of ALMO SCF needs orbitals)
CALL almo_scf_p_blk_to_t_blk(almo_scf_env, ionic=.FALSE.)
CASE (restart_guess)
project_name = logger%iter_info%project_name
DO ispin = 1, nspins
WRITE (file_name, '(A,I0,A)') TRIM(project_name)//"_ALMO_SPIN_", ispin, "_RESTART.mo"
CALL dbcsr_get_info(almo_scf_env%matrix_t_blk(ispin), distribution=dist)
CALL dbcsr_binary_read(file_name, distribution=dist, matrix_new=almo_scf_env%matrix_t_blk(ispin))
cs_pos = dbcsr_checksum(almo_scf_env%matrix_t_blk(ispin), pos=.TRUE.)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A,E20.8)') "Read restart ALMO "//TRIM(file_name)//" with checksum: ", cs_pos
END IF
END DO
END SELECT
ELSE !aspc_guess
CALL cite_reference(Kolafa2004)
CALL cite_reference(Kuhne2007)
naspc = MIN(almo_scf_env%almo_history%istore, almo_scf_env%almo_history%nstore)
IF (unit_nr > 0) THEN
WRITE (unit_nr, FMT="(/,T2,A,/,/,T3,A,I0)") &
"Parameters for the always stable predictor-corrector (ASPC) method:", &
"ASPC order: ", naspc
END IF
DO ispin = 1, nspins
! extrapolation
DO iaspc = 1, naspc
istore = MOD(almo_scf_env%almo_history%istore - iaspc, almo_scf_env%almo_history%nstore) + 1
alpha = (-1.0_dp)**(iaspc + 1)*REAL(iaspc, KIND=dp)* &
binomial(2*naspc, naspc - iaspc)/binomial(2*naspc - 2, naspc - 1)
IF (unit_nr > 0) THEN
WRITE (unit_nr, FMT="(T3,A2,I0,A4,F10.6)") &
"B(", iaspc, ") = ", alpha
END IF
IF (iaspc == 1) THEN
CALL dbcsr_copy(almo_scf_env%matrix_t_blk(ispin), &
almo_scf_env%almo_history%matrix_t(ispin), &
keep_sparsity=.TRUE.)
CALL dbcsr_scale(almo_scf_env%matrix_t_blk(ispin), alpha)
ELSE
CALL dbcsr_multiply("N", "N", alpha, &
almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
almo_scf_env%almo_history%matrix_t(ispin), &
1.0_dp, almo_scf_env%matrix_t_blk(ispin), &
retain_sparsity=.TRUE.)
END IF
END DO !iaspc
END DO !ispin
END IF !aspc_guess?
DO ispin = 1, nspins
CALL orthogonalize_mos(ket=almo_scf_env%matrix_t_blk(ispin), &
overlap=almo_scf_env%matrix_sigma_blk(ispin), &
metric=almo_scf_env%matrix_s_blk(1), &
retain_locality=.TRUE., &
only_normalize=.FALSE., &
nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
eps_filter=almo_scf_env%eps_filter, &
order_lanczos=almo_scf_env%order_lanczos, &
eps_lanczos=almo_scf_env%eps_lanczos, &
max_iter_lanczos=almo_scf_env%max_iter_lanczos)
!! Application of an occupation-rescaling trick for smearing, if requested
IF (almo_scf_env%smear) THEN
CALL almo_scf_t_rescaling(matrix_t=almo_scf_env%matrix_t_blk(ispin), &
mo_energies=almo_scf_env%mo_energies(:, ispin), &
mu_of_domain=almo_scf_env%mu_of_domain(:, ispin), &
real_ne_of_domain=almo_scf_env%real_ne_of_domain(:, ispin), &
spin_kTS=almo_scf_env%kTS(ispin), &
smear_e_temp=almo_scf_env%smear_e_temp, &
ndomains=almo_scf_env%ndomains, &
nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin))
END IF
CALL almo_scf_t_to_proj(t=almo_scf_env%matrix_t_blk(ispin), &
p=almo_scf_env%matrix_p(ispin), &
eps_filter=almo_scf_env%eps_filter, &
orthog_orbs=.FALSE., &
nocc_of_domain=almo_scf_env%nocc_of_domain(:, ispin), &
s=almo_scf_env%matrix_s(1), &
sigma=almo_scf_env%matrix_sigma(ispin), &
sigma_inv=almo_scf_env%matrix_sigma_inv(ispin), &
use_guess=.FALSE., &
smear=almo_scf_env%smear, &
algorithm=almo_scf_env%sigma_inv_algorithm, &
eps_lanczos=almo_scf_env%eps_lanczos, &
max_iter_lanczos=almo_scf_env%max_iter_lanczos, &
inv_eps_factor=almo_scf_env%matrix_iter_eps_error_factor, &
para_env=almo_scf_env%para_env, &
blacs_env=almo_scf_env%blacs_env)
END DO
! compute dm from the projector(s)
IF (nspins == 1) THEN
CALL dbcsr_scale(almo_scf_env%matrix_p(1), 2.0_dp)
!! Rescaling electronic entropy contribution by spin_factor
IF (almo_scf_env%smear) THEN
almo_scf_env%kTS(1) = almo_scf_env%kTS(1)*2.0_dp
END IF
END IF
IF (almo_scf_env%smear) THEN
kTS_sum = SUM(almo_scf_env%kTS)
ELSE
kTS_sum = 0.0_dp
END IF
CALL almo_dm_to_almo_ks(qs_env, &
almo_scf_env%matrix_p, &
almo_scf_env%matrix_ks, &
energy, &
almo_scf_env%eps_filter, &
almo_scf_env%mat_distr_aos, &
smear=almo_scf_env%smear, &
kTS_sum=kTS_sum)
IF (unit_nr > 0) THEN
IF (almo_scf_env%almo_scf_guess .EQ. molecular_guess) THEN
WRITE (unit_nr, '(T2,A38,F40.10)') "Single-molecule energy:", &
SUM(mscfg_env%energy_of_frag)
END IF
WRITE (unit_nr, '(T2,A38,F40.10)') "Energy of the initial guess:", energy
WRITE (unit_nr, '()')
END IF
CALL timestop(handle)
END SUBROUTINE almo_scf_initial_guess
! **************************************************************************************************
!> \brief store a history of matrices for later use in almo_scf_initial_guess
!> \param almo_scf_env ...
!> \par History
!> 2016.11 created [Rustam Z Khaliullin]
!> \author Rustam Khaliullin
! **************************************************************************************************
SUBROUTINE almo_scf_store_extrapolation_data(almo_scf_env)
TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env
CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_store_extrapolation_data'
INTEGER :: handle, ispin, istore, unit_nr
LOGICAL :: delocalization_uses_extrapolation
TYPE(cp_logger_type), POINTER :: logger
TYPE(dbcsr_type) :: matrix_no_tmp1, matrix_no_tmp2, &
matrix_no_tmp3, matrix_no_tmp4
CALL timeset(routineN, handle)
! get a useful output_unit
logger => cp_get_default_logger()
IF (logger%para_env%is_source()) THEN
unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
ELSE
unit_nr = -1
END IF
IF (almo_scf_env%almo_history%nstore > 0) THEN
almo_scf_env%almo_history%istore = almo_scf_env%almo_history%istore + 1
DO ispin = 1, SIZE(almo_scf_env%matrix_t_blk)
istore = MOD(almo_scf_env%almo_history%istore - 1, almo_scf_env%almo_history%nstore) + 1
IF (almo_scf_env%almo_history%istore == 1) THEN
CALL dbcsr_create(almo_scf_env%almo_history%matrix_t(ispin), &
template=almo_scf_env%matrix_t_blk(ispin), &
matrix_type=dbcsr_type_no_symmetry)
END IF
CALL dbcsr_copy(almo_scf_env%almo_history%matrix_t(ispin), &
almo_scf_env%matrix_t_blk(ispin))
IF (almo_scf_env%almo_history%istore <= almo_scf_env%almo_history%nstore) THEN
CALL dbcsr_create(almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
template=almo_scf_env%matrix_s(1), &
matrix_type=dbcsr_type_no_symmetry)
END IF
CALL dbcsr_create(matrix_no_tmp1, template=almo_scf_env%matrix_t_blk(ispin), &
matrix_type=dbcsr_type_no_symmetry)
CALL dbcsr_create(matrix_no_tmp2, template=almo_scf_env%matrix_t_blk(ispin), &
matrix_type=dbcsr_type_no_symmetry)
! compute contra-covariant density matrix
CALL dbcsr_multiply("N", "N", 1.0_dp, almo_scf_env%matrix_s(1), &
almo_scf_env%matrix_t_blk(ispin), &
0.0_dp, matrix_no_tmp1, &
filter_eps=almo_scf_env%eps_filter)
CALL dbcsr_multiply("N", "N", 1.0_dp, matrix_no_tmp1, &
almo_scf_env%matrix_sigma_inv_0deloc(ispin), &
0.0_dp, matrix_no_tmp2, &
filter_eps=almo_scf_env%eps_filter)
CALL dbcsr_multiply("N", "T", 1.0_dp, &
almo_scf_env%matrix_t_blk(ispin), &
matrix_no_tmp2, &
0.0_dp, almo_scf_env%almo_history%matrix_p_up_down(ispin, istore), &
filter_eps=almo_scf_env%eps_filter)
CALL dbcsr_release(matrix_no_tmp1)
CALL dbcsr_release(matrix_no_tmp2)
END DO
END IF
! exrapolate xalmos?
delocalization_uses_extrapolation = &
.NOT. ((almo_scf_env%deloc_method .EQ. almo_deloc_none) .OR. &
(almo_scf_env%deloc_method .EQ. almo_deloc_xalmo_1diag))
IF (almo_scf_env%xalmo_history%nstore > 0 .AND. &
delocalization_uses_extrapolation) THEN
almo_scf_env%xalmo_history%istore = almo_scf_env%xalmo_history%istore + 1
DO ispin = 1, SIZE(almo_scf_env%matrix_t)
istore = MOD(almo_scf_env%xalmo_history%istore - 1, almo_scf_env%xalmo_history%nstore) + 1
IF (almo_scf_env%xalmo_history%istore == 1) THEN
CALL dbcsr_create(almo_scf_env%xalmo_history%matrix_t(ispin), &
template=almo_scf_env%matrix_t(ispin), &
matrix_type=dbcsr_type_no_symmetry)
END IF
CALL dbcsr_copy(almo_scf_env%xalmo_history%matrix_t(ispin), &
almo_scf_env%matrix_t(ispin))
IF (almo_scf_env%xalmo_history%istore <= almo_scf_env%xalmo_history%nstore) THEN
!CALL dbcsr_init(almo_scf_env%xalmo_history%matrix_x(ispin, istore))
!CALL dbcsr_create(almo_scf_env%xalmo_history%matrix_x(ispin, istore), &
! template=almo_scf_env%matrix_t(ispin), &
! matrix_type=dbcsr_type_no_symmetry)
CALL dbcsr_create(almo_scf_env%xalmo_history%matrix_p_up_down(ispin, istore), &
template=almo_scf_env%matrix_s(1), &
matrix_type=dbcsr_type_no_symmetry)
END IF
CALL dbcsr_create(matrix_no_tmp3, template=almo_scf_env%matrix_t(ispin), &
matrix_type=dbcsr_type_no_symmetry)
CALL dbcsr_create(matrix_no_tmp4, template=almo_scf_env%matrix_t(ispin), &
matrix_type=dbcsr_type_no_symmetry)
! compute contra-covariant density matrix
CALL dbcsr_multiply("N", "N", 1.0_dp, almo_scf_env%matrix_s(1), &
almo_scf_env%matrix_t(ispin), &
0.0_dp, matrix_no_tmp3, &
filter_eps=almo_scf_env%eps_filter)
CALL dbcsr_multiply("N", "N", 1.0_dp, matrix_no_tmp3, &
almo_scf_env%matrix_sigma_inv(ispin), &
0.0_dp, matrix_no_tmp4, &
filter_eps=almo_scf_env%eps_filter)
CALL dbcsr_multiply("N", "T", 1.0_dp, &
almo_scf_env%matrix_t(ispin), &
matrix_no_tmp4, &
0.0_dp, almo_scf_env%xalmo_history%matrix_p_up_down(ispin, istore), &
filter_eps=almo_scf_env%eps_filter)
! store the difference between t and t0
!CALL dbcsr_copy(almo_scf_env%xalmo_history%matrix_x(ispin, istore),&
! almo_scf_env%matrix_t(ispin))
!CALL dbcsr_add(almo_scf_env%xalmo_history%matrix_x(ispin, istore),&
! almo_scf_env%matrix_t_blk(ispin),1.0_dp,-1.0_dp)
CALL dbcsr_release(matrix_no_tmp3)
CALL dbcsr_release(matrix_no_tmp4)
END DO
END IF
CALL timestop(handle)
END SUBROUTINE almo_scf_store_extrapolation_data
! **************************************************************************************************
!> \brief Prints out a short summary about the ALMO SCF job
!> \param almo_scf_env ...
!> \param unit_nr ...
!> \par History
!> 2011.10 created [Rustam Z Khaliullin]
!> \author Rustam Z Khaliullin
! **************************************************************************************************
SUBROUTINE almo_scf_print_job_info(almo_scf_env, unit_nr)
TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env
INTEGER, INTENT(IN) :: unit_nr
CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_print_job_info'
CHARACTER(len=13) :: neig_string
CHARACTER(len=33) :: deloc_method_string
INTEGER :: handle, idomain, index1_prev, sum_temp
INTEGER, ALLOCATABLE, DIMENSION(:) :: nneighbors
CALL timeset(routineN, handle)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '()')
WRITE (unit_nr, '(T2,A,A,A)') REPEAT("-", 32), " ALMO SETTINGS ", REPEAT("-", 32)
WRITE (unit_nr, '(T2,A,T48,E33.3)') "eps_filter:", almo_scf_env%eps_filter
IF (almo_scf_env%almo_update_algorithm .EQ. almo_scf_skip) THEN
WRITE (unit_nr, '(T2,A)') "skip optimization of block-diagonal ALMOs"
ELSE
WRITE (unit_nr, '(T2,A)') "optimization of block-diagonal ALMOs:"
SELECT CASE (almo_scf_env%almo_update_algorithm)
CASE (almo_scf_diag)
! the DIIS algorith is the only choice for the diagonlaization-based algorithm
CALL print_optimizer_options(almo_scf_env%opt_block_diag_diis, unit_nr)
CASE (almo_scf_pcg)
! print out PCG options
CALL print_optimizer_options(almo_scf_env%opt_block_diag_pcg, unit_nr)
CASE (almo_scf_trustr)
! print out TRUST REGION options
CALL print_optimizer_options(almo_scf_env%opt_block_diag_trustr, unit_nr)
END SELECT
END IF
SELECT CASE (almo_scf_env%deloc_method)
CASE (almo_deloc_none)
deloc_method_string = "NONE"
CASE (almo_deloc_x)
deloc_method_string = "FULL_X"
CASE (almo_deloc_scf)
deloc_method_string = "FULL_SCF"
CASE (almo_deloc_x_then_scf)
deloc_method_string = "FULL_X_THEN_SCF"
CASE (almo_deloc_xalmo_1diag)
deloc_method_string = "XALMO_1DIAG"
CASE (almo_deloc_xalmo_x)
deloc_method_string = "XALMO_X"
CASE (almo_deloc_xalmo_scf)
deloc_method_string = "XALMO_SCF"
END SELECT
WRITE (unit_nr, '(T2,A,T48,A33)') "delocalization:", TRIM(deloc_method_string)
IF (almo_scf_env%deloc_method .NE. almo_deloc_none) THEN
SELECT CASE (almo_scf_env%deloc_method)
CASE (almo_deloc_x, almo_deloc_scf, almo_deloc_x_then_scf)
WRITE (unit_nr, '(T2,A,T48,A33)') "delocalization cutoff radius:", &
"infinite"
deloc_method_string = "FULL_X_THEN_SCF"
CASE (almo_deloc_xalmo_1diag, almo_deloc_xalmo_x, almo_deloc_xalmo_scf)
WRITE (unit_nr, '(T2,A,T48,F33.5)') "XALMO cutoff radius:", &
almo_scf_env%quencher_r0_factor
END SELECT
IF (almo_scf_env%deloc_method .EQ. almo_deloc_xalmo_1diag) THEN
! print nothing because no actual optimization is done
ELSE
WRITE (unit_nr, '(T2,A)') "optimization of extended orbitals:"
SELECT CASE (almo_scf_env%xalmo_update_algorithm)
CASE (almo_scf_diag)
CALL print_optimizer_options(almo_scf_env%opt_xalmo_diis, unit_nr)
CASE (almo_scf_trustr)
CALL print_optimizer_options(almo_scf_env%opt_xalmo_trustr, unit_nr)
CASE (almo_scf_pcg)
CALL print_optimizer_options(almo_scf_env%opt_xalmo_pcg, unit_nr)
END SELECT
END IF
END IF
!SELECT CASE(almo_scf_env%domain_layout_mos)