forked from GAmfe/genray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemission_spectrum.f
2285 lines (1913 loc) · 73.6 KB
/
emission_spectrum.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
c calculate the spectrum of the emission flux
c
subroutine emission_spectrum(ifreq,iray_start_point,
&nrayelt_o_cutoff_emis)
c---------------------------------------------------------------------
c calculate the energy spectrum of the emission
c---------------------------------------------------------------------
implicit none
include 'param.i'
include 'one.i'
include 'writencdf.i'
include 'emissa.i'
include 'write.i'
include 'ions.i'
include 'oxb.i' ! gives nrayelt_o_cutoff
c-----input
integer ifreq,
& nrayelt_o_cutoff_emis !the OX cutoff point at the ray
integer iray_start_point !number of ray launching point
!it will put ray trajectories data for central ray only
!at iray_start_point=1,
!for iray_start_point > 1 the rays will not be put in
!netcdf file
c-----output
c-----external
real*8 x,y,tempe,b,gamma1,cn,tpoprho,dense,zeff,vflowrho, zeffi
external x,y,tempe,b,gamma1,cn,tpoprho,dense,zeff,vflowrho, zeffi
c-----local
integer i,j,iray_loc,i_geom_optic_loc,n_elt
integer i_fkin,iabsorp_collisional_l
real*8 z,r,phi,cnz,cnr,cm,xe,ye,T_kev,
&ds,dc,cnt,cnpar,cnper,
&vgrmods,vgroup,
&te,u(6),deru(6),bf(3),vgr(3),
&cnray,
&coll_mult_l,tempe_l,dense_l,zeff_l
cSAP090808 nbulk -> nbulk
c reaL*8 x_ar(nbulka),y_ar(nbulka),
c &t_av_ar(nbulka),tpop_ar(nbulka),vflow_ar(nbulka)
real*8 x_ar(nbulk), y_ar(nbulk),
+ t_av_ar(nbulk), tpop_ar(nbulk), vflow_ar(nbulk)
complex*16 cex,cey,cez,cflown
cSAP090808 jx_kin_a-> jx_kin
c real*8 j_emis_x(jx_kin_a),
real*8 j_emis_x(jx_kin)
real*8 al_emis_loc,j_emis_loc,temp_rad_em_loc
cSAP090808 jx_kin_a -> jx_kin
c real*8 wj_emis_x(nrelta,jx_kin_a),
c &work_j_emis_x_n(jx_kin_a),work_j_emis_x_np1(jx_kin_a),
c &work_in_sn_x_n(jx_kin_a),work_in_0_x_n(jx_kin_a),
c &in_sn_x(nrelta,jx_kin_a), ! emission I_n at the detector side
c ! of nth bin at s=s_n
c &in_0_x(nrelta,jx_kin_a), ! emission at the plasma boundary s=s_1 from one
c ! nth bin s_n<s<s_n+1
c &i_0_x(jx_kin_a), ! emission I_0 at the plasma boundary from the
c ! ray at s=s(1)=0
c &i_0sn_x(nrelta,jx_kin_a) ! sum{k=1,n}[in_0(k)]! emission at the plasma boundary
real*8 work_j_emis_x_n(jx_kin), work_j_emis_x_np1(jx_kin),
&work_in_sn_x_n(jx_kin), work_in_0_x_n(jx_kin),
&i_0_x(jx_kin) ! emission I_0 at the plasma boundary from the
! ray at s=s(1)=0
integer jx_kin_a ! YuP: added for 4 arrays below.
parameter (jx_kin_a=200) ! if jx_kin used instead of jx_kin_a,
! the code overflows (in IVF-10 on PC)
real*8 wj_emis_x(nrelta,jx_kin_a),
&in_sn_x(nrelta,jx_kin_a), ! emission I_n at the detector side
! of nth bin at s=s_n
&in_0_x(nrelta,jx_kin_a), ! emission at the plasma boundary s=s_1 from one
! nth bin s_n<s<s_n+1
&i_0sn_x(nrelta,jx_kin_a) ! sum{k=1,n}[in_0(k)]! emission at the plasma boundary
c---- for testr
real*8 test_i_0
integer iray_loc_
c write(*,*)'emission_spectrum: 1st exec statemnt bombs w viz:ifort'
c write(*,*)'emission_spectrum:i_emission,i_emission_spectrum=',
c + i_emission,i_emission_spectrum,nrayelt_o_cutoff_emis
if (jx_kin_a .lt. jx_kin) then ! Added by YuP
print*,'Need to increase jx_kin_a parameter in emission_spectrum'
print*,'set jx_kin_a equal to jx_kin in subr.emission_spectrum()'
stop
endif
if (i_emission.ne.1) go to 10 !nothing to do
if (i_emission_spectrum.ne.1) go to 10 !nothing to do
c----------------------------------------------------------------------
c create kinetic energy grid: kinetic_energy_kev(jx_kin)
c----------------------------------------------------------------------
cSAP090808 jx_kin_a -> jx_kin,
c call kinetic_energy_grid_spectrum(jx_kin_a,jx_kin,
call kinetic_energy_grid_spectrum(jx_kin,jx_kin,
&max_kin_energy_kev,kinetic_energy_kev)
c write(*,*)'in emission_spectrum.f'
c write(*,*)'jx_kin_a,jx_kin,max_kin_energy_kev',
c &jx_kin,jx_kin,max_kin_energy_kev
c write(*,*)'kinetic_energy_kev',kinetic_energy_kev
c------------------------------------------------------------------------
if ((i_diskf.eq.0).or.(i_diskf.eq.5)) then
c--------usage of the analytical relativistic function and its derivatives
i_fkin=0
else
c--------usage of the mech relativistic function and its derivatives
i_fkin=1
endif
write(*,*)'emission_spectrum i_diskf,i_fkin',i_diskf,i_fkin
if( iray_start_point.eq.1) then
c---------------------------------------------------------------
c central ray data will be saved for writing in netcdf file
c-----------------------------------------------------------------
c nrayelt_emis=nrayelt_emis_nc(ifreq)
iray_loc=1
c write(*,*)'nrayelt_emis',nrayelt_emis
do n_elt=1,nrayelt_emis
write(*,*)' n_elt=', n_elt
c wsn_nc(n_elt,ifreq)=wsn(n_elt) !ray distance
c wr_em_nc(n_elt,ifreq)=wr_em(n_elt) !r
c wz_em_nc(n_elt,ifreq)=wz_em(n_elt) !z
c wphi_em_nc(n_elt,ifreq)=wphi_em(n_elt) !phi
c wal_emis_nc(n_elt,ifreq)=wal_emis(n_elt) !alpha_emis
c wj_emis_nc(n_elt,ifreq)=wj_emis(n_elt) !j_emis
c wnray_nc(n_elt,ifreq)=wnray(n_elt) !n_ray
r=wr_em(n_elt)
z=wz_em(n_elt)
phi=wphi_em(n_elt)
cnz=wcnz_em(n_elt)
cnr=wcnr_em(n_elt)
cm=wcm_em(n_elt)
c---------calculate the data for emission
bmod=b(z,r,phi)
xe=x(z,r,phi,1)
ye=y(z,r,phi,1) !it will be used as negative for electron
T_kev=tempe(z,r,phi,1)
u(1)=z
u(2)=r
u(3)=phi
c nrayelt_emis=nrayelt
c nrayelt_o_cutoff_emis=nrayelt_o_cutoff
u(4)=cnz
u(5)=cnr
u(6)=cm
bf(1)=bz
bf(2)=br
bf(3)=bphi
gam=gamma1(z,r,phi,cnz,cnr,cm)
ds=dsin(gam)
dc=dcos(gam)
cnt=cn(r,cnz,cnr,cm)
cnpar=cnt*dc
cnper=cnt*ds
i_geom_optic_loc=i_geom_optic
i_geom_optic=1 !to get group velocity in deru
c write(*,*)'before rside1'
call rside1(0.d0,u,deru)
c write(*,*)'after rside1'
i_geom_optic=i_geom_optic_loc
vgr(1)=deru(1)
vgr(2)=deru(2)
vgr(3)=r*deru(3)
vgrmods=vgr(1)**2+vgr(2)**2+vgr(3)**2
vgroup=dsqrt(vgrmods) !in clightc
c---------calculate cnray
do i=1,nbulk
x_ar(i)=x(z,r,phi,i)
y_ar(i)=y(z,r,phi,i)
if(i.eq.1) y_ar(1)=-y_ar(1)
te=tempe(z,r,phi,i) ! kev
t_av_ar(i)=te*1000.d0 ! ev
tpop_ar(i)=tpoprho(rho,i)
vflow_ar(i)=vflowrho(rho,i)
enddo
c call rayrind(i_rrind,nbulk,dmas,x_ar,y_ar,
c . t_av_ar,tpop_ar,vflow_ar,cnpar,cnper,cnray)
c write(*,*)'cnray from rayrind ',cnray
cnray=wnray(n_elt)
write(*,*)'cnray from wbray(n_elt) ',cnray
c---------calculate electric field (cex,cey,cez) and flux cflown
c write(*,*)'before elf_emis'
call elf_emis(0.d0,u,deru,cex,cey,cez,cflown)
c write(*,*)'after elf_emis'
c write(*,*)'z,r,phi',z,r,phi
c write(*,*)'cex,cey,cez',cex,cey,cez
c write(*,*)'cflown',cflown,'vgroup',vgroup
c write(*,*)'cnpar,cnper,cnray',cnpar,cnper,cnray
c---------the data for collisional absorption
iabsorp_collisional_l=iabsorp_collisional
coll_mult_l=coll_mult
tempe_l=tempe(z,r,phi,1) ! kev
dense_l=dense(z,r,phi,1)
zeff_l=zeff(z,r,phi)
c if (n_elt.ne.nrayelt_emis) then
c win_sn_nc(n_elt,ifreq)=win_sn(n_elt) !In_sn
c win_0_nc(n_elt,ifreq)=win_0(in_elt) !In_0
c wi_0sn_nc(n_elt,ifreq)=wi_0sn(n_elt) |I_0_sn
c wtaun_em_nc(n_elt,ifreq)=wtaun_em(n_elt)
c endif
c---------calculate emission coefficient
c emission absorptivity al_emis (1/cm)
c emissivity j_emis (erg*sec/cm**3) and
c radiation temperature temprad
c---------the data for collisional absorption
iabsorp_collisional_l=iabsorp_collisional
coll_mult_l=coll_mult
tempe_l=tempe(z,r,phi,1) ! kev
dense_l=dense(z,r,phi,1)
zeff_l=zeff(z,r,phi)
c write(*,*)'before calc_emis_coef_spectrum'
call calc_emis_coef_spectrum(xe,-ye,T_kev,cnpar,cnper,cnray,
+ n_relt_harm1,n_relt_harm2,n_relt_intgr,i_fkin,r,z,
+ phi,
+ cex,cey,cez,cflown,vgroup,frqncy,
+ iabsorp_collisional,coll_mult,tempe_l,dense_l,zeff_l,
+ al_emis_loc,j_emis_loc,temp_rad_em_loc,
+ jx_kin,kinetic_energy_kev,j_emis_x)
c write(*,*)'after calc_emis_coef_spectrum'
do j=1,jx_kin
wj_emis_x_nc(n_elt,j,ifreq)=j_emis_x(j)
enddo
enddo !n_elt
c-------input data for calc_emission_spectrum
do n_elt=1,nrayelt_emis
do j=1,jx_kin
wj_emis_x(n_elt,j)=wj_emis_x_nc(n_elt,j,ifreq)
enddo
enddo
c write(*,*)'before calc_emission_spectrum'
call calc_emission_spectrum(nrelta,wsn,
& wal_emis,wj_emis,
& wnray,win_sn,win_0,wi_0,wi_0sn,wtaun_em,nrayelt_emis,
& transm_ox,nrayelt_o_cutoff_emis,
cSm061215
cSAP090808 jx_kin_a -> jx_kin
c & jx_kin_a,jx_kin,kinetic_energy_kev,
& jx_kin,kinetic_energy_kev,
& wj_emis_x,in_sn_x,in_0_x,i_0_x,i_0sn_x,
& work_j_emis_x_n,work_j_emis_x_np1,
& work_in_sn_x_n,work_in_0_x_n)
c write(*,*)'after calc_emission_spectrum'
c-------write output spectrums to netcdf file for centrum rays
do j=1,jx_kin
do n_elt=1,nrayelt_emis
win_sn_x_nc(n_elt,j,ifreq)=in_sn_x(n_elt,j)
win_0_x_nc(n_elt,j,ifreq) =in_0_x(n_elt,j)
wi_0sn_x_nc(n_elt,j,ifreq) =i_0sn_x(n_elt,j)
enddo !n_elt
wi_0_x_nc(j,ifreq) =i_0_x(j)
enddo !j
c-------test
test_i_0=0.d0
do j=1,jx_kin
test_i_0=test_i_0+i_0_x(j)
enddo
iray_loc_=1
write(*,*)'ifreq,wi_0(iray_loc_,ifreq),test_i_0',
& ifreq,wi_0(iray_loc_,ifreq),test_i_0
endif ! iray_start_point.eq.1
10 continue
return
end
c-----------------------------------------------------------------------------
subroutine calc_emis_coef_spectrum(xe,ye,T_kev,cnpar,
+cnper,cnray,
+n_relt_harm1,n_relt_harm2,n_relt_intgr,i_fkin,r,z,phi,
+cex,cey,cez,cflown,vgroup,frqncy,
+iabsorp_collisional,coll_mult,tempe,dense,zeff,
+al_emis,j_emis,temprad,
+jx_kin,kinetic_energy_kev,j_emis_x)
c---- calcultes the emission absorptivity al_emis (1/cm)
c emissivity j_emis (erg*sec/cm**3) and
c radiation temperature temprad
implicit none
cSm061213
include 'param.i'
c-----input
real*8 xe,ye,T_kev,cnpar,cnper,cnray,z,r,phi
c cnray is the ray refractive index N_ray
integer n_relt_harm1, n_relt_harm2,n_relt_intgr,i_fkin
complex*16 cex,cey,cez
c wave energy flux for the normalized field |E|=1
c cflown=(vectorB*vector_B^*+vector_E*d(omega*tensor_eps_herm)/dw*vector_E)
complex*16 cflown
real*8 frqncy !GhZ
c the data for collisional absorption
integer iabsorp_collisional ! =0 do not calculate collisional absorption
! =1 to calculte collisonal absorption
real*8
& vgroup, !in clight
& coll_mult, !multiplier for coll absorption
& tempe, !electron temperature (keV)
& dense, !electron density (10*13/cm**3
& zeff !plasma charge
cSm061213
integer jx_kin !number of grid points in momentum
real*8 kinetic_energy_kev(jx_kin) ! kinetic energy grid used
c ! for emission spectrum
c-----external
real*8 rrind
c-----output
real*8 al_emis,j_emis,temprad
cSm061213
real*8 j_emis_x(jx_kin) !(erg*sec/sm**3)
c-----local
complex*16 aK(3,3),fluctcur(3,3),ce(3)
real*8
& v_gr_cm_sec, !cm/sec
& omega, !2*pi*f, here f in [HZ]
& omegpedce,omegdce, !omega_pe/omega_ce and omega/omega_ce
& cn, !refructive index
& clight,pi
cSm061213
cSAP090808 jx_kin_a -> jx_kin
c complex*16 aK_x(3,3,jx_kin_a),fluctcur_x(3,3,jx_kin_a)
complex*16, dimension(1:3,1:3,1:jx_kin) :: K_x,fluctcur_x
ctest
integer j
c write(*,*)'calc_emis_coef_spectrum bef emis_tens'
call emis_tens_spectrum(xe,ye,T_kev,cnpar,cnper,
+n_relt_harm1,n_relt_harm2,n_relt_intgr,i_fkin,r,z,phi,
+aK,fluctcur,
cSm051213
+jx_kin,kinetic_energy_kev,fluctcur_x)
ce(1)=cex
ce(2)=cey
ce(3)=cez
clight=2.99792458d10 !cm/sec
v_gr_cm_sec=clight*vgroup !cm/sec
pi=4.d0*datan(1.d0)
omega=2.d0*pi*frqncy*1.d9 !1/esc
c write(*,*)'in calc_emis_coef_spectrum'
call emiss_coef_spectrum(aK,fluctcur,ce,cflown,
+v_gr_cm_sec,omega,cnray,
+iabsorp_collisional,coll_mult,tempe,dense,zeff,
+al_emis,j_emis,
cSm061213
+fluctcur_x,
+jx_kin,kinetic_energy_kev,j_emis_x)
c write(*,*)'after calc_emis_coef_spectrum'
c do j=1,jx_kin
c write(*,*)'j,j_emis_x(j)',j,j_emis_x(j)
c enddo
c-----radiation temperature
if(al_emis.ne.0.d0) then
if(al_emis.gt.1.d-12) then
c----------we choosed this number 1.d-12 to avoid the division
c the small number for the other small number.
temprad=(2.d0*pi)**3*(clight)**2/(omega*cnray)**2
+ *j_emis/al_emis/1.6022d-9
else
temprad=0.d0
endif
c write(*,*)'in calc_emis_coef T_kev,temprad=',T_kev,temprad
else
temprad=0.d0
endif
return
end
subroutine emiss_coef_spectrum(aK,fluctcur,ce,flux,v_group,omega,
+nr,
+iabsorp_collisional,coll_mult,tempe,dense,zeff,
+al_emis,j_emis,
cSm061213
+fluctcur_x,
+jx_kin,kinetic_energy_kev,j_emis_x)
c al_emis (1/cm)
c j_emis (erg*sec/cm**3)
c
c-----calculates the emission coefficient j_emis(erg*sec/cm**3)
c energy spectrum of emission coefficient j_emis_x(erg*sec/cm**3)
c and absorption al_emis (1/cm)
c
c
c see the article
c R.W.Harvey at al., Phys.Fluids B 5(2),Febrary 1993, page 446
c j_emis is the power radiated by the plasma
c per unit volume-radian frequency-steradian,
c
c formula (3)
c j_emis=pi*Nr**2(omega/clight)**2*vectorE^*tensorG*vectorE/S
c
c vector S(omega,k) is the flux energy density per frequency and
c per unit volume of k space,
c
c formula(4)
c S=vectorVgroup*U
c
c vectorVgroup is the wave group velocity
c
c U is the spectral energy density
c
c formula (5)
c U=1/(8*pi)(vectorB^*vectorB+
c +vectorE^*d(omega*eps_hermitian)/domega*vectorE)
c
c al_emis is absorption coefficient, the inverse damping length
c along the ray of rf wave energy
c
c formula (2)
c al_emis=(omega/(4*pi))vectorE^*eps_anti-herm*vectorE/abs(S)
c
c G is the correlation tensor formula(7)
c
c if iabsorp_collisional=1 it will add the collisional absorption
c al_emis_collisional=nu_ei/(Vgroup) (1/cm)
c in the absorption coeficient
c nu_ei is the electron-ion collision frequency
c coll_mult = multiplier for coll absorption expression (default=1.0)
c------------------------------------------------------------------
implicit none
cSm061213
include 'param.i'
c-----input
complex*16
& aK(3,3), ! anti-hermitian relativistic tensor
& fluctcur(3,3), ! correltion tensor G for the fluctuating current(erg)
& ce(3), ! wave (normalized) electric field in Stix frame
c wave energy flux for the normalized field |E|=1
c flux=(vectorB*vector_B^*+vector_E*d(omega*tensor_eps_herm)/dw*vector_E)
& flux ! wave energy flux for the normalized field |E|=1
real*8
& omega, ! wave angle frequency (1/sec) =2*pi*f
& v_group, ! wave group velocity [cm/sec]
& nr ! ray refructive index
integer iabsorp_collisional ! =0 do not calculate collisional absorption
! =1 to calculte collisonal absorption
real*8
& coll_mult, ! multiplier for coll absorption
& tempe, !electron temperature (keV)
& dense, !electron density (10*13/cm**3
& zeff !plasma charge
cSm061213
integer jx_kin !number of kinetic energy grid points
complex*16 fluctcur_x(3,3,jx_kin) !energy spectrum of fluctcur
real*8 kinetic_energy_kev(jx_kin) ! kinetic energy grid used
! for emission spectrum
c-----output
real*8
& al_emis, !(1/sm)
& j_emis, !(erg*sec/sm**3)
cSm061213
& j_emis_x(jx_kin) !(erg*sec/sm**3)
c-----local
complex*16 cec(3),cal_emis,cj_emis
integer i,j,j1
real*8 s,pi,clight,absflux,p,
&arg,cln,r_nu_ei,al_emis_collisional
cSm061213
complex*16, dimension(1:jx_kin) :: cj_emis_x
c-----for test
real*8 test_j_emis
pi=4*datan(1.d0)
clight=2.99792458d10 !cm/sec
c--------------------------------------------------------------
c ce - wave electric field
c cec- comlex conjugate wave electric field
c----------------------------------------------------------
do i=1,3
cec(i)=dconjg(ce(i))
enddo
p=flux*dconjg(flux)
absflux=dsqrt(p)
c write(*,*)'emiss_coeff flux,absflux',flux,absflux
c s is the energy flux density per frequency and per unit volume in k space
s=dabs(v_group*absflux/(8.d0*pi))
s=s*4.d0*pi
c write(*,*)'emiss_coeff v_group,absflux,s',v_group,absflux,s
cal_emis=dcmplx(0.0d00,0.0d00)
cj_emis=dcmplx(0.0d00,0.0d00)
cSm061213
do j1=1,jx_kin
cj_emis_x(j1)=dcmplx(0.0d00,0.0d00)
enddo
c write(*,*)'emiss_coef aK(i,j)',aK(1,1),aK(1,2),aK(1,3)
c write(*,*)aK(2,1),aK(2,2),aK(2,3)
c write(*,*)aK(3,1),aK(3,2),aK(3,3)
c write(*,*)'emiss_coef fluctcur',fluctcur(1,1)*omega,
c +fluctcur(1,2)*omega,fluctcur(1,3)*omega
c write(*,*)fluctcur(2,1)*omega,
c +fluctcur(2,2)*omega,fluctcur(2,3)*omega
c write(*,*)fluctcur(3,1)*omega,
c +fluctcur(3,2)*omega,fluctcur(3,3)*omega
c write(*,*)'emiss_coef ce',ce
do i=1,3
do j=1,3
cal_emis=cal_emis+cec(i)*aK(i,j)*ce(j)
cj_emis =cj_emis +cec(i)*fluctcur(i,j)*ce(j)
cSm061213
do j1=1,jx_kin
cj_emis_x(j1) =cj_emis_x(j1)+
& cec(i)*fluctcur_x(i,j,j1)*ce(j)
enddo
c write(*,*)'emiss_coef i,j',i,j
c write(*,*)'cec(i),ce(j),aK(i,j)',cec(i),ce(j),aK(i,j)
c write(*,*)'cec(i)*aK(i,j)*ce(j)',cec(i)*aK(i,j)*ce(j)
c write(*,*)'fluctcur(i,j)',fluctcur(i,j)
c write(*,*)'cj_emis',cj_emis
enddo
enddo
c write(*,*)'emiss_coef 0 cal_emis',cal_emis
c write(*,*)'emiss_coef 0 cj_emis',cj_emis
cal_emis=cal_emis*omega/(4.d0*pi)/s
cj_emis=cj_emis*pi*(nr*omega/clight)**2/s
cSm061213
do j1=1,jx_kin
cj_emis_x(j1) =cj_emis_x(j1)*pi*(nr*omega/clight)**2/s
enddo
c write(*,*)'omega,s,omega/(4.d0*pi)/s',omega,s,omega/(4.d0*pi)/s
c write(*,*)'nr,clight,pi*(nr*omega/clight)**2/s',
c +nr,clight,pi*(nr*omega/clight)**2/s
c write(*,*)'emiss_coef cal_emis',cal_emis
c write(*,*)'emiss_coef cj_emis',cj_emis
p=cal_emis*dconjg(cal_emis)
al_emis=dsqrt(p)
al_emis=al_emis*4.d0*pi
c write(*,*)'emiss_coeff cal_emis,al_emis',cal_emis,al_emis
p=cj_emis*dconjg(cj_emis)
j_emis=dsqrt(p)*omega
j_emis=j_emis*4.d0*pi
cSm061213
do j1=1,jx_kin
p=cj_emis_x(j1)*dconjg(cj_emis_x(j1))
j_emis_x(j1)=dsqrt(p)*omega
j_emis_x(j1)=j_emis_x(j1)*4.d0*pi
enddo
ctest----------------------------------
c write(*,*)'in emiss_coef_spectrum'
test_j_emis=0.d0
do j1=1,jx_kin
test_j_emis=test_j_emis+j_emis_x(j1)
c write(*,*)'j1,j_emis_x(j1)',j1,j_emis_x(j1)
enddo
c write(*,*)'test_j_emis, j_emis',test_j_emis, j_emis
cend test ---------------------------
c write(*,*)'emiss_coeff nr,cj_emis,j_emis',nr,cj_emis,j_emis
if (iabsorp_collisional.eq.0) then
al_emis_collisional=0.d0
endif
if (iabsorp_collisional.eq.1) then
c-------------------------------------------------------------------------------------
c collisional absorption calculations
c-------------------------------------------------------------------------------------
c--------Coulomb Logarithm = cln
arg=(1.d3/tempe)*dsqrt(10.d0*dense) !tempe KeV,
!dense 10**13/sm**3
cln=24.d0-dlog(arg)
c--------electron-ion collision rate =r_nu_ei [1/sec]
r_nu_ei=dense/(tempe*dsqrt(tempe))*zeff*cln*0.919d3 ![1/sec]
al_emis_collisional=2.d0*r_nu_ei/(v_group)*coll_mult
endif
c write(*,*)'al_emis,al_emis_collisional',
c &al_emis,al_emis_collisional
c-----total absorption
al_emis= al_emis+al_emis_collisional
return
end
subroutine emis_tens_spectrum(X,Y,T_kev,nll_in,np_in,
+n_relt_harm1,n_relt_harm2,n_relt_intgr,
+i_fkin,r,z,phi,
+aK,fluctcur,
cSm051213
+jx_kin,kinetic_energy_kev,fluctcur_x)
c-----calulates the anti-hermitian relativistic dielectric tensor aK
c for electron plasma
c and the correlation tensor fluctcur=G for the fluctuating current density
c
c see the article
c R.W.Harvey at all Phys.Fluids B 5(2),Febrary 1993, page 446
c G is the correlation tensor formula(7)
c aK formula (6)
c
c INPUTS:
c
c X = (fpe/f)**2
c Y = fce/f
c T_kev - electron temperature
c nll_in - parallel index of refraction N.
c np_in - perpendicular refractive index N
c n_relt_harm1 - min number of used cyclotron jn harmonics,
c n_relt_harm2 - max number of used cyclotron jn harmonics,
c n_relt_harm1 <= jn <= n_relt_harm2
c n_relt_intgr - the number of points for the integration over p_perp
c i_fkin =0 the usage of the analytic relativistic distribution
c =1 the usage of the numerical 3D distribution from diskf or netcdfnm.nc
c written be CQL3D code or created analytically at mesh points
c r - the major radius (it is used for i_fkin=1)
c z - the vertical coordinate (it is used for i_fkin=1)
c phi - toroidal angle
c OUTPUT:
c aK(3,3): the nine components of the anti-hermition
c part dielectric relativistic tensor
c evaluated at (X,Y,Te,nll,np_out,n)
c
c fluctcur(3,3) the correlation tensor fluctcur=G (egr)
c for the fluctuating current density
c
c jx_kin !the number of kinetic energy grid points
c kinetic_energy_kev(jx_kin) the kinetic energy grid used
c for emission spectrum
implicit none
cSm061213
include 'param.i'
c input
real*8 X,Y,T_kev,nll_in,np_in
integer n_relt_harm1,n_relt_harm2,n_relt_intgr,i_fkin
real*8 r,z,phi
cSm061213
integer jx_kin
real*8 kinetic_energy_kev(jx_kin)
complex*16 aK(3,3),fluctcur(3,3)
cSm061213
complex*16 fluctcur_x(3,3,jx_kin) !velosity spectrum of fluctcur
c local
real*8 c,mass_e,k_1_kev,nll,np_out,nlls,p_perp0,
&theta,pi,
*dens,xpidens,xpidensmcs,p,psi,rho
complex*16 integral(3,3),fluctcur_n(3,3)
c061213
complex*16, dimension(1:3,1:3,1:jx_kin) :: fluctcur_n_x
integer jn,ires,jn_negative
cSm061213
integer j,k1,k2
c external zeroK, npnllmin, ec_cond, intgr_rl,fdens_fdist
real*8 fdens_fdist,fpsi,rhopsi,densrho
c-----test
complex*16 test_fluctcur(3,3),test_fluctcur_sum(3,3),
&test_fluctcur_n(3,3)
call zeroK(test_fluctcur)
c--------------------------------
c =2.99792458d10 !speed of light (cm/sec)
mass_e=9.1094d-28 !electron rest mass (g)
k_1_kev=1.6022d-9 !egrs in 1 KeV (erg)
theta=mass_e*c**2/(k_1_kev*T_kev)
pi=4.d0*datan(1.d0)
call npnllmin(nll_in,np_in,nll,np_out)
nlls = nll**2
c write(*,*)'in emis_tens_spectrum'
c-----initialization aK=0
call zeroK(aK)
call zeroK(fluctcur)
c for test
call zeroK(test_fluctcur_sum)
cendtet
cSm061213
do k1=1,3
do k2=1,3
do j=1,jx_kin
fluctcur_x(k1,k2,j)=dcmplx(0.d0,0.d0)
enddo
enddo
enddo
c-----the loop over the cyclotron harmonics
do jn=n_relt_harm1,n_relt_harm2
jn_negative=-jn
c-------control the EC resonance condition
cSm060315
c call ec_cond(jn,Y,nll,ires,p_perp0)
call ec_cond(jn_negative,Y,nll,ires,p_perp0)
c write(*,*)'emis_tens_spectrum jn,ires,p_perp0',jn,ires,p_perp0
if(ires.eq.0) then
c---------no resonace
goto 10
endif
call intgr_emis_spectrum(jn_negative,nll,np_out,Y,theta,ires,
+ p_perp0,
+ n_relt_intgr,
+ i_fkin,r,z,phi,
+ integral,fluctcur_n,
cSm061213
+ jx_kin,kinetic_energy_kev,fluctcur_n_x)
c write(*,*)'emis_tens_spectrum after integr_emis integral',
c & integral
c write(*,*)'emis_tens_spectrum after integr_emis fluctcur_n',
c & fluctcur_n
c-------test
c call zeroK(test_fluctcur_n)
c write(*,*)'in emis_tens_spectrum afterintgr_emis_spectrum jn',jn
c do j=1,jx_kin
c do k1=1,3
c do k2=1,3
c test_fluctcur_n(k1,k2)=test_fluctcur_n(k1,k2)+
c & fluctcur_n_x(k1,k2,j)
c enddo
c enddo
c enddo
c do k1=1,3
c do k2=1,3
c write(*,*)'k1,k2',k1,k2
c write(*,*)'fluctcur_n(k1,k2),test_fluctcur_n(k1,k2)',
c & fluctcur_n(k1,k2),test_fluctcur_n(k1,k2)
c enddo
c enddo
c-------end_test
aK(1,1)=aK(1,1)+integral(1,1)
aK(1,2)=aK(1,2)+integral(1,2)
aK(1,3)=aK(1,3)+integral(1,3)
aK(2,2)=aK(2,2)+integral(2,2)
aK(2,3)=aK(2,3)+integral(2,3)
aK(3,3)=aK(3,3)+integral(3,3)
fluctcur(1,1)=fluctcur(1,1)+fluctcur_n(1,1)
fluctcur(1,2)=fluctcur(1,2)+fluctcur_n(1,2)
fluctcur(1,3)=fluctcur(1,3)+fluctcur_n(1,3)
fluctcur(2,2)=fluctcur(2,2)+fluctcur_n(2,2)
fluctcur(2,3)=fluctcur(2,3)+fluctcur_n(2,3)
fluctcur(3,3)=fluctcur(3,3)+fluctcur_n(3,3)
cSm061213
do j=1,jx_kin
fluctcur_x(1,1,j)=fluctcur_x(1,1,j)+fluctcur_n_x(1,1,j)
fluctcur_x(1,2,j)=fluctcur_x(1,2,j)+fluctcur_n_x(1,2,j)
fluctcur_x(1,3,j)=fluctcur_x(1,3,j)+fluctcur_n_x(1,3,j)
fluctcur_x(2,2,j)=fluctcur_x(2,2,j)+fluctcur_n_x(2,2,j)
fluctcur_x(2,3,j)=fluctcur_x(2,3,j)+fluctcur_n_x(2,3,j)
fluctcur_x(3,3,j)=fluctcur_x(3,3,j)+fluctcur_n_x(3,3,j)
enddo
ctest
c call zeroK(test_fluctcur_sum)
c do j=1,jx_kin
c do k1=1,3
c do k2=1,3
c test_fluctcur_sum(k1,k2)=test_fluctcur_sum(k1,k2)+
c & fluctcur_n_x(k1,k2,j)
c test_fluctcur_sum(k1,k2)=test_fluctcur_sum(k1,k2)+
c & fluctcur_x(k1,k2,j)
c enddo
c enddo
c enddo
c do k1=1,3
c do k2=1,3
c write(*,*)'k1,k2,test_fluctcur_sum(k1,k2),fluctcur(k1,k2)'
c & ,k1,k2,test_fluctcur_sum(k1,k2),fluctcur(k1,k2)
c enddo
c enddo
cendtest
10 continue
enddo !jn
ctest
c call zeroK(test_fluctcur)
c do j=1,jx_kin
c do k1=1,3
c do k2=1,3
c test_fluctcur(k1,k2)=test_fluctcur(k1,k2)+
c & fluctcur_n_x(k1,k2,j)
c enddo
c enddo
c enddo
c do k1=1,3
c do k2=1,3
c write(*,*)'k1,k2,test_fluctcur(k1,k2),fluctcur(k1,k2)'
c & ,k1,k2,test_fluctcur(k1,k2),fluctcur(k1,k2)
c enddo
c enddo
cendtest
if (i_fkin.eq.0) then
dens=1.d0
else
dens=fdens_fdist(r,z,phi)
c write(*,*)'fdens_fdis dens',dens
cSm011228 call the density of the bulk plasma to reduce the CPU time
psi=fpsi(r,z)
rho=rhopsi(psi)
dens=densrho(rho,1)
c write(*,*)'emision_tens dens',dens
c dens=1.d0
endif
c-----normalization for the unit electron density
xpidens=X*pi/dens
aK(1,1)=-xpidens*aK(1,1)
aK(1,2)=-xpidens*aK(1,2)
aK(1,3)=-xpidens*aK(1,3)
aK(2,2)=-xpidens*aK(2,2)
aK(2,3)=-xpidens*aK(2,3)
aK(3,3)=-xpidens*aK(3,3)
xpidensmcs=X*pi/(2.d0*pi)**5*(mass_e*c**2)/dens
cSm061213
do j=1,jx_kin
fluctcur_x(1,1,j)=fluctcur_x(1,1,j)*xpidensmcs
fluctcur_x(1,2,j)=fluctcur_x(1,2,j)*xpidensmcs
fluctcur_x(1,3,j)=fluctcur_x(1,3,j)*xpidensmcs
fluctcur_x(2,2,j)=fluctcur_x(2,2,j)*xpidensmcs
fluctcur_x(2,3,j)=fluctcur_x(2,3,j)*xpidensmcs
fluctcur_x(3,3,j)=fluctcur_x(3,3,j)*xpidensmcs
fluctcur_x(2,1,j)=-fluctcur_x(1,2,j)
fluctcur_x(3,1,j)= fluctcur_x(1,3,j)
fluctcur_x(3,2,j)=-fluctcur_x(2,3,j)
enddo
fluctcur(1,1)=fluctcur(1,1)*xpidensmcs
fluctcur(1,2)=fluctcur(1,2)*xpidensmcs
fluctcur(1,3)=fluctcur(1,3)*xpidensmcs
fluctcur(2,2)=fluctcur(2,2)*xpidensmcs
fluctcur(2,3)=fluctcur(2,3)*xpidensmcs
fluctcur(3,3)=fluctcur(3,3)*xpidensmcs
fluctcur(2,1)=-fluctcur(1,2)
fluctcur(3,1)= fluctcur(1,3)
fluctcur(3,2)=-fluctcur(2,3)
c-----test
c do j=1,jx_kin
c do k1=1,3
c do k2=1,3
c test_fluctcur(k1,k2)=test_fluctcur(k1,k2)+
c & fluctcur_x(k1,k2,j)
c enddo
c enddo
c enddo
c write(*,*)'in emis_tens_spectrum'
c do k1=1,3
c do k2=1,3
c write(*,*)'k1,k2,test_fluctcur(k1,k2),fluctcur(k1,k2)',
c & k1,k2,test_fluctcur(k1,k2),fluctcur(k1,k2)
c enddo
c enddo
c-----endtest
return
end
subroutine intgr_emis_spectrum(n,nll,nper,Y,theta,ires,p_perp0,
+n_relt_intgr,
+i_fkin,r,z,phi,
+integral,fluctcur_n,
cSm061213
+ jx_kin,kinetic_energy_kev,fluctcur_n_x)
c-----------------------------------------------------------------
c calculates the matrix: double complex integrals
c for the relativistic electron plasma
c I(n)^=integral(0<=p_perp<=p_perp0)g_n, g_n={sum_k=1,2,G_nk(p_perp)
c fluctcar(n)^=integral(0<=p_perp<=p_perp0)g_fluctcur_n.
c g_fluctcur__n={sum_k=1,2,g_fluctcur_nk(p_perp)
c for the EC harmonic with number 'n'
c-----------------------------------------------------------------
c input
c n - EC harmonic number
c nll - N_parallel
c nper - N_perpendicular
c Y = omega_ce/omega for the electron rest mass
c theta = mc**2/T
c ires =0 no resonance,=1 ellipse,=2 parabola,=3 hyperbole
c n_relt_intgr - the number of points for the integration over p_perp
c p_perp0 - max value of the perpendicular momentum divided by mc
c on the resonanse ellipse
c i_fkin =0 the usage of the analytic relativistic distribution
c =1 the usage of the numerical 3D distribution from diskf
c written be CQL3D code
c r - the major radius (it is used for i_fkin=1)
c z - the vertical coordinate (it is used for i_fkin=1)
c phi - toroidal angle (it is used for i_fkin=1)
c jx_kin the number of the kinetic energy grid points
c kinetic_energy_kev(jx_kin)! kinetic energy grid used
! for emission spectrum
c output
c integral(3,3) double complex integral from G_nk over 0<=p_perp=<p_perpmax
c fluctcur(3,3) double complec integral from fluct_cur_nk over 0<=p_perp=<p_perpmax
c
c fluctcur_n_x(3,3,jx_kin_a) is the velosity spectrum of fluctcur
c----------------------------------------------------------------
c The integration method is specified by the variable