Skip to content

plasma_current

PlasmaCurrentModel

Bases: IntEnum

Source code in process/models/physics/plasma_current.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class PlasmaCurrentModel(IntEnum):
    PENG_ANALYTIC_FIT = (1, "Peng analytic fit")
    PENG_DIVERTOR_SCALING = (2, "Peng divertor scaling")
    ITER_SCALING = (3, "Simple ITER scaling (cylindrical case)")
    IPDG89_SCALING = (4, "IPDG89 scaling")
    TODD_EMPIRICAL_SCALING_I = (5, "Todd empirical scaling I")
    TODD_EMPIRICAL_SCALING_II = (6, "Todd empirical scaling II")
    CONNOR_HASTIE_MODEL = (7, "Connor-Hastie model")
    SAUTER_SCALING = (8, "Sauter scaling")
    FIESTA_ST_SCALING = (9, "FIESTA ST scaling")

    def __new__(cls, value, full_name):
        obj = int.__new__(cls, value)
        obj._value_ = value
        obj.full_name = full_name
        return obj

PENG_ANALYTIC_FIT = (1, 'Peng analytic fit') class-attribute instance-attribute

PENG_DIVERTOR_SCALING = (2, 'Peng divertor scaling') class-attribute instance-attribute

ITER_SCALING = (3, 'Simple ITER scaling (cylindrical case)') class-attribute instance-attribute

IPDG89_SCALING = (4, 'IPDG89 scaling') class-attribute instance-attribute

TODD_EMPIRICAL_SCALING_I = (5, 'Todd empirical scaling I') class-attribute instance-attribute

TODD_EMPIRICAL_SCALING_II = (6, 'Todd empirical scaling II') class-attribute instance-attribute

CONNOR_HASTIE_MODEL = (7, 'Connor-Hastie model') class-attribute instance-attribute

SAUTER_SCALING = (8, 'Sauter scaling') class-attribute instance-attribute

FIESTA_ST_SCALING = (9, 'FIESTA ST scaling') class-attribute instance-attribute

PlasmaCurrent

Class to hold plasma current calculations for plasma processing.

Source code in process/models/physics/plasma_current.py
 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
class PlasmaCurrent:
    """Class to hold plasma current calculations for plasma processing."""

    def __init__(self):
        self.outfile = constants.NOUT
        self.mfile = constants.MFILE

    def calculate_plasma_current(
        self,
        alphaj: float,
        alphap: float,
        b_plasma_toroidal_on_axis: float,
        eps: float,
        i_plasma_current: int,
        kappa: float,
        kappa95: float,
        pres_plasma_on_axis: float,
        len_plasma_poloidal: float,
        q95: float,
        rmajor: float,
        rminor: float,
        triang: float,
        triang95: float,
    ) -> tuple[float, float, float, float, float]:
        """Calculate the plasma current.

        Args:
            alphaj (float): Current profile index.
            alphap (float): Pressure profile index.
            b_plasma_toroidal_on_axis (float): Toroidal field on axis (T).
            eps (float): Inverse aspect ratio.
            i_plasma_current (int): Current scaling model to use.
                1 = Peng analytic fit
                2 = Peng divertor scaling (TART,STAR)
                3 = Simple ITER scaling
                4 = IPDG89 scaling
                5 = Todd empirical scaling I
                6 = Todd empirical scaling II
                7 = Connor-Hastie model
                8 = Sauter scaling (allowing negative triangularity)
                9 = FIESTA ST scaling
            kappa (float): Plasma elongation.
            kappa95 (float): Plasma elongation at 95% surface.
            pres_plasma_on_axis (float): Central plasma pressure (Pa).
            len_plasma_poloidal (float): Plasma perimeter length (m).
            q95 (float): Plasma safety factor at 95% flux (= q-bar for i_plasma_current=2).
            rmajor (float): Major radius (m).
            rminor (float): Minor radius (m).
            triang (float): Plasma triangularity.
            triang95 (float): Plasma triangularity at 95% surface.

        Returns:
            Tuple[float, float, float,]: Tuple containing b_plasma_poloidal_average, qstar, plasma_current,

        Raises:
            ValueError: If invalid value for i_plasma_current is provided.

        Notes:
            This routine calculates the plasma current based on the edge safety factor q95.
            It will also make the current profile parameters consistent with the q-profile if required.

        References:
            - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document
            - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
              'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
              1729-1738. https://doi.org/10.13182/FST92-A29971
            - ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990
            - M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants - Part 1: Physics
            - H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO
            - T. Hartmann, 2013, Development of a modular systems code to analyse the implications of physics assumptions on the design of a demonstration fusion power plant
            - Sauter, Geometric formulas for systems codes..., FED 2016
        """
        # Aspect ratio
        aspect_ratio = 1.0 / eps

        # Only the Sauter scaling (i_plasma_current=8) is suitable for negative triangularity:
        if i_plasma_current != 8 and triang < 0.0:
            raise ProcessValueError(
                f"Triangularity is negative without i_plasma_current = 8 selected: {triang=}, {i_plasma_current=}"
            )
        try:
            model = PlasmaCurrentModel(int(i_plasma_current))
            # Calculate the function Fq that scales the edge q from the
            # circular cross-section cylindrical case

            # Peng analytical fit
            if model == PlasmaCurrentModel.PENG_ANALYTIC_FIT:
                fq = self.calculate_current_coefficient_peng(
                    eps, len_plasma_poloidal, rminor
                )

            # Peng scaling for double null divertor; TARTs [STAR Code]
            elif model == PlasmaCurrentModel.PENG_DIVERTOR_SCALING:
                plasma_current = 1.0e6 * self.calculate_plasma_current_peng(
                    q95,
                    aspect_ratio,
                    eps,
                    rminor,
                    b_plasma_toroidal_on_axis,
                    kappa,
                    triang,
                )

            # Simple ITER scaling (simply the cylindrical case)
            elif model == PlasmaCurrentModel.ITER_SCALING:
                fq = 1.0

            # ITER formula (IPDG89)
            elif model == PlasmaCurrentModel.IPDG89_SCALING:
                fq = self.calculate_current_coefficient_ipdg89(eps, kappa95, triang95)

            # Todd empirical scalings
            # D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181
            elif model in [
                PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I,
                PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II,
            ]:
                fq = self.calculate_current_coefficient_todd(
                    eps, kappa95, triang95, model=1
                )

                if model == PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II:
                    fq = self.calculate_current_coefficient_todd(
                        eps, kappa95, triang95, model=2
                    )

            # Connor-Hastie asymptotically-correct expression
            elif model == PlasmaCurrentModel.CONNOR_HASTIE_MODEL:
                fq = self.calculate_current_coefficient_hastie(
                    alphaj,
                    alphap,
                    b_plasma_toroidal_on_axis,
                    triang95,
                    eps,
                    kappa95,
                    pres_plasma_on_axis,
                    constants.RMU0,
                )

            # Sauter scaling allowing negative triangularity [FED May 2016]
            # https://doi.org/10.1016/j.fusengdes.2016.04.033.
            elif model == PlasmaCurrentModel.SAUTER_SCALING:
                # Assumes zero squareness, note takes kappa, delta at separatrix not _95
                fq = self.calculate_current_coefficient_sauter(eps, kappa, triang)

            # FIESTA ST scaling
            # https://doi.org/10.1016/j.fusengdes.2020.111530.
            elif model == PlasmaCurrentModel.FIESTA_ST_SCALING:
                fq = self.calculate_current_coefficient_fiesta(eps, kappa, triang)

        except ValueError as e:
            raise ProcessValueError(
                "Illegal value of i_plasma_current",
                i_plasma_current=physics_variables.i_plasma_current,
            ) from e

        # Main plasma current calculation using the fq value from the different settings
        if model != PlasmaCurrentModel.PENG_DIVERTOR_SCALING:
            plasma_current = (
                self.calculate_cyclindrical_plasma_current(
                    rminor=rminor,
                    rmajor=rmajor,
                    q95=q95,
                    b_plasma_toroidal_on_axis=b_plasma_toroidal_on_axis,
                )
                * fq
            )

        return plasma_current

    def calculate_all_plasma_current_models(
        self,
        alphaj: float,
        alphap: float,
        b_plasma_toroidal_on_axis: float,
        eps: float,
        kappa: float,
        kappa95: float,
        pres_plasma_on_axis: float,
        len_plasma_poloidal: float,
        q95: float,
        rmajor: float,
        rminor: float,
        triang: float,
        triang95: float,
    ) -> dict[PlasmaCurrentModel, float]:
        """Calculate the plasma current for all models.

        This function calculates the plasma current for all models and returns a dictionary of the results.

        Parameters
        ----------
        alphaj :
            current profile index
        alphap :
            pressure profile index
        b_plasma_toroidal_on_axis :
            toroidal field on axis (T)
        eps :
            inverse aspect ratio
        kappa :
            plasma elongation
        kappa95 :
            plasma elongation at 95% surface
        pres_plasma_on_axis :
            central plasma pressure (Pa)
        len_plasma_poloidal :
            plasma perimeter length (m)
        q95 :
            plasma safety factor at 95% flux
        rmajor :
            major radius (m)
        rminor :
            minor radius (m)
        triang :
            plasma triangularity
        triang95 :
            plasma triangularity at 95% surface
        Returns
        -------
        dict[PlasmaCurrentModel, float]
            Dictionary containing the plasma current for each model.
        """
        results = {}
        for model in PlasmaCurrentModel:
            results[model] = self.calculate_plasma_current(
                alphaj=alphaj,
                alphap=alphap,
                b_plasma_toroidal_on_axis=b_plasma_toroidal_on_axis,
                eps=eps,
                i_plasma_current=model.value,
                kappa=kappa,
                kappa95=kappa95,
                pres_plasma_on_axis=pres_plasma_on_axis,
                len_plasma_poloidal=len_plasma_poloidal,
                q95=q95,
                rmajor=rmajor,
                rminor=rminor,
                triang=triang,
                triang95=triang95,
            )
        return results

    def output_plasma_current_models(self) -> None:
        """Output the plasma current for all models.

        This function outputs the plasma current for all models to the output file.
        """
        plasma_currents = self.calculate_all_plasma_current_models(
            alphaj=physics_variables.alphaj,
            alphap=physics_variables.alphap,
            b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
            eps=physics_variables.eps,
            kappa=physics_variables.kappa,
            kappa95=physics_variables.kappa95,
            pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis,
            len_plasma_poloidal=physics_variables.len_plasma_poloidal,
            q95=physics_variables.q95,
            rmajor=physics_variables.rmajor,
            rminor=physics_variables.rminor,
            triang=physics_variables.triang,
            triang95=physics_variables.triang95,
        )

        physics_variables.c_plasma_peng_analytic = plasma_currents.get(
            PlasmaCurrentModel.PENG_ANALYTIC_FIT
        )
        physics_variables.c_plasma_peng_double_null = plasma_currents.get(
            PlasmaCurrentModel.PENG_DIVERTOR_SCALING
        )
        physics_variables.c_plasma_cyclindrical = plasma_currents.get(
            PlasmaCurrentModel.ITER_SCALING
        )
        physics_variables.c_plasma_ipdg89 = plasma_currents.get(
            PlasmaCurrentModel.IPDG89_SCALING
        )
        physics_variables.c_plasma_todd_empirical_i = plasma_currents.get(
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I
        )
        physics_variables.c_plasma_todd_empirical_ii = plasma_currents.get(
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II
        )
        physics_variables.c_plasma_connor_hastie = plasma_currents.get(
            PlasmaCurrentModel.CONNOR_HASTIE_MODEL
        )
        physics_variables.c_plasma_sauter = plasma_currents.get(
            PlasmaCurrentModel.SAUTER_SCALING
        )
        physics_variables.c_plasma_fiesta_st = plasma_currents.get(
            PlasmaCurrentModel.FIESTA_ST_SCALING
        )

        po.osubhd(self.outfile, "Plasma Currents using different models :")

        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.PENG_ANALYTIC_FIT.full_name}",
            "(c_plasma_peng_analytic)",
            physics_variables.c_plasma_peng_analytic,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}",
            "(c_plasma_peng_double_null)",
            physics_variables.c_plasma_peng_double_null,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.ITER_SCALING.full_name}",
            "(c_plasma_cyclindrical)",
            physics_variables.c_plasma_cyclindrical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}",
            "(c_plasma_ipdg89)",
            physics_variables.c_plasma_ipdg89,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}",
            "(c_plasma_todd_empirical_i)",
            physics_variables.c_plasma_todd_empirical_i,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}",
            "(c_plasma_todd_empirical_ii)",
            physics_variables.c_plasma_todd_empirical_ii,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}",
            "(c_plasma_connor_hastie)",
            physics_variables.c_plasma_connor_hastie,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}",
            "(c_plasma_sauter)",
            physics_variables.c_plasma_sauter,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}",
            "(c_plasma_fiesta_st)",
            physics_variables.c_plasma_fiesta_st,
            "OP ",
        )

    @staticmethod
    def plot_plasma_current_comparison(axis: plt.Axes, mfile: mf.MFile, scan: int):
        """Function to plot a scatter box plot of different plasma current comparisons.

        Parameters
        ----------
        axis :
            Axis object to plot to.
        mfile :
            MFILE data object.
        scan :
            Scan number to use.
        """
        c_plasma_peng_analytic = mfile.get("c_plasma_peng_analytic", scan=scan)
        c_plasma_peng_double_null = mfile.get("c_plasma_peng_double_null", scan=scan)
        c_plasma_cyclindrical = mfile.get("c_plasma_cyclindrical", scan=scan)
        c_plasma_ipdg89 = mfile.get("c_plasma_ipdg89", scan=scan)
        c_plasma_todd_empirical_i = mfile.get("c_plasma_todd_empirical_i", scan=scan)
        c_plasma_todd_empirical_ii = mfile.get("c_plasma_todd_empirical_ii", scan=scan)
        c_plasma_connor_hastie = mfile.get("c_plasma_connor_hastie", scan=scan)
        c_plasma_sauter = mfile.get("c_plasma_sauter", scan=scan)
        c_plasma_fiesta_st = mfile.get("c_plasma_fiesta_st", scan=scan)

        # Data for the box plot
        data = {
            f"{PlasmaCurrentModel.PENG_ANALYTIC_FIT.full_name}": c_plasma_peng_analytic,
            f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}": c_plasma_peng_double_null,
            f"{PlasmaCurrentModel.ITER_SCALING.full_name}": c_plasma_cyclindrical,
            f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}": c_plasma_ipdg89,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}": c_plasma_todd_empirical_i,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}": c_plasma_todd_empirical_ii,
            f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}": c_plasma_connor_hastie,
            f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}": c_plasma_sauter,
            f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}": c_plasma_fiesta_st,
        }

        # Create the violin plot
        axis.violinplot(data.values(), showextrema=False)

        # Create the box plot
        axis.boxplot(
            data.values(), showfliers=True, showmeans=True, meanline=True, widths=0.3
        )

        # Scatter plot for each data point
        colors = plt.cm.plasma(np.linspace(0, 1, len(data.values())))
        for index, (key, value) in enumerate(data.items()):
            axis.scatter(1, value, color=colors[index], label=key, alpha=1.0)
        axis.legend(loc="upper left", bbox_to_anchor=(-0.9, 1))

        # Calculate average, standard deviation, and median
        data_values = list(data.values())
        avg_density_limit = np.mean(data_values)
        std_density_limit = np.std(data_values)
        median_density_limit = np.median(data_values)

        # Plot average, standard deviation, and median as text
        axis.text(
            -0.45,
            0.15,
            rf"Average: {avg_density_limit * 1e-6:.4f}",
            transform=axis.transAxes,
            fontsize=9,
        )
        axis.text(
            -0.45,
            0.1,
            rf"Standard Dev: {std_density_limit * 1e-6:.4f}",
            transform=axis.transAxes,
            fontsize=9,
        )
        axis.text(
            -0.45,
            0.05,
            rf"Median: {median_density_limit * 1e-6:.4f}",
            transform=axis.transAxes,
            fontsize=9,
        )

        axis.set_title("Plasma Current Comparison")
        axis.set_ylabel(r"Plasma Current [MA]")
        axis.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f"{x * 1e-6:.1f}"))
        axis.set_xlim([0.5, 1.5])
        axis.set_xticks([])
        axis.set_xticklabels([])
        axis.set_facecolor("#f0f0f0")

    @staticmethod
    def calculate_cyclindrical_plasma_current(
        rminor: float, rmajor: float, q95: float, b_plasma_toroidal_on_axis: float
    ) -> float:
        """Calculate the plasma current for a cylindrical plasma.

        Parameters
        ----------
        rminor :
            plasma minor radius (m)
        rmajor :
            plasma major radius (m)
        q95 :
            plasma safety factor at 95% flux
        b_plasma_toroidal_on_axis :
            toroidal field on axis (T)

        Returns
        -------
        float
            plasma current (A)

        """

        return (
            (2.0 * np.pi / constants.RMU0)
            * rminor**2
            / (rmajor * q95)
            * b_plasma_toroidal_on_axis
        )

    @staticmethod
    def _plascar_bpol(
        aspect: float, eps: float, kappa: float, delta: float
    ) -> tuple[float, float, float, float]:
        """Calculate the poloidal field coefficients for determining the plasma current
        and poloidal field.


        This internal function calculates the poloidal field coefficients,
        which is used to calculate the poloidal field and the plasma current.

        Parameters
        ----------
        aspect :
            plasma aspect ratio
        eps :
            inverse aspect ratio
        kappa :
            plasma elongation
        delta :
            plasma triangularity

        Returns
        -------
        :
            coefficients ff1, ff2, d1, d2

        References
        ----------
            - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
            'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
            1729-1738. https://doi.org/10.13182/FST92-A29971
            - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
            unpublished internal Oak Ridge document

        """
        # Original coding, only suitable for TARTs [STAR Code]

        c1 = (kappa**2 / (1.0 + delta)) + delta
        c2 = (kappa**2 / (1.0 - delta)) - delta

        d1 = (kappa / (1.0 + delta)) ** 2 + 1.0
        d2 = (kappa / (1.0 - delta)) ** 2 + 1.0

        c1_aspect = ((c1 * eps) - 1.0) if aspect < c1 else (1.0 - (c1 * eps))

        y1 = np.sqrt(c1_aspect / (1.0 + eps)) * ((1.0 + delta) / kappa)
        y2 = np.sqrt((c2 * eps + 1.0) / (1.0 - eps)) * ((1.0 - delta) / kappa)

        h2 = (1.0 + (c2 - 1.0) * (eps / 2.0)) / np.sqrt((1.0 - eps) * (c2 * eps + 1.0))
        f2 = (d2 * (1.0 - delta) * eps) / ((1.0 - eps) * ((c2 * eps) + 1.0))
        g = (eps * kappa) / (1.0 - (eps * delta))
        ff2 = f2 * (g + 2.0 * h2 * np.arctan(y2))

        h1 = (1.0 + (1.0 - c1) * (eps / 2.0)) / np.sqrt((1.0 + eps) * c1_aspect)
        f1 = (d1 * (1.0 + delta) * eps) / ((1.0 + eps) * (c1 * eps - 1.0))

        if aspect < c1:
            ff1 = f1 * (g - h1 * np.log((1.0 + y1) / (1.0 - y1)))
        else:
            ff1 = -f1 * (-g + 2.0 * h1 * np.arctan(y1))

        return ff1, ff2, d1, d2

    def calculate_poloidal_field(
        self,
        i_plasma_current: int,
        ip: float,
        q95: float,
        aspect: float,
        eps: float,
        b_plasma_toroidal_on_axis: float,
        kappa: float,
        delta: float,
        perim: float,
    ) -> float:
        """Function to calculate poloidal field from the plasma current

        This function calculates the poloidal field from the plasma current in Tesla,
        using a simple calculation using Ampere's law for conventional
        tokamaks, or for TARTs, a scaling from Peng, Galambos and
        Shipe (1992).

        Parameters
        ----------
        i_plasma_current :
            current scaling model to use
        ip :
            plasma current (A)
        q95 :
            95% flux surface safety factor
        aspect :
            plasma aspect ratio
        eps :
            inverse aspect ratio
        b_plasma_toroidal_on_axis :
            toroidal field on axis (T)
        kappa :
            plasma elongation
        delta :
            plasma triangularity
        perim :
            plasma perimeter (m)

        Returns
        -------
        :
            poloidal field in Tesla


        References
        ----------
            - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
            unpublished internal Oak Ridge document
            - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
            'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
            1729-1738. https://doi.org/10.13182/FST92-A29971

        """
        # Use Ampere's law using the plasma poloidal cross-section
        if i_plasma_current != 2:
            return constants.RMU0 * ip / perim
        # Use the relation from Peng, Galambos and Shipe (1992) [STAR code] otherwise
        ff1, ff2, _, _ = self._plascar_bpol(aspect, eps, kappa, delta)

        # Transform q95 to qbar
        qbar = q95 * 1.3e0 * (1.0e0 - physics_variables.eps) ** 0.6e0

        return b_plasma_toroidal_on_axis * (ff1 + ff2) / (2.0 * np.pi * qbar)

    @staticmethod
    def calculate_current_coefficient_peng(
        eps: float, len_plasma_poloidal: float, rminor: float
    ) -> float:
        """
        Calculate the plasma current scaling coefficient for the Peng scaling from the STAR code.

        :param eps: Plasma inverse aspect ratio.
        :type eps: float
        :param len_plasma_poloidal: Plasma poloidal perimeter length [m].
        :type len_plasma_poloidal: float
        :param rminor: Plasma minor radius [m].
        :type rminor: float

        :return: The plasma current scaling coefficient.
        :rtype: float

        :references: None
        """

        return (
            (1.22 - 0.68 * eps)
            / ((1.0 - eps * eps) ** 2)
            * (len_plasma_poloidal / (2.0 * np.pi * rminor)) ** 2
        )

    def calculate_plasma_current_peng(
        self,
        q95: float,
        aspect: float,
        eps: float,
        rminor: float,
        b_plasma_toroidal_on_axis: float,
        kappa: float,
        delta: float,
    ) -> float:
        """
        Function to calculate plasma current (Peng scaling from the STAR code)

        Parameters:
        - q95: float, 95% flux surface safety factor
        - aspect: float, plasma aspect ratio
        - eps: float, inverse aspect ratio
        - rminor: float, plasma minor radius (m)
        - b_plasma_toroidal_on_axis: float, toroidal field on axis (T)
        - kappa: float, plasma elongation
        - delta: float, plasma triangularity

        Returns:
        - float, plasma current in MA

        This function calculates the plasma current in MA,
        using a scaling from Peng, Galambos and Shipe (1992).
        It is primarily used for Tight Aspect Ratio Tokamaks and is
        selected via i_plasma_current=2.

        References:
        - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
        unpublished internal Oak Ridge document
        - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
        'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
        1729-1738. https://doi.org/10.13182/FST92-A29971
        """

        # Transform q95 to qbar
        qbar = q95 * 1.3e0 * (1.0e0 - physics_variables.eps) ** 0.6e0

        ff1, ff2, d1, d2 = self._plascar_bpol(aspect, eps, kappa, delta)

        e1 = (2.0 * kappa) / (d1 * (1.0 + delta))
        e2 = (2.0 * kappa) / (d2 * (1.0 - delta))

        return (
            rminor
            * b_plasma_toroidal_on_axis
            / qbar
            * 5.0
            * kappa
            / (2.0 * np.pi**2)
            * (np.arcsin(e1) / e1 + np.arcsin(e2) / e2)
            * (ff1 + ff2)
        )

    @staticmethod
    def calculate_current_coefficient_ipdg89(
        eps: float, kappa95: float, triang95: float
    ) -> float:
        """
        Calculate the fq coefficient from the IPDG89 guidlines used in the plasma current scaling.

        Parameters:
        - eps: float, plasma inverse aspect ratio
        - kappa95: float, plasma elongation 95%
        - triang95: float, plasma triangularity 95%

        Returns:
        - float, the fq plasma current coefficient

        This function calculates the fq coefficient used in the IPDG89 plasma current scaling,
        based on the given plasma parameters.

        References:
        - N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'
        - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
        """
        return (
            0.5
            * (1.17 - 0.65 * eps)
            / ((1.0 - eps * eps) ** 2)
            * (1.0 + kappa95**2 * (1.0 + 2.0 * triang95**2 - 1.2 * triang95**3))
        )

    @staticmethod
    def calculate_current_coefficient_todd(
        eps: float, kappa95: float, triang95: float, model: int
    ) -> float:
        """
        Calculate the fq coefficient used in the two Todd plasma current scalings.

        Parameters:
        - eps: float, plasma inverse aspect ratio
        - kappa95: float, plasma elongation 95%
        - triang95: float, plasma triangularity 95%

        Returns:
        - float, the fq plasma current coefficient

        This function calculates the fq coefficient based on the given plasma parameters for the two Todd scalings.

        References:
        - D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181
        - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
        """
        # Calculate the Todd scaling based on the model
        base_scaling = (
            (1.0 + 2.0 * eps**2)
            * ((1.0 + kappa95**2) / 2)
            * (
                1.24
                - 0.54 * kappa95
                + 0.3 * (kappa95**2 + triang95**2)
                + 0.125 * triang95
            )
        )
        if model == 1:
            return base_scaling
        if model == 2:
            return base_scaling * (1.0 + (abs(kappa95 - 1.2)) ** 3)
        raise ProcessValueError(f"model = {model} is an invalid option")

    @staticmethod
    def calculate_current_coefficient_hastie(
        alphaj: float,
        alphap: float,
        b_plasma_toroidal_on_axis: float,
        delta95: float,
        eps: float,
        kappa95: float,
        pres_plasma_on_axis: float,
        rmu0: float,
    ) -> float:
        """
        Routine to calculate the f_q coefficient for the Connor-Hastie model used for scaling the plasma current.

        Parameters:
        - alphaj: float, the current profile index
        - alphap: float, the pressure profile index
        - b_plasma_toroidal_on_axis: float, the toroidal field on axis (T)
        - delta95: float, the plasma triangularity 95%
        - eps: float, the inverse aspect ratio
        - kappa95: float, the plasma elongation 95%
        - pres_plasma_on_axis: float, the central plasma pressure (Pa)
        - rmu0: float, the vacuum permeability (H/m)

        Returns:
        - float, the F coefficient

        This routine calculates the f_q coefficient used for scaling the plasma current,
        using the Connor-Hastie scaling

        Reference:
        - J.W.Connor and R.J.Hastie, Culham Lab Report CLM-M106 (1985).
        https://scientific-publications.ukaea.uk/wp-content/uploads/CLM-M106-1.pdf
        - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
        """
        # Exponent in Connor-Hastie current profile
        lamda = alphaj

        # Exponent in Connor-Hastie pressure profile
        nu = alphap

        # Central plasma beta
        beta0 = 2.0 * rmu0 * pres_plasma_on_axis / (b_plasma_toroidal_on_axis**2)

        # Plasma internal inductance
        lamp1 = 1.0 + lamda
        li = lamp1 / lamda * (lamp1 / lamda * np.log(lamp1) - 1.0)

        # T/r in AEA FUS 172
        kap1 = kappa95 + 1.0
        tr = kappa95 * delta95 / kap1**2

        # E/r in AEA FUS 172
        er = (kappa95 - 1.0) / kap1

        # T primed in AEA FUS 172
        tprime = 2.0 * tr * lamp1 / (1.0 + 0.5 * lamda)

        # E primed in AEA FUS 172
        eprime = er * lamp1 / (1.0 + lamda / 3.0)

        # Delta primed in AEA FUS 172
        deltap = (0.5 * kap1 * eps * 0.5 * li) + (
            beta0 / (0.5 * kap1 * eps)
        ) * lamp1**2 / (1.0 + nu)

        # Delta/R0 in AEA FUS 172
        deltar = beta0 / 6.0 * (1.0 + 5.0 * lamda / 6.0 + 0.25 * lamda**2) + (
            0.5 * kap1 * eps
        ) ** 2 * 0.125 * (1.0 - (lamda**2) / 3.0)

        # F coefficient
        return (0.5 * kap1) ** 2 * (
            1.0
            + eps**2 * (0.5 * kap1) ** 2
            + 0.5 * deltap**2
            + 2.0 * deltar
            + 0.5 * (eprime**2 + er**2)
            + 0.5 * (tprime**2 + 4.0 * tr**2)
        )

    @staticmethod
    def calculate_current_coefficient_sauter(
        eps: float,
        kappa: float,
        triang: float,
    ) -> float:
        """
        Routine to calculate the f_q coefficient for the Sauter model used for scaling the plasma current.

        Parameters:
        - eps: float, inverse aspect ratio
        - kappa: float, plasma elongation at the separatrix
        - triang: float, plasma triangularity at the separatrix

        Returns:
        - float, the fq coefficient

        Reference:
        - O. Sauter, Geometric formulas for system codes including the effect of negative triangularity,
        Fusion Engineering and Design, Volume 112, 2016, Pages 633-645,
        ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2016.04.033.
        """
        w07 = 1.0  # zero squareness - can be modified later if required

        return (
            (4.1e6 / 5.0e6)
            * (1.0 + 1.2 * (kappa - 1.0) + 0.56 * (kappa - 1.0) ** 2)
            * (1.0 + 0.09 * triang + 0.16 * triang**2)
            * (1.0 + 0.45 * triang * eps)
            / (1.0 - 0.74 * eps)
            * (1.0 + 0.55 * (w07 - 1.0))
        )

    @staticmethod
    def calculate_current_coefficient_fiesta(
        eps: float, kappa: float, triang: float
    ) -> float:
        """
        Calculate the fq coefficient used in the FIESTA plasma current scaling.

        Parameters:
        - eps: float, plasma inverse aspect ratio
        - kappa: float, plasma elongation at the separatrix
        - triang: float, plasma triangularity at the separatrix

        Returns:
        - float, the fq plasma current coefficient

        This function calculates the fq coefficient based on the given plasma parameters for the FIESTA scaling.

        References:
        - S.Muldrew et.al,“PROCESS”: Systems studies of spherical tokamaks, Fusion Engineering and Design,
        Volume 154, 2020, 111530, ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2020.111530.
        """
        return 0.538 * (1.0 + 2.440 * eps**2.736) * kappa**2.154 * triang**0.060

outfile = constants.NOUT instance-attribute

mfile = constants.MFILE instance-attribute

calculate_plasma_current(alphaj, alphap, b_plasma_toroidal_on_axis, eps, i_plasma_current, kappa, kappa95, pres_plasma_on_axis, len_plasma_poloidal, q95, rmajor, rminor, triang, triang95)

Calculate the plasma current.

Args: alphaj (float): Current profile index. alphap (float): Pressure profile index. b_plasma_toroidal_on_axis (float): Toroidal field on axis (T). eps (float): Inverse aspect ratio. i_plasma_current (int): Current scaling model to use. 1 = Peng analytic fit 2 = Peng divertor scaling (TART,STAR) 3 = Simple ITER scaling 4 = IPDG89 scaling 5 = Todd empirical scaling I 6 = Todd empirical scaling II 7 = Connor-Hastie model 8 = Sauter scaling (allowing negative triangularity) 9 = FIESTA ST scaling kappa (float): Plasma elongation. kappa95 (float): Plasma elongation at 95% surface. pres_plasma_on_axis (float): Central plasma pressure (Pa). len_plasma_poloidal (float): Plasma perimeter length (m). q95 (float): Plasma safety factor at 95% flux (= q-bar for i_plasma_current=2). rmajor (float): Major radius (m). rminor (float): Minor radius (m). triang (float): Plasma triangularity. triang95 (float): Plasma triangularity at 95% surface.

Returns: Tuple[float, float, float,]: Tuple containing b_plasma_poloidal_average, qstar, plasma_current,

Raises: ValueError: If invalid value for i_plasma_current is provided.

Notes: This routine calculates the plasma current based on the edge safety factor q95. It will also make the current profile parameters consistent with the q-profile if required.

References: - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992). 'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A), 1729-1738. https://doi.org/10.13182/FST92-A29971 - ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990 - M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants - Part 1: Physics - H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO - T. Hartmann, 2013, Development of a modular systems code to analyse the implications of physics assumptions on the design of a demonstration fusion power plant - Sauter, Geometric formulas for systems codes..., FED 2016

Source code in process/models/physics/plasma_current.py
 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
def calculate_plasma_current(
    self,
    alphaj: float,
    alphap: float,
    b_plasma_toroidal_on_axis: float,
    eps: float,
    i_plasma_current: int,
    kappa: float,
    kappa95: float,
    pres_plasma_on_axis: float,
    len_plasma_poloidal: float,
    q95: float,
    rmajor: float,
    rminor: float,
    triang: float,
    triang95: float,
) -> tuple[float, float, float, float, float]:
    """Calculate the plasma current.

    Args:
        alphaj (float): Current profile index.
        alphap (float): Pressure profile index.
        b_plasma_toroidal_on_axis (float): Toroidal field on axis (T).
        eps (float): Inverse aspect ratio.
        i_plasma_current (int): Current scaling model to use.
            1 = Peng analytic fit
            2 = Peng divertor scaling (TART,STAR)
            3 = Simple ITER scaling
            4 = IPDG89 scaling
            5 = Todd empirical scaling I
            6 = Todd empirical scaling II
            7 = Connor-Hastie model
            8 = Sauter scaling (allowing negative triangularity)
            9 = FIESTA ST scaling
        kappa (float): Plasma elongation.
        kappa95 (float): Plasma elongation at 95% surface.
        pres_plasma_on_axis (float): Central plasma pressure (Pa).
        len_plasma_poloidal (float): Plasma perimeter length (m).
        q95 (float): Plasma safety factor at 95% flux (= q-bar for i_plasma_current=2).
        rmajor (float): Major radius (m).
        rminor (float): Minor radius (m).
        triang (float): Plasma triangularity.
        triang95 (float): Plasma triangularity at 95% surface.

    Returns:
        Tuple[float, float, float,]: Tuple containing b_plasma_poloidal_average, qstar, plasma_current,

    Raises:
        ValueError: If invalid value for i_plasma_current is provided.

    Notes:
        This routine calculates the plasma current based on the edge safety factor q95.
        It will also make the current profile parameters consistent with the q-profile if required.

    References:
        - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document
        - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
          'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
          1729-1738. https://doi.org/10.13182/FST92-A29971
        - ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990
        - M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants - Part 1: Physics
        - H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO
        - T. Hartmann, 2013, Development of a modular systems code to analyse the implications of physics assumptions on the design of a demonstration fusion power plant
        - Sauter, Geometric formulas for systems codes..., FED 2016
    """
    # Aspect ratio
    aspect_ratio = 1.0 / eps

    # Only the Sauter scaling (i_plasma_current=8) is suitable for negative triangularity:
    if i_plasma_current != 8 and triang < 0.0:
        raise ProcessValueError(
            f"Triangularity is negative without i_plasma_current = 8 selected: {triang=}, {i_plasma_current=}"
        )
    try:
        model = PlasmaCurrentModel(int(i_plasma_current))
        # Calculate the function Fq that scales the edge q from the
        # circular cross-section cylindrical case

        # Peng analytical fit
        if model == PlasmaCurrentModel.PENG_ANALYTIC_FIT:
            fq = self.calculate_current_coefficient_peng(
                eps, len_plasma_poloidal, rminor
            )

        # Peng scaling for double null divertor; TARTs [STAR Code]
        elif model == PlasmaCurrentModel.PENG_DIVERTOR_SCALING:
            plasma_current = 1.0e6 * self.calculate_plasma_current_peng(
                q95,
                aspect_ratio,
                eps,
                rminor,
                b_plasma_toroidal_on_axis,
                kappa,
                triang,
            )

        # Simple ITER scaling (simply the cylindrical case)
        elif model == PlasmaCurrentModel.ITER_SCALING:
            fq = 1.0

        # ITER formula (IPDG89)
        elif model == PlasmaCurrentModel.IPDG89_SCALING:
            fq = self.calculate_current_coefficient_ipdg89(eps, kappa95, triang95)

        # Todd empirical scalings
        # D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181
        elif model in [
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I,
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II,
        ]:
            fq = self.calculate_current_coefficient_todd(
                eps, kappa95, triang95, model=1
            )

            if model == PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II:
                fq = self.calculate_current_coefficient_todd(
                    eps, kappa95, triang95, model=2
                )

        # Connor-Hastie asymptotically-correct expression
        elif model == PlasmaCurrentModel.CONNOR_HASTIE_MODEL:
            fq = self.calculate_current_coefficient_hastie(
                alphaj,
                alphap,
                b_plasma_toroidal_on_axis,
                triang95,
                eps,
                kappa95,
                pres_plasma_on_axis,
                constants.RMU0,
            )

        # Sauter scaling allowing negative triangularity [FED May 2016]
        # https://doi.org/10.1016/j.fusengdes.2016.04.033.
        elif model == PlasmaCurrentModel.SAUTER_SCALING:
            # Assumes zero squareness, note takes kappa, delta at separatrix not _95
            fq = self.calculate_current_coefficient_sauter(eps, kappa, triang)

        # FIESTA ST scaling
        # https://doi.org/10.1016/j.fusengdes.2020.111530.
        elif model == PlasmaCurrentModel.FIESTA_ST_SCALING:
            fq = self.calculate_current_coefficient_fiesta(eps, kappa, triang)

    except ValueError as e:
        raise ProcessValueError(
            "Illegal value of i_plasma_current",
            i_plasma_current=physics_variables.i_plasma_current,
        ) from e

    # Main plasma current calculation using the fq value from the different settings
    if model != PlasmaCurrentModel.PENG_DIVERTOR_SCALING:
        plasma_current = (
            self.calculate_cyclindrical_plasma_current(
                rminor=rminor,
                rmajor=rmajor,
                q95=q95,
                b_plasma_toroidal_on_axis=b_plasma_toroidal_on_axis,
            )
            * fq
        )

    return plasma_current

calculate_all_plasma_current_models(alphaj, alphap, b_plasma_toroidal_on_axis, eps, kappa, kappa95, pres_plasma_on_axis, len_plasma_poloidal, q95, rmajor, rminor, triang, triang95)

Calculate the plasma current for all models.

This function calculates the plasma current for all models and returns a dictionary of the results.

Parameters:

Name Type Description Default
alphaj float

current profile index

required
alphap float

pressure profile index

required
b_plasma_toroidal_on_axis float

toroidal field on axis (T)

required
eps float

inverse aspect ratio

required
kappa float

plasma elongation

required
kappa95 float

plasma elongation at 95% surface

required
pres_plasma_on_axis float

central plasma pressure (Pa)

required
len_plasma_poloidal float

plasma perimeter length (m)

required
q95 float

plasma safety factor at 95% flux

required
rmajor float

major radius (m)

required
rminor float

minor radius (m)

required
triang float

plasma triangularity

required
triang95 float

plasma triangularity at 95% surface

required

Returns:

Type Description
dict[PlasmaCurrentModel, float]

Dictionary containing the plasma current for each model.

Source code in process/models/physics/plasma_current.py
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
def calculate_all_plasma_current_models(
    self,
    alphaj: float,
    alphap: float,
    b_plasma_toroidal_on_axis: float,
    eps: float,
    kappa: float,
    kappa95: float,
    pres_plasma_on_axis: float,
    len_plasma_poloidal: float,
    q95: float,
    rmajor: float,
    rminor: float,
    triang: float,
    triang95: float,
) -> dict[PlasmaCurrentModel, float]:
    """Calculate the plasma current for all models.

    This function calculates the plasma current for all models and returns a dictionary of the results.

    Parameters
    ----------
    alphaj :
        current profile index
    alphap :
        pressure profile index
    b_plasma_toroidal_on_axis :
        toroidal field on axis (T)
    eps :
        inverse aspect ratio
    kappa :
        plasma elongation
    kappa95 :
        plasma elongation at 95% surface
    pres_plasma_on_axis :
        central plasma pressure (Pa)
    len_plasma_poloidal :
        plasma perimeter length (m)
    q95 :
        plasma safety factor at 95% flux
    rmajor :
        major radius (m)
    rminor :
        minor radius (m)
    triang :
        plasma triangularity
    triang95 :
        plasma triangularity at 95% surface
    Returns
    -------
    dict[PlasmaCurrentModel, float]
        Dictionary containing the plasma current for each model.
    """
    results = {}
    for model in PlasmaCurrentModel:
        results[model] = self.calculate_plasma_current(
            alphaj=alphaj,
            alphap=alphap,
            b_plasma_toroidal_on_axis=b_plasma_toroidal_on_axis,
            eps=eps,
            i_plasma_current=model.value,
            kappa=kappa,
            kappa95=kappa95,
            pres_plasma_on_axis=pres_plasma_on_axis,
            len_plasma_poloidal=len_plasma_poloidal,
            q95=q95,
            rmajor=rmajor,
            rminor=rminor,
            triang=triang,
            triang95=triang95,
        )
    return results

output_plasma_current_models()

Output the plasma current for all models.

This function outputs the plasma current for all models to the output file.

Source code in process/models/physics/plasma_current.py
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
def output_plasma_current_models(self) -> None:
    """Output the plasma current for all models.

    This function outputs the plasma current for all models to the output file.
    """
    plasma_currents = self.calculate_all_plasma_current_models(
        alphaj=physics_variables.alphaj,
        alphap=physics_variables.alphap,
        b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
        eps=physics_variables.eps,
        kappa=physics_variables.kappa,
        kappa95=physics_variables.kappa95,
        pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis,
        len_plasma_poloidal=physics_variables.len_plasma_poloidal,
        q95=physics_variables.q95,
        rmajor=physics_variables.rmajor,
        rminor=physics_variables.rminor,
        triang=physics_variables.triang,
        triang95=physics_variables.triang95,
    )

    physics_variables.c_plasma_peng_analytic = plasma_currents.get(
        PlasmaCurrentModel.PENG_ANALYTIC_FIT
    )
    physics_variables.c_plasma_peng_double_null = plasma_currents.get(
        PlasmaCurrentModel.PENG_DIVERTOR_SCALING
    )
    physics_variables.c_plasma_cyclindrical = plasma_currents.get(
        PlasmaCurrentModel.ITER_SCALING
    )
    physics_variables.c_plasma_ipdg89 = plasma_currents.get(
        PlasmaCurrentModel.IPDG89_SCALING
    )
    physics_variables.c_plasma_todd_empirical_i = plasma_currents.get(
        PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I
    )
    physics_variables.c_plasma_todd_empirical_ii = plasma_currents.get(
        PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II
    )
    physics_variables.c_plasma_connor_hastie = plasma_currents.get(
        PlasmaCurrentModel.CONNOR_HASTIE_MODEL
    )
    physics_variables.c_plasma_sauter = plasma_currents.get(
        PlasmaCurrentModel.SAUTER_SCALING
    )
    physics_variables.c_plasma_fiesta_st = plasma_currents.get(
        PlasmaCurrentModel.FIESTA_ST_SCALING
    )

    po.osubhd(self.outfile, "Plasma Currents using different models :")

    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.PENG_ANALYTIC_FIT.full_name}",
        "(c_plasma_peng_analytic)",
        physics_variables.c_plasma_peng_analytic,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}",
        "(c_plasma_peng_double_null)",
        physics_variables.c_plasma_peng_double_null,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.ITER_SCALING.full_name}",
        "(c_plasma_cyclindrical)",
        physics_variables.c_plasma_cyclindrical,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}",
        "(c_plasma_ipdg89)",
        physics_variables.c_plasma_ipdg89,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}",
        "(c_plasma_todd_empirical_i)",
        physics_variables.c_plasma_todd_empirical_i,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}",
        "(c_plasma_todd_empirical_ii)",
        physics_variables.c_plasma_todd_empirical_ii,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}",
        "(c_plasma_connor_hastie)",
        physics_variables.c_plasma_connor_hastie,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}",
        "(c_plasma_sauter)",
        physics_variables.c_plasma_sauter,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}",
        "(c_plasma_fiesta_st)",
        physics_variables.c_plasma_fiesta_st,
        "OP ",
    )

plot_plasma_current_comparison(axis, mfile, scan) staticmethod

Function to plot a scatter box plot of different plasma current comparisons.

Parameters:

Name Type Description Default
axis Axes

Axis object to plot to.

required
mfile MFile

MFILE data object.

required
scan int

Scan number to use.

required
Source code in process/models/physics/plasma_current.py
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
@staticmethod
def plot_plasma_current_comparison(axis: plt.Axes, mfile: mf.MFile, scan: int):
    """Function to plot a scatter box plot of different plasma current comparisons.

    Parameters
    ----------
    axis :
        Axis object to plot to.
    mfile :
        MFILE data object.
    scan :
        Scan number to use.
    """
    c_plasma_peng_analytic = mfile.get("c_plasma_peng_analytic", scan=scan)
    c_plasma_peng_double_null = mfile.get("c_plasma_peng_double_null", scan=scan)
    c_plasma_cyclindrical = mfile.get("c_plasma_cyclindrical", scan=scan)
    c_plasma_ipdg89 = mfile.get("c_plasma_ipdg89", scan=scan)
    c_plasma_todd_empirical_i = mfile.get("c_plasma_todd_empirical_i", scan=scan)
    c_plasma_todd_empirical_ii = mfile.get("c_plasma_todd_empirical_ii", scan=scan)
    c_plasma_connor_hastie = mfile.get("c_plasma_connor_hastie", scan=scan)
    c_plasma_sauter = mfile.get("c_plasma_sauter", scan=scan)
    c_plasma_fiesta_st = mfile.get("c_plasma_fiesta_st", scan=scan)

    # Data for the box plot
    data = {
        f"{PlasmaCurrentModel.PENG_ANALYTIC_FIT.full_name}": c_plasma_peng_analytic,
        f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}": c_plasma_peng_double_null,
        f"{PlasmaCurrentModel.ITER_SCALING.full_name}": c_plasma_cyclindrical,
        f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}": c_plasma_ipdg89,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}": c_plasma_todd_empirical_i,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}": c_plasma_todd_empirical_ii,
        f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}": c_plasma_connor_hastie,
        f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}": c_plasma_sauter,
        f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}": c_plasma_fiesta_st,
    }

    # Create the violin plot
    axis.violinplot(data.values(), showextrema=False)

    # Create the box plot
    axis.boxplot(
        data.values(), showfliers=True, showmeans=True, meanline=True, widths=0.3
    )

    # Scatter plot for each data point
    colors = plt.cm.plasma(np.linspace(0, 1, len(data.values())))
    for index, (key, value) in enumerate(data.items()):
        axis.scatter(1, value, color=colors[index], label=key, alpha=1.0)
    axis.legend(loc="upper left", bbox_to_anchor=(-0.9, 1))

    # Calculate average, standard deviation, and median
    data_values = list(data.values())
    avg_density_limit = np.mean(data_values)
    std_density_limit = np.std(data_values)
    median_density_limit = np.median(data_values)

    # Plot average, standard deviation, and median as text
    axis.text(
        -0.45,
        0.15,
        rf"Average: {avg_density_limit * 1e-6:.4f}",
        transform=axis.transAxes,
        fontsize=9,
    )
    axis.text(
        -0.45,
        0.1,
        rf"Standard Dev: {std_density_limit * 1e-6:.4f}",
        transform=axis.transAxes,
        fontsize=9,
    )
    axis.text(
        -0.45,
        0.05,
        rf"Median: {median_density_limit * 1e-6:.4f}",
        transform=axis.transAxes,
        fontsize=9,
    )

    axis.set_title("Plasma Current Comparison")
    axis.set_ylabel(r"Plasma Current [MA]")
    axis.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f"{x * 1e-6:.1f}"))
    axis.set_xlim([0.5, 1.5])
    axis.set_xticks([])
    axis.set_xticklabels([])
    axis.set_facecolor("#f0f0f0")

calculate_cyclindrical_plasma_current(rminor, rmajor, q95, b_plasma_toroidal_on_axis) staticmethod

Calculate the plasma current for a cylindrical plasma.

Parameters:

Name Type Description Default
rminor float

plasma minor radius (m)

required
rmajor float

plasma major radius (m)

required
q95 float

plasma safety factor at 95% flux

required
b_plasma_toroidal_on_axis float

toroidal field on axis (T)

required

Returns:

Type Description
float

plasma current (A)

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_cyclindrical_plasma_current(
    rminor: float, rmajor: float, q95: float, b_plasma_toroidal_on_axis: float
) -> float:
    """Calculate the plasma current for a cylindrical plasma.

    Parameters
    ----------
    rminor :
        plasma minor radius (m)
    rmajor :
        plasma major radius (m)
    q95 :
        plasma safety factor at 95% flux
    b_plasma_toroidal_on_axis :
        toroidal field on axis (T)

    Returns
    -------
    float
        plasma current (A)

    """

    return (
        (2.0 * np.pi / constants.RMU0)
        * rminor**2
        / (rmajor * q95)
        * b_plasma_toroidal_on_axis
    )

calculate_poloidal_field(i_plasma_current, ip, q95, aspect, eps, b_plasma_toroidal_on_axis, kappa, delta, perim)

Function to calculate poloidal field from the plasma current

This function calculates the poloidal field from the plasma current in Tesla, using a simple calculation using Ampere's law for conventional tokamaks, or for TARTs, a scaling from Peng, Galambos and Shipe (1992).

Parameters:

Name Type Description Default
i_plasma_current int

current scaling model to use

required
ip float

plasma current (A)

required
q95 float

95% flux surface safety factor

required
aspect float

plasma aspect ratio

required
eps float

inverse aspect ratio

required
b_plasma_toroidal_on_axis float

toroidal field on axis (T)

required
kappa float

plasma elongation

required
delta float

plasma triangularity

required
perim float

plasma perimeter (m)

required

Returns:

Type Description
float

poloidal field in Tesla

References
- J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
unpublished internal Oak Ridge document
- Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
1729-1738. https://doi.org/10.13182/FST92-A29971
Source code in process/models/physics/plasma_current.py
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
def calculate_poloidal_field(
    self,
    i_plasma_current: int,
    ip: float,
    q95: float,
    aspect: float,
    eps: float,
    b_plasma_toroidal_on_axis: float,
    kappa: float,
    delta: float,
    perim: float,
) -> float:
    """Function to calculate poloidal field from the plasma current

    This function calculates the poloidal field from the plasma current in Tesla,
    using a simple calculation using Ampere's law for conventional
    tokamaks, or for TARTs, a scaling from Peng, Galambos and
    Shipe (1992).

    Parameters
    ----------
    i_plasma_current :
        current scaling model to use
    ip :
        plasma current (A)
    q95 :
        95% flux surface safety factor
    aspect :
        plasma aspect ratio
    eps :
        inverse aspect ratio
    b_plasma_toroidal_on_axis :
        toroidal field on axis (T)
    kappa :
        plasma elongation
    delta :
        plasma triangularity
    perim :
        plasma perimeter (m)

    Returns
    -------
    :
        poloidal field in Tesla


    References
    ----------
        - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
        unpublished internal Oak Ridge document
        - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
        'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
        1729-1738. https://doi.org/10.13182/FST92-A29971

    """
    # Use Ampere's law using the plasma poloidal cross-section
    if i_plasma_current != 2:
        return constants.RMU0 * ip / perim
    # Use the relation from Peng, Galambos and Shipe (1992) [STAR code] otherwise
    ff1, ff2, _, _ = self._plascar_bpol(aspect, eps, kappa, delta)

    # Transform q95 to qbar
    qbar = q95 * 1.3e0 * (1.0e0 - physics_variables.eps) ** 0.6e0

    return b_plasma_toroidal_on_axis * (ff1 + ff2) / (2.0 * np.pi * qbar)

calculate_current_coefficient_peng(eps, len_plasma_poloidal, rminor) staticmethod

Calculate the plasma current scaling coefficient for the Peng scaling from the STAR code.

:param eps: Plasma inverse aspect ratio. :type eps: float :param len_plasma_poloidal: Plasma poloidal perimeter length [m]. :type len_plasma_poloidal: float :param rminor: Plasma minor radius [m]. :type rminor: float

:return: The plasma current scaling coefficient. :rtype: float

:references: None

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_current_coefficient_peng(
    eps: float, len_plasma_poloidal: float, rminor: float
) -> float:
    """
    Calculate the plasma current scaling coefficient for the Peng scaling from the STAR code.

    :param eps: Plasma inverse aspect ratio.
    :type eps: float
    :param len_plasma_poloidal: Plasma poloidal perimeter length [m].
    :type len_plasma_poloidal: float
    :param rminor: Plasma minor radius [m].
    :type rminor: float

    :return: The plasma current scaling coefficient.
    :rtype: float

    :references: None
    """

    return (
        (1.22 - 0.68 * eps)
        / ((1.0 - eps * eps) ** 2)
        * (len_plasma_poloidal / (2.0 * np.pi * rminor)) ** 2
    )

calculate_plasma_current_peng(q95, aspect, eps, rminor, b_plasma_toroidal_on_axis, kappa, delta)

Function to calculate plasma current (Peng scaling from the STAR code)

Parameters: - q95: float, 95% flux surface safety factor - aspect: float, plasma aspect ratio - eps: float, inverse aspect ratio - rminor: float, plasma minor radius (m) - b_plasma_toroidal_on_axis: float, toroidal field on axis (T) - kappa: float, plasma elongation - delta: float, plasma triangularity

Returns: - float, plasma current in MA

This function calculates the plasma current in MA, using a scaling from Peng, Galambos and Shipe (1992). It is primarily used for Tight Aspect Ratio Tokamaks and is selected via i_plasma_current=2.

References: - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992). 'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A), 1729-1738. https://doi.org/10.13182/FST92-A29971

Source code in process/models/physics/plasma_current.py
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
def calculate_plasma_current_peng(
    self,
    q95: float,
    aspect: float,
    eps: float,
    rminor: float,
    b_plasma_toroidal_on_axis: float,
    kappa: float,
    delta: float,
) -> float:
    """
    Function to calculate plasma current (Peng scaling from the STAR code)

    Parameters:
    - q95: float, 95% flux surface safety factor
    - aspect: float, plasma aspect ratio
    - eps: float, inverse aspect ratio
    - rminor: float, plasma minor radius (m)
    - b_plasma_toroidal_on_axis: float, toroidal field on axis (T)
    - kappa: float, plasma elongation
    - delta: float, plasma triangularity

    Returns:
    - float, plasma current in MA

    This function calculates the plasma current in MA,
    using a scaling from Peng, Galambos and Shipe (1992).
    It is primarily used for Tight Aspect Ratio Tokamaks and is
    selected via i_plasma_current=2.

    References:
    - J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
    unpublished internal Oak Ridge document
    - Peng, Y. K. M., Galambos, J. D., & Shipe, P. C. (1992).
    'Small Tokamaks for Fusion Technology Testing'. Fusion Technology, 21(3P2A),
    1729-1738. https://doi.org/10.13182/FST92-A29971
    """

    # Transform q95 to qbar
    qbar = q95 * 1.3e0 * (1.0e0 - physics_variables.eps) ** 0.6e0

    ff1, ff2, d1, d2 = self._plascar_bpol(aspect, eps, kappa, delta)

    e1 = (2.0 * kappa) / (d1 * (1.0 + delta))
    e2 = (2.0 * kappa) / (d2 * (1.0 - delta))

    return (
        rminor
        * b_plasma_toroidal_on_axis
        / qbar
        * 5.0
        * kappa
        / (2.0 * np.pi**2)
        * (np.arcsin(e1) / e1 + np.arcsin(e2) / e2)
        * (ff1 + ff2)
    )

calculate_current_coefficient_ipdg89(eps, kappa95, triang95) staticmethod

Calculate the fq coefficient from the IPDG89 guidlines used in the plasma current scaling.

Parameters: - eps: float, plasma inverse aspect ratio - kappa95: float, plasma elongation 95% - triang95: float, plasma triangularity 95%

Returns: - float, the fq plasma current coefficient

This function calculates the fq coefficient used in the IPDG89 plasma current scaling, based on the given plasma parameters.

References: - N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989' - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_current_coefficient_ipdg89(
    eps: float, kappa95: float, triang95: float
) -> float:
    """
    Calculate the fq coefficient from the IPDG89 guidlines used in the plasma current scaling.

    Parameters:
    - eps: float, plasma inverse aspect ratio
    - kappa95: float, plasma elongation 95%
    - triang95: float, plasma triangularity 95%

    Returns:
    - float, the fq plasma current coefficient

    This function calculates the fq coefficient used in the IPDG89 plasma current scaling,
    based on the given plasma parameters.

    References:
    - N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'
    - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
    """
    return (
        0.5
        * (1.17 - 0.65 * eps)
        / ((1.0 - eps * eps) ** 2)
        * (1.0 + kappa95**2 * (1.0 + 2.0 * triang95**2 - 1.2 * triang95**3))
    )

calculate_current_coefficient_todd(eps, kappa95, triang95, model) staticmethod

Calculate the fq coefficient used in the two Todd plasma current scalings.

Parameters: - eps: float, plasma inverse aspect ratio - kappa95: float, plasma elongation 95% - triang95: float, plasma triangularity 95%

Returns: - float, the fq plasma current coefficient

This function calculates the fq coefficient based on the given plasma parameters for the two Todd scalings.

References: - D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181 - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_current_coefficient_todd(
    eps: float, kappa95: float, triang95: float, model: int
) -> float:
    """
    Calculate the fq coefficient used in the two Todd plasma current scalings.

    Parameters:
    - eps: float, plasma inverse aspect ratio
    - kappa95: float, plasma elongation 95%
    - triang95: float, plasma triangularity 95%

    Returns:
    - float, the fq plasma current coefficient

    This function calculates the fq coefficient based on the given plasma parameters for the two Todd scalings.

    References:
    - D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181
    - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
    """
    # Calculate the Todd scaling based on the model
    base_scaling = (
        (1.0 + 2.0 * eps**2)
        * ((1.0 + kappa95**2) / 2)
        * (
            1.24
            - 0.54 * kappa95
            + 0.3 * (kappa95**2 + triang95**2)
            + 0.125 * triang95
        )
    )
    if model == 1:
        return base_scaling
    if model == 2:
        return base_scaling * (1.0 + (abs(kappa95 - 1.2)) ** 3)
    raise ProcessValueError(f"model = {model} is an invalid option")

calculate_current_coefficient_hastie(alphaj, alphap, b_plasma_toroidal_on_axis, delta95, eps, kappa95, pres_plasma_on_axis, rmu0) staticmethod

Routine to calculate the f_q coefficient for the Connor-Hastie model used for scaling the plasma current.

Parameters: - alphaj: float, the current profile index - alphap: float, the pressure profile index - b_plasma_toroidal_on_axis: float, the toroidal field on axis (T) - delta95: float, the plasma triangularity 95% - eps: float, the inverse aspect ratio - kappa95: float, the plasma elongation 95% - pres_plasma_on_axis: float, the central plasma pressure (Pa) - rmu0: float, the vacuum permeability (H/m)

Returns: - float, the F coefficient

This routine calculates the f_q coefficient used for scaling the plasma current, using the Connor-Hastie scaling

Reference: - J.W.Connor and R.J.Hastie, Culham Lab Report CLM-M106 (1985). https://scientific-publications.ukaea.uk/wp-content/uploads/CLM-M106-1.pdf - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_current_coefficient_hastie(
    alphaj: float,
    alphap: float,
    b_plasma_toroidal_on_axis: float,
    delta95: float,
    eps: float,
    kappa95: float,
    pres_plasma_on_axis: float,
    rmu0: float,
) -> float:
    """
    Routine to calculate the f_q coefficient for the Connor-Hastie model used for scaling the plasma current.

    Parameters:
    - alphaj: float, the current profile index
    - alphap: float, the pressure profile index
    - b_plasma_toroidal_on_axis: float, the toroidal field on axis (T)
    - delta95: float, the plasma triangularity 95%
    - eps: float, the inverse aspect ratio
    - kappa95: float, the plasma elongation 95%
    - pres_plasma_on_axis: float, the central plasma pressure (Pa)
    - rmu0: float, the vacuum permeability (H/m)

    Returns:
    - float, the F coefficient

    This routine calculates the f_q coefficient used for scaling the plasma current,
    using the Connor-Hastie scaling

    Reference:
    - J.W.Connor and R.J.Hastie, Culham Lab Report CLM-M106 (1985).
    https://scientific-publications.ukaea.uk/wp-content/uploads/CLM-M106-1.pdf
    - T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
    """
    # Exponent in Connor-Hastie current profile
    lamda = alphaj

    # Exponent in Connor-Hastie pressure profile
    nu = alphap

    # Central plasma beta
    beta0 = 2.0 * rmu0 * pres_plasma_on_axis / (b_plasma_toroidal_on_axis**2)

    # Plasma internal inductance
    lamp1 = 1.0 + lamda
    li = lamp1 / lamda * (lamp1 / lamda * np.log(lamp1) - 1.0)

    # T/r in AEA FUS 172
    kap1 = kappa95 + 1.0
    tr = kappa95 * delta95 / kap1**2

    # E/r in AEA FUS 172
    er = (kappa95 - 1.0) / kap1

    # T primed in AEA FUS 172
    tprime = 2.0 * tr * lamp1 / (1.0 + 0.5 * lamda)

    # E primed in AEA FUS 172
    eprime = er * lamp1 / (1.0 + lamda / 3.0)

    # Delta primed in AEA FUS 172
    deltap = (0.5 * kap1 * eps * 0.5 * li) + (
        beta0 / (0.5 * kap1 * eps)
    ) * lamp1**2 / (1.0 + nu)

    # Delta/R0 in AEA FUS 172
    deltar = beta0 / 6.0 * (1.0 + 5.0 * lamda / 6.0 + 0.25 * lamda**2) + (
        0.5 * kap1 * eps
    ) ** 2 * 0.125 * (1.0 - (lamda**2) / 3.0)

    # F coefficient
    return (0.5 * kap1) ** 2 * (
        1.0
        + eps**2 * (0.5 * kap1) ** 2
        + 0.5 * deltap**2
        + 2.0 * deltar
        + 0.5 * (eprime**2 + er**2)
        + 0.5 * (tprime**2 + 4.0 * tr**2)
    )

calculate_current_coefficient_sauter(eps, kappa, triang) staticmethod

Routine to calculate the f_q coefficient for the Sauter model used for scaling the plasma current.

Parameters: - eps: float, inverse aspect ratio - kappa: float, plasma elongation at the separatrix - triang: float, plasma triangularity at the separatrix

Returns: - float, the fq coefficient

Reference: - O. Sauter, Geometric formulas for system codes including the effect of negative triangularity, Fusion Engineering and Design, Volume 112, 2016, Pages 633-645, ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2016.04.033.

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def calculate_current_coefficient_sauter(
    eps: float,
    kappa: float,
    triang: float,
) -> float:
    """
    Routine to calculate the f_q coefficient for the Sauter model used for scaling the plasma current.

    Parameters:
    - eps: float, inverse aspect ratio
    - kappa: float, plasma elongation at the separatrix
    - triang: float, plasma triangularity at the separatrix

    Returns:
    - float, the fq coefficient

    Reference:
    - O. Sauter, Geometric formulas for system codes including the effect of negative triangularity,
    Fusion Engineering and Design, Volume 112, 2016, Pages 633-645,
    ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2016.04.033.
    """
    w07 = 1.0  # zero squareness - can be modified later if required

    return (
        (4.1e6 / 5.0e6)
        * (1.0 + 1.2 * (kappa - 1.0) + 0.56 * (kappa - 1.0) ** 2)
        * (1.0 + 0.09 * triang + 0.16 * triang**2)
        * (1.0 + 0.45 * triang * eps)
        / (1.0 - 0.74 * eps)
        * (1.0 + 0.55 * (w07 - 1.0))
    )

calculate_current_coefficient_fiesta(eps, kappa, triang) staticmethod

Calculate the fq coefficient used in the FIESTA plasma current scaling.

Parameters: - eps: float, plasma inverse aspect ratio - kappa: float, plasma elongation at the separatrix - triang: float, plasma triangularity at the separatrix

Returns: - float, the fq plasma current coefficient

This function calculates the fq coefficient based on the given plasma parameters for the FIESTA scaling.

References: - S.Muldrew et.al,“PROCESS”: Systems studies of spherical tokamaks, Fusion Engineering and Design, Volume 154, 2020, 111530, ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2020.111530.

Source code in process/models/physics/plasma_current.py
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
@staticmethod
def calculate_current_coefficient_fiesta(
    eps: float, kappa: float, triang: float
) -> float:
    """
    Calculate the fq coefficient used in the FIESTA plasma current scaling.

    Parameters:
    - eps: float, plasma inverse aspect ratio
    - kappa: float, plasma elongation at the separatrix
    - triang: float, plasma triangularity at the separatrix

    Returns:
    - float, the fq plasma current coefficient

    This function calculates the fq coefficient based on the given plasma parameters for the FIESTA scaling.

    References:
    - S.Muldrew et.al,“PROCESS”: Systems studies of spherical tokamaks, Fusion Engineering and Design,
    Volume 154, 2020, 111530, ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2020.111530.
    """
    return 0.538 * (1.0 + 2.440 * eps**2.736) * kappa**2.154 * triang**0.060