-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpolarizability.f90
2178 lines (2141 loc) · 71.4 KB
/
polarizability.f90
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
module polarizability
!
use accuracy, only : hik, ik, rk, rk, cl, out, vellgt, planck, &
avogno, boltz, pi, small_
use diatom_module, only : job, Intensity, quantaT, eigen, basis, Ndipoles, Nss, &
dipoletm, duo_j0, fieldT, poten, three_j, &
jmin_global,spinspin
use timer, only : IOstart, Arraystart, Arraystop, ArrayMinus, &
Timerstart, Timerstop, MemoryReport, &
TimerReport, memory_limit, memory_now
use symmetry, only : sym,correlate_to_Cs
private
public pol_tranint
real(rk), allocatable, save :: polarisability_me(:, :)
type DmatT
real(rk), pointer :: mat(:, :, :)
end type DmatT
type DimatT
integer(ik),pointer :: imat(:,:,:)
end type DimatT
type DkmatT
integer(ik),pointer :: kmat(:,:)
end type DkmatT
type ElevelT
integer(ik) :: jind ! J index
integer(ik) :: igamma
integer(ik) :: ilevel
end type ElevelT
type dipoleT
real(rk),pointer :: rot(:,:,:,:,:)
end type dipoleT
integer(ik) :: Neigenlevels
type(ElevelT), allocatable :: Elevel(:)
type(dipoleT), allocatable :: wigner(:,:) ! rot. component of matrix elems
contains
subroutine pol_tranint
! Obtain the partition function, polarisability transition moments,
! linestrengths, and intensities.
! Transition moments and intensities are computed by the call to
! pol_intensity subroutine.
integer(ik) :: info
integer(ik) :: nJ, jind
real(rk), allocatable :: Jval(:), q_part(:,:)
real(rk) :: Jmin, Jmax, Jval_min, Jval_, energy, &
beta, exp_en, part
integer(ik) :: ilevel, igamma, irrep, istate, parity_gu, isym
integer(ik) :: iverbose = 4
! initialise array of J values
! J = 0 always present, regardless of whether it is used in calculations
!
Jmin = minval(intensity%J(1:2))
Jmax = maxval(intensity%J(1:2))
!
Jmin = max(jmin_global, Jmin)
!
! we now count J states, starting from the lowest J = 0 or 0.5, to make
! sure all J > 0 are included in the line list for any intensity%J to
! guarantee consistent energy list numbering
!
! find lowest possible J value
Jval_min = 0
if (mod(nint(2.0_rk*job%j_list(1)),2) /= 0) Jval_min = 0.5_rk
Jval_min = max(jmin_global, Jval_min)
!
Jval_ = Jval_min
nJ = 1
!
! count the number of J states
do while (Jval_ < Jmax)
Jval_ = Jval_ + 1.0_rk
nJ = nJ + 1
enddo
!
allocate(Jval(nJ), stat = info)
if (info /= 0) stop 'pol_tranint allocation error: Jval - out of memory'
!
allocate(q_part(20, nJ), stat = info)
if (info /= 0) stop 'pol_tranint allocation error: q_part - out of memory'
!
Jval_ = Jval_min
jind = 1
Jval(jind) = Jval_
do while (Jval_ < Jmax)
jind = jind + 1
Jval_ = Jval_ + 1.0_rk
Jval(jind) = Jval_
enddo
!
call duo_j0(iverbose, Jval)
!
! include ZPE if not provided as part of intensity input
!
if (job%shift_to_zpe) then
!
do jind = 1, nJ
!
Jval_ = Jval(jind)
!
do igamma = 1, sym%NrepresCs
!
do ilevel = 1, eigen(jind, igamma)%Nlevels
!
energy = eigen(jind, igamma)%val(ilevel)
!
intensity%zpe = min(intensity%zpe, energy)
!
enddo
!
enddo
enddo
!
if (iverbose >= 4) &
write (out,"(/'Partition function = ',f18.4,' T = ',f12.2)") intensity%part_func,intensity%temperature
!
endif
!
select case (trim(intensity%action))
!
case('ABSORPTION', 'EMISSION', 'TM')
!
call Sort_levels(iverbose, nJ, Jval(1:nJ))
!
! run intensity simulations
!
beta = planck * vellgt / (boltz * intensity%temperature)
!
! compute partition function if not given
if (intensity%part_func < small_) then
!
intensity%part_func = 0
!
do jind = 1, nJ
!
Jval_ = Jval(jind)
!
do igamma = 1, sym%NrepresCs
!
do ilevel = 1, eigen(jind, igamma)%Nlevels
!
energy = eigen(jind, igamma)%val(ilevel)
irrep = eigen(jind, igamma)%quanta(ilevel)%igamma
!
! for homonuclear symmetries Nrepres = 4 and the irrep can be reconstucted baed on the parity and g/u:
istate = eigen(jind,igamma)%quanta(ilevel)%istate
parity_gu = poten(istate)%parity%gu
isym = correlate_to_Cs(igamma,parity_gu)
!
exp_en = exp(-(energy - intensity%ZPE) * beta)
!
intensity%part_func = intensity%part_func + intensity%gns(isym)*(2.0_rk*Jval_+1.0_rk) * exp_en
!
enddo
!
enddo
!
enddo
!
if (iverbose >= 4) write(out, "(/'Partition function = ', f18.4,'T = ', f12.2)") &
intensity%part_func, intensity%temperature
endif
!
call pol_intensity(Jval, iverbose)
!
write(out, '(/a)') 'done'
!
! compute parition function
case('PARTFUNC')
!
write(out, '(/a)') 'compute parition function'
!
beta = planck * vellgt / (boltz * intensity%temperature)
!
q_part = 0
!
! loop over J values
do jind = 1, nJ
!
Jval_ = Jval(jind)
!
do igamma = 1, sym%NrepresCs
!
do ilevel = 1, eigen(jind, igamma)%Nlevels
!
energy = eigen(jind, igamma)%val(ilevel)
irrep = eigen(jind, igamma)%quanta(ilevel)%igamma
!
! for homonuclear, symmetries Nrepres = 4, and the irrep can be
! reconstructed based on the parity and g/u:
istate = eigen(jind, igamma)%quanta(ilevel)%istate
parity_gu = poten(istate)%parity%gu
isym = correlate_to_Cs(igamma, parity_gu)
!
exp_en = exp(-(energy - intensity%ZPE) * beta)
!
q_part(irrep, jind) = q_part(irrep, jind)&
+ intensity%gns(isym)*(2.0_rk*Jval_+1.0_rk) * exp_en
!
enddo
!
enddo
enddo
!
part = sum(q_part(:,:))
!
do jind = 1, nJ
do irrep = 1, sym%NrepresCs
write(out, '(i4,1x,f18.1,1x,es16.8)') &
irrep, Jval(jind), q_part(irrep, jind)
enddo
enddo
!
write(out, '(es16.8)') part
!
end select
!
call MemoryReport
!
call TimerReport
!
end subroutine pol_tranint
!
!
!
function cg(j0, k0, dj, dk)
!
! Returns values for some Clebsch-Gordan coefficients
!
! Inputs:
! j0, k0 are j" and k" (initial state)
! dj, dk such that j0 + dj and k0 + dk are j' and k' (final state)
! Returns:
! cg = <j0 k0, 1 dk| j0 + dj j0 + dk>
!
integer(ik), intent(in) :: j0, k0, dj, dk
real(rk) :: cg
real(rk) :: j, m
j = real(j0, kind = rk)
m = real(k0 + dk, kind = rk)
cg = 0.0_rk
if (dj == 0 .and. dk == 0) cg = m / sqrt(j * (j + 1.0_rk))
if (dj == 0 .and. dk == 1) cg = -sqrt((j + m) * (j - m + 1.0_rk) / (2.0_rk * j * (j + 1.0_rk)))
if (dj == 0 .and. dk == -1) cg = sqrt((j - m) * (j + m + 1.0_rk) / (2.0_rk * j * (j + 1.0_rk)))
if (dj == 1 .and. dk == 0) cg = sqrt((j - m + 1.0_rk) * (j + m + 1.0_rk) / ((2.0_rk * j + 1.0_rk) * (j + 1.0_rk)))
if (dj == 1 .and. dk == 1) cg = sqrt((j + m) * (j + m + 1.0_rk) / ((2.0_rk * j + 1.0_rk) * (2.0_rk * j + 2.0_rk)))
if (dj == 1 .and. dk == -1) cg = sqrt((j - m) * (j - m + 1.0_rk) / ((2.0_rk * j + 1.0_rk) * (2.0_rk * j + 2.0_rk)))
if (dj == -1 .and. dk == 0) cg =-sqrt((j - m) * (j + m) / (j * (2.0_rk * j + 1.0_rk)))
if (dj == -1 .and. dk == 1) cg = sqrt((j - m) * (j - m + 1.0_rk) / (2.0_rk * j * (2.0_rk * j + 1.0_rk)))
if (dj == -1 .and. dk == -1) cg = sqrt((j + m + 1.0_rk) * (j + m) / (2.0_rk * j * (2.0_rk * j + 1.0_rk)))
return
end function cg
!
!
!
subroutine pol_intensity(Jval, iverbose)
! Calculates the polarisability transition moments and intensities
!
implicit none
!
real(rk),intent(in) :: Jval(:)
integer(ik),intent(in) :: iverbose
!
integer(ik) :: nJ, dimenmax
integer(ik) :: ilevelI, ilevelF
integer(ik) :: nlevelsG(sym%Nrepresen)
integer(ik) :: info, indI, indF, itransit, Ntransit, Nrepresen
integer(ik) :: igammaI, igammaF
integer(ik) :: dimenI, dimenF, nmax, parity_gu, isymI, isymF
real(rk) :: energyI, energyF, nu_if, linestr, linestr_zero, &
ener_, linestr2, linestr2_zero
real(rk) :: tm, jI, jF, ddot
logical :: passed, passed_
!
real(rk), allocatable :: vecI(:), vecF(:)
real(rk), allocatable :: half_linestr(:), half_linestr_zero(:)
!
integer(ik) :: jind, nlevels
!
integer(ik) :: iroot, NlevelsI, NlevelsF, nlower,iLF, iflag_rich
!
integer(ik) :: igamma_pair(sym%Nrepresen), igamma, istateI, istateF,&
ivibI, ivibF, ivI, ivF, ilambdaI, ilambdaF, iparityI, itau
real(rk) :: spinI, spinF, omegaI, omegaF, sigmaI, sigmaF
integer(hik) :: matsize
!
character(len=1) :: branch, ef, pm
character(len=2) :: dir
character(len=10) :: statename
!
type(quantaT),pointer :: quantaI, quantaF
!
real(rk) :: boltz_fc, beta, intens_cm_mol, emcoef,&
A_coef_s_1, A_einst, absorption_int
!
character(len=130) :: my_fmt !format for I/O specification
!
integer :: ndecimals
integer(ik) :: enunit, transunit
character(len=cl) :: filename, ioname
!
logical :: integer_spin = .true.
!
integer(ik) :: alloc_p
!
integer(ik) :: Jmax_, ID_J
real(rk) :: J_
!
character(len=12) :: char_Jf,char_Ji,char_LF
integer(ik), allocatable :: richunit(:,:)
character(len=2) :: let_LF ! richmol letters x,y,z
!
call TimerStart('Intensity calculations')
!
if (sym%maxdegen > 2) then
!
write(out, "('pol_intensity: this procedure has not been tested for symmetries with degeneracy higher than 2')")
!
endif
!
Nrepresen = sym%NrepresCs
!
! constants that will be needed
beta = planck * vellgt / (boltz * intensity%temperature)
intens_cm_mol = 8.0d-36 * pi**3 / (3.0_rk * planck * vellgt)
emcoef = planck*vellgt / (4.0_rk*pi)
A_coef_s_1 = 64.0d-36 * pi**4 / (3.0_rk * planck)
!
nJ = size(Jval)
!
! open units for the line list in the Exomol format
! the next section establishes the files to which the line intensities
! and energies will be written
if (trim(intensity%linelist_file)/="NONE") then
!
! open the '.states' file, which contains the energy levels themselves
filename = trim(intensity%linelist_file)//'.states'
write(ioname, '(a, i4)') 'Energy file' ! heading
call IOstart(trim(ioname), enunit)
open(unit = enunit, action = 'write', &
status = 'replace', file = filename)
!
! open the '.tans' file, which contains the positions and A coeffs.
! of the spectral lines
filename = trim(intensity%linelist_file)//'.trans'
write(ioname, '(a, i4)') 'Transition file' ! heading
call IOstart(trim(ioname), transunit)
open(unit = transunit, action = 'write', &
status = 'replace', file = filename)
!
if (intensity%matelem) then
!
Jmax_ = nint(maxval(Jval(:)))
!
allocate(richunit(nJ, nJ)) ! used to mrk I/O unit
!
! we now begin writing the matrix elements to the file
do indI = 1, nJ
!
jI = Jval(indI)
!
write(char_jI, '(i12)') nint(jI)
!
do indF = 1, nJ
!
jF = Jval(indF)
!
if (Jf<Ji) cycle
!
! selection rules for SECOND rank spherical component
if(nint(abs(jI - jF)) > 2) cycle
!
write(char_jF, '(i12)') nint(jF)
!
! New Richmol format - one file for all components
!
! open the file for the matrix elements of the i-th lab component
filename = &
"matelem_ALPHA"//"_j"//trim(adjustl(char_jI))//"_j"//trim(adjustl(char_jF))//"_"//trim(intensity%linelist_file)//".rchm"
!
call IOstart(trim(filename), richunit(indI, indF))
open(unit = richunit(indI, indF), action = 'write', &
status='replace', file=filename)
!
write(richunit(indI, indF), "('Start richmol format')")
!
! 2nd rank tensor, with 6 non-zero components
write(richunit(indI, indF), "('ALPHA',' 2',' 6')")
write(richunit(indI, indF), "('M-tensor')")
!
! Nine lab-frame polarisability tensor components
do iLF = 1,6
!
let_LF = "xx"
if (iLF == 2) let_LF = "xy"
if (iLF == 3) let_LF = "xz"
if (iLF == 4) let_LF = "yy"
if (iLF == 5) let_LF = "yz"
if (iLF == 6) let_LF = "zz"
if (iLF == 7) let_LF = "yx"
if (iLF == 8) let_LF = "zx"
if (iLF == 9) let_LF = "zy"
!
! flag is -1 when sum over alpha^k_m has prefactor of i
iflag_rich = 0
!if (iLF == 2 .or. iLF == 5) iflag_rich = -1
if (iLF == 2 .or. iLF == 5 .or. iLF == 7 .or. iLF == 9) iflag_rich = -1
!
write(char_LF, '(i12)') iLF
!
write(richunit(indI, indF), "('alpha',i5,i3,1x,a2)") &
iLF, iflag_rich, let_LF
!
! call subroutine to calculate LF portion of matrix elements
call do_LF_matrix_elements(iLF, richunit(indI, indF), jI, jF)
enddo
!
write(richunit(indI, indF), "('K-tensor')")
!
enddo
enddo
endif
!
endif
!
! maximal size of basis functions
!
dimenmax = 0
!
! loop over J values
!
do jind = 1, nJ
do igamma = 1, Nrepresen
!
! Estimate the maximal size of basis functions
dimenmax = max(dimenmax, eigen(jind, igamma)%Ndimen)
!
enddo
enddo
!
Nmax = nint(Jval(nJ)) + 1
!
! We now count the number of non-zero transitions, this will help keep
! keep track of the calculation process.
!
Ntransit = 0
!
! number of inital states
nlevels = Neigenlevels
!
! For a given symmetry (igamma) with some gns(igamma), we find it's
! counterpart jgamma /= igamma having the same gns(jgamma). We assume
! that there is only one such pair in the case of absorption or emission
!
call find_igamma_pair(igamma_pair)
!
call TimerStart('Intens_Filter-1')
!
ener_ = 0
nlower = 0
iroot = 0
!
! loop over initial states
do indI = 1, nJ
!
! rotational quantum number
jI = Jval(indI)
!
! loop for each symmetry
do igammaI = 1, Nrepresen
!
nlevelsI = eigen(indI, igammaI)%Nlevels
!
! loop over energy levels in initial J state
do ilevelI = 1, nlevelsI
!
! energy and quanta of initial state
energyI = eigen(indI, igammaI)%val(ilevelI)
istateI = eigen(indI, igammaI)%quanta(ilevelI)%istate
parity_gu = poten(istateI)%parity%gu
isymI = correlate_to_Cs(igammaI, parity_gu)
!
call energy_filter_lower(jI, energyI, passed)
!
if (.not. passed) cycle
!
nlower = nlower + 1
!
! loop over final states
do indF = 1, nJ
!
jF = jval(indF)
!
do igammaF = 1, Nrepresen
!
nlevelsF = eigen(indF, igammaF)%Nlevels
!
! loop over energy levels in final J state
do ilevelF = 1, nlevelsF
!
! energy and quanta of final state
energyF = eigen(indF, igammaF)%val(ilevelF)
istateF = eigen(indF, igammaF)%quanta(ilevelF)%istate
parity_gu = poten(istateF)%parity%gu
isymF = correlate_to_Cs(igammaF, parity_gu)
!
call intens_filter(jI, jF, energyI, energyF, isymI, &
isymF, igamma_pair, passed)
!
if (intensity%matelem) call matelem_filter(jI, jF, energyI,&
energyF, isymI, isymF, igamma_pair, passed)
!
! if transition is non-zero then increment counter
if (passed) then
!
Ntransit = Ntransit + 1
!
endif
enddo
enddo
enddo
enddo
enddo
enddo ! end of transition counting
!
call TimerStop('Intens_Filter-1')
!
! loop over final states -> count states for each symmetry
!
nlevelsG = 0
!
! guess if half-integer spin case
if (mod(eigen(1, 1)%quanta(1)%imulti, 2) == 0) integer_spin = .false.
!
allocate(vecI(dimenmax), stat = info)
call ArrayStart('intensity-vecI', info, size(vecI), kind(vecI))
!
do indI = 1, nJ
!
! rotational quantum number
jI = jval(indI)
J_ = -1 ! for Richmol count
!
do igammaI = 1, Nrepresen
!
nlevelsI = eigen(indI, igammaI)%Nlevels
dimenI = eigen(indI, igammaI)%Ndimen
!
do ilevelI = 1, nlevelsI
!
! energy and symmetry of the state
energyI = eigen(indI, igammaI)%val(ilevelI)
!
istateI = eigen(indI, igammaI)%quanta(ilevelI)%istate
parity_gu = poten(istateI)%parity%gu
! C2v/Cs symmetry
isymI = correlate_to_Cs(igammaI, parity_gu)
!
! ignore states with zero nuclear weight
if (intensity%gns(isymI) < small_) cycle
!
iroot = iroot + 1
eigen(indI, igammaI)%quanta(ilevelI)%iroot = iroot
!
if (trim(intensity%linelist_file) /= "NONE") then
!
! dimension of the basis for initial states
!
! energy, quanta, and degeneracy order of the initial state
quantaI => eigen(indI, igammaI)%quanta(ilevelI)
ivibI = quantaI%ivib
ivI = quantaI%v
sigmaI = quantaI%sigma
spinI = quantaI%spin
ilambdaI = quantaI%ilambda
omegaI = quantaI%omega
iparityI = quantaI%iparity
statename = trim(quantaI%name)
!
! reconstruct +/- and e/f parities
pm = "+" ; if (iparityI == 1) pm = "-"
ef = "e"
!
if (mod(nint(2.0 * jI), 2) == 1) then
itau = mod(nint(jI - 0.5), 2)
else
itau = mod(nint(jI), 2)
endif
!
if (itau /= iparityI) then
ef = "f"
endif
!
! the variable 'ndecimals' gives the number of decimal digits to
! print the values of the energy levels to.
! we use 6 decimals for energy levels up to 100,000 cm-1 before
! sacrificing decimals to fit larger values in 12 spaces.
! this format works for energy levels larger than -10,000 cm-1 and
! less than 1e11 cm-1 - Lorenzo Lodi
!
ndecimals = 6 - max(0, int(log10(abs(energyI - intensity%ZPE) + 1.d-6) - 4))
!
if ( intensity%matelem ) then
!
ndecimals=6-max(0, int( log10(abs(energyI-intensity%ZPE)+1.d-6)-4) )
!
if (nint(2*Ji)/=nint(2*J_)) then
!
J_ = Ji
ID_J = 0
!
endif
!
ID_J = ID_J + 1
quantaI%iJ_ID = ID_J
!
if (integer_spin) then
!
write(my_fmt,'(a)') "(i6,1x,i8,1x,i2,1x,i2,3x,e21.14,5x,a4,i3,1x,a2,i4,1x,a2,f8.4,1x,i6,1x,i6,1x,i4,1x,i6,1x,a1,1x,a10)"
write(enunit,my_fmt) &
nint(J_),ID_J,iparityI+1,1,energyI-intensity%ZPE,'tau:',iparityI,'j:',nint(J_),'c',1.000_rk,nint((omegaI)),&
ivI,(ilambdaI),nint((sigmaI)),pm,statename
!
else
!
!stop 'not tested'
!
write(my_fmt,'(A,i0,a)') "(i7,1x,i12,1x,i1,1x,i2,1x,f12.",ndecimals,",1x,f7.1,1x,i6,1x,i4,1x,f7.1,1x,a1,1x,a10)"
write(enunit,my_fmt) &
int(J_),ID_J,iparityI+1,1,energyI-intensity%ZPE,omegaI,&
ivI,(ilambdaI),sigmaI,pm,statename
!
endif
!
else
!
ndecimals=6-max(0, int( log10(abs(energyI-intensity%ZPE)+1.d-6)-4) )
if (integer_spin) then
!
write(my_fmt,'(A,i0,a)') "(i12,1x,f12.",ndecimals,",1x,i6,1x,i7,1x,a1,1x,a1,1x,a10,1x,i3,1x,i2,2i8)"
write(enunit,my_fmt) &
iroot,energyI-intensity%ZPE,nint(intensity%gns(isymI)*( 2.0_rk*jI + 1.0_rk )),nint(jI),&
pm,ef,statename,ivI,(ilambdaI),nint((sigmaI)),nint((omegaI))
!
else
!
write(my_fmt,'(A,i0,a)') "(i12,1x,f12.",ndecimals,",1x,i6,1x,f7.1,1x,a1,1x,a1,1x,a10,1x,i3,1x,i2,2f8.1)"
write(enunit,my_fmt) &
iroot,energyI-intensity%ZPE,nint(intensity%gns(isymI)*( 2.0_rk*jI + 1.0_rk )),jI,&
pm,ef,statename,ivI,(ilambdaI),(sigmaI),(omegaI)
!
endif
!
endif
!
endif
!
call energy_filter_upper(jI, energyI, passed)
!
call energy_filter_lower(jI, energyI, passed_)
!
if (.not. passed .and. .not. passed_) cycle
!
istateI = eigen(indI, igammaI)%quanta(ilevelI)%istate
parity_gu = poten(istateI)%parity%gu
isymI = correlate_to_Cs(igammaI, parity_gu)
!
nlevelsG(isymI) = nlevelsG(isymI) + 1
!
enddo
enddo
enddo
!
deallocate(vecI)
call ArrayStop('intensity-vecI')
!
if (trim(intensity%linelist_file) /= "NONE") close(enunit, status='keep')
!
write(my_fmt,'(A,I0,A)') &
"('Number of states for each symm = ',", sym%Nrepresen, "i8)"
!
write(out,my_fmt) nlevelsG(:)
!
matsize = int(sum(nlevelsG(:)), hik)
!
if (iverbose >= 4) write(out,"(/'Dipole moment integration (i)...')")
!
if (Ntransit == 0) then
write(out,"('pol_intensity: the transition filters are too tight: no entry')")
!
stop 'pol_intensity: the filters are too tight'
endif
!
write(out, "(/'...done!')")
!
allocate(vecI(dimenmax), vecF(dimenmax), stat=info)
!
call ArrayStart('intensity-vectors', info, size(vecI), kind(vecI))
call ArrayStart('intensity-vectors', info, size(vecF), kind(vecF))
!
! loop over final states -> count states for each symmetry
!
write(my_fmt,'(A,I0,A)') &
"('Number of states for each symm = ',", sym%Nrepresen, "i8)"
!
write(out,my_fmt) nlevelsG(:)
!
if (iverbose >= 0) then
write(out, "(' Total number of lower states = ',i8)") nlower
write(out, "(' Total number of transitions = ',i8)") Ntransit
end if
!
if (iverbose >= 0) then
write(out, "(/' Statistical weights gns = ',4f12.1)") intensity%gns(1:)
end if
!
! To speed up the line strength evaluation, we perform the calculation:
! S_{if} = | <i|a|f> |^2 = | \sum_{nm} C_in C_fm <n|a|m> |^2
! in three steps:
! 1. Evaluate the expansion of the initial state:
! s_{im} = sum_{n} C_in <n|a|m>
! 2. Evaluate the product with the expansion of the final state:
! s_{if} = sum_{m} C_fm s_{im}
! 3. Square the result to obtain S_{if}
! S_{if} = s_{if}^2
!
! The temporary object s_{im} is referred to as the 'half linestrength',
! with corresponding variable "half_linestr".
!
allocate(half_linestr(dimenmax), stat = info)
allocate(half_linestr_zero(dimenmax), stat = info)
!
call ArrayStart('half_linestr', info, size(half_linestr), &
kind(half_linestr))
!
if (iverbose >= 5) call MemoryReport
!
write(out,"(/a,a,a,a)") &
'Linestrength S(f<-i) [Debye**2],', ' Transition moments [Debye],', &
' Einstein coefficient A(if) [1/s],', ' and Intensities [cm/mol]'
!
! Prepare the table header
!
select case (trim(intensity%action))
!
case('ABSORPTION')
!
write(out, &
"(/t5,'J',t7,'Gamma <-',t18,'J',t21,'Gamma',t27,'Typ',t37,'Ei',&
&t44,'<-',t52,'Ef',t64,'nu_if',8x,'S(f<-i)',10x,'A(if)',12x,&
&'I(f<-i)',7x,'State v lambda sigma omega <- State v lambda&
& sigma omega ')")
!
dir = '<-'
!
case('EMISSION')
!
write(out, &
"(/t5,'J',t7,'Gamma ->',t18,'J',t21,'Gamma',t27,'Typ',t37,'Ei',&
&t44,'->',t52,'Ef',t64,'nu_if',8x,'S(i->f)',10x,'A(if)',12x,&
&'I(i->f)',7x,'State v lambda sigma omega -> State v lambda&
& sigma omega ')")
!
dir = '->'
!
case('TM')
!
write(out,"(/t4,'J',t6,'Gamma <-',t17,'J',t19,'Gamma',t25,'Typ',t35,'Ei',&
&t42,'<-',t52,'Ef',t65,'nu_if',10x,'TM(f->i)')")
!
!
end select
!
deallocate(vecF)
!
! ---------------------------------
! The actual intensity calculations
! ---------------------------------
!
itransit = 0
!
! loop over initial states
do indI = 1, nJ
!
jI = jval(indI)
!
! loop over initial state symmetries
do igammaI = 1, Nrepresen
!
! number of sublevels and dimension of basis for initial state
nlevelsI = eigen(indI, igammaI)%Nlevels
dimenI = eigen(indI, igammaI)%Ndimen
!
! loop over final states
do indF = 1, nJ
!
jF = jval(indF)
!
! selection rules for irreducible second & zeroth rank
! spherical polarisability tensor components
if (abs(nint(jI - jF)) > 2 ) cycle
!
! loop over final state symmetries
do igammaF = 1, Nrepresen
!
! number of sublevels and dimension of basis for final state
nlevelsF = eigen(indF, igammaF)%Nlevels
dimenF = eigen(indF, igammaF)%Ndimen
!
Ilevels_loop : do ilevelI = 1, nlevelsI
!
! energy, quanta and degeneracy of the initial state
energyI = eigen(indI, igammaI)%val(ilevelI)
!
quantaI => eigen(indI, igammaI)%quanta(ilevelI)
istateI = quantaI%istate
ivibI = quantaI%ivib
ivI = quantaI%v
sigmaI = quantaI%sigma
spinI = quantaI%spin
ilambdaI = quantaI%ilambda
omegaI = quantaI%omega
!
! reconstruct symmetry for C2v which is different to Cs case
parity_gu = poten(istateI)%parity%gu
isymI = correlate_to_Cs(igammaI, parity_gu)
!
call energy_filter_lower(jI, energyI, passed)
!
if (.not. passed) cycle
!
vecI(1:dimenI) = eigen(indI, igammaI)%vect(1:dimenI, ilevelI)
!
! Compute the half-linestrength
!
! if no transitions from ilevelI -> jF exist then skip
! calculation, so we check for this condition
passed = .false.
!
! loop over final states
do ilevelF = 1, nlevelsF
!
! energy and quanta of final state
energyF = eigen(indF,igammaF)%val(ilevelF)
!
quantaF => eigen(indF,igammaF)%quanta(ilevelF)
istateF = quantaF%istate
ivibF = quantaF%ivib
ivF = quantaF%v
sigmaF = quantaF%sigma
spinF = quantaF%spin
ilambdaF = quantaF%ilambda
omegaF = quantaF%omega
!
! reconstruct symmetry for C2v which is different to Cs case
parity_gu = poten(istateF)%parity%gu
isymF = correlate_to_Cs(igammaF, parity_gu)
!
call intens_filter(jI, jF, energyI, energyF, isymI, isymF, &
igamma_pair, passed)
!
! prevents diagonal matrix elements from being skipped
if (intensity%matelem) &
call matelem_filter(jI, jF, energyI, energyF, isymI, isymF,&
igamma_pair,passed)
!
! stop checking when a transition passed the filter
if (passed) exit
!
enddo
!
! if no transition pass the filter, cycle to next state
if (.not. passed) cycle
!
select case (trim(intensity%action))
!
case('ABSORPTION', 'EMISSION')
!
if (isymF /= igamma_pair(isymI)) cycle
!
if ((intensity%J(1) + intensity%J(2) > 0) &
.and. abs(nint(jI - jF)) <= 2 ) then
!
call do_1st_half_linestrength(jI, jF, indI, indF, dimenI, &
dimenF, vecI(1:dimenI), &
half_linestr, &
half_linestr_zero)
!
endif
!
case('TM')
!
call do_1st_half_tm(indI, indF, dimenI, dimenF, &
vecI(1:dimenI), half_linestr)
!
end select
!
! loop over final states
allocate(vecF(dimenmax), stat = alloc_p)
!
if (alloc_p /= 0) then
write(out, &
"(' dipole: ',i9,' trying to allocate array -vecF')") &
alloc_p
!
stop 'dipole-vecF - out of memory'
!
end if
!
Flevels_loop : do ilevelF = 1, nlevelsF
!
! energy and quanta of final state
energyF = eigen(indF, igammaF)%val(ilevelF)
!
! dimension of bases for final state
dimenF = eigen(indF, igammaF)%Ndimen
!
quantaF => eigen(indF, igammaF)%quanta(ilevelF)
!
istateF = quantaF%istate
ivibF = quantaF%ivib
ivF = quantaF%v
sigmaF = quantaF%sigma
spinF = quantaF%spin
ilambdaF = quantaF%ilambda
omegaF = quantaF%omega
!
call energy_filter_upper(jF, energyF, passed)
!
if (.not.passed) cycle Flevels_loop
!
parity_gu = poten(istateF)%parity%gu
isymF = correlate_to_Cs(igammaF, parity_gu)
!
call intens_filter(jI, jF, energyI, energyF, isymI, isymF,&
igamma_pair, passed)
!
if (intensity%matelem) &
call matelem_filter(jI, jF, energyI, energyF, isymI, &
isymF, igamma_pair, passed)
!
if (.not. passed) cycle Flevels_loop
!
! Find PQR branch for transition
branch = PQR_branch(jI, jF)
!
nu_if = energyF - energyI
!
! filer out zero-frequency transitions
if (nu_if < small_) cycle
!
! Count processed transitions
itransit = itransit + 1
!
vecF(1:dimenF) = eigen(indF, igammaF)%vect(1:dimenF, ilevelF)
!
select case (trim(intensity%action))
!
case default
!
stop 'only ABSORPTION and TM are properly coded'
!
case('ABSORPTION', 'EMISSION')
!
linestr = ddot(dimenF, half_linestr, 1, vecF, 1)
linestr_zero = ddot(dimenF, half_linestr_zero, 1, vecF, 1)
!
linestr2 = linestr**2
linestr2_zero = linestr_zero**2
!
!
! calculate intensity
A_einst = A_coef_s_1 * (2.0_rk * jI + 1.0_rk) &
* linestr2 * abs(nu_if)**3