forked from compxco/genray
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdinit.f
4181 lines (3507 loc) · 152 KB
/
dinit.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 **********************_dinit_mr************************
c * - *
c * this subroutine reads the data from genray.in *
c *******************************************************
c
c-------------------------dinit_mr---------------------------------
c It creates data for multiple ray case.
c for spline approximations
c density,temperature and Z_effective profiles.
c Calculates initial data for all rays.
c It uses input data from genray.in or genray.dat
c file for multiple ray case.
c Data from genray.in or genray.dat file were read
c previously in genray.f file
c It reads or creates the non-maxwellian electron distribution
c
c it uses the following functions and subroutines
c bmod,spldens1
c This program reads data from genray.in file for !
c multiple ray case. !
c It creates the files for spline approximations !
c density,temperature and Z_effective profiles. !
c it uses the following functions and subroutines !
c bmod,spldens1 !
c------------------------------------------------------------------
c output parameters: !
c ndim-number of the ray-tracing equations!
c nray-number of the rays at antenna !
c------------------------------------------------------------------
subroutine dinit_mr(ndim,nray)
implicit none
include 'param.i'
include 'one.i'
include 'ions.i'
include 'three.i'
include 'five.i'
include 'cone.i'
include 'grill.i'
include 'rkutta.i'
include 'six.i'
include 'scatnper.i'
include 'write.i'
include 'writencdf.i'
include 'onetwo.i'
include 'output.i'
include 'emissa.i'
integer myrank !In serial run: myrank=0; In MPI run: myrank=rank
common/mpimyrank/myrank !In serial run: myrank=0; In MPI run: myrank=rank
c-----output
integer
&ndim, !number of the ray-tracing equations
&nray !number of the rays at antenna
c..............................................................
c these two arrays are for namelist work only
c dimension prof2(nbulka,ndensa)
c dimension prof(nbulka*ndensa)
c Following are working arrays for the namelist input of density
c and temperature,... at nonuniform radii grids
real*8 prof2_nonuniform(nbulka,ndensa),prof_radii(nbulka,ndensa)
c integer nj_tab(nbulka) !the number of profile points for each species
c..............................................................
include 'dinit_nml.i'
c..............................................................
integer nbulk1,i,j,k,iraystop,i1,j1,ifreq,ii,initial,nray1,icone,
&imax
real*8 trnspi,h,v0,w0,hfreq,delt,zefftest,zion,psi,denstot,
&szini,szi2ni,stini,pressure,den_test,prestest,tem_test,
&energy,pitch,fdist,dfdx,dfdpitch,dfdp,psi_mag,xi,yi,tetan,x0,
&zconv,rconv,theta,rhoconv,phiconv,xconv,yconv,cnparopt,
&h_rho,dens,temp,psi_loc,
&tpop,
cSAP090311 for test
&zeff_loc,vflow_loc
c-----externals
real*8 b,psi_rho,prespsi,densrho,temperho,psif,x,y,tpoprho,
cSAP090311
&zeffrho,vflowrho
cSAP080711BH080714
c-----genray input file: genray.in or genray.dat
character*10 genray_in_dat
iraystop=0
pi=4.d0*datan(1.d0)
trnspi=pi/180.d0
c---------------------------------------------------------------
c read all namelists from input genray.in or genray.dat file
c---------------------------------------------------------------
cSAP080731
c call read_all_namelists(genray_in_dat,ndim,nray)
c write(*,*)'in dinit_mr, genray_in_dat=', genray_in_dat
c-----If input file is genray.in, then it will change
c input data to genray.dat file format
c if (genray_in_dat.eq.'genray.in') then
c write(*,*)'genray.f before transform_genray_in_to_dat'
c call transform_genray_in_to_dat
c endif
c---------------------------------------------------------------------
if (n_wall.gt.0) then
c-------calculate poloidal angles [at radian] and small radius
c of wall and limiter points
c thetapol_wall(i=1,..,n_wall)
c thetapol_limiter(i=1,...,n_limiter(j),j=1,max_limiters)
c rho_wall(i=1,..,n_wall)
c rho_limiter(i=1,..,n_limiter(j),j=1,max_limiters))
c
c These arrays will be in common /fourb/ in file fourb.i
call wall_limiter_theta_pol_rho
endif
c------------------------------------------------------------------------
cyup write(*,*)'dinit_mr: Absorption'
c------------------------------------------------------------------------
c iabsorp=Imag(N_perp)
c (imaginary part of the perpendicular refructive index)
c-------------------------------------------------------------------------
cyup write(*,*)'dinit_mr: iabsorp=',iabsorp
c iabsorp=1 for EC waves from Mazzucato solver
c iabsorp=2 for LH waves
c iabsorp=3 for FW waves
c-----------------------------------------------------
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: n_relt_harm1',n_relt_harm1
write(*,*)'dinit_mr: n_relt_harm',n_relt_harm
write(*,*)'dinit_mr: n_relt_harma',n_relt_harma
endif ! outprint
if (n_relt_harm1.eq.9999)then
n_relt_harm1=-n_relt_harm
n_relt_harm2= n_relt_harm
else
n_relt_harm2=n_relt_harm1+n_relt_harm-1
endif
cSm060313
if(n_relt_harm1.lt.n_relt_harm1a) then
write(*,*)'n_relt_harm1<n_relt_harm1a'
write(*,*)'it should be n_relt_harm1=>n_relt_harm1a'
write(*,*)'please change n_relt_harm1a'
write(*,*)'in param.i and recompile the code'
write(*,*)'n_relt_harm1,n_relt_harm1a',
& n_relt_harm1,n_relt_harm1a
stop 'in dinit_mr'
endif
if(n_relt_harm2.gt.n_relt_harma) then
write(*,*)'n_relt_harm2>n_relt_harma'
write(*,*)'it should be n_relt_harm2=<n_relt_harma'
write(*,*)'please change n_relt_harma'
write(*,*)'in param.i and recompile the code'
write(*,*)'n_relt_harm2,n_relt_harm2a',
& n_relt_harm2,n_relt_harm2a
stop 'in dinit_mr'
endif
cyup write(*,*)'dinit_mr: 1 nbulk=',nbulk
do i=1,nbulk
if ((i_salphal(i).ne.1).and.(i_salphal(i).ne.0)) then
write(*,*)'(i_salphal(i).ne.1).or.(i_salphal(i).ne.0)'
write(*,*)'It should i_salphal(i) =0 or =1'
write(*,*)'i=',i,'i_salphal(i)',i_salphal(i)
write(*,*)'Please chagne i_saplhal(i)'
write(*,*)'in input genray.in or genray.dat file'
stop 'in dinit_mr: i_salphal problem'
endif
enddo
if (n_contour_plot_disp.gt.n_contour_plot_disp_a)then
write(*,*)'in dinit.f'
write(*,*)'n_contour_plot_disp.gt.n_contour_plot_disp_a'
write(*,*)'n_contour_plot_disp',n_contour_plot_disp
write(*,*)'n_contour_plot_disp_a',n_contour_plot_disp_a
write(*,*)'Please change n_contour_plot_disp_a in param.i'
write(*,*)'and recompile the code'
write(*,*)'or change n_contour_plot_disp in genray.dat'
stop 'dinit.f dinit_mr'
endif
c$$$ endif
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: Plasma parameters'
write(*,*)'dinit_mr: izeff=',izeff
do i=1,nbulk
write(*,*)'dinit_mr: i,temp_scale(i),den_scale(i)',
. i,temp_scale(i),den_scale(i)
enddo
do i=1,nbulk
write(*,*)'dinit_mr: i, dmas(i)',i,dmas(i)
! dmas(i)=Mass(i)/Mass_electron
enddo
endif ! outprint
do i=1,nbulk
te0(i)=ate0(i)
teb(i)=ateb(i)
enddo
c-----------------------------------------------------
c /species/
c plasma component charges charge(i)=mod(charge(i)/charge_electron)
c----------------------------------------------------
c-----------------------------------------------------
c plasma components mass dmas(i)=Mass(i)/Mass_electron
c-----------------------------------------------------
do i=1,nbulk
write(*,*)'dinit_mr: i, dmas(i)',i,dmas(i)
enddo
c--------------------------------------------------------------
c calculation of nbulk1
if(((izeff.eq.0).or.(izeff.eq.2)).or.(izeff.eq.3)) then
c izeff=0, zeff will be calculated using the given ions;
c the electron density will be calculated using ion's densities;
c =1 ion's densities(i) i=nbulk and i=nbulk-1 will be calculated using
c Zeff, the electon density and ion's densities(i), i=2,nbulk-1;
c izeff=2, zeff will not coincide with the plasma components
c =3 it uses eqdsk pres (pressure) and ions densities_i
c for i=2,... nbulk
c Let temperature T_E=T_i
c pres=dens1(k,1)*temp1(k,1)+
c Sum(i=2,nbulk)(dens1(k,i)*temp1(k,i)
c In this case we will calculate Zeff(rho),
c dens_electron(rho) and T_e(rho)=T_i(rho)
c =4 it uses eqdsk pres (pressure), zeff,ions densities
c for i=2,... nbulk-2 (nbulk>2) and T_e(rho),T_i(rho)
c pres=dens1(k,1)*temp1(k,1)+
c Sum(i=2,nbulk)(dens1(k,i)*temp1(k,i)
c In this case we will calculate dens_electron(rho) and
c ion densities for i=nbulk and i=nbulk-1
nbulk1=nbulk
else
c (izeff=1 or izeff=4), zeff is given, the ions component will be calculated
if (nbulk.le.2) nbulk1=nbulk
if (nbulk.eq.2) then
write(*,*)'dinit_mr: nbulk=2, Zeff must be equal charge(2)'
write(*,*)'Please check it or use the option izeff=0'
cSAP090801
c stop
endif
if (nbulk.gt.2) nbulk1=nbulk-2
endif !izeff
cyup write(*,*)'nbulk1=',nbulk1
c------------------------------------------------------------------
h=1.d0/(ndens-1)
do i=1,ndens
rhom(i)=h*(i-1)
enddo
c------------------------------------------------------------------
c The parameters for the density fluctuations
c /varden/
c------------------------------------------------------------------
if(idens.eq.0) then
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: Analytical radial profiles'
c-dense_(i)=(dense0(i)-denseb(i))*(1-rho**rn1de(i))**rn2de(i)+denseb(i)
c------------------------------------------------------------------\
do i=1,nbulk1
write(*,*)'dinit_mr: i, dense0(i)',i,dense0(i)
enddo
do i=1,nbulk1
write(*,*)'dinit_mr: i, denseb(i)',i,denseb(i)
enddo
do i=1,nbulk1
write(*,*)'dinit_mr: i, rn1de(i)',i,rn1de(i)
enddo
do i=1,nbulk1
write(*,*)'dinit_mr: i, rn2de(i)',i,rn2de(i)
enddo
do i=1,nbulk1
write(*,*)'dinit_mr: i, dense0(i)',i,dense0(i)
enddo
endif ! outprint
c--------creation the array dens1(ndensa,nbulka)
cSm080118
do i=1,nbulk1
do k=1,ndens
rho=rhom(k)
dens1(k,i)=(dense0(i)-denseb(i))*
1 (1.d0-rho**rn1de(i))**rn2de(i)+denseb(i)
enddo
enddo
do i=nbulk1,1,-1
do k=1,ndens
rho=rhom(k)
if (((izeff.eq.0).or.(izeff.eq.3)).and.(i.eq.1)) then
dens1(k,1)=0.d0
do j=2,nbulk
dens1(k,1)=dens1(k,1)+charge(j)*dens1(k,j)
enddo
else
dens1(k,i)=(dense0(i)-denseb(i))*
1 (1.d0-rho**rn1de(i))**rn2de(i)+denseb(i)
cSm070426
c-----------------multiply density profiles by den_scale
dens1(k,i)=dens1(k,i)*den_scale(i)
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: i,k,dens1(k,i)',i,k,dens1(k,i)
write(*,*)'dense0(i),denseb(i),rho,rn1de(i),rn2de(i)',
* dense0(i),denseb(i),rho,rn1de(i),rn2de(i)
endif ! outprint
endif
enddo
enddo
cyup write(*,*)'dinit_mr: end of analytical density profiles input'
c------------------------------------------------------------------
c /tpopprof/
c /vflprof/
c--------------------------------------------------------------------
c creation the arrays for analytical profoliles
c tpop1(ndensa,nbulka), vflow1(ndensa,nbulka)
do i=1,nbulk
do k=1,ndens
rho=rhom(k)
tpop1(k,i)=(tp0(i)-tpb(i))*
1 (1.d0-rho**rn1tp(i))**rn2tp(i)+tpb(i)
vflow1(k,i)=(vfl0(i)-vflb(i))*
1 (1.d0-rho**rn1vfl(i))**rn2vfl(i)+vflb(i)
enddo
enddo
c---------------------------------------------------------------------
c /zprof/
if (izeff.eq.3) goto 10
c /tprof/
c----------------------------------------------------------
cTemperature
ctempe_(i)=(te0(i)-teb(i))*(1-rho**rn1te(i))**rn2te(i)+teb(i)
c-----------------------------------------------------------
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
do i=1,nbulk
write(*,*)'dinit_mr: i, te0(i)',i,te0(i)
write(*,*)'dinit_mr: i, teb(i)',i,teb(i)
enddo
do i=1,nbulk
write(*,*)'dinit_mr: i, rn1te(i)',i,rn1te(i)
enddo
do i=1,nbulk
write(*,*)'dinit_mr: i, rn2te(i)',i,rn2te(i)
enddo
do i=1,nbulk
write(*,*)'dinit_mr: i,tp0(i),tpb(i)',i,tp0(i),tpb(i)
write(*,*)'dinit_mr: rn1tp(i),rn2tp(i)',rn1tp(i),rn2tp(i)
enddo
endif ! outprint
c------- creation of array temp1(ndensa,nbulka)
do i=1,nbulk
do k=1,ndens
rho=rhom(k)
temp1(k,i)=(te0(i)-teb(i))*
1 (1.d0-rho**rn1te(i))**rn2te(i)+teb(i)
cSm070426
c--------------multiply temperature profiles by temp_scale
temp1(k,i)=temp1(k,i)*temp_scale(i)
enddo
enddo
10 continue
cyup write(*,*)'dinit_mr: zeff0,zeffb,rn1zeff,rn2zeff'
cyup write(*,*)zeff0,zeffb,rn1zeff,rn2zeff
if(((izeff.eq.1).or.(izeff.eq.2)).or.(izeff.eq.4)) then
c the given analytical Zeff profile
c-------------------------------------------
c zeff=(zeff0-zeffb)*(1-rho**rn1zeff)**rn2zeff+zeffb
c-------------------------------------------
c the creation of array zeff1(ndens)
do k=1,ndens
rho=rhom(k)
zeff1(k)=(zeff0-zeffb)*
1 (1.d0-rho**rn1zeff)**rn2zeff+zeffb
enddo
endif
if((izeff.eq.0).or.(izeff.eq.3)) then
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: izeff=1 zeff will be calculated using
1 the given ions densities'
endif ! outprint
endif
endif ! idens analytical
cyup write(*,*)'dinit_mr: partner=',partner
c--------------------------------------------------------------------
if (partner.eq.'genray_profs_in.txt' .or.
1 partner.eq.'genray_profs_in.nc') then
c--------------------------------------------------------------
c read density ,temperature and zeff profiles from
c the file created by ONETWO : genray_profs_in
c
c Read in from external file
c 1) the density, temperature and zeff profiles
c at genray small radial mesh:
c dens1,temp1,zeff1,eqdskin
c 2) nbulk - the number of plasma species
c 3) set izeff =2 (for nbulk.ge.1)
c-------------------------------------------------------------
c call read_transport_prof(ndens,charge,dmas,
c & nbulk,dens1,temp1,tpop1,vflow1,zeff1,izeff,eqdskin,partner)
c write(*,*)'*******************************************'
c write(*,*)'sub read_transport_prof changes izeff, eqdskin'
c write(*,*)'izeff=',izeff
c write(*,*)'eqdskin=',eqdskin
cSm070203
c write(*,*)'dinit.f after read_transport_prof'
c write(*,*)'nbulk ',nbulk
c write(*,*)'charge',charge
c write(*,*)'dmas',dmas
c dmas(1)=1.d0
c--------multiply density profiles by den_scale(i)
do i=1,nbulk
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: i,temp_scale(i)',i,temp_scale(i)
endif ! outprint
do k=1,ndens
dens1(k,i)=dens1(k,i)*den_scale(i)
temp1(k,i)=temp1(k,i)*temp_scale(i)
enddo
enddo
cyup write(*,*)'*******************************************'
go to 20 ! <<<<<==========
endif
c------------------------------------
if (idens.eq.1) then
c spline approximation of the density, temperature, zeff,
c tpop=T_perp/T_parallel, vflow
c radial profiles
c input of the arrays on the radial mesh from dtzprof.dat
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: idens=1: Before mult by den_scale'
write(*,*)'nbulka,ndensa,nbulk,ndens',nbulka,ndensa,nbulk,ndens
do i=1,nbulk
write(*,*)'i',i,'dens1(k,i)'
write(*,'(a,2i4,e12.4)')'dens1=',i,1, dens1(1,i)
write(*,'(a,2i4,e12.4)')'dens1=',i,ndens,dens1(ndens,i)
enddo
endif ! outprint
!pause !!!
cSm070426
c---------multiply density profiles by den_scale(i)
cBh080102 do i=i1,nbulk
do i=1,nbulk
do k=1,ndens
dens1(k,i)=den_scale(i)*dens1(k,i)
enddo
enddo
c 21 format(5e16.9)
cyup write(*,*)'dinit_mr: nbulk1',nbulk1,'ndens',ndens
if ((izeff.eq.0).or.(izeff.eq.3)) then
i1=2
else
i1=1
endif
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: idens=1: After mult by den_scale'
do i=i1,nbulk1
write(*,*)'i',i,'dens1(k,i)'
write(*,*)(dens1(k,i),k=1,ndens)
enddo
endif ! outprint
c----------------------------------------------------------
c calculation of the electron density from
c the charge neutrality
c----------------------------------------------------------
if ((izeff.eq.0).or.(izeff.eq.3)) then
cSmirnov/00/05/26
do k=1,ndens
dens1(k,1)=0.d0
do j=2,nbulk
dens1(k,1)=dens1(k,1)+charge(j)*dens1(k,j)
enddo
enddo
endif
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: dens1(k,1)'
write(*,*)(dens1(k,1),k=1,ndens)
endif ! outprint
cSm070426
c--------multiply temperature profiles by temp_scale
do i=1,nbulk
do k=1,ndens
c write(*,*)'i,k,temp1(k,i),temp_scale(i)',
c & i,k,temp1(k,i),temp_scale(i)
temp1(k,i)=temp1(k,i)*temp_scale(i)
c write(*,*)'temp1(k,i)',temp1(k,i)
enddo
enddo
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
do i=1,nbulk
write(*,*)'i',i,'temp1(k,i)'
write(*,*) (temp1(k,i),k=1,ndens)
enddo
c---------tpoptab
do i=1,nbulk
write(*,*)'i',i,'tpop1(k,i)'
write(*,*) (tpop1(k,i),k=1,ndens)
enddo
c--------vflowtab
do i=1,nbulk
write(*,*)'i',i,'vflow1(k,i)'
write(*,*) (vflow1(k,i),k=1,ndens)
enddo
write(*,*)'dinit_mr: idens=1: izeff=',izeff
if(((izeff.eq.1).or.(izeff.eq.2)).or.(izeff.eq.4)) then
c the given Zeff profile is in the table form
write(*,*)'dinit_mr: idens=1: zeff1(k)'
else
write(*,*)'dinit_mr: idens=1: uniform zeff1',zeff1
endif !izeff
endif ! outprint
endif ! idens=1
c-----------------------------------------------------------
20 continue !from: if (partner.eq.
cyup write(*,*)'dinit_mr: after 20 continue '
c------------------------------------------------------------
c read the data for emission calculations
c /emission/
cyup write(*,*)'dinit_mr: i_emission',i_emission
if (i_emission.eq.1) then
c if (nfreqa.lt.nfreq) then
c write(*,*)'dinit_mr nfreqa<nfreq'
c write(*,*)'it should be nfreqa.ge.nfreq'
c write(*,*)'change nfreqa in param.i and recompile the code
c + or reduce nfreq in genray.in'
c stop
c endif
cSAP090808 delete jx_kin_a
c if ((i_emission_spectrum.eq.1).and.(jx_kin_a.lt.jx_kin)) then
c write(*,*)'dinit_mr jx_kina<jx_kin'
c write(*,*)'it should be jx_kin_a.ge.jx'
c write(*,*)'change jx_kin_a in param.i and recompile the code
c + or reduce jx_kin in genray.in'
c stop
c endif
if ((wallr.lt.0.d0).or.(wallr.gt.1.d0)) then
WRITE(*,*)'dinit_mr: it should be {0=< wallr =<1}'
WRITE(*,*)'but wallr=',wallr
WRITE(*,*)'change wallr in genray.in'
STOP
endif
cyup write(*,*)'dinit_mr: i_rrind',i_rrind
endif ! (i_emission.eq.1)
c---------------------------------------------------------
c read the data for for EC cone vertex coordinates calculations
c This case is used for the optimal OX mode conversion.
c /ox/
if(i_ox.eq.1) then
istart=3
prmt(3)=-prmt3 !case i_ox=1, to create the negative time
i_vgr_ini=+1
ireflm=1
!WRITE(*,*)'WARNING:dinit_mr: Enforcing id=2 for i_ox=1 run'
!id=2 !YuP[2020-07-29] Added: enforce cold plasma for i_ox=1 run
!Actually, not really needed.
endif
if(((i_ox.ne.0).and.(i_ox.ne.1)).and.(i_ox.ne.2)) then
write(*,*)'dinit_mr: i_ox can =0 or =1 or =2'
write(*,*)'in namelist /ox/ i_ox=',i_ox
write(*,*)'please change i_ox in input file'
stop 'in dinit /ox/'
endif
c------------------------------------------------------------
if(i_emission.eq.0) then
c no emission calculations, set one frequency
nfreq=1
endif
c-----------------------------------------------
c for the emission multi frequency case
c calculate the electron gyro-frequency freqncy0 at the plasma center
c---------------------------------------------
bmod=b(yma,xma,0.d0) !TL
freqncy0=28.d0*b0*bmod !GHZ
if ((i_emission.eq.0).or.(nfreq.eq.1)) then
c--------no emission or only one frequency in the emission calculations
v0=806.2d0/(frqncy*frqncy)
w0=28.d0*b0/frqncy
c-----------------------------------------------------
c set the arrays for v and w
v(1)=v0
w(1)=w0
do i=2,nbulk
v(i)=v0*charge(i)**2/dmas(i)
w(i)=w0*charge(i)/dmas(i)
cyup write(*,*)'dinit_mr: i charge(i),dmas(i),v(i),w(i)'
cyup + ,i,charge(i),dmas(i),v(i),w(i)
enddo
else
c----------------------------------------------
c for the emission multi frequency case
c calculate the electron gyro-frequency freqncy0 at the plasma center
c and create the array of the frequencies wfreq()
c---------------------------------------------
c bmod=b(yma,xma,0.d0) !TL
c freqncy0=28.0*b0*bmod !GHZ
c hfreq=(freq01-freq00)/dfloat(nfreq-1)
c write(*,*)'bmod,b0,freq01,freq00,nfreq,hfreq',
c + bmod,b0,freq01,freq00,nfreq,hfreq
c write(*,*)'freqncy0',freqncy0
c do ifreq=1,nfreq
c-----------set the array for the frequenciesc
c wfreq(ifreq)=freqncy0*(freq00+hfreq*(ifreq-1))
c enddo
c write(*,*)'dinit.f nfreq',nfreq
c--------choose the frequency wfreq(ifre0) most close to the central
c second harmonic 2*freqncy0
c ifreq0=1
c delt=dabs(wfreq(1)-2.d0*freqncy0)
c do ifreq=1,nfreq
c if (delt.gt.dabs(wfreq(ifreq)-2.d0*freqncy0)) then
c delt=dabs(wfreq(ifreq)-2.d0*freqncy0)
c ifreq0=ifreq
c endif
c write(*,*)'dinit.f ifreq,wfreq(ifreq)',ifreq,wfreq(ifreq)
c enddo
c write(*,*)'dinit.f ifreq0,wfreq(ifreq0)',ifreq0,wfreq(ifreq0)
endif
c---------------------------------------------------------
if (partner.eq.'genray_profs_in.txt' .or.
1 partner.eq.'genray_profs_in.nc') goto 30
c-------------------------------------------------------------
if ((izeff.eq.0).or.(izeff.eq.3))then
c---------------------------------------------------------
c calculation of the table for the radial profile zeff1(ndens)
call zeffcalc
c zeff1(ndens) is in common six.i
cyup do i=1,ndens
cyup write(*,*)'i',i,'zeff1(i)',zeff1(i)
cyup enddo
endif !izeff=0
c---------------------------------------------------------
if(izeff.eq.1) then
c---------------------------------------------------------
c calculation of the table for the ion densities profiles
c---------------------------------------------------------
if (nbulk.lt.3) then
WRITE(*,*)'dinit_mr: nbulk.lt.3, Zeff must be equal
1 charge(2), control it and use the option izeff=0'
STOP
else
c nbulk.ge.3
c calculation of the tables for the radial profile
c dens1(ndens,nbulk) and dens1(ndens,nbulk-1)
if( charge(nbulk).eq.charge(nbulk-1)) then
WRITE(*,*)'WARNING: in dinit_mr: nbulk(.ge.3)=',nbulk
WRITE(*,*)'in dinit: charge(nbulk)=charge(nbulk-1)'
WRITE(*,*)'it is impossible to find the ions densities'
WRITE(*,*)'change charge(nulk) or charge(nbulk-1)'
WRITE(*,*)'it should be charge(nulk)>charge(nbulk-1)'
WRITE(*,*)'or use the option izeff=0'
STOP
endif
call denscalc
!pause !!!
c------------------------------------------------
c for test
cyup do i1=1,nbulk
cyup write(*,*)'dinit_mr: after call denscalc i1=',i1
cyup do j1=1,ndens
cyup write(*,*)'j1=',j1,'dens1(j1,i1)',dens1(j1,i1)
cyup enddo
cyup enddo
cyup do j1=1,ndens
cyup zefftest=0.d0
cyup zion=0.d0
cyup do i1=2,nbulk
cyup if(dens1(j1,1).ne.0.d0) then
cyup zefftest=zefftest+(dens1(j1,i1)/dens1(j1,1))*
cyup 1 charge(i1)*charge(i1)
cyup zion=zion+charge(i1)*dens1(j1,i1)/dens1(j1,1)
cyup else
cyup write(*,*)'dinit_mr: dens1(j1,1)=0'
cyup zefftest=zefftest+1.d0*charge(i1)*charge(i1)
cyup endif
cyup enddo
cyup write(*,*)'j1',j1,'zefftest',zefftest,'zion',zion
cyup enddo
c end test
c------------------------------------------------
endif ! nbulk
endif ! izeff=1
if (izeff.eq.3) then
do i=1,nbulk
do k=1,ndens
rho=rhom(k)
psi=psi_rho(rho)
denstot=dens1(k,1)
do ii=2,nbulk
denstot=denstot+dens1(k,ii)
enddo
temp1(k,i)=prespsi(psi)/denstot/(1.6d3)
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: izeff=3,k,rho',k,rho
write(*,*)'prespsi(psi),denstot',prespsi(psi),denstot
write(*,*)'in dinit i,temp1(k,i)',i,temp1(k,i)
write(*,*)'in dinit i,dens1(k,i)',i,dens1(k,i)
write(*,*)'in dinit i,dens1(k,1)',i,dens1(k,1)
endif ! outprint
enddo
enddo
endif !izeff=3
if(izeff.eq.4) then
cSAP090801
c if(nbulk.lt.3) then
c write(*,*)'in dinit: izeff=4 nbulk=',nbulk
c write(*,*)'in dinit: it should be nbulk>2, use another '
c write(*,*)'in dinit: izeff option '
c stop
c else
c nbulk.ge.3
c calculation of the tables for the radial profiles
c dens1(ndens,nbulk),dens1(ndens,nbulk-1) and
c dens1(ndens,1)
call denscalp
!pause !!!
c test izeff=4 beg
cSAP090801
if (nbulk.ge.3) then
do j=1,ndens
szini=0.d0 !sum(i=2,nbulk){charge(i)*dens1(j,i)}
szi2ni=0.d0 !sum(i=2,nbulk){charge(i)**2*dens1(j,i)}
stini=0.d0 !sum(i=2,nbulk){temp1(j,i)*dens1(j,i})
rho=rhom(j)
psi=psi_rho(rho)
pressure=prespsi(psi)/1.6d3
do i=2,nbulk
szini=szini+charge(i)*dens1(j,i)
szi2ni=szi2ni+charge(i)*charge(i)*dens1(j,i)
stini=stini+temp1(j,i)*dens1(j,i)
enddo
prestest=temp1(j,1)*dens1(j,1)+stini
zefftest=szi2ni/dens1(j,1)
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: izeff=4,j,rho',j,rho
write(*,*)'pressure,prestest',pressure,prestest
write(*,*)'zeff,zefftest',zeff1(j),zefftest
write(*,*)'dens1(j,1),szini',dens1(j,1),szini
endif ! outprint
enddo !j
c test izeff=4 end
endif !nbulk.ge.3
endif !izeff=4
30 continue ! if (partner.eq. ....) goto20
c creation of the density,temperature,zeff and
c tpop, vflow
c spline coefficients
call spldens1
cyup write(*,*)'dinit_mr: after spldens1'
c-----test printing density,temperature,zeff
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
do j=1,ndens
write(*,*)'j,rhom(j)',j,rhom(j)
do i=1,nbulk
den_test=densrho(rhom(j),i)
tem_test=temperho(rhom(j),i)
write(*,*)'i,dens(i,rhom(j)),temp(i,rhom(j))',
& i,den_test,tem_test
enddo
enddo
endif ! outprint
c------------------------------------------------------------
c Reading or creation the non-maxwellian electron distribution
c for the calculation the anti-hermitian relativistic tensor
c------------------------------------------------------------
c i_diskf=0 no usage of the non-maxwellian electron distribution
c i_diskf=1 reading the file diskf
c i_diskf=2 readinf the file netcdfnm.nc
c i_diskf=3 analitical calculation of the non-maxwellian disribution
c i_diskf=4 analytic calculation of continuous non-Maxwellian distribution
c with three temperatures in three energy ranges
c (uses splines or tabulated distributions)
c i_diskf=5 fully analytic calculation of continuous non-Maxwellian
c distribution with three temperatures in three energy ranges.
c Generally much faster than i_diskf=4.
c----------------------------------------------------
initial=1
cyup write(*,*)'dinit_mr: before dskin i_diskf=',i_diskf
call dskin(initial,energy,pitch,rho,fdist,dfdx,dfdpitch,
. dfdp,1)
cyup write(*,*)'dinit_mr aft dskin non-Maxwellian distribution was set'
c---------------------------------------------------------
if (istart.eq.1) then
c-----------EC wave-----------
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: ncone=',ncone
write(*,*)'zst=',(zst(i),i=1,ncone),
1 'rst=',(rst(i),i=1,ncone),
1 'phist=',(phist(i),i=1,ncone)
write(*,*)'dinit_mr: betast=',(betast(i),i=1,ncone),
1 'alfast=',(alfast(i),i=1,ncone)
write(*,*)'dinit_mr: na1=', na1,'na2=',na2,
1 'powtot=',(powtot(i),i=1,ncone)
write(*,*)'dinit_mr: alpha1=', alpha1,
1 'alpha2=',(alpha2(i),i=1,ncone)
endif ! outprint
endif
if (istart.eq.2) then
c-----------LH and FW---------
c write(*,*)'zst=',zst,'rst=',rst,'phist=',phist
c write(*,*)'cnphi=',cnphi,'cnteta=',cnteta
end if
do i=1,ncone
phist(i)=phist(i)*trnspi
betast(i)=betast(i)*trnspi
alfast(i)=alfast(i)*trnspi
enddo
c--------------------------------------------------------------
c normalization of the start parameters
do i=1,ncone
zst(i)=zst(i)/r0x
rst(i)=rst(i)/r0x
enddo
c normaliszation 'diskdisk' parameters
d_disk=d_disk/r0x
rho_launching_disk=rho_launching_disk/r0x
rho_focus_disk=rho_focus_disk/r0x
sigma_launching_disk=sigma_launching_disk/r0x
c--------------------------------------------------------------
c xst=rst*dcos(phist)
c yst=rst*dsin(phist)
c-----------------------------------------------------------
c printing of total magnetic field on the magnetic axis (for control)
cyup write(*,*)'dinit_mr: yma,xma',yma,xma
bmod=b(yma,xma,0.d0)
cyup write(*,*)'dinit_mr: magn. field on the magnetic axis bmag=',bmod
psi_mag=psif(yma,xma)
cyup write(*,*)'dinit_mr: psi on the magnetic axis psi_mag=',psi_mag
cyup write(*,*)'dinit_mr: istart,nray=',istart, nray
ctest
if ((i_emission.eq.0).or.(nfreq.eq.1)) then
c--------no emission or only one frequency in the emission calculations
xi=x(yma,xma,0.d0,1)
yi=y(yma,xma,0.d0,1)
cyup write(*,*)'dinit_mr: at magnetic axis Xe,Ye ',xi,yi
c---------------------------------------------------------------
c the creation the data for the contours X_e=const,Y_e=const
c B_tot,B_tor, B_pol on the plate (rho,theta)
c These data will have the form of the tables in
c xybrhoth.dat: rho(i),theta(j),xe,ye,(xe+ye*ye),bmod,bphi,
c * dsqrt(bz**2+br**2)
c nrhomap=30
c nthetmap=100
c call mapxyb(nrhomap,nthetmap)
c write(*,*)'mapxyb was created'
c stop
endif
c---------------------------------------------------------------
c if ray start point is outside the plasma (ECR -case)
c then:
c determination of arrays :1)for ray coordinates on the ECR cone
c alphaj(nray),betaj(nray)-spherical and cylindrical angles
c 2)for wave power angle distribution
c powj(nray) -power flowing in the ray chanel at antenna
c with normalized Sum(i=1,nray)delpw0(i)=1
c---------------------------------------------------------------
if (istart.eq.1) then
c---------EC waves---------------------------------
if(outprint.eq.'enabled')then !YuP[2018-01-17] Added
write(*,*)'dinit_mr: istart=',istart
write(*,*)'dinit_mr: raypatt=',raypatt
write(*,*)'dinit_mr: ncone=',ncone
endif ! outprint
nray1=1 ! Counter for position in ray arrays
do icone=1,ncone
if (raypatt.ne.'toray') then !.eq.genray -
! defined below as tetan=0.5d0*pi-betast(icone)
tetan=0.5d0*pi-betast(icone) ! here - just for printout
else ! .eq.toray - defined below as tetan=betast(icone)/trnspi
tetan=betast(icone) ! just for printout
endif
cyup write(*,*)'alpha1,na1,na2,alpha2,phist,alfast,tetan',
cyup 1 alpha1(icone),na1,na2,alpha2(icone),phist(icone),
cyup 1 alfast(icone),tetan
c if (raypatt.ne.'toray') then
if (raypatt.eq.'genray') then
alpha1(icone)=alpha1(icone)*trnspi
alpha2(icone)=alpha2(icone)*trnspi
tetan=0.5d0*pi-betast(icone) !Polar angle (radians)
cyup write(*,*)'in dinit_mr before cone_ec'
call cone_ec(alpha1(icone),na1,na2,alpha2(icone),
1 phist(icone),alfast(icone),tetan,powtot(icone),nray,
1 alphaj(nray1),betaj(nray1),powj(nray1))
do i=nray1,(nray1-1)+nray
zstj(i)=zst(icone)
rstj(i)=rst(icone)
phistj(i)=phist(icone)
enddo
cyup write(*,*)'in dinit_mr after cone_ec: nray',nray
cyup do i=nray1,(nray1-1)+nray
cyup write(*,*)' i,powj(i)',i,powj(i)
cyup write(*,*)' i,betaj(i),alphaj(i)',i,betaj(i),alphaj(i)
cyup enddo
endif
if(raypatt.eq.'toray') then
alfast(icone)=alfast(icone)/trnspi
tetan=betast(icone)/trnspi
cyup write(*,*)'dinit_mr: bef raypat: tetan,alfast',
cyup 1 tetan,alfast(icone)
call raypat(tetan,alfast(icone),alpha1(icone),cr,nray_in,
1 gzone,mray,betaj(nray1),alphaj(nray1))
nray=nray_in
if(nray.gt.nraymax)then
if(myrank.eq.0)then
WRITE(*,*)'dinit_mr: nray>nraymax. '
WRITE(*,*)'dinit_mr: Increase nraymax in param.i'
endif
STOP
endif
do i=nray1,(nray1-1)+nray
zstj(i)=zst(icone)
rstj(i)=rst(icone)
phistj(i)=phist(icone)
c write(*,*)'zstj(i),rstj(i)=',
c + zstj(i),rstj(i)
enddo
cyup do i=nray1,(nray1-1)+nray
cyup write(*,*)'Raypat ray starting angles (degrees):'
cyup write(*,*)' i,betaj(i),alphaj(i)',i,betaj(i),alphaj(i)
cyup enddo
do i=nray1,(nray1-1)+nray
powj(i)=(powtot(icone)/nray)*1.e13
alphaj(i)=alphaj(i)*trnspi
betaj(i)=(90.-betaj(i))*trnspi
enddo
cyup write(*,*)'in dinit_mr after raypat powj(i)'
cyup do i=nray1,(nray1-1)+nray
cyup write(*,*)' i,powj(i)',i,powj(i)
cyup write(*,*)' i,betaj(i),alphaj(i)',i,betaj(i),alphaj(i)
cyup enddo
endif !(On raypatt)
if (raypatt.eq.'diskdisk') then
call disk_to_disk_rays_initial_launching_data(nray)
endif !diskdisk
c stop 'dinit.f after disk_to_disk_rays_initial_launching_dat'