-
Notifications
You must be signed in to change notification settings - Fork 3
/
Pedestal.for
764 lines (666 loc) · 26.3 KB
/
Pedestal.for
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
SUBROUTINE PEDESTAL
INCLUDE 'Soldiv.fi'
DOUBLE PRECISION TEDP,XLZ1DP,DLDT1DP,XLZ2DP,DLDT2DP
C CALCULATE PEDESTAL VALUES
C PEDESTAL WIDTH CALCULATION
gami = tibar/(tibar+tebar)
game = tebar/(tibar+tebar)
xlnbarold = xlnbar
xltibarold = xltibar
xltebarold = xltebar
deltbold = deltb
widthnold = widthn
OMEGAPOL = (1.6E-19*BFIELD/XMASS)*BETAG
CSBAR = SQRT(2.*XK*TISOL/XMASS)
RHOBAR = CSBAR/OMEGAPOL
C DELTB FIT FROM IGITKHANOV et al.
FPED = 0.134*(RMAJOR**0.96)
C PEDFAC = 1/2 IS A MACHINE DEPENDENDENT ADJUSTMENT FACTOR
C FOR DIII-D
C OPTION 1 (IGITKHANOV FIT NF,) PEDESTAL WIDTH
DELTB1 = PEDFAC*FPED*SQRT(RHOBAR*RMAJOR)
C OPTION 2 (GROEBNER&OSBORNE FIT PoP,5,1800,1998) PEDESTAL WIDTH
BPOL = BFIELD*BETAG
DELTB2 = CPED*RMAJOR*(2.*XNPED*XK*TPED/((BPOL**2)/(2.52E-6)))**0.4
c OPTIONS 3&4 ROGERS-DRAKE
RHOBARI = RHOBAR*SQRT((TISOL+TIPED)/(2.*TISOL))
BETAPED = XNBAR*XK*(TEBAR+TIBAR)*2.*1.257E-6/(BFIELD**2)
XV = (0.5*gami)**0.333
XLP = (1./XLNBAR)+gami*(1./XLTIBAR)+game*(1./XLTEBAR)
XLP = 1./XLP
C FSHAPE1 = CPED2*(1.+1.2*TRIANG)*(1. + ELONG**2)
C FSHAPE2=CPED2*(1.+(ELONG**2)*(1.+2.*(TRIANG**2)-1.3*(TRIANG**3)))
C FSHAPE = FSHAPE1
C IF(ISHAPE.EQ.2) FSHAPE = FSHAPE2
C ***********
C FSHAPE = 1.
C *********
C OPTION 3 R&D DELTB & GSLs SOLVED ITERATIVELY
DELTB3 = 2.667*XLP*((RHOBARI/RMAJOR)**.667)*XV*FSHAPE/
2 ((Q95**2)*BETAPED)
C OPTION 4 CALCULATED LATER
IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.1) DELTB = DELTB1
IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.2) DELTB = DELTB2
IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.3) DELTB = DELTB3
C BALLOONING MODE LIMIT ON PPED = PSEP*(1.+FAC)
PSEP = XK*XNSEP*TSEP
CBAL = CBALLOON
FAC = CBAL*((BFIELD**2)/(2.52E-6))*DELTB/((Q95**2)*RMAJOR*PSEP)
C HEAT REMOVAL LIMIT ON NPED*TPED*CHIPERP*LT-1 = QPERP*LPERP
C EDGE CHIR CONSISTENT WITH HEAT REMOVAL
CHIRTEMP = FCOND*FLUXHEAT*DELTB/(XNPED*XK*TPED*LOG(SQRT(1.+FAC)))
C EDGE DRAD CONSISTENT WITH PARTICLE FLUX
DRTEMP = FLUXPART*DELTB/(XNPED-XNSOL)
C CORE CHI & D SCALED FROM DEFINITIONS FOR DISRUPTION STABILITY
CHIRCORE(2) = CHIRTEMP
DRCORE = DRTEMP
IF(JJOPTPED.NE.1) GOTO 20
C OPTION 1
C EQUIPARTITION BALLOONING LIMIT, CALC CHIEDGE TO REMOVE HEAT
10 CONTINUE
TPED = TSEP*SQRT(1.+FAC)
XNPED = XNSEP*SQRT(1.+FAC)
XLNBAR = LOG(SQRT(1.+FAC))/DELTB
XLTBAR = XLNBAR
C IF(JJOPTPED.NE.1) GOTO 50
C EDGE CHIR NEEDED TO REMOVE HEAT WITH BALLOON LIMIT LT^-1
C CHIREDGE = CHIRTEMP
GOTO 75
C OPTION 2
C COMBINE HEAT REMOVAL & BALLOONING LIMITS
C IF(ITERN.LT.15) GOTO 10
20 IF(JJOPTPED.NE.2) GOTO 30
RATIO = (CHIREDGE*CBAL*((BFIELD**2)/(2.52E-6))/
2 ((Q95**2)*RMAJOR*FLUXHEAT*FCOND)) - 1.
XLTBAR = FLUXHEAT*FCOND/(XNPED*XK*TPED*CHIREDGE)
XLNBAR = RATIO*XLTBAR
TPED = TSEP*EXP(XLTBAR*DELTB)
XNPED = XNSEP*EXP(XLNBAR*DELTB)
GOTO 75
C OPTION 3
C COMBINE HEAT REMOVAL & BALLOONING LIMITS--SIMPLER
30 if(jjoptped.ne.3) goto 40
BE = FLUXHEAT*FCOND*DELTB/(CHIREDGE*XK*TSOL)-0.5*FAC*XNSEP
RADICAL = SQRT(1. + (XNSEP**2)*(1.+FAC)/(BE**2))
IF(BE.GT.0.0) XNPED = BE*(RADICAL - 1.)
IF(BE.LT.0.0) XNPED = -1.*BE*(RADICAL + 1.)
C XNPED=(XNSOL*XK*TSOL*(1.+FAC)-FLUXHEAT*FCOND*DELTB/CHIREDGE)/
C 2 (XK*TSOL)
TPED = XNSEP*TSEP*(1.+FAC)/XNPED
XLNBAR = LOG(XNPED/XNSOL)/DELTB
XLTBAR = LOG(TPED/TSEP)/DELTB
GOTO 75
C OPTIONS 4-8
C NPED FROM TRANSBARRIER IONIZATION, TPED FROM HEAT REMOVAL
40 IF(JJOPTPED.GT.8) GOTO 50
C AVERAGE TRANSPORT BARRIER IONIZATION RATE
FF = (YIONTB*(BETAG*XLPERP-0.5*DELXPT)+0.5*DELXPT*YIONTBXPT)/
1 (BETAG*XLPERP)
FY = ELONG*AMINOR*DELTB/(2.*SQRT(0.5*(1.+ELONG**2))*TAUN*DREDGE)
XNPED = XNSEP + XNAV*FY*(1.- 0.5*FF/FLUXPART)
RECFRAC = FF
IF(JJOPTPED.GT.4) XNPED = APED*XNAV
IF(JJOPTPED.EQ.8) XNPED = 1.05*XNSEP
X = 2.*FCOND*FLUXHEAT*DELTB/((1.+XNPED/XNSEP)*PSEP*CHIREDGE)
TPED=TSEP*(X+1.)
IF(JJOPTPED.EQ.8) TPED = 1.05*TSEP
C CHECK BALLOONING LIMIT
FF = XNPED*TPED/(XNSEP*TSEP)
IF(FF.LE.(1.+FAC)) GOTO 45
IF(JJOPTPED.EQ.5) XNPED = XNSEP*TSEP*(1.+FAC)/TPED
IF(JJOPTPED.EQ.6) TPED = XNSEP*TSEP*(1.+FAC)/XNPED
45 XLNBAR = LOG(XNPED/XNSEP)/DELTB
XLTBAR = LOG(TPED/TSEP)/DELTB
GOTO 75
C OPTION 9--FIXED NPED/NAV,TPED FROM BALLOONING LIMIT, CHI FROM HEAT REMOVAL
50 IF(JJOPTPED.NE.9) GOTO 55
XNPED = APED*XNAV*RATNLINEAV
write(*,*) 'XNAV =', XNAV
c ALPHAN = (XNCTRPED*APED*RATNLINEAV-1.)/(1.-APED*RATNLINEAV)
XN0 = (1.+ALPHAN)*XNAV - ALPHAN*XNPED
TPED = XNSEP*TSEP*(1.+FAC)/XNPED
alphat = alphat2
X1 = (TAV/(APED*RATNLINEAV)) - ALPHAT*TPED*(1./(1.+ALPHAT) +
2 (XNCTRPED-1.)/((1.+ALPHAN)*(1.+ALPHAN+ALPHAT)))
X2 = 1./(1.+ALPHAT) + (XNCTRPED-1.)/(1.+ALPHAN+ALPHAT)
T0 = X1/X2
CHIREDGE = 2.*FCOND*FLUXHEAT*DELTB/(XK*(TPED-TSEP)*(XNPED+XNSOL))
XLNBAR = 1.0/(0.5*(XNPED+XNSEP)*DELTB/(XNPED-XNSEP))
XLTBAR = 1.0/(0.5*(TPED+TSEP)*DELTB/(TPED-TSEP))
deltb = widthnx
GOTO 75
C OPTION 10--FIXED TPED/TAV,NPED FROM BALLOONING LIMIT, CHI FROM HEAT REMOVAL
C PREDICTIVE MODE FOR PEDESTAL MODEL
55 IF(JJOPTPED.NE.10) GOTO 75
alphat = alphat2
IF(ITERN.EQ.1) THEN
TESEP = TSEP
TISEP = TSEP
TEPED = TPED
TIPED = TPED
ENDIF
FLUXHEATE = HEATFRACE*FLUXHEAT
FLUXHEATI = (1.-HEATFRACE)*FLUXHEAT
OMEGAI = (1.6E-19*Bfield/XMASS)
CSBARI = SQRT(XK*(TIPED+TISOL)/XMASS)
IF(JOPTPED2.EQ.2) CSBARI = SQRT(XK*2.*TIPED/XMASS)
RHOBARI = CSBARI/OMEGAI
TEBAR = 0.5*(TESOL+TEPED)
IF(JOPTPED2.EQ.2) TEBAR = TEPED
TIBAR = 0.5*(TISEP+TIPED)
IF(JOPTPED2.EQ.2) TIBAR = TIPED
TAVBAR = 0.5*(TEBAR+TIBAR)
TRAT = TIBAR/TEBAR
BALP = 2.667*FSHAPE*((RHOBARI/DELTB)**0.667)*
2 (((0.5/(1.+(1./TRAT)))*(RMAJOR/DELTB))**0.333)
c BALP=(1.+1.2*TRIANG)*(((0.5/(1.+TRAT))*(RHOBARI**2)*RMAJOR)**.333)
c 2 /(DELTB*3./8.)
BALP = 1.0
PRESSTB = 0.5*XK*(XNPED*(TIPED+TEPED) + XNSOL*(TISEP+TESEP))
c IF(JOPTPED2.EQ.2) PRESSTB = XK*XNPED*(TIPED+TEPED)
DPDRCRIT = (cmhd/((Q95**2)*RMAJOR))*((BFIELD**2)/2.52E-6)
XLMHD = PRESSTB/DPDRCRIT
C IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.3.AND.ITERN.GT.15)
C 2 DELTB = XLMHD
OMEGTI = OMREWEAKI(14)
OMEGTE = OMREWEAKE(14)
IF(OMEGTI.LT.0.0) OMEGTI = 0.0
IF(OMEGTE.LT.0.0) OMEGTE = 0.0
IF(iopttran.eq.0) THEN
OMEGTI = 0.0
OMEGTE = 0.0
OMEGTIN = 0.0
END IF
C SATURATION **********************************
C IF(OMEGTI.GT.3.0E4) OMEGTI = 3.0E4
C
C IF(OMEGTE.GT.3.0E4) OMEGTE = 3.0E4
OMEGTIN = OMEGTI
IF(ITERN.LT.90) GOTO 59
XCV = 0.0
59 CONTINUE
XI = 1. + C89*OMEGTI*(DELTB**2)/(1.E-4*CHITBI)
XE = 1. + C89*OMEGTE*(DELTB**2)/(1.E-4*CHITBE)
XIN= 1. + C89N*OMEGTIN*(DELTB**2)/(1.E-4*CHITBI)
IF(ITERN.LT.30) THEN
IF(XI.GT.6.0) XI = 6.0
IF(XE.GT.6.0) XE = 6.0
IF(XIN.GT.6.0) XIN = 6.0
ENDIF
C XI = 1.0
C XE = 1.0
C XLTIBAR = PRESSTB*1.e-4*CHITBI*XI/(FCOND*FLUXHEAT)
C XLTEBAR = PRESSTB*1.e-4*CHITBE*XE/(FCOND*FLUXHEAT)
C CHRAT = (XI/XE)*TRAT/(CHEI*RXLTIXLTE)
C XLTEBAR = (PRESSTB*1.E-4*CHITBE*XE*(1.+CHRAT))/
C 2 (FCOND*FLUXHEAT*(1.+TRAT))
C XLTIBAR = RXLTIXLTE*XLTEBAR
C XLNBAR = 1./XLMHD - 0.5*((1./XLTIBAR)+(1./XLTEBAR))
C XLNBAR = 1./XLNBAR
Z = (1.+TRAT)/(1.+(1./TRAT))
CIRCUM = 6.28*AMINOR*SQRT((1.+(ELONG**2))/2.)
WTXPT = DELXPT/CIRCUM
WXPT = 0.5
C ***** IF AVERAGE NOT 50-50, NEED TO READ IN WTXPT*******
XNOBARAV = XNOBAR*(1.-WTXPT) + XNOBARXPT*WTXPT
YIONBARAV = YIONTB*(1.-WTXPT) + YIONTBXPT*WTXPT
XNOCOLDBARAV = XNOCOLDBAR*(1.-WTXPT) + XNOCOLDBARXPT*WTXPT
XNOSOLAV = XNOSOL*(1.-WTXPT) + XNOSOLXPT*WTXPT
IF(ITERN.EQ.1) XLNBAR = 1.E-2
C2 = 1.E-13
TEDP = TEBAR
NZIMP1 = IZINJECT
NZIMP2 = IZINTRIN
CALL CEFITS(NZIMP1,TEDP,XLZ1DP,0,DLDT1DP)
CALL CEFITS(NZIMP2,TEDP,XLZ2DP,0,DLDT2DP)
XFO = XNOBARAV/XNBAR
IZ2 = 6
IF(NZIMP2.EQ.4.or.nzimp2.eq.6.or.nzimp2.eq.74) then
CALL CXRCEFITS(IZ2,TEDP,XFO,XLZ2DP,DLDT2DP,ZAV2)
endif
XNZLZBAR = XNBAR*(CFZINJTB*XLZ1DP + CFZINTTB*XLZ2DP)*QZMULTCORE*C2
DLZDTBAR = XNBAR*(CFZINJTB*DLDT1DP+CFZINTTB*DLDT2DP)*QZMULTCORE*C2
ZL = BETAG*XLPERP - 0.5*DELXPT
FCTR = 1.
FCTR2 = 1.
IF(IGRADPED.EQ.3) FCTR = TIPED/TIBAR
IF(IGRADPED.EQ.3) FCTR2 = TEPED/TEBAR
EIONM = EIONBAR
C CALCULATE DELTB
C OPTION 4 R&D DELTB & GSLs SOLVED SIMULTANEOUSLY
PSEP = 2.*XK*XNSEP*TSEP
PPED = 2.*XK*XNPED*TPED
PRESSTB = 0.5*(PSEP + PPED)
C USING ROGERS-DRAKE
PCRIT = 2.667*(BFIELD**2/2.514E-6)*((RHOBARI/RMAJOR)**.667)*
2 XV*FSHAPE/(Q95**2)*ccrit
C DENSITY WIDTH = DIFFUSION MFP
C VOBAR = SQRT(2.*XK*TIBAR/XMASS)
IF(IDRAKE.EQ.0) THEN
if((pcrit/psep).le.1.0.and.itern.lt.10) psep = 1.5*pcrit
G = LOG(2.*(PCRIT/PSEP) - 1.)*FSHAPE
IF(JOPTPED2.EQ.1) G = LOG(2.*(PCRIT/PSEP) - 1.)*FSHAPE
IF(JOPTPED2.EQ.2) G = LOG(PCRIT/PSEP)*FSHAPE
ENDIF
IF(IDRAKE.EQ.1) G = 2.667*((RHOBARI/RMAJOR)**.667)*XV*FSHAPE/
2 ((Q95**2)*BETAPED)
IF(IDRAKE.EQ.2) G = 0.75*BETAPED*(Q95**2)*FSHAPE/
2 (((RHOBARI/RMAJOR)**.667)*XV)
DPDRCRIT = (CMHD*((BFIELD**2)/2.52E-6)/((Q95**2)*RMAJOR))
SIGION = SVIONBAR/VOBAR
SIGTRAN = (SVIONBAR + SVATBAR - 0.667*SVELBAR)/VOBAR
GAME = TEBAR/(TEBAR+TIBAR)
GAMI = TIBAR/(TEBAR+TIBAR)
DELTB4OLD = DELTB4
IF(MODPED.EQ.0) THEN
BFAC = ((FLUXPART/XNBAR)-VPINCH)/(1.E-4*FI*CHITBI*XI) +
2 GAMI*((FLUXHEATI/(XK*TIBAR))-2.5*FLUXPART)/
3 (XNBAR*1.E-4*CHITBI*XI) +
4 GAME*((FLUXHEATE/(XK*TEBAR))-2.5*FLUXPART)/
5 (XNBAR*1.E-4*CHITBE*XE)
AFAC = 0.5*(GAMI*(1.5*XNOCOLDBARAV*SVATBAR
3 + 2.5*XNOBARAV*SVIONBAR)/(1.E-4*CHITBI*XI) +
4 GAME*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 (EIONM/TEBAR) +2.5)/(1.E-4*CHITBE*XE) -
5 XNOBARAV*SVIONBAR/(1.E-4*FI*CHITBI*XI))
C FIX 6/21/02
IF((1.+4.*AFAC*G/(BFAC**2)).LE.0.0) AFAC = 0.
IF(AFAC.EQ.0.0) DELTB4 = G/BFAC
IF(AFAC.NE.0.0) THEN
DELTB4 = (BFAC/(2.*AFAC))*(SQRT(1.+4.*AFAC*G/(BFAC**2))-1.)
ENDIF
C IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
WIDTHN = DELTB4
ENDIF
IF(MODPED.EQ.1.OR.MODPED.EQ.2) THEN
WIDTHN = cmfp/(XNBAR*SQRT(3.*SIGION*SIGTRAN))
IF (ITERN.LT.5.AND.WIDTHN.LT.5.E-3) WIDTHN = 5.E-3
AFAC = 0.5*(GAMI*(1.5*XNOCOLDBARAV*SVATBAR
3 + 2.5*XNOBARAV*SVIONBAR)/(1.E-4*CHITBI*XI) +
4 GAME*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 ((EIONM/TEBAR) +2.5))/(1.E-4*CHITBE*XE))
BFAC = ((FLUXPART/XNBAR)-VPINCH-0.5*XNOBARAV*SVIONBAR*WIDTHN)/
1 (1.E-4*FI*CHITBI*XI) +
2 GAMI*((FLUXHEATI/(XK*TIBAR))-2.5*FLUXPART)/
3 (XNBAR*1.E-4*CHITBI*XI) +
4 GAME*((FLUXHEATE/(XK*TEBAR))-2.5*FLUXPART)/
5 (XNBAR*1.E-4*CHITBE*XE)
IF(AFAC.EQ.0.0) DELTB4 = G/BFAC
IF(AFAC.NE.0.0) THEN
DELTB4 = (BFAC/(2.*AFAC))*
2 (SQRT(1.+4.*AFAC*G/(BFAC**2))-1.)
ENDIF
IF(MODPED.EQ.2) DELTB4 = WIDTHN
IF(MODPED.EQ.1.AND.ITERN.LT.5) DELTB4 = WIDTHN
C IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
ENDIF
C IF(MODPED.EQ.2) THEN
C ASSOCIATE DELTP = DELTN
C WIDTHN = 1./(XNBAR*SQRT(3.*SIGION*SIGTRAN))
C DELTB4 = widthn
C ENDIF
IF(MODPED.EQ.3) THEN
C USING BALLOONING-PEELING MODE (-dp/dr)^crit LIMIT
goto 326
DELTB4OLD = DELTB4
IF(ITERN.EQ.1) DELTB4OLD = 1.E-2
DTBI = FI*1.E-4*CHITBI*XIN
DPDRCRIT = (CMHD*((BFIELD**2)/2.52E-6)/((Q95**2)*RMAJOR))
XLMHD = PRESSTB/DPDRCRIT
XLMHDMIN1 = 1./XLMHD
C ITERATE ON DELTB FOR LP = LMHD
DELTB0 = DELTB4OLD
init = 0
315 init = init + 1
DE = (((FLUXHEATE)/(XK*TEBAR))-CC*FLUXPART*FCTR2)/XNBAR +
2 0.5*DELTB0*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 (EIONM/TEBAR+CC))
DI = (((FLUXHEATI)/(XK*TIBAR))-CC*FLUXPART*FCTR)/XNBAR +
2 0.5*DELTB0*(1.5*XNOCOLDBARAV*SVATBAR +
3 CC*XNOBARAV*SVIONBAR)
DPART = (FLUXPART/XNBAR)- 0.5*XNOBARAV*SVIONBAR*FCTR*DELTB0-
2 VPINCH
XLNBAR = DTBI*(1.+CPINCH)/DPART
XLTEBAR = 1.E-4*CHITBE*XE/DE
XLTIBAR = 1.E-4*CHITBI*XI/DI
IF(ITERN.LT.5.AND.XLTEBAR.LE.5E-3) XLTEBAR = 5.E-3
IF(ITERN.LT.5.AND.XLTIBAR.LE.5E-3) XLTIBAR = 5.E-3
IF(ITERN.LT.5.AND.XLNBAR.LE.5E-3) XLNBAR = 5.E-3
GAME = TEBAR/(TEBAR+TIBAR)
GAMI = TIBAR/(TEBAR+TIBAR)
XLPMIN1 = (1./XLNBAR)+(GAME/XLTEBAR)+(GAMI/XLTIBAR)
XLP = 1./XLPMIN1
DDEL = 0.001
320 XYZ = XLPMIN1/XLMHDMIN1 - 1.0
IF(ABS(XYZ).LT.DDEL) GOTO 325
IF(XYZ.GT.0.0) DELTB0 = DELTB0 + DDEL
IF(XYZ.LT.0.0) DELTB0 = DELTB0 - DDEL
IF(DELTB0.LT.5.E-3.AND.ITERN.LT.5) THEN
DELTB0 = 5.E-3
GOTO 325
ENDIF
if(init.gt.5.and.itern.lt.5) goto 325
GOTO 315
325 CONTINUE
DELTB4 = DELTB0
goto 330
326 BFAC = DPDRCRIT/PSEP
AFAC = 2.*((1.+ CPED1)/(1.+TISEP/TESEP))*
2 EXP(2.)/(XLNBAR*XLTEBAR)
DELTB4 = (BFAC/(2.*AFAC))*(1.+SQRT(1.+4.*AFAC/(BFAC**2)))
328 dpdrnom = (((BFIELD**2)/2.52E-6)/((Q95**2)*RMAJOR))
if(xltebar.ge.xltibar) xltibar = xltebar + 0.001
af1 = 2.*exp(2.)*(1.+cped1)/(xlnbar*xltebar)
af2 = ((1./xltebar)-(1./xltibar))*cped1*dpdrnom/psEP
cmhdmax = af1/af2
if(cmhd.ge.cmhdmax) cmhd = cmhdmax
dpdrcrit = cmhd*dpdrnom
afac = cmhd*af2 - af1
bfac = ((1./xltebar)-(1./xltibar))*cped1 +
2 (1.+cped1)*dpdrcrit/psEP
cfac = 1. + cped1
afac = abs(afac)
deltb4 = (bfac/(2.*afac))*(1.+sqrt(1.+4.*afac*cfac/(bfac**2)))
C DELTB4 = ((DPDRCRIT/PRESSTB)-BFAC)/AFAC
C IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
330 IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
WIDTHN = DELTB4
ENDIF
IF(MODPED.EQ.4) THEN
WIDTHN = cmfp/(XNBAR*SQRT(3.*SIGION*SIGTRAN))
IF(ITERN.LE.5.AND.WIDTHN.LT.5.E-3) WIDTHN = 5.E-3
DELTB4 = WIDTHN
XLMHD = PRESSTB/DPDRCRIT
ENDIF
IF(MODPED.EQ.5) THEN
DTBI = FI*1.E-4*CHITBI*XIN
WIDTHN = ((DTBI/XLNBAR)-(FLUXPART/XNBAR)+VPINCH)/
2 (0.5*XNOBARAV*SVIONBAR)
IF(ITERN.LE.5.AND.WIDTHN.LT.5.E-3) WIDTHN = 5.E-3
DELTB4 = WIDTHN
ENDIF
IF(MODPED.EQ.6) THEN
IF(AFAC.EQ.0.0) DELTB4 = G/BFAC
IF(AFAC.NE.0.0) THEN
DELTB4 = (BFAC/(2.*AFAC))*
2 (SQRT(1.+4.*AFAC*G/(BFAC**2))-1.)
ENDIF
IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
WIDTHN = DELTB4
ENDIF
IF(MODPED.EQ.7) THEN
IF(AFAC.EQ.0.0) DELTB4 = G/BFAC
IF(AFAC.NE.0.0) THEN
DELTB4 = (BFAC/(2.*AFAC))*
2 (SQRT(1.+4.*AFAC*G/(BFAC**2))-1.)
ENDIF
IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
WIDTHN = cmfp/(XNBAR*SQRT(3.*SIGION*SIGTRAN))
ENDIF
C DELTB4 = (G/BFAC)*(1. - XX + 2.*(XX**2) )
C IF(ITERN.LT.20) GOTO 65
60 PTB = XNPED*XK*TEPED*(EXP(-.5*DELTB4*(1./XLNBAR + 1./XLTEBAR))
2 + CPED1*EXP(-.5*DELTB4*(1./XLNBAR + 1./XLTIBAR)))
c IF(ABS(PTB/PCRIT-1.).LT.0.05) GOTO 65
c DELTB4 = DELTB4*(1. + (PTB/PCRIT))
c IF(PTB/PCRIT.LT.1.0) DELTB4 = DELTB4*(1. - (PTB/PCRIT))
c GOTO 60
65 IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.4) DELTB =DELTB4
C OPTION 5 IDEAL BALLOONING MODE SETS DELTB
GBAL = 0.6*SHEARQ*((BFIELD**2)/2.514E-6)/(PRESSTB*(Q95**2)*RMAJOR)
C DELTB5 = (CBALL*GBAL*FSHAPE - BFAC)/AFAC
IF(JJOPTPED.EQ.10.AND.IOPTPEDWIDTH.EQ.5) DELTB = DELTB5
C EVALUATE MHD IDEAL BALLOONING MODE LIMITS ON GRADIENT SCALE LENGTHS
C CALL SECONDSTAB
c CRITICAL HEAT FLUX
C YY = 0.667*((BFIELD**2)/(2.514E-6*PRESSTB))*
C 2 *((CPED1/(2.*(1.+CPED1)))**0.333)
C YZ = (-1.*XNOBARAV*SVIONBAR*(TIBAR+TEBAR)*XK/(FI*1.E-4*CHITBI) +
C 2 (1.5*XNOCOLDBARAV*SVATBAR +
C 3 CC*XNOBARAV*SVIONBAR)*XK*TIBAR/(1.E-4*CHITBI) +
C 4 (XNZLZBAR+XNOBARAV*SVIONBAR*XK*
C 3 (EIONM+TEBAR*CC))/(1.E-4*CHITBE) )
C YZ = ABS(YZ)
C AZ = (4.*XNBAR*SQRT(1.+CPED1)*((RHOBARI/RMAJOR)**0.333)/Q95)*
C 2 SQRT(YY*YZ)
C BZ = FLUXPART*((TIBAR+TEBAR)*XK/(FI*1.E-4*CHITBI) -
C 2 CC*XK*(TIBAR/(1.E-4*CHITBI) + TEBAR/(1.E-4*CHITBE))) -
C 3 XK*(TEBAR+TIBAR)*XNBAR*VPINCH/(1.E-4*CHITBE)
C CRITICAL HEAT FLUX (WHEN AFAC < 0)
C IF(ITERN.LT.83) GOTO 125
C ZM = 0.
C125 ZM = 2.*PRESSTB*SQRT(G*ABS(AFAC))
C QHL = (ZM-BZ)/
C 2 (FISEP/(1.E-4*CHITBI) + FESEP/(1.E-4*CHITBE))
C BZL = FLUXPART*((TIBAR+TEBAR)*XK/(FI*1.E-4*CHITBLI) -
C 2 CC*XK*(TIBAR/(1.E-4*CHITBLI) + TEBAR/(1.E-4*CHITBLE))) -
C 3 XK*(TEBAR+TIBAR)*XNBAR*VPINCH/(1.E-4*CHITBLE)
C QLH = (2.*PRESSTB*SQRT(G*ABS(AFAC))-BZL)/
C 2 (FISEP/(1.E-4*CHITBLI) + FESEP/(1.E-4*CHITBLE))
C QRHL = QHL/(FLUXHEATE+FLUXHEATI)
C S = 39.48*RMAJOR*AMINOR*SQRT(0.5*(1.+(ELONG**2)))
C QCRITFIT = 0.054E6*((XNEL*1.E-20)**0.49)*(BFIELD**0.85)/(S**0.16)
C QCRITFIT = QCRITFIT*(1. - FRACRAD)
IF(IGRADPED.GT.1) THEN
DE = (((FLUXHEATE)/(XK*TEBAR))-CC*FLUXPART*FCTR2)/XNBAR +
2 0.5*DELTB*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 (EIONM/TEBAR+CC))
DI = (((FLUXHEATI)/(XK*TIBAR))-CC*FLUXPART*FCTR)/XNBAR +
2 0.5*DELTB*(1.5*XNOCOLDBARAV*SVATBAR +
3 CC*XNOBARAV*SVIONBAR)
DPART = (FLUXPART/XNBAR)- 0.5*XNOBARAV*SVIONBAR*FCTR*WIDTHN-VPINCH
ENDIF
if(itern.lt.50) goto 5000
xxcb = 12.
5000 continue
IF(IGRADPED.EQ.1) THEN
DE = (((FLUXHEATE)/(XK*TEBAR))-CC*FLUXPART*FCTR2)/XNBAR
C DE = (((FLUXHEATE-fluxheateanom)/(XK*TESOL))-2.5*FLUXPART)/XNSOL
DPART = (FLUXPART/XNBAR)- VPINCH
DI = (((FLUXHEATI)/(XK*TIBAR))-CC*FLUXPART*FCTR)/XNBAR
C DI = (((FLUXHEATI-fluxheatianom)/(XK*TISOL))-2.5*FLUXPART)/XNSOL
ENDIF
XLTEBAR = 1.E-4*CHITBE*XE/DE
XLTIBAR = 1.E-4*CHITBI*XI/DI
IF(ITERN.LT.5.AND.XLTEBAR.LE.5E-3) XLTEBAR = 5.E-3
IF(ITERN.LT.5.AND.XLTIBAR.LE.5E-3) XLTIBAR = 5.E-3
C DPART = (FLUXPART/XNSOL)-VPINCH
C ************************
C ASSOCIATE PARTICLE TRANSPORT WITH ION TRANSPORT IN EDGE TB
DTBI = FI*1.E-4*CHITBI*XIN
C *************************
C CALCULATE DENSITY GRADIENT SCALE LENGTH
XLNBAR1 = DTBI*(1.+CPINCH)/DPART
IF(ITERN.LT.5.AND.XLNBAR1.LE.0.005) XLNBAR1 = 0.005
XLNBAR2 = (1./XLMHD)-(1./XLTEBAR)*GAME - (1./XLTIBAR)*GAMI
XLNBAR2 = 1./XLNBAR2
IF(MODPED.EQ.0) XLNBAR = XLNBAR1
IF(MODPED.EQ.1) XLNBAR = XLNBAR1
IF(MODPED.EQ.2) XLNBAR = XLNBAR1
IF(MODPED.EQ.3) XLNBAR = XLNBAR1
IF(MODPED.EQ.4) XLNBAR = XLNBAR2
IF(MODPED.EQ.5) XLNBAR = XLNBAR2
IF(MODPED.EQ.6) XLNBAR = XLNBAR2
IF(MODPED.EQ.7) XLNBAR = XLNBAR2
IF(XLNBAR.LT.0.005) XLNBAR = 0.005
c****************new 6/17/02************************
c RD + BALLOONING + TRANSPORT + NEUTRAL PENETRATION 5/30/02
IF(IOPTPEDWIDTH.NE.10) GOTO 369
C pressure width set by mhd pressure limit and pressure grad limit
WIDTHP = PCRIT*LOG(2.*(PCRIT/PSEP)-1.)/DPDRCRIT
if(widthp.le.0.0) widthp = 5.e-3
WIDTHN = cmfp/(XNBAR*SQRT(3.*SIGION*SIGTRAN))
c neutral penetration sets both widths for modped = 2
if(modped.eq.2) widthp = widthn
c mhd sets both widths for modped = 0
if(modped.eq.0) widthn = widthp
if(modped.eq.3) widthp = widthn
if(modped.eq.4) then
BFAC = ((FLUXPART/XNBAR)-VPINCH)/(1.E-4*FI*CHITBI*XI) +
2 GAMI*((FLUXHEATI/(XK*TIBAR))-2.5*FLUXPART)/
3 (XNBAR*1.E-4*CHITBI*XI) +
4 GAME*((FLUXHEATE/(XK*TEBAR))-2.5*FLUXPART)/
5 (XNBAR*1.E-4*CHITBE*XE)
AFAC = 0.5*(GAMI*(1.5*XNOCOLDBARAV*SVATBAR
3 + 2.5*XNOBARAV*SVIONBAR)/(1.E-4*CHITBI*XI) +
4 GAME*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 (EIONM/TEBAR) +2.5)/(1.E-4*CHITBE*XE) -
5 XNOBARAV*SVIONBAR/(1.E-4*FI*CHITBI*XI))
C FIX 6/21/02
IF((1.+4.*AFAC*G/(BFAC**2)).LE.0.0) AFAC = 0.
IF(AFAC.EQ.0.0) DELTB4 = G/BFAC
IF(AFAC.NE.0.0) THEN
DELTB4 = (BFAC/(2.*AFAC))*(SQRT(1.+4.*AFAC*G/(BFAC**2))-1.)
ENDIF
C IF(ITERN.GE.5) DELTB4 = 0.5*(DELTB4 + DELTB4OLD)
IF(DELTB4.LT.5.E-3.AND.ITERN.LE.5) DELTB4 = 5.E-3
WIDTHN = DELTB4
widthp = widthn
ENDIF
C ratio of gsl from transport
DE = (((FLUXHEATE)/(XK*TEBAR))-2.5*FLUXPART*FCTR2)/XNBAR +
2 0.5*WIDTHP*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
3 (EIONM/TEBAR+2.5))
DI = (((FLUXHEATI)/(XK*TIBAR))-2.5*FLUXPART*FCTR)/XNBAR +
2 0.5*WIDTHP*(1.5*XNOCOLDBARAV*SVATBAR +
3 2.5*XNOBARAV*SVIONBAR)
SQUIGIE = (CHITBe/CHITBi)*(DI/DE)
DPART = (FLUXPART/XNBAR)- 0.5*XNOBARAV*SVIONBAR*FCTR*WIDTHN-VPINCH
DTBI = FI*1.E-4*CHITBI*XIN
SQUIGNE = (1.E-4*CHITBE/DTBI)*(DPART/DE)
C LTe from pressure grad constraint
GAME = TEBAR/(TEBAR+TIBAR)
GAMI = TIBAR/(TEBAR+TIBAR)
IF(MODPED.EQ.1)
1XLTEBAR = (GAME+GAMI*SQUIGIE)/((DPDRCRIT/PCRIT) - (1./XLNBAR))
IF(MODPED.EQ.0.or.modped.eq.3.or.modped.eq.4)
1XLTEBAR = (SQUIGNE+GAME+GAMI*SQUIGIE)/(DPDRCRIT/PCRIT)
IF(XLTEBAR.LT.0.0) XLTEBAR = 0.005
c LTi from transport
XLTIBAR = XLTEBAR/SQUIGIE
c density gsl from transport
if(modped.eq.1) XLNBAR = DTBI/DPART
if(modped.ne.1) XLNBAR = XLTEBAR/SQUIGNE
c associate deltb = widtht
if(modped.eq.0) DELTB = WIDTHP
if(modped.eq.1) DELTB = WIDTHP
if(modped.eq.2) DELTB = WIDTHN
if(modped.eq.3) DELTB = WIDTHN
if(modped.eq.4) deltb = widthp
if(itern.lt.5) widthN = widthP
C********************NEW 6/17/02*******************************
369 if(itern.gt.10) then
xlnbar = 0.5*(xlnbarold+xlnbar)
xltibar = 0.5*(xltibarold+xltibar)
xltebar = 0.5*(xltebarold+xltebar)
deltb = 0.5*(deltbold+deltb)
widthn = 0.5*(widthnold+widthn)
endif
C BALLOONING INDEX BI>1 INSTABILITY, < STABLE
xlp = 1./((1./xlnbar)+gami*(1./xltibar)+game*(1./xltebar))
BIA = xlmhd/xlp
X1NOLD = X1N
X1IOLD = X1I
X1EOLD = X1E
X1N = (WIDTHN/XLNBAR)
X1N = 0.5*(X1N+X1NOLD)
XNPED = XNSEP*EXP(X1N)
X1E = DELTB/XLTEBAR
X1I = DELTB/XLTIBAR
X1E = 0.5*(X1E+X1EOLD)
X1I = 0.5*(X1I+X1IOLD)
X1E = EXP(-1.*X1E)
X1I = EXP(-1.*X1I)
C ****** new 6/17/02
XQ = CPED1*X1I/X1E
TESEP = 2.*TSEP/(1. + XQ)
TISEP = XQ*TESEP
TEPED = TESEP/X1E
TIPED = TISEP/X1I
c ********
TPED = 0.5*(TEPED + TIPED)
IF(TPED.LT.0.) TPED = 200.
PSEP = XK*XNSEP*(TISEP+TESEP)
PPED = XK*XNPED*(TIPED+TEPED)
C ELM heat flux LIMITS
C ALPHE = XNU*XNZLZBAR/(XK*TEBAR)-DLZDTBAR +
C 2 (XNU-1.)*SVIONBAR*(EIONM/TEBAR+1.5)
C ALPHI = (XNU-1.)*1.5*(XNOCOLDBARAV*SVATBAR+XNOBARAV*SVIONBAR)
DENOME = (1.E-4*CHITBE+0.6667*ALPHE*C89*(DELTB**2))/
2 (SQRT(8.*XNU*C89/3.)*DELTB)
DENOMI = (1.E-4*CHITBI+0.6667*ALPHI*C89*(DELTB**2))/
2 (SQRT(8.*XNU*C89/3.)*DELTB)
C DENOMI = 0.5*DELTB*(1.5*XNOCOLDBARAV*SVATBAR +
C 1 1.5*(2.*FCTR-1.)*XNOBARAV*SVIONBAR)
C DENOME = 0.5*DELTB*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
C 1 (EIONM/TEBAR+1.5*(2.*FCTR2-1.)))
C PELME = (FLUXHEATE-1.5*XK*TEBAR*FLUXPART)/DENOME
C PELMI = (FLUXHEATI-1.5*XK*TIBAR*FLUXPART)/DENOMI
XNUME = ((FLUXHEATE/(XK*TEBAR)-CC*FLUXPART)/XNBAR) +
2 (0.5*DELTB*((XNZLZBAR/(XK*TEBAR))+XNOBARAV*SVIONBAR*
1 (EIONM/TEBAR)))
XNUMI = ((FLUXHEATI/(XK*TIBAR)-CC*FLUXPART)/XNBAR) +
2 (0.5*DELTB*(CC*XNOCOLDBARAV*SVATBAR +
1 CC*XNOBARAV*SVIONBAR))
ELMINDEXE = XNUME/DENOME
ELMINDEXI = XNUMI/DENOMI
c goto 75
C H-MODE INDEX
C DENOME = SQRT(ALPHE*1.E-4*CHITBE/XNU)
C DENOMI = SQRT(ALPHI*1.E-4*CHITBI/XNU)
C IF(DENOME.EQ.0.0) DENOME = 1.0
C IF(DENOMI.EQ.0.0) DENOMI = 1.0
C HINDEXE = XNUME/DENOME
C HINDEXI = XNUMI/DENOMI
C WE0 = -1.*(1.E-4*CHITBE-0.667*ALPHE*C89*(DELTB**2))/
C 1 (2.*C89*(DELTB**2))
C WI0 = -1.*(1.E-4*CHITBE-0.667*ALPHI*C89*(DELTB**2))/
C 1 (2.*C89*(DELTB**2))
C CALCULATE TRANSPORT BARRIER AVERAGE VALUES
75 XNBAR = 0.5*(XNSEP+XNPED)
TBAR = 0.5*(TSEP + TPED)
if(jjoptped.eq.9) then
tisolx = tsepexi
tesolx = tsepexe
tsolx = 0.5*(tisolx+tesolx)
tepedx = tpedexe
tipedx = tpedexi
tpedx = 0.5*(tepedx+tipedx)
tebarx = 0.5*(tesolx+tepedx)
tibarx = 0.5*(tisolx+tipedx)
xnbarx = 0.5*(xnpedex+xnsepex)
xnsolx = xnsepex
xnpedx = xnpedex
xnbarx = 0.5*(xnsolx+xnpedx)
xlnbarx = 1./gradnbar(3)
xltebarx = 1./gradtebar(3)
xltibarx = 1./gradtbar(3)
PSOLx = 2.*XK*XNSOL*TSOL
PPEDx = 2.*XK*XNPED*TPED
tbar = 0.5*(tebarx+tibarx)
xnbar = xnbarx
deltb = widthnx
endif
C EXCESS OF NOMINAL BALLOONING LIMIT
BALP = 1.0
PRESSTB = 0.5*XK*(XNPED*(TIPED+TEPED) + XNSEP*(TISEP+TESEP))
PTB = 0.5*(PPED + PSEP)
PTD = XK*(XNPED*TPED+XNSEP*TSEP)
C IF(JOPTPED2.EQ.2) PRESSTB = XK*XNPED*(TIPED+TEPED)
DPDRCRIT = (CMHD/((Q95**2)*RMAJOR))*((BFIELD**2)/2.52E-6)
XLMHD = PRESSTB/DPDRCRIT
xlmhdmin1 = 1./xlmhd
GAME = TEBAR/(TEBAR+TIBAR)
GAMI = TIBAR/(TEBAR+TIBAR)
XLPMIN1 = (1./XLNBAR)+(GAME/XLTEBAR)+(GAMI/XLTIBAR)
XLP = 1./XLPMIN1
BALNOM =XLMHD/XLP
CMHDEFF = CMHD*BALNOM
x=td
x=tav
1000 RETURN
END