Repository navigation
Expand file tree
/
Copy pathbse_print.F
More file actions
1036 lines (943 loc) · 54.5 KB
/
Copy pathbse_print.F
File metadata and controls
1036 lines (943 loc) · 54.5 KB
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-2026 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Routines for printing information in context of the BSE calculation
!> \par History
!> 10.2024 created [Maximilian Graml]
! **************************************************************************************************
MODULE bse_print
USE atomic_kind_types, ONLY: get_atomic_kind
USE bibliography, ONLY: Graml2026,&
cite_reference
USE bse_properties, ONLY: compute_and_print_absorption_spectrum,&
exciton_descr_type
USE bse_types, ONLY: bse_env_type
USE bse_util, ONLY: filter_eigvec_contrib,&
get_bse_spin_block_layout
USE cp_fm_types, ONLY: cp_fm_get_info,&
cp_fm_type
USE input_constants, ONLY: bse_abba_mk_davidson,&
bse_iterdiag,&
bse_screening_alpha,&
bse_screening_rpa,&
bse_screening_tdhf,&
bse_screening_w0,&
bse_singlet
USE kinds, ONLY: dp
USE particle_types, ONLY: particle_type
USE physcon, ONLY: angstrom,&
evolt
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'bse_print'
PUBLIC :: print_BSE_start_flag, fm_write_thresh, print_excitation_energies, &
print_output_header, print_transition_amplitudes, print_optical_properties, &
print_exciton_descriptors
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param bse_tda ...
!> \param bse_abba ...
!> \param unit_nr ...
! **************************************************************************************************
SUBROUTINE print_BSE_start_flag(bse_tda, bse_abba, unit_nr)
LOGICAL, INTENT(IN) :: bse_tda, bse_abba
INTEGER, INTENT(IN) :: unit_nr
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_BSE_start_flag'
INTEGER :: handle
CALL timeset(routineN, handle)
CALL cite_reference(Graml2026)
IF (unit_nr > 0) THEN
WRITE (unit_nr, *) ' '
WRITE (unit_nr, '(T2,A79)') '*******************************************************************************'
WRITE (unit_nr, '(T2,A79)') '** **'
WRITE (unit_nr, '(T2,A79)') '** Bethe Salpeter equation (BSE) for excitation energies **'
IF (bse_tda .AND. bse_abba) THEN
WRITE (unit_nr, '(T2,A79)') '** solved with and without Tamm-Dancoff approximation (TDA) **'
ELSE IF (bse_tda) THEN
WRITE (unit_nr, '(T2,A79)') '** solved with Tamm-Dancoff approximation (TDA) **'
ELSE
WRITE (unit_nr, '(T2,A79)') '** solved without Tamm-Dancoff approximation (TDA) **'
END IF
WRITE (unit_nr, '(T2,A79)') '** **'
WRITE (unit_nr, '(T2,A79)') '*******************************************************************************'
WRITE (unit_nr, *) ' '
END IF
CALL timestop(handle)
END SUBROUTINE print_BSE_start_flag
! **************************************************************************************************
!> \brief Banner, defining equations and legend of one BSE problem, printed before it is solved
!> \param homo ...
!> \param virtual ...
!> \param homo_irred ...
!> \param flag_TDA ...
!> \param bse_env the BSE environment (settings)
!> \param unit_nr ...
! **************************************************************************************************
SUBROUTINE print_output_header(homo, virtual, homo_irred, flag_TDA, bse_env, unit_nr)
INTEGER, INTENT(IN) :: homo, virtual, homo_irred
LOGICAL, INTENT(IN) :: flag_TDA
TYPE(bse_env_type), INTENT(IN) :: bse_env
INTEGER, INTENT(IN) :: unit_nr
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_output_header'
CHARACTER(LEN=10) :: multiplet
INTEGER :: handle
LOGICAL :: iterative
REAL(KIND=dp) :: alpha
CALL timeset(routineN, handle)
IF (bse_env%bse_spin_config == bse_singlet) THEN
multiplet = "Singlet"
alpha = 2.0_dp
ELSE
multiplet = "Triplet"
alpha = 0.0_dp
END IF
iterative = bse_env%bse_diag_method == bse_iterdiag
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '**************************************************************************'
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '* Bethe Salpeter equation (BSE) with Tamm Dancoff approximation (TDA) *'
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '**************************************************************************'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (iterative) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'The lowest excitations are obtained iteratively (block Davidson)'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'from the BSE within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A48,A23)') 'BSE|', 'The excitations are calculated by diagonalizing ', &
'the BSE within the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T29,A16)') 'BSE|', 'A X^n = Ω^n X^n'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A23)') 'BSE|', 'i.e. in index notation:'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A41)') 'BSE|', 'sum_jb ( A_ia,jb X_jb^n ) = Ω^n X_ia^n'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A14)') 'BSE|', 'Ref.: Eq. (18)'
WRITE (unit_nr, '(T2,A4,T7,A61)') 'BSE|', 'in PRB 113,205152 (2026); https://doi.org/10.1103/38k2-d55h .'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '**************************************************************************'
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '* Full ("ABBA") Bethe Salpeter equation (BSE) (i.e. without TDA) *'
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', '**************************************************************************'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (iterative) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'The lowest excitations are obtained iteratively (block Davidson)'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'from the BSE without the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A48,A24)') 'BSE|', 'The excitations are calculated by diagonalizing ', &
'the BSE without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T22,A30)') 'BSE|', '|A B| |X^n| |1 0| |X^n|'
WRITE (unit_nr, '(T2,A4,T22,A31)') 'BSE|', '|B A| |Y^n| = Ω^n |0 -1| |Y^n|'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A23)') 'BSE|', 'i.e. in index notation:'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A62)') 'BSE|', ' sum_jb ( A_ia,jb X_jb^n + B_ia,jb Y_jb^n ) = Ω^n X_ia^n'
WRITE (unit_nr, '(T2,A4,T7,A62)') 'BSE|', '- sum_jb ( B_ia,jb X_jb^n + A_ia,jb Y_jb^n ) = Ω^n Y_ia^n'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A13)') 'BSE|', 'Ref.: Eq. (8)'
WRITE (unit_nr, '(T2,A4,T7,A61)') 'BSE|', 'in PRB 113,205152 (2026); https://doi.org/10.1103/38k2-d55h .'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A4,T18,A42,T70,A1,I4,A1,I4,A1)') 'BSE|', 'i,j:', &
'occupied molecular orbitals, i.e. state in', '[', homo_irred - homo + 1, ',', homo_irred, ']'
WRITE (unit_nr, '(T2,A4,T7,A4,T18,A44,T70,A1,I4,A1,I4,A1)') 'BSE|', 'a,b:', &
'unoccupied molecular orbitals, i.e. state in', '[', homo_irred + 1, ',', homo_irred + virtual, ']'
WRITE (unit_nr, '(T2,A4,T7,A2,T18,A16)') 'BSE|', 'n:', 'Excitation index'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (bse_env%screening_method == bse_screening_w0) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'A_ia,jb = (ε_a-ε_i) δ_ij δ_ab + α * v_ia,jb - W_ij,ab'
ELSE IF (bse_env%screening_method == bse_screening_rpa) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'A_ia,jb = (ε_a-ε_i) δ_ij δ_ab + α * v_ia,jb'
END IF
IF (.NOT. flag_TDA) THEN
IF (bse_env%screening_method == bse_screening_w0) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'B_ia,jb = α * v_ia,jb - W_ib,aj'
ELSE IF (bse_env%screening_method == bse_screening_rpa) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'B_ia,jb = α * v_ia,jb'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A14)') 'BSE|', 'Ref.: Eq. (10)'
WRITE (unit_nr, '(T2,A4,T7,A61)') 'BSE|', 'in PRB 113,205152 (2026); https://doi.org/10.1103/38k2-d55h .'
END IF
IF (iterative) THEN
CALL print_iterative_method(flag_TDA, bse_env%abba_solver, unit_nr)
ELSE IF (.NOT. flag_TDA) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A74)') 'BSE|', 'The BSE is solved for Ω^n and X_ia^n as a hermitian problem, e.g. Eq.(42)'
WRITE (unit_nr, '(T2,A4,T7,A71)') 'BSE|', 'in PRB 92,045209 (2015); http://dx.doi.org/10.1103/PhysRevB.92.045209 .'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A7,T31,A23)') 'BSE|', 'ε_...:', 'GW quasiparticle energy'
WRITE (unit_nr, '(T2,A4,T7,A7,T31,A15)') 'BSE|', 'δ_...:', 'Kronecker delta'
WRITE (unit_nr, '(T2,A4,T7,A3,T31,A21)') 'BSE|', 'α:', 'spin-dependent factor (Singlet/Triplet)'
WRITE (unit_nr, '(T2,A4,T7,A6,T30,A34)') 'BSE|', 'v_...:', 'Electron-hole exchange interaction'
IF (bse_env%screening_method == bse_screening_w0) THEN
WRITE (unit_nr, '(T2,A4,T7,A,T31,A)') 'BSE|', 'W_... = 1/ϵ v_...:', &
'Direct interaction screened by '
WRITE (unit_nr, '(T2,A4,T30,A)') 'BSE|', &
'dielectric function ϵ(ω=0)'
ELSE IF (bse_env%screening_method == bse_screening_tdhf) THEN
WRITE (unit_nr, '(T2,A4,T7,A,T30,A)') 'BSE|', 'W_... = v_...:', 'Direct interaction without screening'
ELSE IF (bse_env%screening_method == bse_screening_alpha) THEN
WRITE (unit_nr, '(T2,A4,T7,A,T31,A,F5.2)') 'BSE|', 'W_... = γ v_...:', &
'Direct interaction, artificial screening γ=', bse_env%screening_factor
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A47,A7,A9,F3.1)') 'BSE|', &
'The spin-dependent factor is for the requested ', multiplet, " is α = ", alpha
WRITE (unit_nr, '(T2,A4)') 'BSE|'
END IF
CALL timestop(handle)
END SUBROUTINE print_output_header
! **************************************************************************************************
!> \brief Equations of the block Davidson that BSE_DIAG_METHOD ITERDIAG runs, one arm per solver
!> \param flag_TDA ...
!> \param abba_solver ABBA_SOLVER, read outside the TDA
!> \param unit_nr ...
! **************************************************************************************************
SUBROUTINE print_iterative_method(flag_TDA, abba_solver, unit_nr)
LOGICAL, INTENT(IN) :: flag_TDA
INTEGER, INTENT(IN) :: abba_solver, unit_nr
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Iterative solution (block Davidson); A is applied, never formed:'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Trial space'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'Z_ia,m with sum_ia Z_ia,m Z_ia,n = δ_mn'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Reduced problem'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'G_mn = sum_ia Z_ia,m sum_jb A_ia,jb Z_jb,n'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'sum_n G_mn c_n^k = θ^k c_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'Ω^k = θ^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'X_ia^k = sum_m Z_ia,m c_m^k'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Residual and correction'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'r_ia^k = sum_jb A_ia,jb X_jb^k - θ^k X_ia^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 't_ia^k = r_ia^k / (d_ia - θ^k)'
ELSE IF (abba_solver == bse_abba_mk_davidson) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Iterative solution (block Davidson); A and B are applied, never formed:'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Trial space, orthonormal in the (A-B) metric'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'W_ia,m = sum_jb (A-B)_ia,jb T_jb,m'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'sum_ia T_ia,m W_ia,n = δ_mn'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Reduced problem'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'H_mn = sum_ia W_ia,m sum_jb (A+B)_ia,jb W_jb,n'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'sum_n H_mn c_n^k = θ^k c_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'Ω^k = (θ^k)^1/2'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'X_ia^k - Y_ia^k = (Ω^k)^1/2 sum_m T_ia,m c_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'X_ia^k + Y_ia^k = (Ω^k)^-1/2 sum_m W_ia,m c_m^k'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Residual and correction'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'r_ia^k = sum_jb (A+B)_ia,jb (X_jb^k + Y_jb^k) - Ω^k (X_ia^k - Y_ia^k)'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 't_ia^k = r_ia^k / ((d_ia)^2 - θ^k)'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Iterative solution (block Davidson); A and B are applied, never formed:'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Trial space'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'b_ia,m with sum_ia b_ia,m b_ia,n = δ_mn'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Reduced pair'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'Mr_mn = sum_ia b_ia,m sum_jb (A+B)_ia,jb b_jb,n'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'Kr_mn = sum_ia b_ia,m sum_jb (A-B)_ia,jb b_jb,n'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'sum_n Mr_mn R_n^k = Ω^k L_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'sum_n Kr_mn L_n^k = Ω^k R_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'X_ia^k + Y_ia^k = sum_m b_ia,m R_m^k'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'X_ia^k - Y_ia^k = sum_m b_ia,m L_m^k'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Residuals and correction'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'rR_ia^k = sum_jb (A+B)_ia,jb (X_jb^k + Y_jb^k) - Ω^k (X_ia^k - Y_ia^k)'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 'rL_ia^k = sum_jb (A-B)_ia,jb (X_jb^k - Y_jb^k) - Ω^k (X_ia^k + Y_ia^k)'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', '|r^k| = max(|rR^k|, |rL^k|)'
WRITE (unit_nr, '(T2,A4,T10,A)') 'BSE|', 't_ia^k = r_ia^k / (d_ia - Ω^k)'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'd_ia from PRECONDITIONER, the trial space grows by the t_ia^k'
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'convergence: |r^k| < EPS_RES, |ΔΩ^k| < EPS_ENERGY (CONVERGENCE_CRITERION)'
END IF
END SUBROUTINE print_iterative_method
! **************************************************************************************************
!> \brief ...
!> \param Exc_ens ...
!> \param homo ...
!> \param virtual ...
!> \param flag_TDA ...
!> \param multiplet ...
!> \param info_approximation ...
!> \param bse_env the BSE environment (settings)
!> \param unit_nr ...
! **************************************************************************************************
SUBROUTINE print_excitation_energies(Exc_ens, homo, virtual, flag_TDA, multiplet, &
info_approximation, bse_env, unit_nr)
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: Exc_ens
INTEGER, INTENT(IN) :: homo, virtual
LOGICAL, INTENT(IN) :: flag_TDA
CHARACTER(LEN=10), INTENT(IN) :: multiplet, info_approximation
TYPE(bse_env_type), INTENT(IN) :: bse_env
INTEGER, INTENT(IN) :: unit_nr
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_excitation_energies'
INTEGER :: handle, i_exc
CALL timeset(routineN, handle)
IF (unit_nr > 0) THEN
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A56)') 'BSE|', 'Excitation energies from solving the BSE within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A57)') 'BSE|', 'Excitation energies from solving the BSE without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T11,A12,T30,A7,T44,A8,T55,A27)') 'BSE|', &
'Excitation n', multiplet, 'TDA/ABBA', 'Excitation energy Ω^n (eV)'
END IF
!prints actual energies values
IF (unit_nr > 0) THEN
DO i_exc = 1, MIN(homo*virtual, bse_env%num_print_exc)
WRITE (unit_nr, '(T2,A4,T7,I16,T30,A7,T46,A6,T59,F22.4)') &
'BSE|', i_exc, multiplet, info_approximation, Exc_ens(i_exc)*evolt
END DO
END IF
CALL timestop(handle)
END SUBROUTINE print_excitation_energies
! **************************************************************************************************
!> \brief ...
!> \param fm_eigvec_X ...
!> \param homo ...
!> \param virtual ...
!> \param homo_irred ...
!> \param info_approximation ...
!> \param bse_env the BSE environment (settings)
!> \param unit_nr ...
!> \param fm_eigvec_Y ...
! **************************************************************************************************
SUBROUTINE print_transition_amplitudes(fm_eigvec_X, homo, virtual, homo_irred, &
info_approximation, bse_env, unit_nr, fm_eigvec_Y)
TYPE(cp_fm_type), INTENT(IN) :: fm_eigvec_X
INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual, homo_irred
CHARACTER(LEN=10), INTENT(IN) :: info_approximation
TYPE(bse_env_type), INTENT(IN) :: bse_env
INTEGER, INTENT(IN) :: unit_nr
TYPE(cp_fm_type), INTENT(IN), OPTIONAL :: fm_eigvec_Y
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_transition_amplitudes'
INTEGER :: handle, i_exc, isp, n_ov_joint, nspins
INTEGER, ALLOCATABLE, DIMENSION(:) :: n_ov, offsets
CALL timeset(routineN, handle)
nspins = SIZE(homo)
ALLOCATE (n_ov(nspins), offsets(nspins))
CALL get_bse_spin_block_layout(homo, virtual, n_ov, offsets, n_ov_joint)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A61)') &
'BSE|', "Single-particle transitions are built up by (de-)excitations,"
WRITE (unit_nr, '(T2,A4,T7,A18)') &
'BSE|', "which we denote by"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T20,A2,T30,A40)') &
'BSE|', "=>", "for excitations, i.e. entries of X_ia^n,"
WRITE (unit_nr, '(T2,A4,T20,A2,T30,A42)') &
'BSE|', "<=", "for deexcitations, i.e. entries of Y_ia^n."
WRITE (unit_nr, '(T2,A4)') &
'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A73)') &
'BSE|', "The following single-particle transitions have significant contributions,"
WRITE (unit_nr, '(T2,A4,T7,A16,F5.3,A15,F5.3,A16)') &
'BSE|', "i.e. |X_ia^n| > ", bse_env%eps_x, " or |Y_ia^n| > ", &
bse_env%eps_x, ", respectively :"
IF (nspins == 1) THEN
WRITE (unit_nr, '(T2,A4,T15,A27,I5,A13,I5,A3)') 'BSE|', '-- Quick reminder: HOMO i =', &
homo_irred(1), ' and LUMO a =', homo_irred(1) + 1, " --"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A12,T30,A1,T32,A5,T42,A1,T49,A8,T64,A17)') &
"BSE|", "Excitation n", "i", "=>/<=", "a", 'TDA/ABBA', "|X_ia^n|/|Y_ia^n|"
ELSE
! bare A (no width) for sigma-bearing literals: explicit widths count bytes, and the
! 2-byte UTF-8 sigma would otherwise truncate.
DO isp = 1, nspins
WRITE (unit_nr, '(T2,A4,T15,A,I2,A,I5,A,I5,A)') 'BSE|', &
'-- Quick reminder: σ =', isp, ', HOMO i =', homo_irred(isp), &
' and LUMO a =', homo_irred(isp) + 1, " --"
END DO
WRITE (unit_nr, '(T2,A4)') 'BSE|'
! T counts bytes: anchors after σ sit one byte past the closed-shell ones; the longer last label ends at column 80
WRITE (unit_nr, '(T2,A4,T7,A12,T22,A,T31,A1,T33,A5,T43,A1,T50,A8,T63,A)') &
"BSE|", "Excitation n", "σ", "i", "=>/<=", "a", 'TDA/ABBA', "|X_iaσ^n|/|Y_iaσ^n|"
END IF
END IF
DO i_exc = 1, MIN(n_ov_joint, bse_env%num_print_exc)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
END IF
!Iterate through eigenvector and print values above threshold
CALL print_transition_amplitudes_core(fm_eigvec_X, "=>", info_approximation, &
i_exc, virtual, homo, homo_irred, &
unit_nr, bse_env, offsets)
IF (PRESENT(fm_eigvec_Y)) THEN
CALL print_transition_amplitudes_core(fm_eigvec_Y, "<=", info_approximation, &
i_exc, virtual, homo, homo_irred, &
unit_nr, bse_env, offsets)
END IF
END DO
DEALLOCATE (n_ov, offsets)
CALL timestop(handle)
END SUBROUTINE print_transition_amplitudes
! **************************************************************************************************
!> \brief ...
!> \param Exc_ens ...
!> \param oscill_str ...
!> \param trans_mom_bse ...
!> \param polarizability_residues ...
!> \param homo ...
!> \param virtual ...
!> \param homo_irred ...
!> \param flag_TDA ...
!> \param info_approximation ...
!> \param bse_env the BSE environment (settings)
!> \param unit_nr ...
!> \param open_shell if .TRUE., print spin-summed (UKS) dipole formula instead of the sqrt(2) one
! **************************************************************************************************
SUBROUTINE print_optical_properties(Exc_ens, oscill_str, trans_mom_bse, polarizability_residues, &
homo, virtual, homo_irred, flag_TDA, &
info_approximation, bse_env, unit_nr, open_shell)
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: Exc_ens, oscill_str
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: trans_mom_bse, polarizability_residues
INTEGER, INTENT(IN) :: homo, virtual, homo_irred
LOGICAL, INTENT(IN) :: flag_TDA
CHARACTER(LEN=10), INTENT(IN) :: info_approximation
TYPE(bse_env_type), INTENT(IN) :: bse_env
INTEGER, INTENT(IN) :: unit_nr
LOGICAL, INTENT(IN), OPTIONAL :: open_shell
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_optical_properties'
INTEGER :: handle, i_exc
LOGICAL :: my_open_shell
CALL timeset(routineN, handle)
my_open_shell = .FALSE.
IF (PRESENT(open_shell)) my_open_shell = open_shell
! Discriminate between singlet and triplet, since triplet state can't couple to light
! and therefore calculations of dipoles etc are not necessary
IF (bse_env%bse_spin_config == 0) THEN
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A60)') &
'BSE|', "Transition moments d_r^n (with r∈(x,y,z), in atomic units)"
WRITE (unit_nr, '(T2,A4,T7,A67)') &
'BSE|', "and oscillator strength f^n of excitation level n are obtained from"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (my_open_shell) THEN
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T10,A)') &
'BSE|', "d_r^n = sum_σ sum_ia < ψ_iσ | r | ψ_aσ > X_iaσ^n"
ELSE
WRITE (unit_nr, '(T2,A4,T10,A)') &
'BSE|', "d_r^n = sum_σ sum_ia < ψ_iσ | r | ψ_aσ > ( X_iaσ^n + Y_iaσ^n )"
END IF
ELSE
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T10,A)') &
'BSE|', "d_r^n = sqrt(2) sum_ia < ψ_i | r | ψ_a > X_ia^n"
ELSE
WRITE (unit_nr, '(T2,A4,T10,A)') &
'BSE|', "d_r^n = sum_ia sqrt(2) < ψ_i | r | ψ_a > ( X_ia^n + Y_ia^n )"
END IF
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T14,A)') &
'BSE|', "f^n = 2/3 * Ω^n sum_r∈(x,y,z) ( d_r^n )^2"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A19)') &
'BSE|', "where we introduced"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A5,T15,A28)') &
'BSE|', "ψ_i:", "occupied molecular orbitals,"
WRITE (unit_nr, '(T2,A4,T7,A5,T15,A28)') &
'BSE|', "ψ_a:", "empty molecular orbitals and"
WRITE (unit_nr, '(T2,A4,T9,A2,T14,A18)') &
'BSE|', "r:", "position operator."
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T7,A21)') &
'BSE|', "Ref.: Eqs. (21), (D3)"
WRITE (unit_nr, '(T2,A4,T7,A69)') &
'BSE|', "in Phys. Rev. B 113, 205152 (2026); https://doi.org/10.1103/38k2-d55h"
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A55)') 'BSE|', &
'Optical properties from solving the BSE within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A56)') 'BSE|', &
'Optical properties from solving the BSE without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T8,A12,T22,A8,T38,A5,T48,A5,T58,A5,T64,A17)') 'BSE|', &
'Excitation n', "TDA/ABBA", "d_x^n", "d_y^n", "d_z^n", 'Osc. strength f^n'
DO i_exc = 1, MIN(homo*virtual, bse_env%num_print_exc)
WRITE (unit_nr, '(T2,A4,T8,I12,T24,A6,T35,F8.3,T45,F8.3,T55,F8.3,T65,F16.3)') &
'BSE|', i_exc, info_approximation, trans_mom_bse(1, 1, i_exc), trans_mom_bse(2, 1, i_exc), &
trans_mom_bse(3, 1, i_exc), oscill_str(i_exc)
END DO
WRITE (unit_nr, '(T2,A4)') 'BSE|'
! the sum rule needs all excitations, an iterative solver provides the lowest ones only
IF (SIZE(oscill_str) == homo*virtual) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', &
'Check for Thomas-Reiche-Kuhn sum rule'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4,T35,A15)') 'BSE|', &
'N_e = Σ_n f^n'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
! Open shell: caller passes homo_irred = n_alpha + n_beta (total electrons).
! Closed shell: homo_irred = n_occ, i.e. 2 electrons per occupied orbital.
WRITE (unit_nr, '(T2,A4,T7,A24,T65,I16)') 'BSE|', &
'Number of electrons N_e:', MERGE(homo_irred, homo_irred*2, my_open_shell)
WRITE (unit_nr, '(T2,A4,T7,A40,T66,F16.3)') 'BSE|', &
'Sum over oscillator strengths Σ_n f^n :', SUM(oscill_str)
WRITE (unit_nr, '(T2,A4)') 'BSE|'
IF (bse_env%bse_cutoff_occ > 0 .OR. bse_env%bse_cutoff_empty > 0) THEN
CALL cp_warn(__LOCATION__, &
"Accuracy of TRK sum rule might suffer from cutoffs.")
END IF
END IF
END IF
! Compute and print the absorption spectrum to external file
IF (bse_env%bse_print_spectrum) THEN
CALL compute_and_print_absorption_spectrum(oscill_str, polarizability_residues, Exc_ens, &
info_approximation, unit_nr, bse_env)
END IF
ELSE
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') 'BSE|'
WRITE (unit_nr, '(T2,A4)') 'BSE|'
CALL cp_warn(__LOCATION__, &
"Requested triplet excitation cannot couple to light. "// &
"Skipping calculation of transition moments, "// &
"oscillator strengths, and spectrum.")
END IF
END IF
CALL timestop(handle)
END SUBROUTINE print_optical_properties
! **************************************************************************************************
!> \brief ...
!> \param fm_eigvec ...
!> \param direction_excitation ...
!> \param info_approximation ...
!> \param i_exc ...
!> \param virtual ...
!> \param homo ...
!> \param homo_irred ...
!> \param unit_nr ...
!> \param bse_env the BSE environment (settings)
!> \param offsets ...
! **************************************************************************************************
SUBROUTINE print_transition_amplitudes_core(fm_eigvec, direction_excitation, info_approximation, &
i_exc, virtual, homo, homo_irred, &
unit_nr, bse_env, offsets)
TYPE(cp_fm_type), INTENT(IN) :: fm_eigvec
CHARACTER(LEN=2), INTENT(IN) :: direction_excitation
CHARACTER(LEN=10), INTENT(IN) :: info_approximation
INTEGER, INTENT(IN) :: i_exc
INTEGER, DIMENSION(:), INTENT(IN) :: virtual, homo, homo_irred
INTEGER, INTENT(IN) :: unit_nr
TYPE(bse_env_type), INTENT(IN) :: bse_env
INTEGER, DIMENSION(:), INTENT(IN) :: offsets
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_transition_amplitudes_core'
CHARACTER(LEN=2), DIMENSION(2), PARAMETER :: spin_label = ["α", "β"]
INTEGER :: handle, isp, k, num_entries
INTEGER, ALLOCATABLE, DIMENSION(:) :: idx_homo, idx_spin, idx_virt
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: eigvec_entries
! 2-byte UTF-8 glyphs (LEN=1 would truncate both alpha/beta to the shared 0xCE byte)
CALL timeset(routineN, handle)
! direction_excitation can be either => (means excitation; from fm_eigvec_X)
! or <= (means deexcitation; from fm_eigvec_Y)
IF (SIZE(homo) == 1) THEN
CALL filter_eigvec_contrib(fm_eigvec, idx_homo, idx_virt, eigvec_entries, &
i_exc, virtual(1), num_entries, bse_env)
IF (unit_nr > 0) THEN
DO k = 1, num_entries
WRITE (unit_nr, '(T2,A4,T14,I5,T26,I5,T35,A2,T38,I5,T51,A6,T65,F16.4)') &
"BSE|", i_exc, homo_irred(1) - homo(1) + idx_homo(k), direction_excitation, &
homo_irred(1) + idx_virt(k), info_approximation, ABS(eigvec_entries(k))
END DO
END IF
ELSE
CALL filter_eigvec_contrib(fm_eigvec, idx_homo, idx_virt, eigvec_entries, &
i_exc, virtual(1), num_entries, bse_env, &
offsets=offsets, virtual_per_spin=virtual, idx_spin=idx_spin)
IF (unit_nr > 0) THEN
DO k = 1, num_entries
isp = idx_spin(k)
! the 2-byte spin glyph shifts the later columns by one byte
WRITE (unit_nr, '(T2,A4,T14,I5,T22,A2,T27,I5,T36,A2,T39,I5,T52,A6,T66,F16.4)') &
"BSE|", i_exc, spin_label(isp), &
homo_irred(isp) - homo(isp) + idx_homo(k), direction_excitation, &
homo_irred(isp) + idx_virt(k), info_approximation, ABS(eigvec_entries(k))
END DO
END IF
DEALLOCATE (idx_spin)
END IF
DEALLOCATE (idx_homo)
DEALLOCATE (idx_virt)
DEALLOCATE (eigvec_entries)
CALL timestop(handle)
END SUBROUTINE print_transition_amplitudes_core
! **************************************************************************************************
!> \brief Prints exciton descriptors, cf. Mewes et al., JCTC 14, 710-725 (2018)
!> \param exc_descr Exciton descriptors with size of num_print_exc_descr
!> \param ref_point_multipole Reference point for computation of multipole moments, e.g. center of mass
!> \param unit_nr ...
!> \param num_print_exc_descr Number of excitation levels for which descriptors are printed
!> \param print_checkvalue Flag, which determines if values for regtests should be printed
!> \param print_directional_exc_descr Flag, which activates printing of directional descriptors
!> \param print_directional_crosscorrelation Flag, which adds the crosscorrelation matrix to the directional descriptors
!> \param prefix_output String, which is put in front of prints, i.e. "BSE|" or "" for TDDFPT
!> \param particle_set Atoms whose coordinates are printed with the descriptors
! **************************************************************************************************
SUBROUTINE print_exciton_descriptors(exc_descr, ref_point_multipole, unit_nr, &
num_print_exc_descr, print_checkvalue, print_directional_exc_descr, &
print_directional_crosscorrelation, prefix_output, particle_set)
TYPE(exciton_descr_type), ALLOCATABLE, &
DIMENSION(:) :: exc_descr
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:), &
INTENT(IN) :: ref_point_multipole
INTEGER, INTENT(IN) :: unit_nr, num_print_exc_descr
LOGICAL, INTENT(IN) :: print_checkvalue, print_directional_exc_descr, &
print_directional_crosscorrelation
CHARACTER(LEN=4), INTENT(IN) :: prefix_output
TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
CHARACTER(LEN=*), PARAMETER :: routineN = 'print_exciton_descriptors'
CHARACTER(LEN=1), DIMENSION(3) :: array_direction_str
CHARACTER(LEN=5) :: method_name
INTEGER :: handle, i_dir, i_exc
IF (prefix_output == 'BSE|') THEN
method_name = 'BSE'
ELSE
method_name = 'TDDFT'
END IF
CALL timeset(routineN, handle)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'Exciton descriptors for excitation level n are given by'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'd_eh = | <r_h - r_e>_exc |'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'σ_e = sqrt( <r_e^2>_exc - <r_e>_exc^2 )'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'σ_h = sqrt( <r_h^2>_exc - <r_h>_exc^2 )'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'COV_eh = <r_e r_h>_exc - <r_e>_exc <r_h>_exc'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'd_exc = sqrt( | < |r_h - r_e|^2 >_exc )'
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
' = sqrt( d_eh^2 + σ_e^2 + σ_h^2 - 2 * COV_eh )'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'R_eh = COV_eh / (σ_e * σ_h)'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'where the expectation values <.>_exc are taken with respect to the '
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'exciton wavefunction of excitation n:'
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T20,A)') prefix_output, &
'𝚿_n(r_e,r_h) = Σ_{i,a} X_ia^n ψ_i(r_h) ψ_a(r_e) ,'
ELSE
WRITE (unit_nr, '(T2,A4,T20,A)') prefix_output, &
'𝚿_n(r_e,r_h) = Σ_{i,a} X_ia^n ψ_i(r_h) ψ_a(r_e)'
WRITE (unit_nr, '(T2,A4,T40,A)') prefix_output, &
'+ Y_ia^n ψ_a(r_h) ψ_i(r_e) ,'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'i.e.'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T20,A)') prefix_output, &
'< O >_exc = < 𝚿_n | O | 𝚿_n > / < 𝚿_n | 𝚿_n > ,'
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'where c_n = < 𝚿_n | 𝚿_n > = 1 within TDA.'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'where c_n = < 𝚿_n | 𝚿_n > ≥ 1 without TDA.'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'Here, we introduced'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A5,T15,A)') &
prefix_output, "ψ_i:", "occupied molecular orbitals,"
WRITE (unit_nr, '(T2,A4,T7,A5,T15,A)') &
prefix_output, "ψ_a:", "empty molecular orbitals and"
WRITE (unit_nr, '(T2,A4,T9,A2,T14,A)') &
prefix_output, "r:", "position operator."
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'Ref.: Eqs. (28)-(32)'
WRITE (unit_nr, '(T2,A4,T7,A,A)') prefix_output, &
'Phys. Rev. B 113, 205152 (2026); ', &
'https://doi.org/10.1103/38k2-d55h'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Exciton descriptors from solving the ', method_name, ' within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Exciton descriptors from solving the ', method_name, ' without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T10,A1,6X,A3,1X,4X,A10,5X,A10,5X,A10,3X,A11,8X,A4)') prefix_output, &
'n', 'c_n', 'd_eh [Å]', 'σ_e [Å]', 'σ_h [Å]', 'd_exc [Å]', 'R_eh'
DO i_exc = 1, num_print_exc_descr
WRITE (unit_nr, '(T2,A4,T7,I4,4X,F5.3,1X,5(2X,F10.4))') &
prefix_output, i_exc, exc_descr(i_exc)%norm_XpY, &
exc_descr(i_exc)%diff_r_abs*angstrom, &
exc_descr(i_exc)%sigma_e*angstrom, exc_descr(i_exc)%sigma_h*angstrom, &
exc_descr(i_exc)%diff_r_sqr*angstrom, exc_descr(i_exc)%corr_e_h
END DO
WRITE (unit_nr, '(T2,A4)') prefix_output
! For debug runs, print first d_exc separately to allow the regtests to read in
IF (print_checkvalue) THEN
WRITE (unit_nr, '(T2)')
WRITE (unit_nr, '(T2,A28,T65,F16.4)') 'Checksum exciton descriptors', &
exc_descr(1)%diff_r_sqr*angstrom
WRITE (unit_nr, '(T2)')
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
! Print exciton descriptor resolved per direction
IF (print_directional_exc_descr) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'We can restrict the exciton descriptors to a specific direction,'
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'e.g. the x-components are:'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'd_eh^x = | <x_h - x_e>_exc |'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'σ_e^x = sqrt( <x_e^2>_exc - <x_e>_exc^2 )'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'σ_h^x = sqrt( <x_h^2>_exc - <x_h>_exc^2 )'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
"COV_eh^{μμ'} = <r^μ_e r^μ'_h>_exc - <r^μ_e>_exc <r^μ'_h>_exc"
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
'd_exc^x = sqrt( | < |x_h - x_e|^2 >_exc )'
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
' = sqrt( (d_eh^x)^2 + (σ_e^x)^2'
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
" + (σ_h^x)^2 - 2 * (COV_eh^{xx}) )"
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (print_directional_crosscorrelation) THEN
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
"Subsequently, the cross-correlation matrix R_eh^{μμ'} is printed"
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T15,A)') prefix_output, &
"R_eh^{μμ'} = COV_eh^{μμ'}/(σ^μ_e σ^μ'_h)"
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
"Rows: electron direction μ, columns: hole direction μ',"
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
"so in general R_eh^{μμ'} ≠ R_eh^{μ'μ}."
WRITE (unit_nr, '(T2,A4)') prefix_output
END IF
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'Ref.: Eqs. (33)-(36)'
WRITE (unit_nr, '(T2,A4,T7,A,A)') prefix_output, &
'Phys. Rev. B 113, 205152 (2026); ', &
'https://doi.org/10.1103/38k2-d55h'
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Exciton descriptors per direction from solving the ', method_name, ' within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Exciton descriptors per direction from solving the ', method_name, ' without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T12,A1,2X,A9,5X,A12,5X,A12,5X,A12,3X,A13)') prefix_output, &
'n', 'r = x/y/z', 'd_eh^r [Å]', 'σ_e^r [Å]', 'σ_h^r [Å]', 'd_exc^r [Å]'
DO i_exc = 1, num_print_exc_descr
DO i_dir = 1, 3
array_direction_str = ["x", "y", "z"]
WRITE (unit_nr, '(T2,A4,T9,I4,10X,A1,1X,4(4X,F10.4))') &
prefix_output, i_exc, array_direction_str(i_dir), &
exc_descr(i_exc)%d_eh_dir(i_dir)*angstrom, &
exc_descr(i_exc)%sigma_e_dir(i_dir)*angstrom, &
exc_descr(i_exc)%sigma_h_dir(i_dir)*angstrom, &
exc_descr(i_exc)%d_exc_dir(i_dir)*angstrom
END DO
WRITE (unit_nr, '(T2,A4)') prefix_output
END DO
IF (print_directional_crosscorrelation) THEN
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4)') prefix_output
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Crosscorrelation matrix from solving the ', method_name, ' within the TDA:'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'Crosscorrelation matrix from solving the ', method_name, ' without the TDA:'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T12,A1,T23,A3,T44,A1,T62,A1,T80,A1)') prefix_output, &
'n', 'e\h', 'x', 'y', 'z'
! rows: electron direction, columns: hole direction
DO i_exc = 1, num_print_exc_descr
WRITE (unit_nr, '(T2,A4,T9,I4,T25,A1,1X,3(11X,F7.4))') prefix_output, i_exc, &
array_direction_str(1), exc_descr(i_exc)%corr_e_h_matrix(1, :)
DO i_dir = 2, 3
WRITE (unit_nr, '(T2,A4,T25,A1,1X,3(11X,F7.4))') prefix_output, &
array_direction_str(i_dir), exc_descr(i_exc)%corr_e_h_matrix(i_dir, :)
END DO
WRITE (unit_nr, '(T2,A4)') prefix_output
END DO
END IF
END IF
! Print the reference atomic geometry for the exciton descriptors
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'With the center of charge as reference point r_0,'
WRITE (unit_nr, '(T2,A4,T15,A7,F10.4,A2,F10.4,A2,F10.4,A1)') prefix_output, &
'r_0 = (', ref_point_multipole(1)*angstrom, ', ', ref_point_multipole(2)*angstrom, ', ', &
ref_point_multipole(3)*angstrom, ')'
IF (exc_descr(1)%flag_TDA) THEN
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'we further obtain r_e and r_h from solving the ', method_name, ' within the TDA'
ELSE
WRITE (unit_nr, '(T2,A4,T7,A,A,A)') prefix_output, &
'we further obtain r_e and r_h from solving the ', method_name, ' without the TDA'
END IF
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T8,A12,1X,13X,A9,13X,A9,13X,A9)') prefix_output, &
'Excitation n', 'x_e [Å]', 'y_e [Å]', 'z_e [Å]'
DO i_exc = 1, num_print_exc_descr
WRITE (unit_nr, '(T2,A4,T8,I12,1X,3(5X,F15.4))') &
prefix_output, i_exc, &
exc_descr(i_exc)%r_e_shift(:)*angstrom
END DO
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T8,A12,1X,13X,A9,13X,A9,13X,A9)') prefix_output, &
'Excitation n', 'x_h [Å]', 'y_h [Å]', 'z_h [Å]'
DO i_exc = 1, num_print_exc_descr
WRITE (unit_nr, '(T2,A4,T8,I12,1X,3(5X,F15.4))') &
prefix_output, i_exc, &
exc_descr(i_exc)%r_h_shift(:)*angstrom
END DO
WRITE (unit_nr, '(T2,A4)') prefix_output
WRITE (unit_nr, '(T2,A4,T7,A)') prefix_output, &
'The reference atomic geometry for these values is given by'
END IF
CALL write_qs_particle_coordinates_bse(particle_set, unit_nr, prefix_output)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T2,A4)') prefix_output
END IF
CALL timestop(handle)
END SUBROUTINE print_exciton_descriptors
! **************************************************************************************************
!> \brief Debug function to write elements of a full matrix to file, if they are larger than a given threshold
!> \param fm ...
!> \param thresh ...
!> \param header ...
!> \param unit_nr ...
!> \param abs_vals ...
! **************************************************************************************************
SUBROUTINE fm_write_thresh(fm, thresh, header, unit_nr, abs_vals)
TYPE(cp_fm_type), INTENT(IN) :: fm
REAL(KIND=dp), INTENT(IN) :: thresh
CHARACTER(LEN=*), INTENT(IN) :: header
INTEGER, INTENT(IN) :: unit_nr
LOGICAL, OPTIONAL :: abs_vals
CHARACTER(LEN=*), PARAMETER :: my_footer = " | ENDING WRITING OF MATRIX", &
routineN = 'fm_write_thresh'
INTEGER :: handle, i, j, ncol_local, nrow_local
INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
LOGICAL :: my_abs_vals
CALL timeset(routineN, handle)
IF (PRESENT(abs_vals)) THEN
my_abs_vals = abs_vals
ELSE
my_abs_vals = .FALSE.
END IF
CALL cp_fm_get_info(matrix=fm, &
nrow_local=nrow_local, &
ncol_local=ncol_local, &
row_indices=row_indices, &
col_indices=col_indices)
IF (unit_nr > 0) THEN
WRITE (unit_nr, *) header
END IF
IF (my_abs_vals) THEN
DO i = 1, nrow_local
DO j = 1, ncol_local
IF (ABS(fm%local_data(i, j)) > thresh) THEN
IF (unit_nr > 0) THEN
WRITE (unit_nr, "(A7,T10,I5,T20,I5,T30,F13.5)") header, row_indices(i), col_indices(j), &
ABS(fm%local_data(i, j))
END IF
END IF
END DO
END DO
ELSE
DO i = 1, nrow_local
DO j = 1, ncol_local
IF (ABS(fm%local_data(i, j)) > thresh) THEN
IF (unit_nr > 0) THEN
WRITE (unit_nr, "(A7,T10,I5,T20,I5,T30,F13.5)") header, row_indices(i), col_indices(j), &
fm%local_data(i, j)
END IF
END IF
END DO
END DO
END IF
CALL fm%matrix_struct%para_env%sync()
IF (unit_nr > 0) THEN
WRITE (unit_nr, *) my_footer
END IF
CALL timestop(handle)
END SUBROUTINE fm_write_thresh
! **************************************************************************************************
!> \brief Write the atomic coordinates to the output unit.