forked from rwharvey/cql3d
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cfpcoefn.f
1480 lines (1373 loc) · 63.3 KB
/
cfpcoefn.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
c
subroutine cfpcoefn
implicit integer (i-n), real*8 (a-h,o-z)
save
ccc real*8,dimension(iy):: prnt1,prnt2,prnt3
ccc real*8,dimension(iy):: prnt4,prnt5,prnt6
c..................................................................
c Subroutine to calculate bounce-averaged Fokker-Planck collision
c coefficients (relativistic corrections added by MARK FRANZ--
c U.S.A.F.)
c If (cqlpmod .eq. "enabled") then compute only the coefficients
c at the orbit position l=l_ and do not perform the bounce-averages.
c..................................................................
include 'param.h'
include 'comm.h'
c
data naccel/100/
ialpha=2
! ialpha=0 !BH180903: Made self-coll ener cons worse than ialpha=2
! ialpha=1 !BH180903: Made self-coll ener cons worse than ialpha=2,0
impcoef=0
if (n.eq.1) then
continue
elseif (mod(n,ncoef).eq.1 .or. ncoef.eq.1) then
continue
else
return
endif
impcoef=1
nccoef=nccoef+1
call bcast(cal(1,1,1,l_),zero,iyjx*ngen)
call bcast(cbl(1,1,1,l_),zero,iyjx*ngen)
call bcast(ccl(1,1,1,l_),zero,iyjx*ngen)
call bcast(cdl(1,1,1,l_),zero,iyjx*ngen)
call bcast(cel(1,1,1,l_),zero,iyjx*ngen)
call bcast(cfl(1,1,1,l_),zero,iyjx*ngen)
call bcast(eal(1,1,1,1,l_),zero,iyjx*ngen*2)
call bcast(ebl(1,1,1,1,l_),zero,iyjx*ngen*2)
c..................................................................
c if only gen. species contributions are desired execute jump..
c..................................................................
if (colmodl.eq.2 ) goto 110
c..................................................................
c if no background species exist execute jump
c..................................................................
if (ntotal.eq.ngen) goto 110
iswwflag=0
do 100 kbm=ngen+1,ntotal ! Maxwellian species:
!k=kbm
c..................................................................
c If this species is not to be included as a field (background)
c species for calculation of the collision integral, jump out.
c..................................................................
if (kfield(kbm).eq."disabled") go to 100
c..................................................................
c Determine the Maxwellian distribution associated with
c background species kbm. This will be a relativistic Maxwellian
c for relativistic calculations.
c..................................................................
temp_loc=temp(kbm,lr_)
if (cqlpmod .eq. "enabled") temp_loc=temppar(kbm,ls_)
!! YuP[08-2017] alternative to the following section: Use table cfpm() instead:
!! See if(cfp_integrals.eq.'enabled') section
if(cfp_integrals.eq.'disabled')then !Original method for integrals (slow)
rstmss=fmass(kbm)*clite2/ergtkev
reltmp=rstmss/temp_loc
if (reltmp .gt. 100. .or. relativ .eq. "disabled") then
ebk2=sqrt(pi/(2.*reltmp))
else if (reltmp .lt. .01) then
ebk2=2.*exp(reltmp)/reltmp**2
else
call cfpmodbe(reltmp,ebk1,ebk2)
endif
rnorm=reltmp/(4.*pi*cnorm3*ebk2)
call bcast(temp1(0,0),zero,iyjx2)
c..................................................................
c Need extra mesh points to represent ions on a mesh meant to
c support electrons. Need more resolution near zero.
c Split each velocity bin into nintg pieces and integrate.
c..................................................................
c990131 nintg0=41.*amax1(1.,sqrt(fmass(kbm)/1.67e-24))
cBH nintg0=41.*max(1.d0,sqrt(fmass(kbm)/1.67e-24))
nintg0=41.*max(1.d0,sqrt(fmass(kbm)/1.67d-24))
c990131 nintg=max0(nintg0,min0(51,int(x(2)/sqrt(.2*cnorm2/reltmp))))
nintg=max(nintg0,min0(51,int(x(2)/sqrt(.2*cnorm2/reltmp))))
nintg=2*(nintg/2)+1
do 10 i=1,nintg
sfac=4.+2.*(2*(i/2)-i)
if (i.eq.1 .or. i.eq.nintg) sfac=1.
sfac=sfac/3.
do 11 j=2,jx
xx=x(j)-(i-1)*dxm5(j)/dfloat(nintg-1)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i) !cnorm2i=0 when relativ(ka).eq."disabled"
!! ! YuP[07-2017] This is not quite correct - cnorm2i is set
!! ! for 'ka' general species, but here we consider 'kbm' Maxw.species.
!! ! Should they be treated as relativistic or not?
!! ! They can be different (relativistically) from 'ka' species.
!! ! There should be a separate setting of relativ() for
!! ! Maxwellian species, too.
gg2=gg**2
if(cnorm2i*xx2-1.d-5 .gt. 0.d0) then
expon=gg-1.
else
expon=.5*xx2/cnorm2
endif
fff=sfac*rnorm*exp(-expon*reltmp)*dxm5(j)/dfloat(nintg-1)
temp1(1,j)=temp1(1,j)+xx*gg*fff
temp1(2,j)=temp1(2,j)+xx*fff
temp1(3,j)=temp1(3,j)+xx2*fff
temp1(4,j)=temp1(4,j)+xx2*fff/gg
temp1(5,j)=temp1(5,j)+(xx2/gg)**2*fff
temp1(6,j)=temp1(6,j)+(xx2/gg2)**2*gg*fff
11 continue
10 continue
c..................................................................
tam2(jx)=0.
tam3(1)=0.
tam5(1)=0.
tam6(jx)=0.
tam7(1)=0.
tam9(1)=0.
c..................................................................
c tam2(jx) and tam6(jx) represent integrals from xmax to infinity
c The following coding performs this integration. In this case 21*xmax
c represents infinity. The lack of this piece is most obvious when
c ions are a general species and electrons are fixed Maxwellians.
c..................................................................
do 15 ll2=1,21
sfac=4.+2.*(2*(ll2/2)-ll2)
if ( ll2.eq.1 .or. ll2.eq.21) sfac=1.
sfac=sfac*x(jx)/60.
do 16 ll1=1,20
xx=(realiota(ll1)+.05*realiota(ll2-1))*x(jx)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i) !cnorm2i=0 when relativ(ka).eq."disabled"
if(cnorm2i*xx2-1.d-5 .gt. 0.d0) then
expon=gg-1.
else
expon=.5*xx2/cnorm2
endif
fff=sfac*rnorm*exp(-expon*reltmp)
tam2(jx)=tam2(jx)+xx*gg*fff
tam6(jx)=tam6(jx)+xx*fff
16 continue
15 continue
do 20 j=2,jx
jj=jx+1-j
jp=jj+1
jm=j-1
c..................................................................
c tam2 - M0; tam3 - N0; tam5 - E0
c tam6 - M0'; tam7 - N0'; tam9 - E0'
c see UCRL manual.
c Eqns. 64-66 of UCRL-96510 by Mark R. Franz
c..................................................................
tam2(jj)=tam2(jp)+temp1(1,jp)
tam3(j)=tam3(jm)+temp1(3,j)
tam5(j)=tam5(jm)+temp1(5,j)
tam6(jj)=tam6(jp)+temp1(2,jp)
tam7(j)=tam7(jm)+temp1(4,j)
tam9(j)=tam9(jm)+temp1(6,j)
20 continue
c..................................................................
do 30 j=2,jx
tam10(j)=cog(0,1)*(3.*tam7(j)+cnorm2i*(2.*xm(j,3)*tam6(j)-
* tam9(j)))*gamsqr(j) ! ~Eq. 61, and cog(0,1)=4*pi/3
tam11(j)=cog(0,1)*(xsq(j)*tam2(j)+
* gamsqr(j)*xm(j,-1)*tam5(j)) ! ~Eq. 62
tam12(j)=cog(0,1)*(tam2(j)+1.5*xm(j,-1)*tam3(j)-
* .5*xm(j,-3)*tam5(j)) ! ~Eq. 63
30 continue
endif ! (cfp_integrals.eq.'disabled')
!YuP[2020-07-16] alternative to the above section. Use table cfpm() instead.
if(cfp_integrals.eq.'enabled')then
! For tam10(1:jx),tam11(1:jx),tam12(1:jx) -
! Instead of the above calculations [cfp_integrals.eq.'disabled']
! use integrals stored in cfpm() array.
kk=kbm-ngen
call cfp_integrals_get(kk,temp_loc) !out: tam10(),tam11(),tam12()
endif ! (cfp_integrals.eq.'enabled')
!YuP[2020-07-16] Done For tam10,11,12
c.......................................................................
c Perform the bounce-average for the background species and introduce
c the contribution to all general species coeff.
c.......................................................................
if (cqlpmod .ne. "enabled") then
call bavdens(kbm)
else
do 59 i=1,iy
bavdn(i,lr_)=denpar(kbm,ls_)
bavpd(i,lr_)=denpar(kbm,ls_)*sinn(i,l_)
59 continue
endif
c Below, eal and ebl are to save contributions to the collisional
c coefficients cal() and cbl(i,j,ka,l_) for general species ka and
c radial location l_, resulting from background electrons
c (eal and ebl of (i,j,ka,1,l_)), and resulting from the sum of the
c effects of the background ions, (eal and ebl of (i,j,ka,2,l_)).
c eal and ebl are used later for calculating powers from the
c general to the Max. species.
do 80 ka=1,ngen !Loop over gen species, adding bkgrnd coeffs
anr1=gama(ka,kbm)*satioz2(kbm,ka)*one_ !ln(Lambda)*(Z_k/Z_kk)**2
anr2=anr1*satiom(ka,kbm) !*mass_kk/mass_k
call bcast(tem1,zero,iyjx)
call bcast(tem2,zero,iyjx)
do 70 j=2,jx
ttta=anr2*tam10(j)*gamefac(j,kbm) !if gamafac="enabled" or "hesslow", then
tttb=anr1*tam11(j)*gamefac(j,kbm) !use gamefac for en dep gama
tttf=anr1*tam12(j)*gamefac(j,kbm) !YuP[2019-07-26] kbm index added
do 60 i=1,iy
jj=i+(j-1)*iy
tem1(jj)=ttta*vptb(i,lr_)*bavdn(i,lr_)
tem2(jj)=tttb*vptb(i,lr_)*bavdn(i,lr_)
cal(i,j,ka,l_)=cal(i,j,ka,l_)+tem1(jj)
cbl(i,j,ka,l_)=cbl(i,j,ka,l_)+tem2(jj)
cfl(i,j,ka,l_)=cfl(i,j,ka,l_)+tttf*vptb(i,lr_)*bavpd(i,lr_)
60 continue
70 continue
ccc do i=1,iy
ccc prnt4(i)=vptb(i,lr_)
ccc prnt5(i)=bavpd(i,lr_)
ccc enddo
if(kbm.eq.kelecm) then
call daxpy(iyjx,one,tem1,1,eal(1,1,ka,1,l_),1)
call daxpy(iyjx,one,tem2,1,ebl(1,1,ka,1,l_),1)
else
do 101 i=1,nionm
if(kbm.eq.kionm(i)) then
call daxpy(iyjx,one,tem1,1,eal(1,1,ka,2,l_),1)
call daxpy(iyjx,one,tem2,1,ebl(1,1,ka,2,l_),1)
cBH180807: Saving individual Maxwl ion components of coll operator
cBH180807: call daxpy(iyjx,one,tem1,1,eal(1,1,ka,kbm+1,l_),1)
cBH180807: call daxpy(iyjx,one,tem2,1,ebl(1,1,ka,kbm+1,l_),1)
cBH180807: Need to increase dimensions of eal,ebl, and calc power transfer
cBH180807: to each genrl species, and put into the .nc output file for
cBH180807: use with radial transport moment codes.
endif
101 continue
endif
80 continue ! ka=1,ngen, line 187
100 continue ! kbm=ngen+1,ntotal, line 49
!------------------------- contribution from partially ionized ions -----
!YuP[2019-07-26]--[2019-09]
if(gamafac.eq."hesslow" .and. kelecg.eq.1)then
!---1---> SCATTERING of free electron on partially screened ions
! These values and gscreen array are set in sub.set_gscreen_hesslow(imp_type):
! fmass_imp ! mass of impurity ion [gram]
! bnumb_imp(kstate) ! Z charge number of each ionization state
!--- Distribution over charge states dens_imp(kstate,lr_) was found in tdchief
! Need to add:
! temp_imp(kstate,lr_) ! T[kev] for each ionization state kstate, at given radial point
! For now, assume all ionization states have same temperature,
! equal to temper. of any Maxwellian ions, so that
kion1=kionm(1)
temp_imp(0:nstates,lr_)=temp(kion1,lr_) !BUT is it ok for kstate=0 (atom)?
!Setup an effective Maxwellian distr. for impurity species,
!find all relevant integrals
rstmss= fmass_imp*clite2/ergtkev
do kstate=0,nstates ! kstate=0 means neutral (atom)
! Note: kstate=0:nstates, with kstate=0 corresponding to a neutral,
! for which bnumb_imp(0)=0;
! and kstate= nstates corresponding to a fully ionized state,
! for which gscreen function (see below) is 0.
temp_loc=temp_imp(kstate,lr_)
!impurity ions - they are cold (non-relativistic)
if(cfp_integrals.eq.'disabled')then
reltmp= rstmss/temp_loc
ebk2=sqrt(pi/(2.*reltmp))
rnorm=reltmp/(4.*pi*cnorm3*ebk2)
call bcast(temp1(0,0),zero,iyjx2)
!Need extra mesh points to represent ions on a mesh meant to
!support electrons. Need more resolution near zero.
!Split each velocity bin into nintg pieces and integrate.
nintg0=41.*max(1.d0,sqrt(fmass_imp/1.67d-24))
nintg=max(nintg0,min0(51,int(x(2)/sqrt(.2*cnorm2/reltmp))))
nintg=2*(nintg/2)+1
do i=1,nintg
sfac=4.+2.*(2*(i/2)-i)
if (i.eq.1 .or. i.eq.nintg) sfac=1.
sfac=sfac/3.
do j=2,jx
xx=x(j)-(i-1)*dxm5(j)/dfloat(nintg-1)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i)
gg2=gg**2
expon=.5*xx2/cnorm2 ! non-relativ. limit
fff=sfac*rnorm*exp(-expon*reltmp)*dxm5(j)/dfloat(nintg-1)
temp1(1,j)=temp1(1,j)+xx*gg*fff
temp1(2,j)=temp1(2,j)+xx*fff
temp1(3,j)=temp1(3,j)+xx2*fff
temp1(4,j)=temp1(4,j)+xx2*fff/gg
temp1(5,j)=temp1(5,j)+(xx2/gg)**2*fff
temp1(6,j)=temp1(6,j)+(xx2/gg2)**2*gg*fff
enddo
enddo
tam2(jx)=0.
tam3(1)=0.
tam5(1)=0.
!tam2(jx) represents integral from xmax to infinity
!The following coding performs this integration. In this case 21*xmax
!represents infinity. The lack of this piece is most obvious when
!ions are a general species and electrons are fixed Maxwellians.
do ll2=1,21
sfac=4.+2.*(2*(ll2/2)-ll2)
if ( ll2.eq.1 .or. ll2.eq.21) sfac=1.
sfac=sfac*x(jx)/60.
do ll1=1,20
xx=(realiota(ll1)+.05*realiota(ll2-1))*x(jx)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i)
expon=.5*xx2/cnorm2 ! non-relativ. limit
fff=sfac*rnorm*exp(-expon*reltmp)
tam2(jx)=tam2(jx)+xx*gg*fff
enddo
enddo
do j=2,jx
jj=jx+1-j
jp=jj+1
jm=j-1
tam2(jj)=tam2(jp)+temp1(1,jp)
tam3(j)= tam3(jm)+temp1(3,j)
tam5(j)= tam5(jm)+temp1(5,j)
enddo
do j=2,jx
tam12(j)=cog(0,1)*(tam2(j)+1.5*xm(j,-1)*tam3(j)-
& 0.5*xm(j,-3)*tam5(j) ) ! ~Eq. 63
enddo
else !if(cfp_integrals.eq.'enabled')then
!YuP[2020-07-16] alternative to the above. Use table cfpm() instead.
! For tam10(1:jx),tam11(1:jx),tam12(1:jx) -
! Instead of the above calculations [cfp_integrals.eq.'disabled']
! use integrals stored in cfpm() array.
ktable=nmax+kstate+1 !so that ktable=(nmax+1):(nmax+nstates+1)
call cfp_integrals_get(ktable,temp_loc) !out:tam10(),tam11(),tam12()
!Here, we only need tam12(j)
endif ! (cfp_integrals.eq.'enabled')
!Perform the bounce-average for the background species and introduce
!the contribution to all general species coeff.
!ka=kelecg ! contribution will be added to cfl(i,j,ka,l_)
Zion2=bnumb_imp(kstate)**2
!Similar to anr1=gama(ka,k)*satioz2(k,ka) !ln(Lambda0)*(Z_k/Z_e)**2
!use anr1= gama(ka,kstate)*Zion2
!i.e.,replace satioz2(i,ka)=(bnumb(i)/bnumb(ka))**2 by bnumb_imp(kstate)**2
!Note: here bnumb(ka)=bnumb(kelecg)=-1
do j=2,jx
! We only need to add contribution for "F" term - scattering
! of electron on ion.
!Consider coulomb_log_ei= gama(ka,kstate)*gamefac(j,kstate)
!Note that for e-on-ions (according to Hesslow; see subr.cfpgamma)
! gama(kelecg,k)*gamefac(j,k) = gama_ei + 0.2*log(1.d0 + p_dep**5)
!where gama_ei=gama(kelecg,kion) = 14.9-0.5*ln(ne20) +ln(T_kev),
!i.e. it does not depend on a particular ion type.
!So, instead of gama(ka,kstate)*gamefac(j,kstate)
!we can use gama(ka,kion)*gamefac(j,kion)
!where kion is kion=kionm(1), for example.
kion1=kionm(1)
coulomb_log_ei= gama(kelecg,kion1)*gamefac(j,kion1)
tttf= tam12(j)*(Zion2*coulomb_log_ei +gscreen(kstate,j))
!Note: for kstate=nstates we have z_state=z_imp (so z_bound=0),
!so that gscreen(nstates,j)=0 for all j.
!But the first term still works, as for a fully-ionized ion:
! Zion2*coulomb_log_ei
do i=1,iy
jj=i+(j-1)*iy
!Find bounce-av. density of this ionization state;
!similar to subr.bavdens, only replace reden(k,lr_)-->dens_imp(kstate,lr_)
bavpd_imp=batot(i,lr_)*sinn(i,lmdpln_)*dens_imp(kstate,lr_)
cfl(i,j,kelecg,l_)= cfl(i,j,kelecg,l_)
& +tttf*vptb(i,lr_)*bavpd_imp
! ka=kelecg here (electron_general)
enddo ! i
enddo ! j
enddo !kstate=0,nstates
!---2---> SLOWING-DOWN of free electron on bound electrons.
! See the slowing down term (Eq. 2.31 in Hesslow, JPP-2018).
! We need to add the second term (SUM_j), because
! the first term (free e on free e) is already added, as usual.
! For the slowing down (drag force)
! the only coll. coefficient that must be changed is A.
! fmass(k) here is for bound electrons.
!Normally, for interaction of free electrons (general species)
!with Maxwellian electrons, we define the distribution function
!of Maxwellian electrons through temp() and reden() values.
!Now, we consider interaction of free electrons with bound electrons.
!We need to add extra term to the A collisional (drag) coefficient.
![For reference: Eq. 61 in UCRL-96510 by Mark R. Franz].
!So what is the temperature of bound electrons?
!It is needed for calculation of integrals below,
!such as M0, N0, E0.
!Should we treat bound electrons as being at T=0?
!For simplicity, we just set them to be at very low T, say 10eV.
temp_e_bound=10.d-3 ! in keV
fmass_e=9.1095d-28 !fmass(kelecg)
rstmss= fmass_e*clite2/ergtkev
!ka=kelecg ! contribution will be added to cal(i,j,ka,l_)
do kstate=0,nstates-1 ! kstate=0 means neutral (atom)
! Note: kstate=0:nstates, with kstate=0 corresponding to a neutral,
! for which bnumb_imp(0)=0;
! and kstate= nstates corresponding to a fully ionized state,
! for which hbethe function is 0 (because z_bound=0).
temp_loc=temp_e_bound
if(cfp_integrals.eq.'disabled')then
reltmp= rstmss/temp_loc
!bound e - they are cold (non-relativistic)
ebk2=sqrt(pi/(2.*reltmp))
rnorm=reltmp/(4.*pi*cnorm3*ebk2)
call bcast(temp1(0,0),zero,iyjx2)
!Need extra mesh points to represent cold e on a mesh meant to
!support general electrons. Need more resolution near zero.
!Split each velocity bin into nintg pieces and integrate.
nintg0=41
nintg=max(nintg0,min0(51,int(x(2)/sqrt(.2*cnorm2/reltmp))))
nintg=2*(nintg/2)+1
do i=1,nintg
sfac=4.+2.*(2*(i/2)-i)
if (i.eq.1 .or. i.eq.nintg) sfac=1.
sfac=sfac/3.
do j=2,jx
xx=x(j)-(i-1)*dxm5(j)/dfloat(nintg-1)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i) ! could set to 1.
gg2=gg**2
expon=.5*xx2/cnorm2 ! non-relativ. limit
fff=sfac*rnorm*exp(-expon*reltmp)*dxm5(j)/dfloat(nintg-1)
!temp1(1,j)=temp1(1,j)+xx*gg*fff !not needed here?
temp1(2,j)=temp1(2,j)+xx*fff
!temp1(3,j)=temp1(3,j)+xx2*fff !not needed here?
temp1(4,j)=temp1(4,j)+xx2*fff/gg
!temp1(5,j)=temp1(5,j)+(xx2/gg)**2*fff !not needed here?
temp1(6,j)=temp1(6,j)+(xx2/gg2)**2*gg*fff
enddo
enddo
tam2(jx)=0. !not needed here?
tam3(1)=0. !not needed here?
tam5(1)=0. !not needed here?
tam6(jx)=0.
tam7(1)=0.
tam9(1)=0.
!tam6(jx) represents integral from xmax to infinity
!The following coding performs this integration. In this case 21*xmax
!represents infinity. The lack of this piece is most obvious when
!ions are a general species and electrons are fixed Maxwellians.
do ll2=1,21
sfac=4.+2.*(2*(ll2/2)-ll2)
if ( ll2.eq.1 .or. ll2.eq.21) sfac=1.
sfac=sfac*x(jx)/60.
do ll1=1,20
xx=(realiota(ll1)+.05*realiota(ll2-1))*x(jx)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i)
expon=.5*xx2/cnorm2 ! non-relativ. limit
fff=sfac*rnorm*exp(-expon*reltmp)
!tam2(jx)=tam2(jx)+xx*gg*fff ! not needed here?
tam6(jx)=tam6(jx)+xx*fff
enddo
enddo
do j=2,jx
jj=jx+1-j
jp=jj+1
jm=j-1
!tam2(jj)=tam2(jp)+temp1(1,jp) ! not needed here?
!tam3(j)= tam3(jm)+temp1(3,j) ! not needed here?
!tam5(j)= tam5(jm)+temp1(5,j) ! not needed here?
tam6(jj)=tam6(jp)+temp1(2,jp)
tam7(j)= tam7(jm)+temp1(4,j)
tam9(j)= tam9(jm)+temp1(6,j)
!tam6 - M0'; tam7 - N0'; tam9 - E0'
!Eqns. 64-66 of UCRL-96510 by Mark R. Franz
enddo
do j=2,jx
tam10(j)=cog(0,1)*(3.*tam7(j)+cnorm2i*(2.*xm(j,3)*tam6(j)-
& tam9(j)))*gamsqr(j)
! ~Eq. 61, (inside {} brackets), and cog(0,1)=4*pi/3
enddo
else !if(cfp_integrals.eq.'enabled')then
!YuP[2020-07-16] alternative to the above. Use table cfpm() instead.
! For tam10(1:jx),tam11(1:jx),tam12(1:jx) -
! Instead of the above calculations [cfp_integrals.eq.'disabled']
! use integrals stored in cfpm() array.
ktable=nmax+nstates+2 !(T-table for bound electrons at 10eV)
call cfp_integrals_get(ktable,temp_loc) !out:tam10(),tam11(),tam12()
!Here, we only need tam10(j).
!Since we assumed that bound e are at same T=10eV (in each kstate)
!we could compute tam10 just once, say, for kstate=0.
endif ! (cfp_integrals.eq.'enabled')
!Perform the bounce-average for the background species and introduce
!the contribution to all general species coeff.
!Instead of ne*gama(ka,k)*satioz2(k,ka)*satiom(ka,k)
!now we must use SUM[n_kstate*hbethe(kstate)].
!Note: here bnumb(ka)=bnumb(kelecg)=-1, so satioz2(k,ka)=1.
!Also here: satiom(ka,k)==mass_kk/mass_k =1.
!Use bounce-av. density of this ionization state;
!similar to subr.bavdens, only replace reden(k,lr_)-->dens_imp(kstate,lr_)
call bcast(tem1,zero,iyjx)
do j=2,jx
! We only need to add contribution for the "A" term -
! drag of (free)electron on (bound)electrons.
! Replace this: ttta= gama(ka,k)*tam10(j)*gamefac(j,k) with this:
ttta= tam10(j)*dens_imp(kstate,lr_)*hbethe(kstate,j)
!Note that density is included here.
!It is multiplied by hbethe(kstate,j), which contains
!z_bound= z_imp-z_state ! Nej in paper (number of bound electrons)
do i=1,iy
jj=i+(j-1)*iy
tem1(jj)= ttta*vptb(i,lr_) !for contributing to eal() below
cal(i,j,kelecg,l_)= cal(i,j,kelecg,l_)+tem1(jj) !free_e on bound_e
! ka=kelecg here (electron_general)
enddo ! i
enddo ! j
!??? Not sure where to add tem1() contribution:
!eal(*,*,ka,1,l_) is for transfer of energy to Maxwellian e [k=kelecm].
!eal(*,*,ka,2,l_) is for transfer of energy to Maxwellian i [k=kionm()],
!and all such ions are summed-up (not for individual ion species).
!Maybe we consider that in this case the energy is transferred to
!the partially ionized ion (kstate) ?
!call daxpy(iyjx,one,tem1,1,eal(1,1,ka,2,l_),1)
enddo !kstate=0,nstates
endif ! gamafac.eq."hesslow" .and. kelecg.eq.1
!YuP[2019-07-26]
!------------------------- contribution from partially ionized ions -----
c.......................................................................
c At this point, contributions to the FP coll coeffs for each
c general species due to the Maxwl background species have been
c added to cal(,,), etc.
c.......................................................................
110 continue !Branch around Maxwl contribs if nmax=0, or colmodl=2
ccc kk=1
ccc do i=1,iy
ccc prnt1(i)=cal(i,2,kk,l_)
ccc prnt2(i)=cbl(i,2,kk,l_)
ccc prnt3(i)=ccl(i,2,kk,l_)
ccc prnt4(i)=cdl(i,2,kk,l_)
ccc prnt5(i)=cel(i,2,kk,l_)
ccc prnt6(i)=cfl(i,2,kk,l_)
ccc enddo
c..................................................................
c Calculate coefficients and their bounce-averages for a general species
c..................................................................
if (colmodl.eq.1) goto 700
if (colmodl.eq.4 .and. n.ge.naccel) then !Undocumented option
! Kerbel
do 250 k=1,ngen
if (k.ne.ngen) then
do 220 j=1,jx
do 210 i=1,iy
if(2.*f(i,j,k,l_)-f_(i,j,k,l_).gt.0.) then
fxsp(i,j,k,l_)= 2.*f(i,j,k,l_)-f_(i,j,k,l_)
else
fxsp(i,j,k,l_)= .5*f(i,j,k,l_)
endif
210 continue
220 continue
else
call diagescl(kelecg)
call dcopy(iyjx2,f(0,0,ngen,l_),1,fxsp(0,0,ngen,l_),1)
endif
250 continue
else
do 280 k=1,ngen
if (colmodl.eq.4 .and. k.eq.ngen) call diagescl(kelecg)
280 continue
endif
madd=1
if (machine.eq."mirror") madd=2
c.......................................................................
c loop over orbit mesh s(l) (for general species only)
c CQLP case: compute only s(l_)
c.......................................................................
if (cqlpmod .ne. "enabled") then
iorbstr=1
iorbend=lz ! Whole flux surface, eqsym="none", else half FS.
else
iorbstr=l_
iorbend=l_
endif
cBH180906: Make sure that expanded eal/ebl and new ecl arrays
cBH180906: for non-isotropic genrl distributions, saving ca,cb,cc
cBH180906: coll contributions to each general species from
cBH180906: itself and other species, are zeroed out. Then,
cBH180906: accumate the contributions below, use for calculating
cBH180906: power flow in diagentr coding, and save powers into
cBH180906: .nc output file.
cBH180906: ecl() can be dimension to cover just the range of
cBH180906 general species k's.
cBH180906 The coding also needs adding to cfpcoefr.f.
do 600 l=iorbstr,iorbend
ileff=l
if (cqlpmod .eq. "enabled") ileff=ls_
do 500 k=1,ngen
c.................................................................
c Jump out if this species is not to be used as a background species
cBH180901: This comment doesn't make much sense, as kfield(k) here is not
cBH180901: related to a background species. Maybe the comment is
cBH180901: mistakenly copied from above.
c..................................................................
if (kfield(k).eq."disabled") go to 500
c zero ca, cb,.., cf :
CPTR>>>REPLACE PTR-BCASTCACD
call bcast(ca,zero,iyjx)
call bcast(cb,zero,iyjx)
call bcast(cc,zero,iyjx)
call bcast(cd,zero,iyjx)
call bcast(ce,zero,iyjx)
call bcast(cf,zero,iyjx)
CPTR<<<END PTR-BCASTCACD
mu1=0
mu2=mx
mu3=madd
if (colmodl.eq.3) then
mu1=1 !Skipping P_0 term
mu2=mx
mu3=1
endif
do 400 m=mu1,mu2,mu3
if (colmodl.eq.4 .and. n.ge.naccel) then
call dcopy(iyjx2,fxsp(0,0,k,l_),1,temp3(0,0),1)
else
call dcopy(iyjx2,f(0,0,k,l_),1,temp3(0,0),1)
endif
c compute V_m_b in tam1(j), for given l, m and gen. species b
c coeff. of Legendre decomposition of f (using temp3)
call cfpleg(m,ileff,1) !-> tam1
tam2(jx)=0.
tam3(1)=0.
tam4(jx)=0.
tam5(1)=0.
tam6(jx)=0.
tam7(1)=0.
tam8(jx)=0.
tam9(1)=0.
c prepare arrays for computation of M_m, N_m, R_m and E_m
do 301 j=2,jx
jm=j-1
tam20(j)=.5*dxm5(j)*
* (gamsqr(j)*xm(j,ix1(m))*tam1(j)+
* gamsqr(jm)*xm(jm,ix1(m))*tam1(jm))
tam13(j)=.5*dxm5(j)*
* (gamsqr(j)*xm(j,ix2(m))*tam1(j)+
* gamsqr(jm)*xm(jm,ix2(m))*tam1(jm))
tam14(j)=.5*dxm5(j)*
* (gamsqr(j)*xm(j,ix3(m))*tam1(j)+
* gamsqr(jm)*xm(jm,ix3(m))*tam1(jm))
tam15(j)=.5*dxm5(j)*
* (gamsqr(j)*xm(j,ix4(m))*tam1(j)+
* gamsqr(jm)*xm(jm,ix4(m))*tam1(jm))
tam16(j)=.5*dxm5(j)*
* (gamma(j)*xm(j,ix1(m))*tam1(j)+
* gamma(jm)*xm(jm,ix1(m))*tam1(jm))
tam17(j)=.5*dxm5(j)*
* (gamma(j)*xm(j,ix2(m))*tam1(j)+
* gamma(jm)*xm(jm,ix2(m))*tam1(jm))
tam18(j)=.5*dxm5(j)*
* (gamma(j)*xm(j,ix3(m))*tam1(j)+
* gamma(jm)*xm(jm,ix3(m))*tam1(jm))
tam19(j)=.5*dxm5(j)*
* (gamma(j)*xm(j,ix4(m))*tam1(j)+
* gamma(jm)*xm(jm,ix4(m))*tam1(jm))
301 continue
c note: ialpha set to 0, 1, or 2 at top of subroutine, Using 2 now.
if (m.ge.1 .or. ialpha.eq.2) goto 308
c..................................................................
c The do loops 302 through 307 seek to take advantage of the
c Maxwellian nature of f for v < vth/2. This is employed in
c the integrations to obtain the functionals - Thus f is
c assumed to be Maxwellian between velocity mesh points,
c not linear. (not used)
c..................................................................
do 302 j=2,jx
xs=sqrt(temp(k,lr_)*ergtkev*0.5/fmass(k))
if (cqlpmod .eq. "enabled")
+ xs=sqrt(temppar(k,ls_)*ergtkev*0.5/fmass(k))
if (x(j)*vnorm.gt.xs) goto 303
302 continue
303 continue
jthov2=j-1
c..................................................................
c Determine the "local" Maxwellian between meshpoints.
c..................................................................
do 304 j=1,jthov2
c990131 tam21(j)=alog(tam1(j)/tam1(j+1))/(gamm1(j+1)-gamm1(j))
tam21(j)=log(tam1(j)/tam1(j+1))/(gamm1(j+1)-gamm1(j))
tam22(j)=tam1(j)/exp(-(gamm1(j)*tam21(j)))
304 continue
rstmss=fmass(k)*clite2/ergtkev
reltmp=rstmss/temp(k,lr_)
if (cqlpmod .eq. "enabled") reltmp=rstmss/temppar(k,ls_)
call bcast(tam23,zero,jx*8)
nintg=max0(21,min0(51,int(x(2)/sqrt(.2*cnorm2/reltmp))))
nintg=2*(nintg/2)+1
do 305 i=1,nintg
sfac=4.+2.*(2*(i/2)-i)
if (i.eq.1 .or. i.eq.nintg) sfac=1.
sfac=sfac/3.
do 306 j=2,jthov2
xx=x(j)-(i-1)*dxm5(j)/dfloat(nintg-1)
xx2=xx**2
gg=sqrt(1.+xx2*cnorm2i)
gg2=gg**2
cBH if(cnorm2i*xx2-1.e-5 .gt. 0.d0) then
if(cnorm2i*xx2-1.d-5 .gt. 0.d0) then
expon=gg-1.
else
expon=.5*xx2/cnorm2
endif
fff=sfac*tam22(j-1)*exp(-expon*tam21(j-1))*dxm5(j)
1 /dfloat(nintg-1)
tam30(j)=tam30(j)+
* gg2*(xx/gg)**ix1(m)*fff
tam23(j)=tam23(j)+
* gg2*(xx/gg)**ix2(m)*fff
tam24(j)=tam24(j)+
* gg2*(xx/gg)**ix3(m)*fff
tam25(j)=tam25(j)+
* gg2*(xx/gg)**ix4(m)*fff
tam26(j)=tam26(j)+
* gg*(xx/gg)**ix1(m)*fff
tam27(j)=tam27(j)+
* gg*(xx/gg)**ix2(m)*fff
tam28(j)=tam28(j)+
* gg*(xx/gg)**ix3(m)*fff
tam29(j)=tam29(j)+
* gg*(xx/gg)**ix4(m)*fff
306 continue
305 continue
do 307 j=1,jthov2
if (ialpha.eq.0) then
alpha=(x(j)/x(jthov2))**2
elseif (ialpha .eq. 1) then
alpha=0.
else
alpha=1.
endif
tam20(j)=alpha*tam20(j)+(1.-alpha)*tam30(j)
tam14(j)=alpha*tam14(j)+(1.-alpha)*tam24(j)
tam16(j)=alpha*tam16(j)+(1.-alpha)*tam26(j)
tam18(j)=alpha*tam18(j)+(1.-alpha)*tam28(j)
tam13(j)=alpha*tam13(j)+(1.-alpha)*tam23(j)
tam15(j)=alpha*tam15(j)+(1.-alpha)*tam25(j)
tam17(j)=alpha*tam17(j)+(1.-alpha)*tam27(j)
tam19(j)=alpha*tam19(j)+(1.-alpha)*tam29(j)
307 continue
308 continue !End of branch on special integration
do 310 j=2,jx
jj=jx+1-j
jp=jj+1
jm=j-1
tam2(jj)=tam2(jp)+tam20(jp)
tam3(j) =tam3(jm)+tam13(j)
tam4(jj)=tam4(jp)+tam14(jp)
tam5(j) =tam5(jm)+tam15(j)
tam6(jj)=tam6(jp)+tam16(jp)
tam7(j) =tam7(jm)+tam17(j)
tam8(jj)=tam8(jp)+tam18(jp)
tam9(j) =tam9(jm)+tam19(j)
310 continue
c..................................................................
c tam2= v**(2+m) * M_m ; tam3= v**(1-m) * N_m ; tam4= v**m * R_m
c tam5= v**(1-m) * E_m
c tam6= v**(2+m) * Mh_m ; tam7= v**(1-m) * Nh_m ; tam8= v**m * Rh_m
c tam9= v**(1-m) * Eh_m ; where Mh="M / gamma(ksi)", etc.
c.......................................................................
do 330 j=1,jx
tam2(j)=xm(j,ix5(m))*tam2(j)
tam3(j)=xm(j,ix6(m))*tam3(j)
tam4(j)=xm(j,ix7(m))*tam4(j)
tam5(j)=xm(j,ix8(m))*tam5(j)
tam6(j)=xm(j,ix5(m))*tam6(j)
tam7(j)=xm(j,ix6(m))*tam7(j)
tam8(j)=xm(j,ix7(m))*tam8(j)
tam9(j)=xm(j,ix8(m))*tam9(j)
330 continue
c..................................................................
c sg(j) = B_m_b, needed for Rosenbluth potential g (g,h with relav corr)
c sh(j) = A_m_b, needed for Rosenbluth potential h (h "=" g/gamma_prime)
c sgx(j) = dsg/dv (not du), etc. for sgxx, ...
c.......................................................................
do 340 j=2,jx
sg(j)=cog(m,1)*(tam5(j)+tam2(j))-
* cog(m,2)*(tam3(j)+tam4(j))
sgx(j)=cog(m,3)*tam2(j)-cog(m,4)*tam5(j)-
* cog(m,5)*tam4(j)+cog(m,6)*tam3(j)
sgx(j)=gamma(j)*xi(j)*sgx(j)
sgxx(j)=cog(m,7)*(tam5(j)+tam2(j))-
* cog(m,8)*(tam3(j)+tam4(j))
sgxx(j)=gamsqr(j)*x2i(j)*sgxx(j)
sh(j)=cog(m,1)*(tam9(j)+tam6(j))-
* cog(m,2)*(tam7(j)+tam8(j))
shx(j)=cog(m,3)*tam6(j)-cog(m,4)*tam9(j)-
* cog(m,5)*tam8(j)+cog(m,6)*tam7(j)
shx(j)=gamma(j)*xi(j)*shx(j)
shxx(j)=cog(m,7)*(tam9(j)+tam6(j))-
* cog(m,8)*(tam7(j)+tam8(j))
shxx(j)=gamsqr(j)*x2i(j)*shxx(j)
shxxx(j)=cog(m,9)*tam6(j)-cog(m,10)*tam9(j)-
* cog(m,11)*tam8(j)+cog(m,12)*tam7(j)
shxxx(j)=gamcub(j)*x3i(j)*shxxx(j)
340 continue
c.......................................................................
c compute A_a, B_a, ..., F_a as in GA report GA-A20978 p.11,
c Nov. 1992 (CQL3D Manual, Harvey and McCoy, IAEA TCM Montreal):
c Mildly relativistic coll FP coeffs per M. Franz, UCRL-96510, 1987.
c.......................................................................
fmmp1=m*(m+1)
do 350 j=1,jx
tam2(j)=-gamcub(j)*xi(j)*fmmp1*sh(j)
* +.5*gamsqr(j)*(2.+fmmp1)*shx(j)
* -gammi(j)*x(j)*shxx(j)
* -.5*gamm2i(j)*xsq(j)*shxxx(j)
tam3(j)=.5*xsq(j)*sgxx(j)
tam4(j)=.5*gamma(j)*(sgx(j)-gamma(j)*xi(j)*sg(j))
tam5(j)=.5*gamcub(j)*x2i(j)*fmmp1*sh(j)
* -gamsqr(j)*xi(j)*shx(j)
* -.5*gammi(j)*shxx(j)
tam6(j)=.5*gamma(j)*xi(j)*sgx(j)
tam7(j)=.5*gamsqr(j)*x2i(j)*sg(j)
350 continue
c$$$c sum over m
c$$$ do 380 iii=1,imax(ileff,lr_)
c$$$ do 370 ii=0,1
c$$$ if (madd.eq.2 .and. ii.eq.0) goto 370
c$$$ i=iii*ii-(iy+1-iii)*(ii-1)
c$$$ do 360 j=2,jx
c$$$ ca(i,j)=ca(i,j)+ss(i,ileff,m,lr_)*tam2(j)*gamefac(j)
c$$$ cb(i,j)=cb(i,j)+ss(i,ileff,m,lr_)*tam3(j)*gamefac(j)
c$$$ cc(i,j)=cc(i,j)+ssy(i,ileff,m,lr_)*tam4(j)*gamefac(j)
c$$$ cd(i,j)=cd(i,j)+sinz(i,ileff,lr_)*
c$$$ * ssy(i,ileff,m,lr_)*tam5(j)*gamefac(j)
c$$$ ce(i,j)=ce(i,j)+sinz(i,ileff,lr_)*
c$$$ * ssy(i,ileff,m,lr_)*tam4(j)*gamefac(j)
c$$$ cf(i,j)=cf(i,j)+sinz(i,ileff,lr_)*
c$$$ * (ss(i,ileff,m,lr_)*tam6(j)+ssyy(i,ileff,m,lr_)
c$$$ + *tam7(j))*gamefac(j)
c$$$ 360 continue
c$$$ 370 continue
c$$$ 380 continue
c$$$c end of loop over m
c sum over m: Add contribution from each m
do 380 iii=1,imax(ileff,lr_)
if(iii.ge.itl+1 .and. mod(m,2).eq.1) goto 380 !YuP
!YuP-111202: This removes a bug in the calculation of
!YuP-111202: collisional contribution to C,D, and F.
!YuP-111202: Check YuP Email to BH, 111201
!YuP-111202:
!In trap region: no contribution from m=1,3,5...
!The contribution from m=0,2,4,... will provide proper
!parity in theta0-(pi/2): even parity for ca,cb,cf;
!odd parity for cc,cd,ce (they are ~ dPm/dtheta).
!No further symmetrization needed.
do 370 ii=0,1
i=iii*ii-(iy+1-iii)*(ii-1) ! i=iy+1-iii or i=iii
do 360 j=2,jx
ca(i,j)=ca(i,j)+ss(i,ileff,m,lr_)*tam2(j)*gamefac(j,k) !YuP[2019-07-26] k index added
cb(i,j)=cb(i,j)+ss(i,ileff,m,lr_)*tam3(j)*gamefac(j,k) !YuP[2019-07-26] k index added
cc(i,j)=cc(i,j)+ssy(i,ileff,m,lr_)*tam4(j)*gamefac(j,k) !YuP[2019-07-26] k index added
cd(i,j)=cd(i,j)+sinz(i,ileff,lr_)*
* ssy(i,ileff,m,lr_)*tam5(j)*gamefac(j,k) !YuP[2019-07-26] k index added
ce(i,j)=ce(i,j)+sinz(i,ileff,lr_)*
* ssy(i,ileff,m,lr_)*tam4(j)*gamefac(j,k) !YuP[2019-07-26] k index added
cf(i,j)=cf(i,j)+sinz(i,ileff,lr_)*
* (ss(i,ileff,m,lr_)*tam6(j)+ssyy(i,ileff,m,lr_)
+ *tam7(j))*gamefac(j,k) !YuP[2019-07-26] k index added
360 continue ! j
370 continue ! ii
380 continue ! iii
400 continue ! m, starting at l 313
if (madd.eq.2 .or. symtrap.ne."enabled") goto 430
c symmetrize in trap region
do 420 i=itl+1,iyh
iu=iy+1-i
do 410 j=2,jx
ca(i,j)=.5*(ca(i,j)+ca(iu,j))
cb(i,j)=.5*(cb(i,j)+cb(iu,j))
cf(i,j)=.5*(cf(i,j)+cf(iu,j))
xq=sign(half,cc(i,j))
xr=sign(half,cd(i,j))
xs=sign(half,ce(i,j))
cd(i,j)=xr*(abs(cd(i,j))+abs(cd(iu,j)))
cc(i,j)=xq*(abs(cc(i,j))+abs(cc(iu,j)))
ce(i,j)=xs*(abs(ce(i,j))+abs(ce(iu,j)))
ca(iu,j)=ca(i,j)
cb(iu,j)=cb(i,j)
cc(iu,j)=-cc(i,j)
cd(iu,j)=-cd(i,j)
ce(iu,j)=-ce(i,j)
cf(iu,j)=cf(i,j)
410 continue
420 continue
430 continue
c.......................................................................
c add contribution to each gen. species A_kk,.., including charge,
c ln(Lambda) and mass coefficients.
c.......................................................................
do 490 kk=1,ngen
if (colmodl.eq.4) then
if (kk.eq.kelecg .and. k.eq.kelecg) goto 490
if (kk.ne.kelecg .and. k.eq.ngen) goto 490
endif
anr1=gama(kk,k)*satioz2(k,kk)*one_
if (anr1.lt.em90) goto 490
CPTR>>>REPLACE PTR-DSCALCACD
call dscal(iyjx,anr1,ca(1,1),1) !-YuP: size of ca..cf: iy*jx
call dscal(iyjx,anr1,cb(1,1),1)
call dscal(iyjx,anr1,cc(1,1),1)
call dscal(iyjx,anr1,cd(1,1),1)
call dscal(iyjx,anr1,ce(1,1),1)
call dscal(iyjx,anr1,cf(1,1),1)
call dscal(iyjx,satiom(kk,k),ca(1,1),1)
call dscal(iyjx,satiom(kk,k),cd(1,1),1)
CPTR<<<END PTR-DSCALCACD
c.......................................................................
c Note: At this point, ca, ..,cf(i,j) are the coeff. from gen. species k
c at a given orbit position l.
c.......................................................................
if (cqlpmod .ne. "enabled") then
c Perform the bounce averaging
do 480 i=1,imax(l,lr_)
ii=iy+1-i
ax=abs(coss(i,l_))*dtau(i,l,lr_)
ay=tot(i,l,lr_)/sqrt(bbpsi(l,lr_))
az=ay*tot(i,l,lr_)
cBH091031 ax1=ax
cBH091031 !i.e, not bounce pt interval:
cBH091031 if (l.eq.lz .or. lmax(i,lr_).ne.l) goto 440
cBH091031 ax1=ax+dtau(i,l+1,lr_)*abs(coss(i,l_))
cBH091031 440 continue
if (eqsym.ne."none") then !i.e. up-down symm
!if not bounce interval
if(l.eq.lz .or. l.ne.lmax(i,lr_)) then
ax1=ax
else !bounce interval: additional contribution